Skip to content

Commit 8eab29a

Browse files
authored
Add group operations (#80)
* Add group operations * Requested changes
1 parent 45ffb92 commit 8eab29a

18 files changed

+687
-30
lines changed

kuflow-rest/kuflow_rest/_generated/_client.py

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from ._serialization import Deserializer, Serializer
4444
from .operations import (
4545
AuthenticationOperations,
46+
GroupOperations,
4647
KmsOperations,
4748
PrincipalOperations,
4849
ProcessItemOperations,
@@ -115,6 +116,8 @@ class KuFlowRestClient: # pylint: disable=client-accepts-api-version-keyword,to
115116
:vartype kms: kuflow.rest.operations.KmsOperations
116117
:ivar principal: PrincipalOperations operations
117118
:vartype principal: kuflow.rest.operations.PrincipalOperations
119+
:ivar group: GroupOperations operations
120+
:vartype group: kuflow.rest.operations.GroupOperations
118121
:ivar tenant: TenantOperations operations
119122
:vartype tenant: kuflow.rest.operations.TenantOperations
120123
:ivar tenant_user: TenantUserOperations operations
@@ -163,6 +166,7 @@ def __init__(
163166
self.authentication = AuthenticationOperations(self._client, self._config, self._serialize, self._deserialize)
164167
self.kms = KmsOperations(self._client, self._config, self._serialize, self._deserialize)
165168
self.principal = PrincipalOperations(self._client, self._config, self._serialize, self._deserialize)
169+
self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize)
166170
self.tenant = TenantOperations(self._client, self._config, self._serialize, self._deserialize)
167171
self.tenant_user = TenantUserOperations(self._client, self._config, self._serialize, self._deserialize)
168172
self.process = ProcessOperations(self._client, self._config, self._serialize, self._deserialize)

kuflow-rest/kuflow_rest/_generated/aio/_client.py

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from ._configuration import KuFlowRestClientConfiguration
4444
from .operations import (
4545
AuthenticationOperations,
46+
GroupOperations,
4647
KmsOperations,
4748
PrincipalOperations,
4849
ProcessItemOperations,
@@ -115,6 +116,8 @@ class KuFlowRestClient: # pylint: disable=client-accepts-api-version-keyword,to
115116
:vartype kms: kuflow.rest.aio.operations.KmsOperations
116117
:ivar principal: PrincipalOperations operations
117118
:vartype principal: kuflow.rest.aio.operations.PrincipalOperations
119+
:ivar group: GroupOperations operations
120+
:vartype group: kuflow.rest.aio.operations.GroupOperations
118121
:ivar tenant: TenantOperations operations
119122
:vartype tenant: kuflow.rest.aio.operations.TenantOperations
120123
:ivar tenant_user: TenantUserOperations operations
@@ -163,6 +166,7 @@ def __init__(
163166
self.authentication = AuthenticationOperations(self._client, self._config, self._serialize, self._deserialize)
164167
self.kms = KmsOperations(self._client, self._config, self._serialize, self._deserialize)
165168
self.principal = PrincipalOperations(self._client, self._config, self._serialize, self._deserialize)
169+
self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize)
166170
self.tenant = TenantOperations(self._client, self._config, self._serialize, self._deserialize)
167171
self.tenant_user = TenantUserOperations(self._client, self._config, self._serialize, self._deserialize)
168172
self.process = ProcessOperations(self._client, self._config, self._serialize, self._deserialize)

kuflow-rest/kuflow_rest/_generated/aio/operations/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from ._authentication_operations import AuthenticationOperations # type: ignore
4040
from ._kms_operations import KmsOperations # type: ignore
4141
from ._principal_operations import PrincipalOperations # type: ignore
42+
from ._group_operations import GroupOperations # type: ignore
4243
from ._tenant_operations import TenantOperations # type: ignore
4344
from ._tenant_user_operations import TenantUserOperations # type: ignore
4445
from ._process_operations import ProcessOperations # type: ignore
@@ -54,6 +55,7 @@
5455
"AuthenticationOperations",
5556
"KmsOperations",
5657
"PrincipalOperations",
58+
"GroupOperations",
5759
"TenantOperations",
5860
"TenantUserOperations",
5961
"ProcessOperations",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
#
4+
# MIT License
5+
#
6+
# Copyright (c) 2022 KuFlow
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the "Software"), to deal
10+
# in the Software without restriction, including without limitation the rights
11+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in all
16+
# copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
# SOFTWARE.
25+
#
26+
# --------------------------------------------------------------------------
27+
#
28+
# Code generated by Microsoft (R) AutoRest Code Generator.
29+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
30+
#
31+
# --------------------------------------------------------------------------
32+
import sys
33+
from typing import Any, Callable, Dict, List, Optional, TypeVar
34+
35+
from azure.core import AsyncPipelineClient
36+
from azure.core.exceptions import (
37+
ClientAuthenticationError,
38+
HttpResponseError,
39+
ResourceExistsError,
40+
ResourceNotFoundError,
41+
ResourceNotModifiedError,
42+
map_error,
43+
)
44+
from azure.core.pipeline import PipelineResponse
45+
from azure.core.rest import AsyncHttpResponse, HttpRequest
46+
from azure.core.tracing.decorator_async import distributed_trace_async
47+
48+
from ... import models as _models
49+
from ..._serialization import Deserializer, Serializer
50+
from ...operations._group_operations import build_find_groups_request
51+
from .._configuration import KuFlowRestClientConfiguration
52+
53+
if sys.version_info >= (3, 9):
54+
from collections.abc import MutableMapping
55+
else:
56+
from typing import MutableMapping # type: ignore
57+
T = TypeVar("T")
58+
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
59+
60+
61+
class GroupOperations:
62+
"""
63+
.. warning::
64+
**DO NOT** instantiate this class directly.
65+
66+
Instead, you should access the following operations through
67+
:class:`~kuflow.rest.aio.KuFlowRestClient`'s
68+
:attr:`group` attribute.
69+
"""
70+
71+
models = _models
72+
73+
def __init__(self, *args, **kwargs) -> None:
74+
input_args = list(args)
75+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
76+
self._config: KuFlowRestClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
77+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
78+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
79+
80+
@distributed_trace_async
81+
async def find_groups(
82+
self,
83+
*,
84+
size: int = 25,
85+
page: int = 0,
86+
sort: Optional[List[str]] = None,
87+
tenant_id: Optional[List[str]] = None,
88+
principal_id: Optional[str] = None,
89+
**kwargs: Any,
90+
) -> _models.GroupPage:
91+
"""Find all accessible Groups.
92+
93+
List all the Groups that have been created and the used credentials has access.
94+
95+
Available sort query values: id, name.
96+
97+
:keyword size: The number of records returned within a single API call. Default value is 25.
98+
:paramtype size: int
99+
:keyword page: The page number of the current page in the returned records, 0 is the first
100+
page. Default value is 0.
101+
:paramtype page: int
102+
:keyword sort: Sorting criteria in the format: property{,asc|desc}. Example: createdAt,desc
103+
104+
Default sort order is ascending. Multiple sort criteria are supported.
105+
106+
Please refer to the method description for supported properties. Default value is None.
107+
:paramtype sort: list[str]
108+
:keyword tenant_id: Filter by tenantId. Default value is None.
109+
:paramtype tenant_id: list[str]
110+
:keyword principal_id: Filter by principalId. Default value is None.
111+
:paramtype principal_id: str
112+
:return: GroupPage
113+
:rtype: ~kuflow.rest.models.GroupPage
114+
:raises ~azure.core.exceptions.HttpResponseError:
115+
"""
116+
error_map: MutableMapping = {
117+
401: ClientAuthenticationError,
118+
404: ResourceNotFoundError,
119+
409: ResourceExistsError,
120+
304: ResourceNotModifiedError,
121+
}
122+
error_map.update(kwargs.pop("error_map", {}) or {})
123+
124+
_headers = kwargs.pop("headers", {}) or {}
125+
_params = kwargs.pop("params", {}) or {}
126+
127+
cls: ClsType[_models.GroupPage] = kwargs.pop("cls", None)
128+
129+
_request = build_find_groups_request(
130+
size=size,
131+
page=page,
132+
sort=sort,
133+
tenant_id=tenant_id,
134+
principal_id=principal_id,
135+
headers=_headers,
136+
params=_params,
137+
)
138+
_request.url = self._client.format_url(_request.url)
139+
140+
_stream = False
141+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
142+
_request, stream=_stream, **kwargs
143+
)
144+
145+
response = pipeline_response.http_response
146+
147+
if response.status_code not in [200]:
148+
map_error(status_code=response.status_code, response=response, error_map=error_map)
149+
error = self._deserialize.failsafe_deserialize(_models.DefaultError, pipeline_response)
150+
raise HttpResponseError(response=response, model=error)
151+
152+
deserialized = self._deserialize("GroupPage", pipeline_response.http_response)
153+
154+
if cls:
155+
return cls(pipeline_response, deserialized, {}) # type: ignore
156+
157+
return deserialized # type: ignore

kuflow-rest/kuflow_rest/_generated/models/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
DefaultError,
4848
DefaultErrorInfo,
4949
DocumentReference,
50+
GroupPage,
51+
GroupPageItem,
5052
JsonPatchOperation,
5153
JsonValue,
5254
JsonValueError,
@@ -109,6 +111,7 @@
109111
AuthenticationType,
110112
JsonPatchOperationType,
111113
PrincipalType,
114+
GroupType,
112115
ProcessItemTaskLogLevel,
113116
ProcessItemTaskState,
114117
ProcessItemType,
@@ -135,6 +138,9 @@
135138
"DefaultError",
136139
"DefaultErrorInfo",
137140
"DocumentReference",
141+
"GroupPage",
142+
"GroupPageItem",
143+
"GroupType",
138144
"JsonPatchOperation",
139145
"JsonValue",
140146
"JsonValueError",

kuflow-rest/kuflow_rest/_generated/models/_enums.py

+9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
6060
SYSTEM = "SYSTEM"
6161

6262

63+
class GroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
64+
"""PrincipalType."""
65+
66+
TENANT_OWNER = "TENANT_OWNER"
67+
TENANT_ADMINISTRATOR = "TENANT_ADMINISTRATOR"
68+
TENANT_USER = "TENANT_USER"
69+
OTHERS = "OTHERS"
70+
71+
6372
class ProcessItemTaskLogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta):
6473
"""ProcessItemTaskLogLevel."""
6574

0 commit comments

Comments
 (0)