stackit-loadbalancer 0.0.1a1__py3-none-any.whl

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 (46) hide show
  1. stackit/loadbalancer/__init__.py +94 -0
  2. stackit/loadbalancer/api/__init__.py +4 -0
  3. stackit/loadbalancer/api/default_api.py +4224 -0
  4. stackit/loadbalancer/api_client.py +626 -0
  5. stackit/loadbalancer/api_response.py +23 -0
  6. stackit/loadbalancer/configuration.py +111 -0
  7. stackit/loadbalancer/exceptions.py +198 -0
  8. stackit/loadbalancer/models/__init__.py +75 -0
  9. stackit/loadbalancer/models/active_health_check.py +142 -0
  10. stackit/loadbalancer/models/create_credentials_payload.py +104 -0
  11. stackit/loadbalancer/models/create_credentials_response.py +92 -0
  12. stackit/loadbalancer/models/create_load_balancer_payload.py +231 -0
  13. stackit/loadbalancer/models/credentials_response.py +106 -0
  14. stackit/loadbalancer/models/get_credentials_response.py +92 -0
  15. stackit/loadbalancer/models/get_quota_response.py +106 -0
  16. stackit/loadbalancer/models/get_service_status_response.py +103 -0
  17. stackit/loadbalancer/models/google_protobuf_any.py +97 -0
  18. stackit/loadbalancer/models/list_credentials_response.py +98 -0
  19. stackit/loadbalancer/models/list_load_balancers_response.py +115 -0
  20. stackit/loadbalancer/models/list_plans_response.py +98 -0
  21. stackit/loadbalancer/models/listener.py +162 -0
  22. stackit/loadbalancer/models/load_balancer.py +231 -0
  23. stackit/loadbalancer/models/load_balancer_error.py +113 -0
  24. stackit/loadbalancer/models/load_balancer_options.py +116 -0
  25. stackit/loadbalancer/models/loadbalancer_option_access_control.py +85 -0
  26. stackit/loadbalancer/models/loadbalancer_option_logs.py +90 -0
  27. stackit/loadbalancer/models/loadbalancer_option_metrics.py +90 -0
  28. stackit/loadbalancer/models/loadbalancer_option_observability.py +100 -0
  29. stackit/loadbalancer/models/network.py +112 -0
  30. stackit/loadbalancer/models/options_tcp.py +96 -0
  31. stackit/loadbalancer/models/options_udp.py +96 -0
  32. stackit/loadbalancer/models/plan_details.py +97 -0
  33. stackit/loadbalancer/models/server_name_indicator.py +81 -0
  34. stackit/loadbalancer/models/session_persistence.py +85 -0
  35. stackit/loadbalancer/models/status.py +111 -0
  36. stackit/loadbalancer/models/target.py +97 -0
  37. stackit/loadbalancer/models/target_pool.py +137 -0
  38. stackit/loadbalancer/models/update_credentials_payload.py +104 -0
  39. stackit/loadbalancer/models/update_credentials_response.py +92 -0
  40. stackit/loadbalancer/models/update_load_balancer_payload.py +231 -0
  41. stackit/loadbalancer/models/update_target_pool_payload.py +137 -0
  42. stackit/loadbalancer/py.typed +0 -0
  43. stackit/loadbalancer/rest.py +148 -0
  44. stackit_loadbalancer-0.0.1a1.dist-info/METADATA +46 -0
  45. stackit_loadbalancer-0.0.1a1.dist-info/RECORD +46 -0
  46. stackit_loadbalancer-0.0.1a1.dist-info/WHEEL +4 -0
