|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | + |
| 13 | +from openstack import proxy2 |
| 14 | +from openstack.workflow.v2 import execution as _execution |
| 15 | +from openstack.workflow.v2 import workflow as _workflow |
| 16 | + |
| 17 | + |
| 18 | +class Proxy(proxy2.BaseProxy): |
| 19 | + |
| 20 | + def create_workflow(self, **attrs): |
| 21 | + """Create a new workflow from attributes |
| 22 | +
|
| 23 | + :param dict attrs: Keyword arguments which will be used to create |
| 24 | + a :class:`~openstack.workflow.v2.workflow.Workflow`, |
| 25 | + comprised of the properties on the Workflow class. |
| 26 | +
|
| 27 | + :returns: The results of workflow creation |
| 28 | + :rtype: :class:`~openstack.workflow.v2.workflow.Workflow` |
| 29 | + """ |
| 30 | + return self._create(_workflow.Workflow, **attrs) |
| 31 | + |
| 32 | + def get_workflow(self, *attrs): |
| 33 | + """Get a workflow |
| 34 | +
|
| 35 | + :param workflow: The value can be the name of a workflow or |
| 36 | + :class:`~openstack.workflow.v2.workflow.Workflow` instance. |
| 37 | +
|
| 38 | + :returns: One :class:`~openstack.workflow.v2.workflow.Workflow` |
| 39 | + :raises: :class:`~openstack.exceptions.ResourceNotFound` when no |
| 40 | + workflow matching the name could be found. |
| 41 | + """ |
| 42 | + return self._get(_workflow.Workflow, *attrs) |
| 43 | + |
| 44 | + def workflows(self, **query): |
| 45 | + """Retrieve a generator of workflows |
| 46 | +
|
| 47 | + :param kwargs \*\*query: Optional query parameters to be sent to |
| 48 | + restrict the workflows to be returned. Available parameters |
| 49 | + include: |
| 50 | +
|
| 51 | + * limit: Requests at most the specified number of items be |
| 52 | + returned from the query. |
| 53 | + * marker: Specifies the ID of the last-seen workflow. Use the |
| 54 | + limit parameter to make an initial limited request and use |
| 55 | + the ID of the last-seen workflow from the response as the |
| 56 | + marker parameter value in a subsequent limited request. |
| 57 | +
|
| 58 | + :returns: A generator of workflow instances. |
| 59 | + """ |
| 60 | + return self._list(_workflow.Workflow, paginated=True, **query) |
| 61 | + |
| 62 | + def delete_workflow(self, value, ignore_missing=True): |
| 63 | + """Delete a workflow |
| 64 | +
|
| 65 | + :param value: The value can be either the name of a workflow or a |
| 66 | + :class:`~openstack.workflow.v2.workflow.Workflow` |
| 67 | + instance. |
| 68 | + :param bool ignore_missing: When set to ``False`` |
| 69 | + :class:`~openstack.exceptions.ResourceNotFound` will |
| 70 | + be raised when the workflow does not exist. |
| 71 | + When set to ``True``, no exception will be set when |
| 72 | + attempting to delete a nonexistent workflow. |
| 73 | +
|
| 74 | + :returns: ``None`` |
| 75 | + """ |
| 76 | + return self._delete(_workflow.Workflow, value, |
| 77 | + ignore_missing=ignore_missing) |
| 78 | + |
| 79 | + def find_workflow(self, name_or_id, ignore_missing=True): |
| 80 | + """Find a single workflow |
| 81 | +
|
| 82 | + :param name_or_id: The name or ID of an workflow. |
| 83 | + :param bool ignore_missing: When set to ``False`` |
| 84 | + :class:`~openstack.exceptions.ResourceNotFound` will be |
| 85 | + raised when the resource does not exist. |
| 86 | + When set to ``True``, None will be returned when |
| 87 | + attempting to find a nonexistent resource. |
| 88 | + :returns: One :class:`~openstack.compute.v2.workflow.Extension` or |
| 89 | + None |
| 90 | + """ |
| 91 | + return self._find(_workflow.Workflow, name_or_id, |
| 92 | + ignore_missing=ignore_missing) |
| 93 | + |
| 94 | + def create_execution(self, **attrs): |
| 95 | + """Create a new execution from attributes |
| 96 | +
|
| 97 | + :param workflow_name: The name of target workflow to execute. |
| 98 | + :param dict attrs: Keyword arguments which will be used to create |
| 99 | + a :class:`~openstack.workflow.v2.execution.Execution`, |
| 100 | + comprised of the properties on the Execution class. |
| 101 | +
|
| 102 | + :returns: The results of execution creation |
| 103 | + :rtype: :class:`~openstack.workflow.v2.execution.Execution` |
| 104 | + """ |
| 105 | + return self._create(_execution.Execution, **attrs) |
| 106 | + |
| 107 | + def get_execution(self, *attrs): |
| 108 | + """Get a execution |
| 109 | +
|
| 110 | + :param workflow_name: The name of target workflow to execute. |
| 111 | + :param execution: The value can be either the ID of a execution or a |
| 112 | + :class:`~openstack.workflow.v2.execution.Execution` instance. |
| 113 | +
|
| 114 | + :returns: One :class:`~openstack.workflow.v2.execution.Execution` |
| 115 | + :raises: :class:`~openstack.exceptions.ResourceNotFound` when no |
| 116 | + execution matching the criteria could be found. |
| 117 | + """ |
| 118 | + return self._get(_execution.Execution, *attrs) |
| 119 | + |
| 120 | + def executions(self, **query): |
| 121 | + """Retrieve a generator of executions |
| 122 | +
|
| 123 | + :param kwargs \*\*query: Optional query parameters to be sent to |
| 124 | + restrict the executions to be returned. Available parameters |
| 125 | + include: |
| 126 | +
|
| 127 | + * limit: Requests at most the specified number of items be |
| 128 | + returned from the query. |
| 129 | + * marker: Specifies the ID of the last-seen execution. Use the |
| 130 | + limit parameter to make an initial limited request and use |
| 131 | + the ID of the last-seen execution from the response as the |
| 132 | + marker parameter value in a subsequent limited request. |
| 133 | +
|
| 134 | + :returns: A generator of execution instances. |
| 135 | + """ |
| 136 | + return self._list(_execution.Execution, paginated=True, **query) |
| 137 | + |
| 138 | + def delete_execution(self, value, ignore_missing=True): |
| 139 | + """Delete an execution |
| 140 | +
|
| 141 | + :param value: The value can be either the name of a execution or a |
| 142 | + :class:`~openstack.workflow.v2.execute.Execution` |
| 143 | + instance. |
| 144 | + :param bool ignore_missing: When set to ``False`` |
| 145 | + :class:`~openstack.exceptions.ResourceNotFound` will be |
| 146 | + raised when the execution does not exist. |
| 147 | + When set to ``True``, no exception will be set when |
| 148 | + attempting to delete a nonexistent execution. |
| 149 | +
|
| 150 | + :returns: ``None`` |
| 151 | + """ |
| 152 | + return self._delete(_execution.Execution, value, |
| 153 | + ignore_missing=ignore_missing) |
| 154 | + |
| 155 | + def find_execution(self, name_or_id, ignore_missing=True): |
| 156 | + """Find a single execution |
| 157 | +
|
| 158 | + :param name_or_id: The name or ID of an execution. |
| 159 | + :param bool ignore_missing: When set to ``False`` |
| 160 | + :class:`~openstack.exceptions.ResourceNotFound` will be |
| 161 | + raised when the resource does not exist. |
| 162 | + When set to ``True``, None will be returned when |
| 163 | + attempting to find a nonexistent resource. |
| 164 | + :returns: One :class:`~openstack.compute.v2.execution.Execution` or |
| 165 | + None |
| 166 | + """ |
| 167 | + return self._find(_execution.Execution, name_or_id, |
| 168 | + ignore_missing=ignore_missing) |
0 commit comments