diff --git a/CHANGELOG.md b/CHANGELOG.md index 17bc64d5..1b6a871c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Bug Fixes 1. [#526](https://github.com/influxdata/influxdb-client-python/pull/526): Creating client instance from static configuration +1. [#531](https://github.com/influxdata/influxdb-client-python/pull/531): HTTP request return type for Management API [async/await] ### CI 1. [#523](https://github.com/influxdata/influxdb-client-python/pull/523): Add Python 3.11 to CI builds diff --git a/examples/asynchronous_management.py b/examples/asynchronous_management.py index 1e36f37b..34b0a3f6 100644 --- a/examples/asynchronous_management.py +++ b/examples/asynchronous_management.py @@ -10,7 +10,7 @@ async def main(): organizations_service = OrganizationsService(api_client=client.api_client) # Find organization with name 'my-org' - organizations = await organizations_service.get_orgs(org='my-org') + organizations = await organizations_service.get_orgs_async(org='my-org') for organization in organizations.orgs: print(f'name: {organization.name}, id: {organization.id}') diff --git a/influxdb_client/_async/api_client.py b/influxdb_client/_async/api_client.py index f8fc2742..3a396a10 100644 --- a/influxdb_client/_async/api_client.py +++ b/influxdb_client/_async/api_client.py @@ -186,8 +186,8 @@ async def __call_api( else: return_data = None - if _return_http_data_only: - return (return_data) + if _return_http_data_only is not False: + return return_data else: return (return_data, response_data.status, response_data.getheaders()) @@ -654,7 +654,7 @@ def __deserialize_model(self, data, klass): async def _signin(self, resource_path: str): if _requires_create_user_session(self.configuration, self.cookie, resource_path): - http_info = await SigninService(self).post_signin_async() + http_info = await SigninService(self).post_signin_async(_return_http_data_only=False) self.cookie = http_info[2]['set-cookie'] async def _signout(self): diff --git a/influxdb_client/client/delete_api_async.py b/influxdb_client/client/delete_api_async.py index 989a0482..ef44c843 100644 --- a/influxdb_client/client/delete_api_async.py +++ b/influxdb_client/client/delete_api_async.py @@ -33,5 +33,5 @@ async def delete(self, start: Union[str, datetime], stop: Union[str, datetime], org_param = get_org_query_param(org=org, client=self._influxdb_client, required_id=False) response = await self._service.post_delete_async(delete_predicate_request=predicate_request, bucket=bucket, - org=org_param) + org=org_param, _return_http_data_only=False) return response[1] == 204 diff --git a/influxdb_client/client/write_api_async.py b/influxdb_client/client/write_api_async.py index f9351783..e0ba021d 100644 --- a/influxdb_client/client/write_api_async.py +++ b/influxdb_client/client/write_api_async.py @@ -120,6 +120,6 @@ async def write(self, bucket: str, org: str = None, body = b'\n'.join(payloads[write_precision]) response = await self._write_service.post_write_async(org=org, bucket=bucket, body=body, precision=write_precision, async_req=False, - content_encoding="identity", + content_encoding="identity", _return_http_data_only=False, content_type="text/plain; charset=utf-8") return response[1] == 204 diff --git a/tests/test_InfluxDBClientAsync.py b/tests/test_InfluxDBClientAsync.py index 3283da40..63cba03b 100644 --- a/tests/test_InfluxDBClientAsync.py +++ b/tests/test_InfluxDBClientAsync.py @@ -8,7 +8,7 @@ import pytest from aioresponses import aioresponses -from influxdb_client import Point, WritePrecision, BucketsService +from influxdb_client import Point, WritePrecision, BucketsService, OrganizationsService, Organizations from influxdb_client.client.exceptions import InfluxDBError from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync from influxdb_client.client.query_api import QueryOptions @@ -329,7 +329,7 @@ async def test_query_and_debug(self): self.assertIn("my-bucket", results) # Bucket API buckets_service = BucketsService(api_client=self.client.api_client) - results = await buckets_service.get_buckets() + results = await buckets_service.get_buckets_async() self.assertIn("my-bucket", list(map(lambda bucket: bucket.name, results.buckets))) @async_test @@ -402,6 +402,13 @@ async def test_parse_utf8_two_bytes_character(self, mocked): data_frame = await self.client.query_api().query_data_frame("from()", "my-org") self.assertEqual(1000, len(data_frame)) + @async_test + async def test_management_apis(self): + service = OrganizationsService(api_client=self.client.api_client) + results = await service.get_orgs_async() + self.assertIsInstance(results, Organizations) + self.assertIn("my-org", list(map(lambda org: org.name, results.orgs))) + async def _prepare_data(self, measurement: str): _point1 = Point(measurement).tag("location", "Prague").field("temperature", 25.3) _point2 = Point(measurement).tag("location", "New York").field("temperature", 24.3)