stackit-opensearch 0.0.1a0__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 (40) hide show
  1. stackit/opensearch/__init__.py +70 -0
  2. stackit/opensearch/api/__init__.py +4 -0
  3. stackit/opensearch/api/default_api.py +4814 -0
  4. stackit/opensearch/api_client.py +626 -0
  5. stackit/opensearch/api_response.py +23 -0
  6. stackit/opensearch/configuration.py +111 -0
  7. stackit/opensearch/exceptions.py +198 -0
  8. stackit/opensearch/models/__init__.py +51 -0
  9. stackit/opensearch/models/backup.py +95 -0
  10. stackit/opensearch/models/create_backup_response_item.py +82 -0
  11. stackit/opensearch/models/create_instance_payload.py +96 -0
  12. stackit/opensearch/models/create_instance_response.py +81 -0
  13. stackit/opensearch/models/credentials.py +97 -0
  14. stackit/opensearch/models/credentials_list_item.py +81 -0
  15. stackit/opensearch/models/credentials_response.py +94 -0
  16. stackit/opensearch/models/error.py +82 -0
  17. stackit/opensearch/models/get_metrics_response.py +153 -0
  18. stackit/opensearch/models/instance.py +147 -0
  19. stackit/opensearch/models/instance_last_operation.py +99 -0
  20. stackit/opensearch/models/instance_parameters.py +199 -0
  21. stackit/opensearch/models/instance_schema.py +95 -0
  22. stackit/opensearch/models/list_backups_response.py +98 -0
  23. stackit/opensearch/models/list_credentials_response.py +98 -0
  24. stackit/opensearch/models/list_instances_response.py +98 -0
  25. stackit/opensearch/models/list_offerings_response.py +98 -0
  26. stackit/opensearch/models/list_restores_response.py +98 -0
  27. stackit/opensearch/models/model_schema.py +81 -0
  28. stackit/opensearch/models/offering.py +127 -0
  29. stackit/opensearch/models/partial_update_instance_payload.py +96 -0
  30. stackit/opensearch/models/plan.py +93 -0
  31. stackit/opensearch/models/raw_credentials.py +88 -0
  32. stackit/opensearch/models/restore.py +93 -0
  33. stackit/opensearch/models/trigger_restore_response.py +81 -0
  34. stackit/opensearch/models/update_backups_config_payload.py +81 -0
  35. stackit/opensearch/models/update_backups_config_response.py +81 -0
  36. stackit/opensearch/py.typed +0 -0
  37. stackit/opensearch/rest.py +148 -0
  38. stackit_opensearch-0.0.1a0.dist-info/METADATA +45 -0
  39. stackit_opensearch-0.0.1a0.dist-info/RECORD +40 -0
  40. stackit_opensearch-0.0.1a0.dist-info/WHEEL +4 -0
