Skip to content

Commit 872b393

Browse files
committed
feat: add managed functions API
1 parent 878b219 commit 872b393

23 files changed

+3406
-1
lines changed

examples/managed_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
description="my first try",
3232
language=FunctionLanguage.FLUX,
3333
org_id=org.id,
34-
script=f"from(bucket: \"bucket-for-testing-2\") |> range(start: -7d) |> limit(n:2)")
34+
script=f"from(bucket: \"{bucket_name}\") |> range(start: -7d) |> limit(n:2)")
3535

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

influxdb_client/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from influxdb_client.service.views_service import ViewsService
4444
from influxdb_client.service.write_service import WriteService
4545
from influxdb_client.service.default_service import DefaultService
46+
from influxdb_client.service.functions_service import FunctionsService
4647

4748
# import ApiClient
4849
from influxdb_client.api_client import ApiClient
@@ -286,6 +287,21 @@
286287
from influxdb_client.domain.write_precision import WritePrecision
287288
from influxdb_client.domain.xy_geom import XYGeom
288289
from influxdb_client.domain.xy_view_properties import XYViewProperties
290+
from influxdb_client.domain.function import Function
291+
from influxdb_client.domain.function_create_request import FunctionCreateRequest
292+
from influxdb_client.domain.function_http_response import FunctionHTTPResponse
293+
from influxdb_client.domain.function_http_response_data import FunctionHTTPResponseData
294+
from influxdb_client.domain.function_http_response_no_data import FunctionHTTPResponseNoData
295+
from influxdb_client.domain.function_invocation_params import FunctionInvocationParams
296+
from influxdb_client.domain.function_language import FunctionLanguage
297+
from influxdb_client.domain.function_run import FunctionRun
298+
from influxdb_client.domain.function_run_base import FunctionRunBase
299+
from influxdb_client.domain.function_run_log import FunctionRunLog
300+
from influxdb_client.domain.function_runs import FunctionRuns
301+
from influxdb_client.domain.function_trigger_request import FunctionTriggerRequest
302+
from influxdb_client.domain.function_trigger_response import FunctionTriggerResponse
303+
from influxdb_client.domain.function_update_request import FunctionUpdateRequest
304+
from influxdb_client.domain.functions import Functions
289305

290306
from influxdb_client.client.authorizations_api import AuthorizationsApi
291307
from influxdb_client.client.bucket_api import BucketsApi

influxdb_client/client/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@
4141
from influxdb_client.service.views_service import ViewsService
4242
from influxdb_client.service.write_service import WriteService
4343
from influxdb_client.service.default_service import DefaultService
44+
from influxdb_client.service.functions_service import FunctionsService

influxdb_client/client/write/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@
4141
from influxdb_client.service.views_service import ViewsService
4242
from influxdb_client.service.write_service import WriteService
4343
from influxdb_client.service.default_service import DefaultService
44+
from influxdb_client.service.functions_service import FunctionsService

influxdb_client/domain/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,18 @@
252252
from influxdb_client.domain.write_precision import WritePrecision
253253
from influxdb_client.domain.xy_geom import XYGeom
254254
from influxdb_client.domain.xy_view_properties import XYViewProperties
255+
from influxdb_client.domain.function import Function
256+
from influxdb_client.domain.function_create_request import FunctionCreateRequest
257+
from influxdb_client.domain.function_http_response import FunctionHTTPResponse
258+
from influxdb_client.domain.function_http_response_data import FunctionHTTPResponseData
259+
from influxdb_client.domain.function_http_response_no_data import FunctionHTTPResponseNoData
260+
from influxdb_client.domain.function_invocation_params import FunctionInvocationParams
261+
from influxdb_client.domain.function_language import FunctionLanguage
262+
from influxdb_client.domain.function_run import FunctionRun
263+
from influxdb_client.domain.function_run_base import FunctionRunBase
264+
from influxdb_client.domain.function_run_log import FunctionRunLog
265+
from influxdb_client.domain.function_runs import FunctionRuns
266+
from influxdb_client.domain.function_trigger_request import FunctionTriggerRequest
267+
from influxdb_client.domain.function_trigger_response import FunctionTriggerResponse
268+
from influxdb_client.domain.function_update_request import FunctionUpdateRequest
269+
from influxdb_client.domain.functions import Functions

