Repository: influxdata/influxdb-client-python

Issue:
Issue with bucket example?
From example to create,list,delete buckets - 


org_name = "redacted"
org = list(filter(lambda it: it.name == org_name, client.organizations_api().find_organizations()))[0]

produces error - "message": "id must have a length of 16 bytes"


Discussion:
codecov-commenter: # [Codecov](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) Report
> Merging [#264](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) (013f239) into [master](https://codecov.io/gh/influxdata/influxdb-client-python/commit/0c1d1d9ff92dd2b3b4a9b6aa1e8f5b1c02fd48ab?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) (0c1d1d9) will **increase** coverage by `0.07%`.
> The diff coverage is `96.96%`.

> :exclamation: Current head 013f239 differs from pull request most recent head 08b8281. Consider uploading reports for the commit 08b8281 to get more accurate results
[![Impacted file tree graph](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264/graphs/tree.svg?width=650&height=150&src=pr&token=PcyupQSPFt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata)](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata)

```diff
@@            Coverage Diff             @@
##           master     #264      +/-   ##
==========================================
+ Coverage   92.52%   92.59%   +0.07%     
==========================================
  Files          25       26       +1     
  Lines        2126     2147      +21     
==========================================
+ Hits         1967     1988      +21     
  Misses        159      159              
```


| [Impacted Files](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) | Coverage Δ | |
|---|---|---|
| [influxdb\_client/client/bucket\_api.py](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-aW5mbHV4ZGJfY2xpZW50L2NsaWVudC9idWNrZXRfYXBpLnB5) | `93.93% <75.00%> (-2.62%)` | :arrow_down: |
| [influxdb\_client/client/query\_api.py](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-aW5mbHV4ZGJfY2xpZW50L2NsaWVudC9xdWVyeV9hcGkucHk=) | `99.08% <100.00%> (-0.02%)` | :arrow_down: |
| [influxdb\_client/client/util/helpers.py](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-aW5mbHV4ZGJfY2xpZW50L2NsaWVudC91dGlsL2hlbHBlcnMucHk=) | `100.00% <100.00%> (ø)` | |
| [influxdb\_client/client/write\_api.py](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-aW5mbHV4ZGJfY2xpZW50L2NsaWVudC93cml0ZV9hcGkucHk=) | `99.06% <100.00%> (ø)` | |
| [influxdb\_client/client/organizations\_api.py](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-aW5mbHV4ZGJfY2xpZW50L2NsaWVudC9vcmdhbml6YXRpb25zX2FwaS5weQ==) | `89.47% <0.00%> (+5.26%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata). Last update [0c1d1d9...08b8281](https://codecov.io/gh/influxdata/influxdb-client-python/pull/264?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata).


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52d1682..d545bee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 ## 1.19.0 [unreleased]
 
+### Features
+1. [#264](https://github.com/influxdata/influxdb-client-python/pull/264): Org parameter can be specified as ID, Name or Organization Object [write, query]
+
+### Deprecated
+1. [#264](https://github.com/influxdata/influxdb-client-python/pull/264): Deprecated `org_id` options BucketsApi.create_bucket in favor of `org` parameter
+
 ## 1.18.0 [2021-06-04]
 
 ### Breaking Changes
diff --git a/examples/buckets_management.py b/examples/buckets_management.py
index 2ff7966..c376f77 100644
--- a/examples/buckets_management.py
+++ b/examples/buckets_management.py
@@ -9,16 +9,11 @@ Define credentials
 """
 url = "http://localhost:8086"
 token = "my-token"
+org = "my-org"
 
 with InfluxDBClient(url=url, token=token) as client:
     buckets_api = client.buckets_api()
 
-    """
-    The Bucket API uses as a parameter the Organization ID. We have to retrieve ID by Organization API.
-    """
-    org_name = "my-org"
-    org = client.organizations_api().find_organizations(org=org_name)[0]
-
     """
     Create Bucket with retention policy set to 3600 seconds and name "bucket-by-python"
     """
@@ -26,7 +21,7 @@ with InfluxDBClient(url=url, token=token) as client:
     retention_rules = BucketRetentionRules(type="expire", every_seconds=3600)
     created_bucket = buckets_api.create_bucket(bucket_name="bucket-by-python",
                                                retention_rules=retention_rules,
-                                               org_id=org.id)
+                                               org=org)
     print(created_bucket)
 
     """
diff --git a/influxdb_client/__init__.py b/influxdb_client/__init__.py
index cd20117..38a6066 100644
--- a/influxdb_client/__init__.py
+++ b/influxdb_client/__init__.py
@@ -298,4 +298,6 @@ from influxdb_client.client.write_api import WriteApi, WriteOptions
 from influxdb_client.client.influxdb_client import InfluxDBClient
 from influxdb_client.client.write.point import Point
 
-__version__ = '1.19.0dev'
+from influxdb_client.version import CLIENT_VERSION
+
+__version__ = CLIENT_VERSION
diff --git a/influxdb_client/api_client.py b/influxdb_client/api_client.py
index dcea6d6..8907cf8 100644
--- a/influxdb_client/api_client.py
+++ b/influxdb_client/api_client.py
@@ -76,7 +76,8 @@ class ApiClient(object):
             self.default_headers[header_name] = header_value
         self.cookie = cookie
         # Set default User-Agent.
-        self.user_agent = 'influxdb-client-python/1.19.0dev'
+        from influxdb_client import CLIENT_VERSION
+        self.user_agent = f'influxdb-client-python/{CLIENT_VERSION}'
 
     def __del__(self):
         """Dispose pools."""
diff --git a/influxdb_client/client/bucket_api.py b/influxdb_client/client/bucket_api.py
index 4ffa511..7b695f5 100644
--- a/influxdb_client/client/bucket_api.py
+++ b/influxdb_client/client/bucket_api.py
@@ -4,9 +4,10 @@ A bucket is a named location where time series data is stored.
 All buckets have a retention policy, a duration of time that each data point persists.
 A bucket belongs to an organization.
 """
-
+import warnings
 
 from influxdb_client import BucketsService, Bucket, PostBucketRequest
+from influxdb_client.client.util.helpers import get_org_query_param
 
 
 class BucketsApi(object):
@@ -18,15 +19,18 @@ class BucketsApi(object):
         self._buckets_service = BucketsService(influxdb_client.api_client)
 
     def create_bucket(self, bucket=None, bucket_name=None, org_id=None, retention_rules=None,
-                      description=None) -> Bucket:
+                      description=None, org=None) -> Bucket:
         """Create a bucket.
 
-        :param Bucket bucket: bucket to create (required)
+        :param Bucket bucket: bucket to create
         :param bucket_name: bucket name
         :param description: bucket description
         :param org_id: org_id
         :param bucket_name: bucket name
         :param retention_rules: retention rules array or single BucketRetentionRules
+        :param str, Organization org: specifies the organization for create the bucket;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :return: Bucket
                  If the method is called asynchronously,
                  returns the request thread.
@@ -41,11 +45,16 @@ class BucketsApi(object):
         else:
             rules.append(retention_rules)
 
+        if org_id is not None:
+            warnings.warn("org_id is deprecated; use org", DeprecationWarning)
+
         if bucket is None:
             bucket = PostBucketRequest(name=bucket_name,
                                        retention_rules=rules,
                                        description=description,
-                                       org_id=self._influxdb_client.org if org_id is None else org_id)
+                                       org_id=get_org_query_param(org=(org_id if org is None else org),
+                                                                  client=self._influxdb_client,
+                                                                  required_id=True))
 
         return self._buckets_service.post_buckets(post_bucket_request=bucket)
 
diff --git a/influxdb_client/client/query_api.py b/influxdb_client/client/query_api.py
index 18f477a..4113e7e 100644
--- a/influxdb_client/client/query_api.py
+++ b/influxdb_client/client/query_api.py
@@ -16,6 +16,7 @@ from influxdb_client import Query, QueryService
 from influxdb_client.client.flux_csv_parser import FluxCsvParser, FluxSerializationMode
 from influxdb_client.client.flux_table import FluxTable, FluxRecord
 from influxdb_client.client.util.date_utils import get_date_helper
+from influxdb_client.client.util.helpers import get_org_query_param
 
 
 class QueryOptions(object):
@@ -51,14 +52,15 @@ class QueryApi(object):
         Execute the Flux query and return results as a CSV iterator. Each iteration returns a row of the CSV file.
 
         :param query: a Flux query
-        :param org: organization name (optional if already specified in InfluxDBClient)
+        :param str, Organization org: specifies the organization for executing the query;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :param dialect: csv dialect format
         :param params: bind parameters
         :return: The returned object is an iterator.  Each iteration returns a row of the CSV file
                  (which can span multiple input lines).
         """
-        if org is None:
-            org = self._influxdb_client.org
+        org = self._org_param(org)
         response = self._query_api.post_query(org=org, query=self._create_query(query, dialect, params),
                                               async_req=False, _preload_content=False)
 
@@ -69,13 +71,14 @@ class QueryApi(object):
         Execute synchronous Flux query and return result as raw unprocessed result as a str.
 
         :param query: a Flux query
-        :param org: organization name (optional if already specified in InfluxDBClient)
+        :param str, Organization org: specifies the organization for executing the query;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :param dialect: csv dialect format
         :param params: bind parameters
         :return: str
         """
-        if org is None:
-            org = self._influxdb_client.org
+        org = self._org_param(org)
         result = self._query_api.post_query(org=org, query=self._create_query(query, dialect, params), async_req=False,
                                             _preload_content=False)
 
@@ -86,12 +89,13 @@ class QueryApi(object):
         Execute synchronous Flux query and return result as a List['FluxTable'].
 
         :param query: the Flux query
-        :param org: organization name (optional if already specified in InfluxDBClient)
+        :param str, Organization org: specifies the organization for executing the query;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :param params: bind parameters
         :return:
         """
-        if org is None:
-            org = self._influxdb_client.org
+        org = self._org_param(org)
 
         response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params),
                                               async_req=False, _preload_content=False, _return_http_data_only=False)
@@ -108,12 +112,13 @@ class QueryApi(object):
         Execute synchronous Flux query and return stream of FluxRecord as a Generator['FluxRecord'].
 
         :param query: the Flux query
-        :param org: organization name (optional if already specified in InfluxDBClient)
+        :param str, Organization org: specifies the organization for executing the query;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :param params: bind parameters
         :return:
         """
-        if org is None:
-            org = self._influxdb_client.org
+        org = self._org_param(org)
 
         response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params),
                                               async_req=False, _preload_content=False, _return_http_data_only=False)
@@ -129,7 +134,9 @@ class QueryApi(object):
         Note that if a query returns more then one table than the client generates a DataFrame for each of them.
 
         :param query: the Flux query
-        :param org: organization name (optional if already specified in InfluxDBClient)
+        :param str, Organization org: specifies the organization for executing the query;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :param data_frame_index: the list of columns that are used as DataFrame index
         :param params: bind parameters
         :return:
@@ -153,13 +160,14 @@ class QueryApi(object):
         Note that if a query returns more then one table than the client generates a DataFrame for each of them.
 
         :param query: the Flux query
-        :param org: organization name (optional if already specified in InfluxDBClient)
+        :param str, Organization org: specifies the organization for executing the query;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :param data_frame_index: the list of columns that are used as DataFrame index
         :param params: bind parameters
         :return:
         """
-        if org is None:
-            org = self._influxdb_client.org
+        org = self._org_param(org)
 
         response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params),
                                               async_req=False, _preload_content=False, _return_http_data_only=False)
@@ -187,6 +195,9 @@ class QueryApi(object):
 
         return q
 
+    def _org_param(self, org):
+        return get_org_query_param(org=org, client=self._influxdb_client)
+
     @staticmethod
     def _params_to_extern_ast(params: dict) -> List['OptionStatement']:
 
diff --git a/influxdb_client/client/util/helpers.py b/influxdb_client/client/util/helpers.py
new file mode 100644
index 0000000..96539bd
--- /dev/null
+++ b/influxdb_client/client/util/helpers.py
@@ -0,0 +1,39 @@
+"""Functions to share utility across client classes."""
+from influxdb_client.rest import ApiException
+
+
+def _is_id(value):
+    """
+    Check if the value is valid InfluxDB ID.
+
+    :param value: to check
+    :return: True if provided parameter is valid InfluxDB ID.
+    """
+    if value and len(value) == 16:
+        try:
+            int(value, 16)
+            return True
+        except ValueError:
+            return False
+    return False
+
+
+def get_org_query_param(org, client, required_id=False):
+    """
+    Get required type of Org query parameter.
+
+    :param str, Organization org: value provided as a parameter into API (optional)
+    :param InfluxDBClient client: with default value for Org parameter
+    :param bool required_id: true if the query param has to be a ID
+    :return: request type of org query parameter or None
+    """
+    _org = client.org if org is None else org
+    if 'Organization' in type(_org).__name__:
+        _org = _org.id
+    if required_id and _org and not _is_id(_org):
+        try:
+            return client.organizations_api().find_organizations(org=_org)[0].id
+        except ApiException:
+            return None
+
+    return _org
diff --git a/influxdb_client/client/write_api.py b/influxdb_client/client/write_api.py
index e4e7786..e1730f3 100644
--- a/influxdb_client/client/write_api.py
+++ b/influxdb_client/client/write_api.py
@@ -16,6 +16,7 @@ from rx.scheduler import ThreadPoolScheduler
 from rx.subject import Subject
 
 from influxdb_client import WritePrecision, WriteService
+from influxdb_client.client.util.helpers import get_org_query_param
 from influxdb_client.client.write.dataframe_serializer import data_frame_to_list_of_points
 from influxdb_client.client.write.point import Point, DEFAULT_WRITE_PRECISION
 from influxdb_client.client.write.retry import WritesRetry
@@ -221,8 +222,9 @@ class WriteApi:
         """
         Write time-series data into InfluxDB.
 
-        :param str org: specifies the destination organization for writes; take either the ID or Name interchangeably;
-                        if both orgID and org are specified, org takes precedence. (required)
+        :param str, Organization org: specifies the destination organization for writes;
+                                      take the ID, Name or Organization;
+                                      if it's not specified then is used default from client.org.
         :param str bucket: specifies the destination bucket for writes (required)
         :param WritePrecision write_precision: specifies the precision for the unix timestamps within
                                                the body line-protocol. The precision specified on a Point has precedes
@@ -231,8 +233,7 @@ class WriteApi:
         :key data_frame_measurement_name: name of measurement for writing Pandas DataFrame
         :key data_frame_tag_columns: list of DataFrame columns which are tags, rest columns will be fields
         """
-        if org is None:
-            org = self._influxdb_client.org
+        org = get_org_query_param(org=org, client=self._influxdb_client)
 
         if self._point_settings.defaultTags and record is not None:
             for key, val in self._point_settings.defaultTags.items():
diff --git a/influxdb_client/configuration.py b/influxdb_client/configuration.py
index 12f9f62..53b55d6 100644
--- a/influxdb_client/configuration.py
+++ b/influxdb_client/configuration.py
@@ -242,12 +242,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
 
         :return: The report for debugging.
         """
+        from influxdb_client import CLIENT_VERSION
         return "Python SDK Debug Report:\n"\
                "OS: {env}\n"\
                "Python Version: {pyversion}\n"\
                "Version of the API: 2.0.0\n"\
-               "SDK Package Version: 1.19.0dev".\
-               format(env=sys.platform, pyversion=sys.version)
+               "SDK Package Version: {client_version}".\
+               format(env=sys.platform, pyversion=sys.version, client_version=CLIENT_VERSION)
 
     def update_request_header_params(self, path: str, params: dict):
         """Update header params based on custom settings.
diff --git a/influxdb_client/version.py b/influxdb_client/version.py
new file mode 100644
index 0000000..75157d5
--- /dev/null
+++ b/influxdb_client/version.py
@@ -0,0 +1,3 @@
+"""Version of the Client that is used in User-Agent header."""
+
+CLIENT_VERSION = '1.19.0dev0'
diff --git a/setup.py b/setup.py
index 83aaf58..46880b2 100644
--- a/setup.py
+++ b/setup.py
@@ -40,12 +40,12 @@ with open('README.rst', 'r') as f:
 NAME = "influxdb_client"
 
 meta = {}
-with open(Path(__file__).parent / 'influxdb_client' / '__init__.py') as f:
-    exec('\n'.join(l for l in f if l.startswith('__')), meta)
+with open(Path(__file__).parent / 'influxdb_client' / 'version.py') as f:
+    exec('\n'.join(l for l in f if l.startswith('CLIENT_VERSION')), meta)
 
 setup(
     name=NAME,
-    version=meta['__version__'],
+    version=meta['CLIENT_VERSION'],
     description="InfluxDB 2.0 Python client library",
     long_description=readme,
     url="https://github.com/influxdata/influxdb-client-python",


Test patch:
diff --git a/tests/base_test.py b/tests/base_test.py
index 131d145..ad6bcd1 100644
--- a/tests/base_test.py
+++ b/tests/base_test.py
@@ -41,7 +41,7 @@ class BaseTest(unittest.TestCase):
 
     def create_test_bucket(self):
         bucket_name = generate_bucket_name()
-        bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org_id=self.my_organization.id,
+        bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org=self.my_organization,
                                                 description=bucket_name + "description")
         return bucket
 
@@ -49,11 +49,7 @@ class BaseTest(unittest.TestCase):
         return self.buckets_api.delete_bucket(bucket)
 
     def find_my_org(self) -> Organization:
-        org_api = influxdb_client.service.organizations_service.OrganizationsService(self.api_client)
-        orgs = org_api.get_orgs()
-        for org in orgs.orgs:
-            if org.name == self.org:
-                return org
+        return self.client.organizations_api().find_organizations(org=self.org)[0]
 
     @staticmethod
     def log(args):
diff --git a/tests/test_AuthorizationApi.py b/tests/test_AuthorizationApi.py
index 53ceb84..8b1850d 100644
--- a/tests/test_AuthorizationApi.py
+++ b/tests/test_AuthorizationApi.py
@@ -82,7 +82,7 @@ class AuthorizationsClientTest(BaseTest):
         organization = self.client.organizations_api().create_organization(self.generate_name("Auth Organization"))
         bucket = self.client.buckets_api().create_bucket(bucket_name=self.generate_name("Auth Bucket"),
                                                          retention_rules=BaseTest.retention_rule(),
-                                                         org_id=self.organization.id)
+                                                         org=self.organization)
         resource = PermissionResource(org_id=organization.id, type="buckets", id=bucket.id)
         create_bucket = Permission(action="read", resource=resource)
         delete_bucket = Permission(action="write", resource=resource)
diff --git a/tests/test_BucketsApi.py b/tests/test_BucketsApi.py
index 79e0c45..aa58cce 100644
--- a/tests/test_BucketsApi.py
+++ b/tests/test_BucketsApi.py
@@ -22,7 +22,7 @@ class BucketsClientTest(BaseTest):
         my_org = self.find_my_org()
 
         bucket_name = generate_bucket_name()
-        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org_id=my_org.id)
+        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org=my_org)
         self.assertEqual(my_bucket.name, bucket_name)
         self.assertEqual(my_bucket.org_id, my_org.id)
         print(my_bucket)
@@ -41,7 +41,7 @@ class BucketsClientTest(BaseTest):
         my_org = self.find_my_org()
 
         bucket_name = generate_bucket_name()
-        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org_id=my_org.id)
+        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org=my_org)
 
         bucket_by_name = self.buckets_api.find_bucket_by_name(bucket_name=my_bucket.name)
 
@@ -58,7 +58,7 @@ class BucketsClientTest(BaseTest):
 
         retention = BucketRetentionRules(type="expire", every_seconds=3600)
         desc = "bucket with retention"
-        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org_id=my_org.id,
+        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org=my_org,
                                                    retention_rules=retention, description=desc)
 
         self.assertEqual(my_bucket.description, desc)
@@ -76,7 +76,7 @@ class BucketsClientTest(BaseTest):
         retention.type = "expire"
         ret_list.append(retention)
 
-        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org_id=my_org.id,
+        my_bucket = self.buckets_api.create_bucket(bucket_name=bucket_name, org=my_org,
                                                    retention_rules=ret_list)
 
         self.assertEqual(my_bucket.name, bucket_name)
@@ -89,8 +89,8 @@ class BucketsClientTest(BaseTest):
         size = len(buckets)
 
         # create 2 buckets
-        self.buckets_api.create_bucket(bucket_name=generate_bucket_name(), org_id=my_org.id)
-        self.buckets_api.create_bucket(bucket_name=generate_bucket_name(), org_id=my_org.id)
+        self.buckets_api.create_bucket(bucket_name=generate_bucket_name(), org=my_org)
+        self.buckets_api.create_bucket(bucket_name=generate_bucket_name(), org=my_org)
 
         buckets = self.buckets_api.find_buckets().buckets
         self.assertEqual(size + 2, len(buckets))
diff --git a/tests/test_Helpers.py b/tests/test_Helpers.py
new file mode 100644
index 0000000..ebf3773
--- /dev/null
+++ b/tests/test_Helpers.py
@@ -0,0 +1,38 @@
+from influxdb_client import InfluxDBClient, Organization
+# noinspection PyProtectedMember
+from influxdb_client.client.util.helpers import get_org_query_param, _is_id
+from tests.base_test import BaseTest
+
+
+class HelpersTest(BaseTest):
+
+    def test_is_id(self):
+        self.assertTrue(_is_id("ffffffffffffffff"))
+        self.assertTrue(_is_id("020f755c3c082000"))
+        self.assertTrue(_is_id("ca55e77eca55e77e"))
+        self.assertTrue(_is_id("02def021097c6000"))
+        self.assertFalse(_is_id("gggggggggggggggg"))
+        self.assertFalse(_is_id("abc"))
+        self.assertFalse(_is_id("abcdabcdabcdabcd0"))
+        self.assertFalse(_is_id("020f75"))
+        self.assertFalse(_is_id("020f755c3c082000aaa"))
+        self.assertFalse(_is_id(None))
+
+    def test_organization_as_query_param(self):
+        organization = Organization(id="org-id", name="org-name")
+        org = get_org_query_param(organization, self.client)
+        self.assertEqual("org-id", org)
+
+    def test_required_id(self):
+        org = get_org_query_param(None, self.client, required_id=True)
+        self.assertEqual(self.my_organization.id, org)
+
+    def test_required_id_not_exist(self):
+        org = get_org_query_param("not_exist_name", self.client, required_id=True)
+        self.assertIsNone(org)
+
+    def test_both_none(self):
+        self.client.close()
+        self.client = InfluxDBClient(url=self.client.url, token="my-token")
+        org = get_org_query_param(None, self.client)
+        self.assertIsNone(org)
diff --git a/tests/test_WriteApiBatching.py b/tests/test_WriteApiBatching.py
index 61cb5f2..e717554 100644
--- a/tests/test_WriteApiBatching.py
+++ b/tests/test_WriteApiBatching.py
@@ -10,7 +10,7 @@ import rx
 from rx import operators as ops
 
 import influxdb_client
-from influxdb_client import WritePrecision, InfluxDBClient
+from influxdb_client import WritePrecision, InfluxDBClient, CLIENT_VERSION
 from influxdb_client.client.write.point import Point
 from influxdb_client.client.write_api import WriteOptions, WriteApi, PointSettings
 
@@ -459,7 +459,7 @@ class BatchingWriteTest(unittest.TestCase):
 
         requests = httpretty.httpretty.latest_requests
         self.assertEqual(1, len(requests))
-        self.assertEqual(f'influxdb-client-python/{influxdb_client.__version__}', requests[0].headers['User-Agent'])
+        self.assertEqual(f'influxdb-client-python/{CLIENT_VERSION}', requests[0].headers['User-Agent'])
 
     def test_to_low_flush_interval(self):