-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathservice_account.py
More file actions
106 lines (85 loc) · 5.24 KB
/
service_account.py
File metadata and controls
106 lines (85 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# coding: utf-8
"""
STACKIT Service Account API
API to manage Service Accounts and their Access Tokens. ### System for Cross-domain Identity Management (SCIM) Service Account Service offers SCIM APIs to query state. The SCIM protocol was created as standard for automating the exchange of user identity information between identity domains, or IT systems. Service accounts are be handled as indentites similar to SCIM users. A custom SCIM schema has been created: `/ServiceAccounts` #### Syntax ##### Attribute operators | OPERATOR | DESCRIPTION | |----------|--------------------------| | eq | equal | | ne | not equal | | co | contains | | sw | starts with | | ew | ends with | ##### Logical operators | OPERATOR | DESCRIPTION | |----------|--------------------------| | and | logical \"and\" | | or | logical \"or\" | ##### Grouping operators | OPERATOR | DESCRIPTION | |----------|--------------------------| | () | precending grouping | ##### Example ``` filter=email eq \"my-service-account-aBc2defg@sa.stackit.cloud\" filter=email ne \"my-service-account-aBc2defg@sa.stackit.cloud\" filter=email co \"my-service-account\" filter=name sw \"my\" filter=name ew \"account\" filter=email co \"my-service-account\" and name sw \"my\" filter=email co \"my-service-account\" and (name sw \"my\" or name ew \"account\") ``` #### Sorting > Sorting is optional | PARAMETER | DESCRIPTION | |-----------|--------------------------------------| | sortBy | attribute response is ordered by | | sortOrder | 'ASCENDING' (default) or 'DESCENDING'| #### Pagination | PARAMETER | DESCRIPTION | |--------------|----------------------------------------------| | startIndex | index of first query result, default: 1 | | count | maximum number of query results, default: 100|
The version of the OpenAPI document: 2.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set
from uuid import UUID
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBool,
StrictStr,
)
from typing_extensions import Self
class ServiceAccount(BaseModel):
"""
ServiceAccount
""" # noqa: E501
email: StrictStr = Field(
description="Unique identifier of the service account in format of an email address generated by the service containing the prefix provided by the user during creation."
)
id: UUID = Field(
description="Unique ID of the service account. It is also used in the 'sub' field of the service accounts access tokens."
)
internal: StrictBool = Field(description="Flag indicating internal service accounts")
project_id: StrictStr = Field(description="ID of the related project", alias="projectId")
token_endpoint: StrictStr = Field(
description="Endpoint used to obtain access tokens for the service account", alias="tokenEndpoint"
)
__properties: ClassVar[List[str]] = ["email", "id", "internal", "projectId", "tokenEndpoint"]
model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of ServiceAccount from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of ServiceAccount from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate(
{
"email": obj.get("email"),
"id": obj.get("id"),
"internal": obj.get("internal"),
"projectId": obj.get("projectId"),
"tokenEndpoint": obj.get("tokenEndpoint"),
}
)
return _obj