Skip to content

Commit 4ca4aa1

Browse files
committed
feat: improve the example
1 parent 2bcc296 commit 4ca4aa1

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

examples/managed_functions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
bucket_name = '...'
1515
org_name = '...'
1616

17-
with InfluxDBClient(url=influx_cloud_url, token=influx_cloud_token, org=org_name, debug=True, timeout=20_000) as client:
17+
with InfluxDBClient(url=influx_cloud_url, token=influx_cloud_token, org=org_name, debug=False, timeout=20_000) as client:
1818
uniqueId = str(datetime.datetime.now())
1919
"""
2020
Find Organization ID by Organization API.
@@ -31,23 +31,24 @@
3131
description="my first try",
3232
language=FunctionLanguage.FLUX,
3333
org_id=org.id,
34-
script=f"from(bucket: \"{bucket_name}\") |> range(start: -7d) |> limit(n:2)")
34+
script=f"from(bucket: \"{bucket_name}\") |> range(start: -30d) |> limit(n:2)")
3535

3636
created_function = functions_service.post_functions(function_create_request=create_request)
3737
print(created_function)
3838

3939
"""
4040
Invoke Function
4141
"""
42-
print(f"\n------- Invoke Function: -------\n")
42+
print(f"\n------- Invoke -------\n")
4343
response = functions_service.post_functions_id_invoke(function_id=created_function.id,
4444
function_invocation_params=FunctionInvocationParams(
4545
params={"bucket_name": bucket_name}))
46+
print(response)
4647

4748
"""
4849
List all Functions
4950
"""
50-
print(f"\n------- Functions: -------\n")
51+
print(f"\n------- List -------\n")
5152
functions = functions_service.get_functions(org=org).functions
5253
print("\n".join([f" ---\n ID: {it.id}\n Name: {it.name}\n Description: {it.description}" for it in functions]))
5354
print("---")
@@ -57,4 +58,4 @@
5758
"""
5859
print(f"------- Delete -------\n")
5960
functions_service.delete_functions_id(created_function.id)
60-
print(f" successfully deleted function: {created_function.name}")
61+
print(f" Successfully deleted function: '{created_function.name}'")

influxdb_client/service/functions_service.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def get_functions_id_invoke(self, function_id, **kwargs): # noqa: E501,D401,D40
353353
:param async_req bool
354354
:param str function_id: (required)
355355
:param dict(str, object) params:
356-
:return: FunctionHTTPResponseData
356+
:return: str
357357
If the method is called asynchronously,
358358
returns the request thread.
359359
""" # noqa: E501
@@ -375,7 +375,7 @@ def get_functions_id_invoke_with_http_info(self, function_id, **kwargs): # noqa
375375
:param async_req bool
376376
:param str function_id: (required)
377377
:param dict(str, object) params:
378-
:return: FunctionHTTPResponseData
378+
:return: str
379379
If the method is called asynchronously,
380380
returns the request thread.
381381
""" # noqa: E501
@@ -437,7 +437,7 @@ def get_functions_id_invoke_with_http_info(self, function_id, **kwargs): # noqa
437437
body=body_params,
438438
post_params=form_params,
439439
files=local_var_files,
440-
response_type='FunctionHTTPResponseData', # noqa: E501
440+
response_type='str', # noqa: E501
441441
auth_settings=auth_settings,
442442
async_req=local_var_params.get('async_req'),
443443
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -891,7 +891,7 @@ def post_functions_id_invoke(self, function_id, **kwargs): # noqa: E501,D401,D4
891891
:param async_req bool
892892
:param str function_id: (required)
893893
:param FunctionInvocationParams function_invocation_params:
894-
:return: FunctionHTTPResponseData
894+
:return: str
895895
If the method is called asynchronously,
896896
returns the request thread.
897897
""" # noqa: E501
@@ -913,7 +913,7 @@ def post_functions_id_invoke_with_http_info(self, function_id, **kwargs): # noq
913913
:param async_req bool
914914
:param str function_id: (required)
915915
:param FunctionInvocationParams function_invocation_params:
916-
:return: FunctionHTTPResponseData
916+
:return: str
917917
If the method is called asynchronously,
918918
returns the request thread.
919919
""" # noqa: E501
@@ -979,7 +979,7 @@ def post_functions_id_invoke_with_http_info(self, function_id, **kwargs): # noq
979979
body=body_params,
980980
post_params=form_params,
981981
files=local_var_files,
982-
response_type='FunctionHTTPResponse', # noqa: E501
982+
response_type='str', # noqa: E501
983983
auth_settings=auth_settings,
984984
async_req=local_var_params.get('async_req'),
985985
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501

0 commit comments

Comments
 (0)