@@ -0,0 +1,111 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Load Balancer API
5
+
6
+ This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee.
7
+
8
+ The version of the OpenAPI document: 1.7.2
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+
15
+ class HostConfiguration:
16
+ def __init__(
17
+ self,
18
+ region=None,
19
+ server_index=None,
20
+ server_variables=None,
21
+ server_operation_index=None,
22
+ server_operation_variables=None,
23
+ ignore_operation_servers=False,
24
+ ) -> None:
25
+ """Constructor"""
26
+ self._base_path = "https://load-balancer.api.eu01.stackit.cloud"
27
+ """Default Base url
28
+ """
29
+ self.server_index = 0 if server_index is None else server_index
30
+ self.server_operation_index = server_operation_index or {}
31
+ """Default server index
32
+ """
33
+ self.server_variables = server_variables or {}
34
+ if region:
35
+ self.server_variables["region"] = "{}.".format(region)
36
+ self.server_operation_variables = server_operation_variables or {}
37
+ """Default server variables
38
+ """
39
+ self.ignore_operation_servers = ignore_operation_servers
40
+ """Ignore operation servers
41
+ """
42
+
43
+ def get_host_settings(self):
44
+ """Gets an array of host settings
45
+
46
+ :return: An array of host settings
47
+ """
48
+ return [
49
+ {
50
+ "url": "https://load-balancer.api.{region}stackit.cloud",
51
+ "description": "No description provided",
52
+ "variables": {
53
+ "region": {
54
+ "description": "No description provided",
55
+ "default_value": "eu01.",
56
+ "enum_values": ["eu01."],
57
+ }
58
+ },
59
+ }
60
+ ]
61
+
62
+ def get_host_from_settings(self, index, variables=None, servers=None):
63
+ """Gets host URL based on the index and variables
64
+ :param index: array index of the host settings
65
+ :param variables: hash of variable and the corresponding value
66
+ :param servers: an array of host settings or None
67
+ :return: URL based on host settings
68
+ """
69
+ if index is None:
70
+ return self._base_path
71
+
72
+ variables = {} if variables is None else variables
73
+ servers = self.get_host_settings() if servers is None else servers
74
+
75
+ try:
76
+ server = servers[index]
77
+ except IndexError:
78
+ raise ValueError(
79
+ "Invalid index {0} when selecting the host settings. "
80
+ "Must be less than {1}".format(index, len(servers))
81
+ )
82
+
83
+ url = server["url"]
84
+
85
+ # go through variables and replace placeholders
86
+ for variable_name, variable in server.get("variables", {}).items():
87
+ used_value = variables.get(variable_name, variable["default_value"])
88
+
89
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
90
+ given_value = variables[variable_name].replace(".", "")
91
+ valid_values = [v.replace(".", "") for v in variable["enum_values"]]
92
+ raise ValueError(
93
+ "The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
94
+ variable_name, given_value, valid_values
95
+ )
96
+ )
97
+
98
+ url = url.replace("{" + variable_name + "}", used_value)
99
+
100
+ return url
101
+
102
+ @property
103
+ def host(self):
104
+ """Return generated host."""
105
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
106
+
107
+ @host.setter
108
+ def host(self, value):
109
+ """Fix base path."""
110
+ self._base_path = value
111
+ self.server_index = None
@@ -0,0 +1,198 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Load Balancer API
5
+
6
+ This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee.
7
+
8
+ The version of the OpenAPI document: 1.7.2
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from typing import Any, Optional
15
+
16
+ from typing_extensions import Self
17
+
18
+
19
+ class OpenApiException(Exception):
20
+ """The base exception class for all OpenAPIExceptions"""
21
+
22
+
23
+ class ApiTypeError(OpenApiException, TypeError):
24
+ def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None:
25
+ """Raises an exception for TypeErrors
26
+
27
+ Args:
28
+ msg (str): the exception message
29
+
30
+ Keyword Args:
31
+ path_to_item (list): a list of keys an indices to get to the
32
+ current_item
33
+ None if unset
34
+ valid_classes (tuple): the primitive classes that current item
35
+ should be an instance of
36
+ None if unset
37
+ key_type (bool): False if our value is a value in a dict
38
+ True if it is a key in a dict
39
+ False if our item is an item in a list
40
+ None if unset
41
+ """
42
+ self.path_to_item = path_to_item
43
+ self.valid_classes = valid_classes
44
+ self.key_type = key_type
45
+ full_msg = msg
46
+ if path_to_item:
47
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
48
+ super(ApiTypeError, self).__init__(full_msg)
49
+
50
+
51
+ class ApiValueError(OpenApiException, ValueError):
52
+ def __init__(self, msg, path_to_item=None) -> None:
53
+ """
54
+ Args:
55
+ msg (str): the exception message
56
+
57
+ Keyword Args:
58
+ path_to_item (list) the path to the exception in the
59
+ received_data dict. None if unset
60
+ """
61
+
62
+ self.path_to_item = path_to_item
63
+ full_msg = msg
64
+ if path_to_item:
65
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
66
+ super(ApiValueError, self).__init__(full_msg)
67
+
68
+
69
+ class ApiAttributeError(OpenApiException, AttributeError):
70
+ def __init__(self, msg, path_to_item=None) -> None:
71
+ """
72
+ Raised when an attribute reference or assignment fails.
73
+
74
+ Args:
75
+ msg (str): the exception message
76
+
77
+ Keyword Args:
78
+ path_to_item (None/list) the path to the exception in the
79
+ received_data dict
80
+ """
81
+ self.path_to_item = path_to_item
82
+ full_msg = msg
83
+ if path_to_item:
84
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
85
+ super(ApiAttributeError, self).__init__(full_msg)
86
+
87
+
88
+ class ApiKeyError(OpenApiException, KeyError):
89
+ def __init__(self, msg, path_to_item=None) -> None:
90
+ """
91
+ Args:
92
+ msg (str): the exception message
93
+
94
+ Keyword Args:
95
+ path_to_item (None/list) the path to the exception in the
96
+ received_data dict
97
+ """
98
+ self.path_to_item = path_to_item
99
+ full_msg = msg
100
+ if path_to_item:
101
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
102
+ super(ApiKeyError, self).__init__(full_msg)
103
+
104
+
105
+ class ApiException(OpenApiException):
106
+
107
+ def __init__(
108
+ self,
109
+ status=None,
110
+ reason=None,
111
+ http_resp=None,
112
+ *,
113
+ body: Optional[str] = None,
114
+ data: Optional[Any] = None,
115
+ ) -> None:
116
+ self.status = status
117
+ self.reason = reason
118
+ self.body = body
119
+ self.data = data
120
+ self.headers = None
121
+
122
+ if http_resp:
123
+ if self.status is None:
124
+ self.status = http_resp.status
125
+ if self.reason is None:
126
+ self.reason = http_resp.reason
127
+ if self.body is None:
128
+ try:
129
+ self.body = http_resp.data.decode("utf-8")
130
+ except Exception: # noqa: S110
131
+ pass
132
+ self.headers = http_resp.getheaders()
133
+
134
+ @classmethod
135
+ def from_response(
136
+ cls,
137
+ *,
138
+ http_resp,
139
+ body: Optional[str],
140
+ data: Optional[Any],
141
+ ) -> Self:
142
+ if http_resp.status == 400:
143
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
144
+
145
+ if http_resp.status == 401:
146
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
147
+
148
+ if http_resp.status == 403:
149
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
150
+
151
+ if http_resp.status == 404:
152
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
153
+
154
+ if 500 <= http_resp.status <= 599:
155
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
156
+ raise ApiException(http_resp=http_resp, body=body, data=data)
157
+
158
+ def __str__(self):
159
+ """Custom error messages for exception"""
160
+ error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
161
+ if self.headers:
162
+ error_message += "HTTP response headers: {0}\n".format(self.headers)
163
+
164
+ if self.data or self.body:
165
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
166
+
167
+ return error_message
168
+
169
+
170
+ class BadRequestException(ApiException):
171
+ pass
172
+
173
+
174
+ class NotFoundException(ApiException):
175
+ pass
176
+
177
+
178
+ class UnauthorizedException(ApiException):
179
+ pass
180
+
181
+
182
+ class ForbiddenException(ApiException):
183
+ pass
184
+
185
+
186
+ class ServiceException(ApiException):
187
+ pass
188
+
189
+
190
+ def render_path(path_to_item):
191
+ """Returns a string representation of a path"""
192
+ result = ""
193
+ for pth in path_to_item:
194
+ if isinstance(pth, int):
195
+ result += "[{0}]".format(pth)
196
+ else:
197
+ result += "['{0}']".format(pth)
198
+ return result
@@ -0,0 +1,75 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ Load Balancer API
6
+
7
+ This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee.
8
+
9
+ The version of the OpenAPI document: 1.7.2
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501 docstring might be too long
14
+
15
+
16
+ # import models into model package
17
+ from stackit.loadbalancer.models.active_health_check import ActiveHealthCheck
18
+ from stackit.loadbalancer.models.create_credentials_payload import (
19
+ CreateCredentialsPayload,
20
+ )
21
+ from stackit.loadbalancer.models.create_credentials_response import (
22
+ CreateCredentialsResponse,
23
+ )
24
+ from stackit.loadbalancer.models.create_load_balancer_payload import (
25
+ CreateLoadBalancerPayload,
26
+ )
27
+ from stackit.loadbalancer.models.credentials_response import CredentialsResponse
28
+ from stackit.loadbalancer.models.get_credentials_response import GetCredentialsResponse
29
+ from stackit.loadbalancer.models.get_quota_response import GetQuotaResponse
30
+ from stackit.loadbalancer.models.get_service_status_response import (
31
+ GetServiceStatusResponse,
32
+ )
33
+ from stackit.loadbalancer.models.google_protobuf_any import GoogleProtobufAny
34
+ from stackit.loadbalancer.models.list_credentials_response import (
35
+ ListCredentialsResponse,
36
+ )
37
+ from stackit.loadbalancer.models.list_load_balancers_response import (
38
+ ListLoadBalancersResponse,
39
+ )
40
+ from stackit.loadbalancer.models.list_plans_response import ListPlansResponse
41
+ from stackit.loadbalancer.models.listener import Listener
42
+ from stackit.loadbalancer.models.load_balancer import LoadBalancer
43
+ from stackit.loadbalancer.models.load_balancer_error import LoadBalancerError
44
+ from stackit.loadbalancer.models.load_balancer_options import LoadBalancerOptions
45
+ from stackit.loadbalancer.models.loadbalancer_option_access_control import (
46
+ LoadbalancerOptionAccessControl,
47
+ )
48
+ from stackit.loadbalancer.models.loadbalancer_option_logs import LoadbalancerOptionLogs
49
+ from stackit.loadbalancer.models.loadbalancer_option_metrics import (
50
+ LoadbalancerOptionMetrics,
51
+ )
52
+ from stackit.loadbalancer.models.loadbalancer_option_observability import (
53
+ LoadbalancerOptionObservability,
54
+ )
55
+ from stackit.loadbalancer.models.network import Network
56
+ from stackit.loadbalancer.models.options_tcp import OptionsTCP
57
+ from stackit.loadbalancer.models.options_udp import OptionsUDP
58
+ from stackit.loadbalancer.models.plan_details import PlanDetails
59
+ from stackit.loadbalancer.models.server_name_indicator import ServerNameIndicator
60
+ from stackit.loadbalancer.models.session_persistence import SessionPersistence
61
+ from stackit.loadbalancer.models.status import Status
62
+ from stackit.loadbalancer.models.target import Target
63
+ from stackit.loadbalancer.models.target_pool import TargetPool
64
+ from stackit.loadbalancer.models.update_credentials_payload import (
65
+ UpdateCredentialsPayload,
66
+ )
67
+ from stackit.loadbalancer.models.update_credentials_response import (
68
+ UpdateCredentialsResponse,
69
+ )
70
+ from stackit.loadbalancer.models.update_load_balancer_payload import (
71
+ UpdateLoadBalancerPayload,
72
+ )
73
+ from stackit.loadbalancer.models.update_target_pool_payload import (
74
+ UpdateTargetPoolPayload,
75
+ )
@@ -0,0 +1,142 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Load Balancer API
5
+
6
+ This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee.
7
+
8
+ The version of the OpenAPI document: 1.7.2
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ import re
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+
25
+ class ActiveHealthCheck(BaseModel):
26
+ """
27
+ ActiveHealthCheck
28
+ """
29
+
30
+ healthy_threshold: Optional[StrictInt] = Field(
31
+ default=None, description="Healthy threshold of the health checking", alias="healthyThreshold"
32
+ )
33
+ interval: Optional[Annotated[str, Field(strict=True)]] = Field(
34
+ default=None, description="Interval duration of health checking in seconds"
35
+ )
36
+ interval_jitter: Optional[Annotated[str, Field(strict=True)]] = Field(
37
+ default=None,
38
+ description="Interval duration threshold of the health checking in seconds",
39
+ alias="intervalJitter",
40
+ )
41
+ timeout: Optional[Annotated[str, Field(strict=True)]] = Field(
42
+ default=None, description="Active health checking timeout duration in seconds"
43
+ )
44
+ unhealthy_threshold: Optional[StrictInt] = Field(
45
+ default=None, description="Unhealthy threshold of the health checking", alias="unhealthyThreshold"
46
+ )
47
+ __properties: ClassVar[List[str]] = [
48
+ "healthyThreshold",
49
+ "interval",
50
+ "intervalJitter",
51
+ "timeout",
52
+ "unhealthyThreshold",
53
+ ]
54
+
55
+ @field_validator("interval")
56
+ def interval_validate_regular_expression(cls, value):
57
+ """Validates the regular expression"""
58
+ if value is None:
59
+ return value
60
+
61
+ if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value):
62
+ raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/")
63
+ return value
64
+
65
+ @field_validator("interval_jitter")
66
+ def interval_jitter_validate_regular_expression(cls, value):
67
+ """Validates the regular expression"""
68
+ if value is None:
69
+ return value
70
+
71
+ if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value):
72
+ raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/")
73
+ return value
74
+
75
+ @field_validator("timeout")
76
+ def timeout_validate_regular_expression(cls, value):
77
+ """Validates the regular expression"""
78
+ if value is None:
79
+ return value
80
+
81
+ if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value):
82
+ raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/")
83
+ return value
84
+
85
+ model_config = ConfigDict(
86
+ populate_by_name=True,
87
+ validate_assignment=True,
88
+ protected_namespaces=(),
89
+ )
90
+
91
+ def to_str(self) -> str:
92
+ """Returns the string representation of the model using alias"""
93
+ return pprint.pformat(self.model_dump(by_alias=True))
94
+
95
+ def to_json(self) -> str:
96
+ """Returns the JSON representation of the model using alias"""
97
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
98
+ return json.dumps(self.to_dict())
99
+
100
+ @classmethod
101
+ def from_json(cls, json_str: str) -> Optional[Self]:
102
+ """Create an instance of ActiveHealthCheck from a JSON string"""
103
+ return cls.from_dict(json.loads(json_str))
104
+
105
+ def to_dict(self) -> Dict[str, Any]:
106
+ """Return the dictionary representation of the model using alias.
107
+
108
+ This has the following differences from calling pydantic's
109
+ `self.model_dump(by_alias=True)`:
110
+
111
+ * `None` is only added to the output dict for nullable fields that
112
+ were set at model initialization. Other fields with value `None`
113
+ are ignored.
114
+ """
115
+ excluded_fields: Set[str] = set([])
116
+
117
+ _dict = self.model_dump(
118
+ by_alias=True,
119
+ exclude=excluded_fields,
120
+ exclude_none=True,
121
+ )
122
+ return _dict
123
+
124
+ @classmethod
125
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
126
+ """Create an instance of ActiveHealthCheck from a dict"""
127
+ if obj is None:
128
+ return None
129
+
130
+ if not isinstance(obj, dict):
131
+ return cls.model_validate(obj)
132
+
133
+ _obj = cls.model_validate(
134
+ {
135
+ "healthyThreshold": obj.get("healthyThreshold"),
136
+ "interval": obj.get("interval"),
137
+ "intervalJitter": obj.get("intervalJitter"),
138
+ "timeout": obj.get("timeout"),
139
+ "unhealthyThreshold": obj.get("unhealthyThreshold"),
140
+ }
141
+ )
142
+ return _obj
@@ -0,0 +1,104 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Load Balancer API
5
+
6
+ This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee.
7
+
8
+ The version of the OpenAPI document: 1.7.2
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ import re
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+
25
+ class CreateCredentialsPayload(BaseModel):
26
+ """
27
+ CreateCredentialsPayload
28
+ """
29
+
30
+ display_name: Optional[Annotated[str, Field(strict=True)]] = Field(
31
+ default=None, description="Credential name", alias="displayName"
32
+ )
33
+ password: Optional[StrictStr] = Field(
34
+ default=None,
35
+ description="A valid password used for an existing ARGUS instance, which is used during basic auth.",
36
+ )
37
+ username: Optional[StrictStr] = Field(
38
+ default=None,
39
+ description="A valid username used for an existing ARGUS instance, which is used during basic auth.",
40
+ )
41
+ __properties: ClassVar[List[str]] = ["displayName", "password", "username"]
42
+
43
+ @field_validator("display_name")
44
+ def display_name_validate_regular_expression(cls, value):
45
+ """Validates the regular expression"""
46
+ if value is None:
47
+ return value
48
+
49
+ if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value):
50
+ raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/")
51
+ return value
52
+
53
+ model_config = ConfigDict(
54
+ populate_by_name=True,
55
+ validate_assignment=True,
56
+ protected_namespaces=(),
57
+ )
58
+
59
+ def to_str(self) -> str:
60
+ """Returns the string representation of the model using alias"""
61
+ return pprint.pformat(self.model_dump(by_alias=True))
62
+
63
+ def to_json(self) -> str:
64
+ """Returns the JSON representation of the model using alias"""
65
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
66
+ return json.dumps(self.to_dict())
67
+
68
+ @classmethod
69
+ def from_json(cls, json_str: str) -> Optional[Self]:
70
+ """Create an instance of CreateCredentialsPayload from a JSON string"""
71
+ return cls.from_dict(json.loads(json_str))
72
+
73
+ def to_dict(self) -> Dict[str, Any]:
74
+ """Return the dictionary representation of the model using alias.
75
+
76
+ This has the following differences from calling pydantic's
77
+ `self.model_dump(by_alias=True)`:
78
+
79
+ * `None` is only added to the output dict for nullable fields that
80
+ were set at model initialization. Other fields with value `None`
81
+ are ignored.
82
+ """
83
+ excluded_fields: Set[str] = set([])
84
+
85
+ _dict = self.model_dump(
86
+ by_alias=True,
87
+ exclude=excluded_fields,
88
+ exclude_none=True,
89
+ )
90
+ return _dict
91
+
92
+ @classmethod
93
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
94
+ """Create an instance of CreateCredentialsPayload from a dict"""
95
+ if obj is None:
96
+ return None
97
+
98
+ if not isinstance(obj, dict):
99
+ return cls.model_validate(obj)
100
+
101
+ _obj = cls.model_validate(
102
+ {"displayName": obj.get("displayName"), "password": obj.get("password"), "username": obj.get("username")}
103
+ )
104
+ return _obj