stackit-authorization 0.2.5__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/PKG-INFO +8 -4
  2. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/pyproject.toml +2 -2
  3. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/__init__.py +8 -0
  4. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/api/default_api.py +270 -0
  5. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/__init__.py +4 -0
  6. stackit_authorization-0.4.0/src/stackit/authorization/models/assignable_subject.py +82 -0
  7. stackit_authorization-0.4.0/src/stackit/authorization/models/list_assignable_subjects_response.py +117 -0
  8. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/LICENSE.md +0 -0
  9. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/NOTICE.txt +0 -0
  10. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/README.md +0 -0
  11. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/api/__init__.py +0 -0
  12. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/api_client.py +0 -0
  13. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/api_response.py +0 -0
  14. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/configuration.py +0 -0
  15. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/exceptions.py +0 -0
  16. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/add_members_payload.py +0 -0
  17. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/error_response.py +0 -0
  18. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/existing_permission.py +0 -0
  19. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/list_members_response.py +0 -0
  20. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/list_permissions_response.py +0 -0
  21. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/list_user_memberships_response.py +0 -0
  22. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/list_user_permissions_response.py +0 -0
  23. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/member.py +0 -0
  24. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/members_response.py +0 -0
  25. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/permission.py +0 -0
  26. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/remove_members_payload.py +0 -0
  27. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/role.py +0 -0
  28. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/roles_response.py +0 -0
  29. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/user_membership.py +0 -0
  30. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/user_permission.py +0 -0
  31. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/models/zookie.py +0 -0
  32. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/py.typed +0 -0
  33. {stackit_authorization-0.2.5 → stackit_authorization-0.4.0}/src/stackit/authorization/rest.py +0 -0
@@ -1,23 +1,27 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: stackit-authorization
3
- Version: 0.2.5
3
+ Version: 0.4.0
4
4
  Summary: STACKIT Membership API
5
+ License-File: LICENSE.md
6
+ License-File: NOTICE.txt
5
7
  Author: STACKIT Developer Tools
6
8
  Author-email: developer-tools@stackit.cloud
7
- Requires-Python: >=3.8,<4.0
9
+ Requires-Python: >=3.9,<4.0
8
10
  Classifier: License :: OSI Approved :: Apache Software License
9
11
  Classifier: Operating System :: OS Independent
10
12
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.8
12
13
  Classifier: Programming Language :: Python :: 3.9
13
14
  Classifier: Programming Language :: Python :: 3.10
14
15
  Classifier: Programming Language :: Python :: 3.11
15
16
  Classifier: Programming Language :: Python :: 3.12
16
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
17
19
  Requires-Dist: pydantic (>=2.9.2)
18
20
  Requires-Dist: python-dateutil (>=2.9.0.post0)
19
21
  Requires-Dist: requests (>=2.32.3)
20
22
  Requires-Dist: stackit-core (>=0.0.1a)
23
+ Project-URL: Homepage, https://github.com/stackitcloud/stackit-sdk-python
24
+ Project-URL: Issues, https://github.com/stackitcloud/stackit-sdk-python/issues
21
25
  Description-Content-Type: text/markdown
22
26
 
23
27
  # stackit.authorization
@@ -3,7 +3,7 @@ name = "stackit-authorization"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "stackit-authorization"
6
- version = "v0.2.5"
6
+ version = "v0.4.0"
7
7
  authors = [
8
8
  "STACKIT Developer Tools <developer-tools@stackit.cloud>",
9
9
  ]
@@ -20,7 +20,7 @@ packages = [
20
20
  ]
21
21
 
22
22
  [tool.poetry.dependencies]
23
- python = ">=3.8,<4.0"
23
+ python = ">=3.9,<4.0"
24
24
  stackit-core = ">=0.0.1a"
25
25
  requests = ">=2.32.3"
26
26
  pydantic = ">=2.9.2"