@@ -0,0 +1,147 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Opensearch API
5
+
6
+ The STACKIT Opensearch API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
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
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
+ from typing_extensions import Self
22
+
23
+ from stackit.opensearch.models.instance_last_operation import InstanceLastOperation
24
+
25
+
26
+ class Instance(BaseModel):
27
+ """
28
+ Instance
29
+ """
30
+
31
+ cf_guid: StrictStr = Field(alias="cfGuid")
32
+ cf_organization_guid: StrictStr = Field(alias="cfOrganizationGuid")
33
+ cf_space_guid: StrictStr = Field(alias="cfSpaceGuid")
34
+ dashboard_url: StrictStr = Field(alias="dashboardUrl")
35
+ image_url: StrictStr = Field(alias="imageUrl")
36
+ instance_id: Optional[StrictStr] = Field(default=None, alias="instanceId")
37
+ last_operation: InstanceLastOperation = Field(alias="lastOperation")
38
+ name: StrictStr
39
+ offering_name: StrictStr = Field(alias="offeringName")
40
+ offering_version: StrictStr = Field(alias="offeringVersion")
41
+ parameters: Dict[str, Any]
42
+ plan_id: StrictStr = Field(alias="planId")
43
+ plan_name: StrictStr = Field(alias="planName")
44
+ status: Optional[StrictStr] = None
45
+ __properties: ClassVar[List[str]] = [
46
+ "cfGuid",
47
+ "cfOrganizationGuid",
48
+ "cfSpaceGuid",
49
+ "dashboardUrl",
50
+ "imageUrl",
51
+ "instanceId",
52
+ "lastOperation",
53
+ "name",
54
+ "offeringName",
55
+ "offeringVersion",
56
+ "parameters",
57
+ "planId",
58
+ "planName",
59
+ "status",
60
+ ]
61
+
62
+ @field_validator("status")
63
+ def status_validate_enum(cls, value):
64
+ """Validates the enum"""
65
+ if value is None:
66
+ return value
67
+
68
+ if value not in set(["active", "failed", "stopped", "creating", "deleting", "updating"]):
69
+ raise ValueError(
70
+ "must be one of enum values ('active', 'failed', 'stopped', 'creating', 'deleting', 'updating')"
71
+ )
72
+ return value
73
+
74
+ model_config = ConfigDict(
75
+ populate_by_name=True,
76
+ validate_assignment=True,
77
+ protected_namespaces=(),
78
+ )
79
+
80
+ def to_str(self) -> str:
81
+ """Returns the string representation of the model using alias"""
82
+ return pprint.pformat(self.model_dump(by_alias=True))
83
+
84
+ def to_json(self) -> str:
85
+ """Returns the JSON representation of the model using alias"""
86
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
87
+ return json.dumps(self.to_dict())
88
+
89
+ @classmethod
90
+ def from_json(cls, json_str: str) -> Optional[Self]:
91
+ """Create an instance of Instance from a JSON string"""
92
+ return cls.from_dict(json.loads(json_str))
93
+
94
+ def to_dict(self) -> Dict[str, Any]:
95
+ """Return the dictionary representation of the model using alias.
96
+
97
+ This has the following differences from calling pydantic's
98
+ `self.model_dump(by_alias=True)`:
99
+
100
+ * `None` is only added to the output dict for nullable fields that
101
+ were set at model initialization. Other fields with value `None`
102
+ are ignored.
103
+ """
104
+ excluded_fields: Set[str] = set([])
105
+
106
+ _dict = self.model_dump(
107
+ by_alias=True,
108
+ exclude=excluded_fields,
109
+ exclude_none=True,
110
+ )
111
+ # override the default output from pydantic by calling `to_dict()` of last_operation
112
+ if self.last_operation:
113
+ _dict["lastOperation"] = self.last_operation.to_dict()
114
+ return _dict
115
+
116
+ @classmethod
117
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
118
+ """Create an instance of Instance from a dict"""
119
+ if obj is None:
120
+ return None
121
+
122
+ if not isinstance(obj, dict):
123
+ return cls.model_validate(obj)
124
+
125
+ _obj = cls.model_validate(
126
+ {
127
+ "cfGuid": obj.get("cfGuid"),
128
+ "cfOrganizationGuid": obj.get("cfOrganizationGuid"),
129
+ "cfSpaceGuid": obj.get("cfSpaceGuid"),
130
+ "dashboardUrl": obj.get("dashboardUrl"),
131
+ "imageUrl": obj.get("imageUrl"),
132
+ "instanceId": obj.get("instanceId"),
133
+ "lastOperation": (
134
+ InstanceLastOperation.from_dict(obj["lastOperation"])
135
+ if obj.get("lastOperation") is not None
136
+ else None
137
+ ),
138
+ "name": obj.get("name"),
139
+ "offeringName": obj.get("offeringName"),
140
+ "offeringVersion": obj.get("offeringVersion"),
141
+ "parameters": obj.get("parameters"),
142
+ "planId": obj.get("planId"),
143
+ "planName": obj.get("planName"),
144
+ "status": obj.get("status"),
145
+ }
146
+ )
147
+ return _obj
@@ -0,0 +1,99 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Opensearch API
5
+
6
+ The STACKIT Opensearch API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
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
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator
21
+ from typing_extensions import Self
22
+
23
+
24
+ class InstanceLastOperation(BaseModel):
25
+ """
26
+ InstanceLastOperation
27
+ """
28
+
29
+ description: StrictStr
30
+ state: StrictStr
31
+ type: StrictStr
32
+ __properties: ClassVar[List[str]] = ["description", "state", "type"]
33
+
34
+ @field_validator("state")
35
+ def state_validate_enum(cls, value):
36
+ """Validates the enum"""
37
+ if value not in set(["in progress", "succeeded", "failed"]):
38
+ raise ValueError("must be one of enum values ('in progress', 'succeeded', 'failed')")
39
+ return value
40
+
41
+ @field_validator("type")
42
+ def type_validate_enum(cls, value):
43
+ """Validates the enum"""
44
+ if value not in set(["create", "update", "delete"]):
45
+ raise ValueError("must be one of enum values ('create', 'update', 'delete')")
46
+ return value
47
+
48
+ model_config = ConfigDict(
49
+ populate_by_name=True,
50
+ validate_assignment=True,
51
+ protected_namespaces=(),
52
+ )
53
+
54
+ def to_str(self) -> str:
55
+ """Returns the string representation of the model using alias"""
56
+ return pprint.pformat(self.model_dump(by_alias=True))
57
+
58
+ def to_json(self) -> str:
59
+ """Returns the JSON representation of the model using alias"""
60
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61
+ return json.dumps(self.to_dict())
62
+
63
+ @classmethod
64
+ def from_json(cls, json_str: str) -> Optional[Self]:
65
+ """Create an instance of InstanceLastOperation from a JSON string"""
66
+ return cls.from_dict(json.loads(json_str))
67
+
68
+ def to_dict(self) -> Dict[str, Any]:
69
+ """Return the dictionary representation of the model using alias.
70
+
71
+ This has the following differences from calling pydantic's
72
+ `self.model_dump(by_alias=True)`:
73
+
74
+ * `None` is only added to the output dict for nullable fields that
75
+ were set at model initialization. Other fields with value `None`
76
+ are ignored.
77
+ """
78
+ excluded_fields: Set[str] = set([])
79
+
80
+ _dict = self.model_dump(
81
+ by_alias=True,
82
+ exclude=excluded_fields,
83
+ exclude_none=True,
84
+ )
85
+ return _dict
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
89
+ """Create an instance of InstanceLastOperation from a dict"""
90
+ if obj is None:
91
+ return None
92
+
93
+ if not isinstance(obj, dict):
94
+ return cls.model_validate(obj)
95
+
96
+ _obj = cls.model_validate(
97
+ {"description": obj.get("description"), "state": obj.get("state"), "type": obj.get("type")}
98
+ )
99
+ return _obj
@@ -0,0 +1,199 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Opensearch API
5
+
6
+ The STACKIT Opensearch API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
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
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import (
21
+ BaseModel,
22
+ ConfigDict,
23
+ Field,
24
+ StrictBool,
25
+ StrictInt,
26
+ StrictStr,
27
+ field_validator,
28
+ )
29
+ from typing_extensions import Annotated, Self
30
+
31
+
32
+ class InstanceParameters(BaseModel):
33
+ """
34
+ InstanceParameters
35
+ """
36
+
37
+ enable_monitoring: Optional[StrictBool] = False
38
+ graphite: Optional[StrictStr] = Field(
39
+ default=None,
40
+ description="If you want to monitor your service with Graphite, you can set the custom parameter graphite. It expects the host and port where the Graphite metrics should be sent to.",
41
+ )
42
+ java_garbage_collector: Optional[StrictStr] = "UseG1GC"
43
+ java_heapspace: Optional[Annotated[int, Field(strict=True, ge=256)]] = Field(
44
+ default=None,
45
+ description="Default: not set, 46% of available memory will be used. The amount of memory (in MB) allocated as heap by the JVM for OpenSearch.",
46
+ )
47
+ java_maxmetaspace: Optional[Annotated[int, Field(le=1024, strict=True, ge=256)]] = Field(
48
+ default=512, description="The amount of memory (in MB) used by the JVM to store metadata for OpenSearch."
49
+ )
50
+ max_disk_threshold: Optional[StrictInt] = Field(
51
+ default=80,
52
+ description="This component monitors ephemeral and persistent disk usage. If one of these disk usages reaches the default configured threshold of 80%, the a9s Parachute stops all processes on that node.",
53
+ )
54
+ metrics_frequency: Optional[StrictInt] = Field(
55
+ default=10, description="Frequency of metrics being emitted in seconds"
56
+ )
57
+ metrics_prefix: Optional[StrictStr] = Field(
58
+ default=None,
59
+ description="Depending on your graphite provider, you might need to prefix the metrics with a certain value, like an API key for example.",
60
+ )
61
+ monitoring_instance_id: Optional[StrictStr] = None
62
+ plugins: Optional[List[StrictStr]] = Field(
63
+ default=None,
64
+ description="The plugins repository-s3 and repository-azure are enabled by default and cannot be disabled.",
65
+ )
66
+ sgw_acl: Optional[StrictStr] = Field(
67
+ default=None,
68
+ description="Comma separated list of IP networks in CIDR notation which are allowed to access this instance.",
69
+ )
70
+ syslog: Optional[List[StrictStr]] = None
71
+ tls_ciphers: Optional[List[StrictStr]] = Field(
72
+ default=None, description="Only Java format is supported.", alias="tls-ciphers"
73
+ )
74
+ tls_protocols: Optional[StrictStr] = Field(default=None, alias="tls-protocols")
75
+ __properties: ClassVar[List[str]] = [
76
+ "enable_monitoring",
77
+ "graphite",
78
+ "java_garbage_collector",
79
+ "java_heapspace",
80
+ "java_maxmetaspace",
81
+ "max_disk_threshold",
82
+ "metrics_frequency",
83
+ "metrics_prefix",
84
+ "monitoring_instance_id",
85
+ "plugins",
86
+ "sgw_acl",
87
+ "syslog",
88
+ "tls-ciphers",
89
+ "tls-protocols",
90
+ ]
91
+
92
+ @field_validator("java_garbage_collector")
93
+ def java_garbage_collector_validate_enum(cls, value):
94
+ """Validates the enum"""
95
+ if value is None:
96
+ return value
97
+
98
+ if value not in set(["UseSerialGC", "UseParallelGC", "UseParallelOldGC", "UseG1GC"]):
99
+ raise ValueError(
100
+ "must be one of enum values ('UseSerialGC', 'UseParallelGC', 'UseParallelOldGC', 'UseG1GC')"
101
+ )
102
+ return value
103
+
104
+ @field_validator("plugins")
105
+ def plugins_validate_enum(cls, value):
106
+ """Validates the enum"""
107
+ if value is None:
108
+ return value
109
+
110
+ for i in value:
111
+ if i not in set(["repository-s3", "repository-azure", "analysis-phonetic"]):
112
+ raise ValueError(
113
+ "each list item must be one of ('repository-s3', 'repository-azure', 'analysis-phonetic')"
114
+ )
115
+ return value
116
+
117
+ @field_validator("tls_protocols")
118
+ def tls_protocols_validate_enum(cls, value):
119
+ """Validates the enum"""
120
+ if value is None:
121
+ return value
122
+
123
+ if value not in set(["TLSv1.2", "TLSv1.3"]):
124
+ raise ValueError("must be one of enum values ('TLSv1.2', 'TLSv1.3')")
125
+ return value
126
+
127
+ model_config = ConfigDict(
128
+ populate_by_name=True,
129
+ validate_assignment=True,
130
+ protected_namespaces=(),
131
+ )
132
+
133
+ def to_str(self) -> str:
134
+ """Returns the string representation of the model using alias"""
135
+ return pprint.pformat(self.model_dump(by_alias=True))
136
+
137
+ def to_json(self) -> str:
138
+ """Returns the JSON representation of the model using alias"""
139
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
140
+ return json.dumps(self.to_dict())
141
+
142
+ @classmethod
143
+ def from_json(cls, json_str: str) -> Optional[Self]:
144
+ """Create an instance of InstanceParameters from a JSON string"""
145
+ return cls.from_dict(json.loads(json_str))
146
+
147
+ def to_dict(self) -> Dict[str, Any]:
148
+ """Return the dictionary representation of the model using alias.
149
+
150
+ This has the following differences from calling pydantic's
151
+ `self.model_dump(by_alias=True)`:
152
+
153
+ * `None` is only added to the output dict for nullable fields that
154
+ were set at model initialization. Other fields with value `None`
155
+ are ignored.
156
+ """
157
+ excluded_fields: Set[str] = set([])
158
+
159
+ _dict = self.model_dump(
160
+ by_alias=True,
161
+ exclude=excluded_fields,
162
+ exclude_none=True,
163
+ )
164
+ return _dict
165
+
166
+ @classmethod
167
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
168
+ """Create an instance of InstanceParameters from a dict"""
169
+ if obj is None:
170
+ return None
171
+
172
+ if not isinstance(obj, dict):
173
+ return cls.model_validate(obj)
174
+
175
+ _obj = cls.model_validate(
176
+ {
177
+ "enable_monitoring": (
178
+ obj.get("enable_monitoring") if obj.get("enable_monitoring") is not None else False
179
+ ),
180
+ "graphite": obj.get("graphite"),
181
+ "java_garbage_collector": (
182
+ obj.get("java_garbage_collector") if obj.get("java_garbage_collector") is not None else "UseG1GC"
183
+ ),
184
+ "java_heapspace": obj.get("java_heapspace"),
185
+ "java_maxmetaspace": obj.get("java_maxmetaspace") if obj.get("java_maxmetaspace") is not None else 512,
186
+ "max_disk_threshold": (
187
+ obj.get("max_disk_threshold") if obj.get("max_disk_threshold") is not None else 80
188
+ ),
189
+ "metrics_frequency": obj.get("metrics_frequency") if obj.get("metrics_frequency") is not None else 10,
190
+ "metrics_prefix": obj.get("metrics_prefix"),
191
+ "monitoring_instance_id": obj.get("monitoring_instance_id"),
192
+ "plugins": obj.get("plugins"),
193
+ "sgw_acl": obj.get("sgw_acl"),
194
+ "syslog": obj.get("syslog"),
195
+ "tls-ciphers": obj.get("tls-ciphers"),
196
+ "tls-protocols": obj.get("tls-protocols"),
197
+ }
198
+ )
199
+ return _obj
@@ -0,0 +1,95 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Opensearch API
5
+
6
+ The STACKIT Opensearch API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
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
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict
21
+ from typing_extensions import Self
22
+
23
+ from stackit.opensearch.models.model_schema import ModelSchema
24
+
25
+
26
+ class InstanceSchema(BaseModel):
27
+ """
28
+ InstanceSchema
29
+ """
30
+
31
+ create: ModelSchema
32
+ update: ModelSchema
33
+ __properties: ClassVar[List[str]] = ["create", "update"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of InstanceSchema from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ # override the default output from pydantic by calling `to_dict()` of create
73
+ if self.create:
74
+ _dict["create"] = self.create.to_dict()
75
+ # override the default output from pydantic by calling `to_dict()` of update
76
+ if self.update:
77
+ _dict["update"] = self.update.to_dict()
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of InstanceSchema from a dict"""
83
+ if obj is None:
84
+ return None
85
+
86
+ if not isinstance(obj, dict):
87
+ return cls.model_validate(obj)
88
+
89
+ _obj = cls.model_validate(
90
+ {
91
+ "create": ModelSchema.from_dict(obj["create"]) if obj.get("create") is not None else None,
92
+ "update": ModelSchema.from_dict(obj["update"]) if obj.get("update") is not None else None,
93
+ }
94
+ )
95
+ return _obj
@@ -0,0 +1,98 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Opensearch API
5
+
6
+ The STACKIT Opensearch API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
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
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field
21
+ from typing_extensions import Self
22
+
23
+ from stackit.opensearch.models.backup import Backup
24
+
25
+
26
+ class ListBackupsResponse(BaseModel):
27
+ """
28
+ ListBackupsResponse
29
+ """
30
+
31
+ instance_backups: List[Backup] = Field(alias="instanceBackups")
32
+ __properties: ClassVar[List[str]] = ["instanceBackups"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of ListBackupsResponse from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([])
65
+
66
+ _dict = self.model_dump(
67
+ by_alias=True,
68
+ exclude=excluded_fields,
69
+ exclude_none=True,
70
+ )
71
+ # override the default output from pydantic by calling `to_dict()` of each item in instance_backups (list)
72
+ _items = []
73
+ if self.instance_backups:
74
+ for _item in self.instance_backups:
75
+ if _item:
76
+ _items.append(_item.to_dict())
77
+ _dict["instanceBackups"] = _items
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of ListBackupsResponse from a dict"""
83
+ if obj is None:
84
+ return None
85
+
86
+ if not isinstance(obj, dict):
87
+ return cls.model_validate(obj)
88
+
89
+ _obj = cls.model_validate(
90
+ {
91
+ "instanceBackups": (
92
+ [Backup.from_dict(_item) for _item in obj["instanceBackups"]]
93
+ if obj.get("instanceBackups") is not None
94
+ else None
95
+ )
96
+ }
97
+ )
98
+ return _obj