influxdb_client/domain/function.py

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
# coding: utf-8
2+
3+
"""
4+
InfluxData Managed Functions CRUD API.
5+
6+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
7+
8+
OpenAPI spec version: 0.1.0
9+
Generated by: https://openapi-generator.tech
10+
"""
11+
12+
13+
import pprint
14+
import re # noqa: F401
15+
16+
import six
17+
18+
19+
class Function(object):
20+
"""NOTE: This class is auto generated by OpenAPI Generator.
21+
22+
Ref: https://openapi-generator.tech
23+
24+
Do not edit the class manually.
25+
"""
26+
27+
"""
28+
Attributes:
29+
openapi_types (dict): The key is attribute name
30+
and the value is attribute type.
31+
attribute_map (dict): The key is attribute name
32+
and the value is json key in definition.
33+
"""
34+
openapi_types = {
35+
'id': 'str',
36+
'name': 'str',
37+
'description': 'str',
38+
'org_id': 'str',
39+
'script': 'str',
40+
'language': 'FunctionLanguage',
41+
'url': 'str',
42+
'created_at': 'datetime',
43+
'updated_at': 'datetime'
44+
}
45+
46+
attribute_map = {
47+
'id': 'id',
48+
'name': 'name',
49+
'description': 'description',
50+
'org_id': 'orgID',
51+
'script': 'script',
52+
'language': 'language',
53+
'url': 'url',
54+
'created_at': 'createdAt',
55+
'updated_at': 'updatedAt'
56+
}
57+
58+
def __init__(self, id=None, name=None, description=None, org_id=None, script=None, language=None, url=None, created_at=None, updated_at=None): # noqa: E501,D401,D403
59+
"""Function - a model defined in OpenAPI.""" # noqa: E501
60+
self._id = None
61+
self._name = None
62+
self._description = None
63+
self._org_id = None
64+
self._script = None
65+
self._language = None
66+
self._url = None
67+
self._created_at = None
68+
self._updated_at = None
69+
self.discriminator = None
70+
71+
if id is not None:
72+
self.id = id
73+
self.name = name
74+
if description is not None:
75+
self.description = description
76+
self.org_id = org_id
77+
self.script = script
78+
if language is not None:
79+
self.language = language
80+
if url is not None:
81+
self.url = url
82+
if created_at is not None:
83+
self.created_at = created_at
84+
if updated_at is not None:
85+
self.updated_at = updated_at
86+
87+
@property
88+
def id(self):
89+
"""Get the id of this Function.
90+
91+
:return: The id of this Function.
92+
:rtype: str
93+
""" # noqa: E501
94+
return self._id
95+
96+
@id.setter
97+
def id(self, id):
98+
"""Set the id of this Function.
99+
100+
:param id: The id of this Function.
101+
:type: str
102+
""" # noqa: E501
103+
self._id = id
104+
105+
@property
106+
def name(self):
107+
"""Get the name of this Function.
108+
109+
:return: The name of this Function.
110+
:rtype: str
111+
""" # noqa: E501
112+
return self._name
113+
114+
@name.setter
115+
def name(self, name):
116+
"""Set the name of this Function.
117+
118+
:param name: The name of this Function.
119+
:type: str
120+
""" # noqa: E501
121+
if name is None:
122+
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501
123+
self._name = name
124+
125+
@property
126+
def description(self):
127+
"""Get the description of this Function.
128+
129+
:return: The description of this Function.
130+
:rtype: str
131+
""" # noqa: E501
132+
return self._description
133+
134+
@description.setter
135+
def description(self, description):
136+
"""Set the description of this Function.
137+
138+
:param description: The description of this Function.
139+
:type: str
140+
""" # noqa: E501
141+
self._description = description
142+
143+
@property
144+
def org_id(self):
145+
"""Get the org_id of this Function.
146+
147+
:return: The org_id of this Function.
148+
:rtype: str
149+
""" # noqa: E501
150+
return self._org_id
151+
152+
@org_id.setter
153+
def org_id(self, org_id):
154+
"""Set the org_id of this Function.
155+
156+
:param org_id: The org_id of this Function.
157+
:type: str
158+
""" # noqa: E501
159+
if org_id is None:
160+
raise ValueError("Invalid value for `org_id`, must not be `None`") # noqa: E501
161+
self._org_id = org_id
162+
163+
@property
164+
def script(self):
165+
"""Get the script of this Function.
166+
167+
script is script to be executed
168+
169+
:return: The script of this Function.
170+
:rtype: str
171+
""" # noqa: E501
172+
return self._script
173+
174+
@script.setter
175+
def script(self, script):
176+
"""Set the script of this Function.
177+
178+
script is script to be executed
179+
180+
:param script: The script of this Function.
181+
:type: str
182+
""" # noqa: E501
183+
if script is None:
184+
raise ValueError("Invalid value for `script`, must not be `None`") # noqa: E501
185+
self._script = script
186+
187+
@property
188+
def language(self):
189+
"""Get the language of this Function.
190+
191+
:return: The language of this Function.
192+
:rtype: FunctionLanguage
193+
""" # noqa: E501
194+
return self._language
195+
196+
@language.setter
197+
def language(self, language):
198+
"""Set the language of this Function.
199+
200+
:param language: The language of this Function.
201+
:type: FunctionLanguage
202+
""" # noqa: E501
203+
self._language = language
204+
205+
@property
206+
def url(self):
207+
"""Get the url of this Function.
208+
209+
invocation endpoint address
210+
211+
:return: The url of this Function.
212+
:rtype: str
213+
""" # noqa: E501
214+
return self._url
215+
216+
@url.setter
217+
def url(self, url):
218+
"""Set the url of this Function.
219+
220+
invocation endpoint address
221+
222+
:param url: The url of this Function.
223+
:type: str
224+
""" # noqa: E501
225+
self._url = url
226+
227+
@property
228+
def created_at(self):
229+
"""Get the created_at of this Function.
230+
231+
:return: The created_at of this Function.
232+
:rtype: datetime
233+
""" # noqa: E501
234+
return self._created_at
235+
236+
@created_at.setter
237+
def created_at(self, created_at):
238+
"""Set the created_at of this Function.
239+
240+
:param created_at: The created_at of this Function.
241+
:type: datetime
242+
""" # noqa: E501
243+
self._created_at = created_at
244+
245+
@property
246+
def updated_at(self):
247+
"""Get the updated_at of this Function.
248+
249+
:return: The updated_at of this Function.
250+
:rtype: datetime
251+
""" # noqa: E501
252+
return self._updated_at
253+
254+
@updated_at.setter
255+
def updated_at(self, updated_at):
256+
"""Set the updated_at of this Function.
257+
258+
:param updated_at: The updated_at of this Function.
259+
:type: datetime
260+
""" # noqa: E501
261+
self._updated_at = updated_at
262+
263+
def to_dict(self):
264+
"""Return the model properties as a dict."""
265+
result = {}
266+
267+
for attr, _ in six.iteritems(self.openapi_types):
268+
value = getattr(self, attr)
269+
if isinstance(value, list):
270+
result[attr] = list(map(
271+
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
272+
value
273+
))
274+
elif hasattr(value, "to_dict"):
275+
result[attr] = value.to_dict()
276+
elif isinstance(value, dict):
277+
result[attr] = dict(map(
278+
lambda item: (item[0], item[1].to_dict())
279+
if hasattr(item[1], "to_dict") else item,
280+
value.items()
281+
))
282+
else:
283+
result[attr] = value
284+
285+
return result
286+
287+
def to_str(self):
288+
"""Return the string representation of the model."""
289+
return pprint.pformat(self.to_dict())
290+
291+
def __repr__(self):
292+
"""For `print` and `pprint`."""
293+
return self.to_str()
294+
295+
def __eq__(self, other):
296+
"""Return true if both objects are equal."""
297+
if not isinstance(other, Function):
298+
return False
299+
300+
return self.__dict__ == other.__dict__
301+
302+
def __ne__(self, other):
303+
"""Return true if both objects are not equal."""
304+
return not self == other

0 commit comments

Comments
 (0)