@@ -29,8 +29,10 @@ __all__ = [
29
29
  "ApiAttributeError",
30
30
  "ApiException",
31
31
  "AddMembersPayload",
32
+ "AssignableSubject",
32
33
  "ErrorResponse",
33
34
  "ExistingPermission",
35
+ "ListAssignableSubjectsResponse",
34
36
  "ListMembersResponse",
35
37
  "ListPermissionsResponse",
36
38
  "ListUserMembershipsResponse",
@@ -64,10 +66,16 @@ from stackit.authorization.exceptions import OpenApiException as OpenApiExceptio
64
66
  from stackit.authorization.models.add_members_payload import (
65
67
  AddMembersPayload as AddMembersPayload,
66
68
  )
69
+ from stackit.authorization.models.assignable_subject import (
70
+ AssignableSubject as AssignableSubject,
71
+ )
67
72
  from stackit.authorization.models.error_response import ErrorResponse as ErrorResponse
68
73
  from stackit.authorization.models.existing_permission import (
69
74
  ExistingPermission as ExistingPermission,
70
75
  )
76
+ from stackit.authorization.models.list_assignable_subjects_response import (
77
+ ListAssignableSubjectsResponse as ListAssignableSubjectsResponse,
78
+ )
71
79
  from stackit.authorization.models.list_members_response import (
72
80
  ListMembersResponse as ListMembersResponse,
73
81
  )
@@ -20,6 +20,9 @@ from typing_extensions import Annotated
20
20
  from stackit.authorization.api_client import ApiClient, RequestSerialized
21
21
  from stackit.authorization.api_response import ApiResponse
22
22
  from stackit.authorization.models.add_members_payload import AddMembersPayload
23
+ from stackit.authorization.models.list_assignable_subjects_response import (
24
+ ListAssignableSubjectsResponse,
25
+ )
23
26
  from stackit.authorization.models.list_members_response import ListMembersResponse
24
27
  from stackit.authorization.models.list_permissions_response import (
25
28
  ListPermissionsResponse,
@@ -307,6 +310,273 @@ class DefaultApi:
307
310
  _request_auth=_request_auth,
308
311
  )
309
312
 
313
+ @validate_call
314
+ def get_assignable_subjects(
315
+ self,
316
+ resource_type: StrictStr,
317
+ resource_id: StrictStr,
318
+ subject: Optional[StrictStr] = None,
319
+ _request_timeout: Union[
320
+ None,
321
+ Annotated[StrictFloat, Field(gt=0)],
322
+ Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
323
+ ] = None,
324
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
325
+ _content_type: Optional[StrictStr] = None,
326
+ _headers: Optional[Dict[StrictStr, Any]] = None,
327
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
328
+ ) -> ListAssignableSubjectsResponse:
329
+ """Get subjects assignable to a resource
330
+
331
+ BFF endpoint for portal. List subjects assignable to a given resource.
332
+
333
+ :param resource_type: (required)
334
+ :type resource_type: str
335
+ :param resource_id: (required)
336
+ :type resource_id: str
337
+ :param subject:
338
+ :type subject: str
339
+ :param _request_timeout: timeout setting for this request. If one
340
+ number provided, it will be total request
341
+ timeout. It can also be a pair (tuple) of
342
+ (connection, read) timeouts.
343
+ :type _request_timeout: int, tuple(int, int), optional
344
+ :param _request_auth: set to override the auth_settings for an a single
345
+ request; this effectively ignores the
346
+ authentication in the spec for a single request.
347
+ :type _request_auth: dict, optional
348
+ :param _content_type: force content-type for the request.
349
+ :type _content_type: str, Optional
350
+ :param _headers: set to override the headers for a single
351
+ request; this effectively ignores the headers
352
+ in the spec for a single request.
353
+ :type _headers: dict, optional
354
+ :param _host_index: set to override the host_index for a single
355
+ request; this effectively ignores the host_index
356
+ in the spec for a single request.
357
+ :type _host_index: int, optional
358
+ :return: Returns the result object.
359
+ """ # noqa: E501
360
+
361
+ _param = self._get_assignable_subjects_serialize(
362
+ resource_type=resource_type,
363
+ resource_id=resource_id,
364
+ subject=subject,
365
+ _request_auth=_request_auth,
366
+ _content_type=_content_type,
367
+ _headers=_headers,
368
+ _host_index=_host_index,
369
+ )
370
+
371
+ _response_types_map: Dict[str, Optional[str]] = {
372
+ "200": "ListAssignableSubjectsResponse",
373
+ "400": "ErrorResponse",
374
+ "401": "ErrorResponse",
375
+ "403": "ErrorResponse",
376
+ }
377
+ response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
378
+ response_data.read()
379
+ return self.api_client.response_deserialize(
380
+ response_data=response_data,
381
+ response_types_map=_response_types_map,
382
+ ).data
383
+
384
+ @validate_call
385
+ def get_assignable_subjects_with_http_info(
386
+ self,
387
+ resource_type: StrictStr,
388
+ resource_id: StrictStr,
389
+ subject: Optional[StrictStr] = None,
390
+ _request_timeout: Union[
391
+ None,
392
+ Annotated[StrictFloat, Field(gt=0)],
393
+ Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
394
+ ] = None,
395
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
396
+ _content_type: Optional[StrictStr] = None,
397
+ _headers: Optional[Dict[StrictStr, Any]] = None,
398
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
399
+ ) -> ApiResponse[ListAssignableSubjectsResponse]:
400
+ """Get subjects assignable to a resource
401
+
402
+ BFF endpoint for portal. List subjects assignable to a given resource.
403
+
404
+ :param resource_type: (required)
405
+ :type resource_type: str
406
+ :param resource_id: (required)
407
+ :type resource_id: str
408
+ :param subject:
409
+ :type subject: str
410
+ :param _request_timeout: timeout setting for this request. If one
411
+ number provided, it will be total request
412
+ timeout. It can also be a pair (tuple) of
413
+ (connection, read) timeouts.
414
+ :type _request_timeout: int, tuple(int, int), optional
415
+ :param _request_auth: set to override the auth_settings for an a single
416
+ request; this effectively ignores the
417
+ authentication in the spec for a single request.
418
+ :type _request_auth: dict, optional
419
+ :param _content_type: force content-type for the request.
420
+ :type _content_type: str, Optional
421
+ :param _headers: set to override the headers for a single
422
+ request; this effectively ignores the headers
423
+ in the spec for a single request.
424
+ :type _headers: dict, optional
425
+ :param _host_index: set to override the host_index for a single
426
+ request; this effectively ignores the host_index
427
+ in the spec for a single request.
428
+ :type _host_index: int, optional
429
+ :return: Returns the result object.
430
+ """ # noqa: E501
431
+
432
+ _param = self._get_assignable_subjects_serialize(
433
+ resource_type=resource_type,
434
+ resource_id=resource_id,
435
+ subject=subject,
436
+ _request_auth=_request_auth,
437
+ _content_type=_content_type,
438
+ _headers=_headers,
439
+ _host_index=_host_index,
440
+ )
441
+
442
+ _response_types_map: Dict[str, Optional[str]] = {
443
+ "200": "ListAssignableSubjectsResponse",
444
+ "400": "ErrorResponse",
445
+ "401": "ErrorResponse",
446
+ "403": "ErrorResponse",
447
+ }
448
+ response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
449
+ response_data.read()
450
+ return self.api_client.response_deserialize(
451
+ response_data=response_data,
452
+ response_types_map=_response_types_map,
453
+ )
454
+
455
+ @validate_call
456
+ def get_assignable_subjects_without_preload_content(
457
+ self,
458
+ resource_type: StrictStr,
459
+ resource_id: StrictStr,
460
+ subject: Optional[StrictStr] = None,
461
+ _request_timeout: Union[
462
+ None,
463
+ Annotated[StrictFloat, Field(gt=0)],
464
+ Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
465
+ ] = None,
466
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
467
+ _content_type: Optional[StrictStr] = None,
468
+ _headers: Optional[Dict[StrictStr, Any]] = None,
469
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
470
+ ) -> RESTResponseType:
471
+ """Get subjects assignable to a resource
472
+
473
+ BFF endpoint for portal. List subjects assignable to a given resource.
474
+
475
+ :param resource_type: (required)
476
+ :type resource_type: str
477
+ :param resource_id: (required)
478
+ :type resource_id: str
479
+ :param subject:
480
+ :type subject: str
481
+ :param _request_timeout: timeout setting for this request. If one
482
+ number provided, it will be total request
483
+ timeout. It can also be a pair (tuple) of
484
+ (connection, read) timeouts.
485
+ :type _request_timeout: int, tuple(int, int), optional
486
+ :param _request_auth: set to override the auth_settings for an a single
487
+ request; this effectively ignores the
488
+ authentication in the spec for a single request.
489
+ :type _request_auth: dict, optional
490
+ :param _content_type: force content-type for the request.
491
+ :type _content_type: str, Optional
492
+ :param _headers: set to override the headers for a single
493
+ request; this effectively ignores the headers
494
+ in the spec for a single request.
495
+ :type _headers: dict, optional
496
+ :param _host_index: set to override the host_index for a single
497
+ request; this effectively ignores the host_index
498
+ in the spec for a single request.
499
+ :type _host_index: int, optional
500
+ :return: Returns the result object.
501
+ """ # noqa: E501
502
+
503
+ _param = self._get_assignable_subjects_serialize(
504
+ resource_type=resource_type,
505
+ resource_id=resource_id,
506
+ subject=subject,
507
+ _request_auth=_request_auth,
508
+ _content_type=_content_type,
509
+ _headers=_headers,
510
+ _host_index=_host_index,
511
+ )
512
+
513
+ _response_types_map: Dict[str, Optional[str]] = {
514
+ "200": "ListAssignableSubjectsResponse",
515
+ "400": "ErrorResponse",
516
+ "401": "ErrorResponse",
517
+ "403": "ErrorResponse",
518
+ }
519
+ response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
520
+ return response_data.response
521
+
522
+ def _get_assignable_subjects_serialize(
523
+ self,
524
+ resource_type,
525
+ resource_id,
526
+ subject,
527
+ _request_auth,
528
+ _content_type,
529
+ _headers,
530
+ _host_index,
531
+ ) -> RequestSerialized:
532
+
533
+ _host = None
534
+
535
+ _collection_formats: Dict[str, str] = {}
536
+
537
+ _path_params: Dict[str, str] = {}
538
+ _query_params: List[Tuple[str, str]] = []
539
+ _header_params: Dict[str, Optional[str]] = _headers or {}
540
+ _form_params: List[Tuple[str, str]] = []
541
+ _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
542
+ _body_params: Optional[bytes] = None
543
+
544
+ # process the path parameters
545
+ if resource_type is not None:
546
+ _path_params["resourceType"] = resource_type
547
+ if resource_id is not None:
548
+ _path_params["resourceId"] = resource_id
549
+ # process the query parameters
550
+ if subject is not None:
551
+
552
+ _query_params.append(("subject", subject))
553
+
554
+ # process the header parameters
555
+ # process the form parameters
556
+ # process the body parameter
557
+
558
+ # set the HTTP header `Accept`
559
+ if "Accept" not in _header_params:
560
+ _header_params["Accept"] = self.api_client.select_header_accept(["application/json"])
561
+
562
+ # authentication setting
563
+ _auth_settings: List[str] = []
564
+
565
+ return self.api_client.param_serialize(
566
+ method="GET",
567
+ resource_path="/v2/bff/{resourceType}/{resourceId}/assignableSubjects",
568
+ path_params=_path_params,
569
+ query_params=_query_params,
570
+ header_params=_header_params,
571
+ body=_body_params,
572
+ post_params=_form_params,
573
+ files=_files,
574
+ auth_settings=_auth_settings,
575
+ collection_formats=_collection_formats,
576
+ _host=_host,
577
+ _request_auth=_request_auth,
578
+ )
579
+
310
580
  @validate_call
311
581
  def list_members(
312
582
  self,
@@ -15,8 +15,12 @@
15
15
 
16
16
  # import models into model package
17
17
  from stackit.authorization.models.add_members_payload import AddMembersPayload
18
+ from stackit.authorization.models.assignable_subject import AssignableSubject
18
19
  from stackit.authorization.models.error_response import ErrorResponse
19
20
  from stackit.authorization.models.existing_permission import ExistingPermission
21
+ from stackit.authorization.models.list_assignable_subjects_response import (
22
+ ListAssignableSubjectsResponse,
23
+ )
20
24
  from stackit.authorization.models.list_members_response import ListMembersResponse
21
25
  from stackit.authorization.models.list_permissions_response import (
22
26
  ListPermissionsResponse,
@@ -0,0 +1,82 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Membership API
5
+
6
+ The Membership API is used to manage memberships, roles and permissions of STACKIT resources, like projects, folders, organizations and other resources.
7
+
8
+ The version of the OpenAPI document: 2.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from typing_extensions import Annotated, Self
22
+
23
+
24
+ class AssignableSubject(BaseModel):
25
+ """
26
+ AssignableSubject
27
+ """ # noqa: E501
28
+
29
+ display_name: Optional[StrictStr] = Field(default=None, alias="displayName")
30
+ subject: Annotated[str, Field(min_length=1, strict=True, max_length=255)]
31
+ __properties: ClassVar[List[str]] = ["displayName", "subject"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+ def to_str(self) -> str:
40
+ """Returns the string representation of the model using alias"""
41
+ return pprint.pformat(self.model_dump(by_alias=True))
42
+
43
+ def to_json(self) -> str:
44
+ """Returns the JSON representation of the model using alias"""
45
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46
+ return json.dumps(self.to_dict())
47
+
48
+ @classmethod
49
+ def from_json(cls, json_str: str) -> Optional[Self]:
50
+ """Create an instance of AssignableSubject from a JSON string"""
51
+ return cls.from_dict(json.loads(json_str))
52
+
53
+ def to_dict(self) -> Dict[str, Any]:
54
+ """Return the dictionary representation of the model using alias.
55
+
56
+ This has the following differences from calling pydantic's
57
+ `self.model_dump(by_alias=True)`:
58
+
59
+ * `None` is only added to the output dict for nullable fields that
60
+ were set at model initialization. Other fields with value `None`
61
+ are ignored.
62
+ """
63
+ excluded_fields: Set[str] = set([])
64
+
65
+ _dict = self.model_dump(
66
+ by_alias=True,
67
+ exclude=excluded_fields,
68
+ exclude_none=True,
69
+ )
70
+ return _dict
71
+
72
+ @classmethod
73
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
74
+ """Create an instance of AssignableSubject from a dict"""
75
+ if obj is None:
76
+ return None
77
+
78
+ if not isinstance(obj, dict):
79
+ return cls.model_validate(obj)
80
+
81
+ _obj = cls.model_validate({"displayName": obj.get("displayName"), "subject": obj.get("subject")})
82
+ return _obj
@@ -0,0 +1,117 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Membership API
5
+
6
+ The Membership API is used to manage memberships, roles and permissions of STACKIT resources, like projects, folders, organizations and other resources.
7
+
8
+ The version of the OpenAPI document: 2.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ import re # noqa: F401
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+ from stackit.authorization.models.assignable_subject import AssignableSubject
25
+
26
+
27
+ class ListAssignableSubjectsResponse(BaseModel):
28
+ """
29
+ ListAssignableSubjectsResponse
30
+ """ # noqa: E501
31
+
32
+ resource_id: Annotated[str, Field(strict=True)] = Field(alias="resourceId")
33
+ resource_type: Annotated[str, Field(strict=True)] = Field(alias="resourceType")
34
+ subjects: List[AssignableSubject]
35
+ __properties: ClassVar[List[str]] = ["resourceId", "resourceType", "subjects"]
36
+
37
+ @field_validator("resource_id")
38
+ def resource_id_validate_regular_expression(cls, value):
39
+ """Validates the regular expression"""
40
+ if not re.match(r"^([a-zA-Z0-9\/_|\-=+@.]{1,})$", value):
41
+ raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9\/_|\-=+@.]{1,})$/")
42
+ return value
43
+
44
+ @field_validator("resource_type")
45
+ def resource_type_validate_regular_expression(cls, value):
46
+ """Validates the regular expression"""
47
+ if not re.match(r"^[a-z](?:-?[a-z]){1,63}$", value):
48
+ raise ValueError(r"must validate the regular expression /^[a-z](?:-?[a-z]){1,63}$/")
49
+ return value
50
+
51
+ model_config = ConfigDict(
52
+ populate_by_name=True,
53
+ validate_assignment=True,
54
+ protected_namespaces=(),
55
+ )
56
+
57
+ def to_str(self) -> str:
58
+ """Returns the string representation of the model using alias"""
59
+ return pprint.pformat(self.model_dump(by_alias=True))
60
+
61
+ def to_json(self) -> str:
62
+ """Returns the JSON representation of the model using alias"""
63
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
64
+ return json.dumps(self.to_dict())
65
+
66
+ @classmethod
67
+ def from_json(cls, json_str: str) -> Optional[Self]:
68
+ """Create an instance of ListAssignableSubjectsResponse from a JSON string"""
69
+ return cls.from_dict(json.loads(json_str))
70
+
71
+ def to_dict(self) -> Dict[str, Any]:
72
+ """Return the dictionary representation of the model using alias.
73
+
74
+ This has the following differences from calling pydantic's
75
+ `self.model_dump(by_alias=True)`:
76
+
77
+ * `None` is only added to the output dict for nullable fields that
78
+ were set at model initialization. Other fields with value `None`
79
+ are ignored.
80
+ """
81
+ excluded_fields: Set[str] = set([])
82
+
83
+ _dict = self.model_dump(
84
+ by_alias=True,
85
+ exclude=excluded_fields,
86
+ exclude_none=True,
87
+ )
88
+ # override the default output from pydantic by calling `to_dict()` of each item in subjects (list)
89
+ _items = []
90
+ if self.subjects:
91
+ for _item in self.subjects:
92
+ if _item:
93
+ _items.append(_item.to_dict())
94
+ _dict["subjects"] = _items
95
+ return _dict
96
+
97
+ @classmethod
98
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
99
+ """Create an instance of ListAssignableSubjectsResponse from a dict"""
100
+ if obj is None:
101
+ return None
102
+
103
+ if not isinstance(obj, dict):
104
+ return cls.model_validate(obj)
105
+
106
+ _obj = cls.model_validate(
107
+ {
108
+ "resourceId": obj.get("resourceId"),
109
+ "resourceType": obj.get("resourceType"),
110
+ "subjects": (
111
+ [AssignableSubject.from_dict(_item) for _item in obj["subjects"]]
112
+ if obj.get("subjects") is not None
113
+ else None
114
+ ),
115
+ }
116
+ )
117
+ return _obj