-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat.] New FunctionGraph Function resource (#506)
[Feat.] New FunctionGraph Function resource Implementation of Function lifecycle endpoints into sdk (https://docs.otc.t-systems.com/function-graph/api-ref/apis/function_lifecycle_management/index.html) Part of #438 Reviewed-by: RusselSand
- Loading branch information
1 parent
7061969
commit 6be3050
Showing
26 changed files
with
1,157 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
FunctionGraph Service (FGS) | ||
=========================== | ||
|
||
.. contents:: Table of Contents | ||
:local: | ||
|
||
FunctionGraph hosts and computes event-driven functions in a serverless | ||
context while ensuring high availability, high scalability, | ||
and zero maintenance. All you need to do is write your code and set conditions. | ||
|
||
Function | ||
-------- | ||
|
||
Function is a combination of code, runtime, resources, | ||
and settings required to achieve a specific purpose. | ||
It is the minimum unit that can run independently. | ||
A function can be triggered by triggers and automatically schedule | ||
required resources and environments to achieve expected results. | ||
|
||
|
||
Create Function | ||
^^^^^^^^^^^^^^^ | ||
|
||
This API is used to create a function. | ||
|
||
.. literalinclude:: ../examples/function_graph/create_function.py | ||
:lines: 16-32 | ||
|
||
Delete Function | ||
^^^^^^^^^^^^^^^ | ||
|
||
This API is used to delete a function. | ||
|
||
.. literalinclude:: ../examples/function_graph/delete_function.py | ||
:lines: 16-33 | ||
|
||
List Functions | ||
^^^^^^^^^^^^^^ | ||
|
||
This API is used to query all functions. | ||
|
||
.. literalinclude:: ../examples/function_graph/list_functions.py | ||
:lines: 16-24 | ||
|
||
Get Function Code | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to query the code of a function. | ||
|
||
.. literalinclude:: ../examples/function_graph/get_function_code.py | ||
:lines: 16-23 | ||
|
||
Get Function Metadata | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to query the metadata of a function. | ||
|
||
.. literalinclude:: ../examples/function_graph/get_function_metadata.py | ||
:lines: 16-23 | ||
|
||
Get Resource Tags | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to query resource tags. | ||
|
||
.. literalinclude:: ../examples/function_graph/get_resource_tags.py | ||
:lines: 16-23 | ||
|
||
Create Resource Tags | ||
^^^^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to create resource tags. | ||
|
||
.. literalinclude:: ../examples/function_graph/create_resource_tags.py | ||
:lines: 16-36 | ||
|
||
Delete Resource Tags | ||
^^^^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to delete resource tags. | ||
|
||
.. literalinclude:: ../examples/function_graph/delete_resource_tags.py | ||
:lines: 16-31 | ||
|
||
Update Function Code | ||
^^^^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to modify the code of a function. | ||
|
||
.. literalinclude:: ../examples/function_graph/update_function_code.py | ||
:lines: 16-37 | ||
|
||
Update Function Metadata | ||
^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to modify the metadata of a function. | ||
|
||
.. literalinclude:: ../examples/function_graph/update_function_metadata.py | ||
:lines: 16-35 | ||
|
||
Update Function Instances | ||
^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
This API is used to update the maximum number of instances of a function. | ||
|
||
.. literalinclude:: ../examples/function_graph/update_function_metadata.py | ||
:lines: 16-23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ Open Telekom Cloud related User Guides | |
dms | ||
dns | ||
dws | ||
function_graph | ||
kms | ||
lts | ||
mrs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FunctionGraph API | ||
================= | ||
|
||
.. automodule:: otcextensions.sdk.function_graph.v2._proxy | ||
|
||
Function Service Class | ||
---------------------- | ||
|
||
The nat high-level interface is available through the ``functiongraph`` | ||
member of a :class:`~openstack.connection.Connection` object. The | ||
``functiongraph`` member will only be added if the | ||
``otcextensions.sdk.register_otc_extensions(conn)`` method is called. | ||
|
||
Function Operations | ||
^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: otcextensions.sdk.function_graph.v2._proxy.Proxy | ||
:noindex: | ||
:members: create_function, delete_function, functions, | ||
get_function_code, get_function_metadata, get_resource_tags, | ||
create_resource_tags, delete_resource_tags, update_pin_status, | ||
update_function_code, update_function_metadata, update_max_instances | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FunctionGraph Resources | ||
======================= | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
v2/function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
otcextensions.sdk.function_graph.v2.function | ||
============================================ | ||
|
||
.. automodule:: otcextensions.sdk.function_graph.v2.function | ||
|
||
The Function Class | ||
------------------ | ||
|
||
The ``Function`` class inherits from | ||
:class:`~otcextensions.sdk.sdk_resource.Resource`. | ||
|
||
.. autoclass:: otcextensions.sdk.function_graph.v2.function.Function | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
""" | ||
Create new function | ||
""" | ||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
sdk.register_otc_extensions(conn) | ||
|
||
attrs = { | ||
'func_name': 'test-function', | ||
'package': 'default', | ||
'runtime': 'Python3.9', | ||
'handler': 'index.handler', | ||
'timeout': 30, | ||
'memory_size': 128, | ||
'code_type': 'inline', | ||
} | ||
fg = conn.functiongraph.create_function(**attrs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
""" | ||
Create resource tags | ||
""" | ||
|
||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
sdk.register_otc_extensions(conn) | ||
|
||
conn.functiongraph.create_resource_tags( | ||
'func_urn', | ||
tags=[ | ||
{ | ||
'key': 'key', | ||
'value': 'value' | ||
}, | ||
{ | ||
'key': 'testKey2', | ||
'value': 'testValue2' | ||
} | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
""" | ||
Delete function | ||
""" | ||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
sdk.register_otc_extensions(conn) | ||
|
||
attrs = { | ||
'func_name': 'test-function', | ||
'package': 'default', | ||
'runtime': 'Python3.9', | ||
'handler': 'index.handler', | ||
'timeout': 30, | ||
'memory_size': 128, | ||
'code_type': 'inline', | ||
} | ||
fg = conn.functiongraph.create_function(**attrs) | ||
conn.functiongraph.delete_function(fg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
""" | ||
Delete resource tags | ||
""" | ||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
sdk.register_otc_extensions(conn) | ||
|
||
conn.functiongraph.delete_resource_tags( | ||
'func_urn', | ||
tags=[ | ||
{ | ||
'key': 'testKey2', | ||
'value': 'testValue2' | ||
} | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
""" | ||
Get function code | ||
""" | ||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
sdk.register_otc_extensions(conn) | ||
|
||
code = conn.functiongraph.get_function_code(function='func_urn') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
""" | ||
Get function metadata | ||
""" | ||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
sdk.register_otc_extensions(conn) | ||
|
||
meta = conn.functiongraph.get_function_metadata(function='func_urn') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
""" | ||
Get resource tags | ||
""" | ||
import openstack | ||
from otcextensions import sdk | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
sdk.register_otc_extensions(conn) | ||
|
||
ft = conn.functiongraph.get_resource_tags(function='func_urn') |
Oops, something went wrong.