Repository navigation
Expand file tree
/
Copy pathget_instance_response.py
More file actions
174 lines (151 loc) · 6.77 KB
/
Copy pathget_instance_response.py
File metadata and controls
174 lines (151 loc) · 6.77 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# coding: utf-8
"""
STACKIT PostgreSQL Flex API
This is the documentation for the STACKIT Postgres Flex service
The version of the OpenAPI document: 3.0.0
Contact: support@stackit.cloud
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 pydantic_core import to_jsonable_python
from typing_extensions import Annotated, Self
from stackit.postgresflex.models.instance_connection_info import InstanceConnectionInfo
from stackit.postgresflex.models.instance_encryption import InstanceEncryption
from stackit.postgresflex.models.instance_network import InstanceNetwork
from stackit.postgresflex.models.state import State
from stackit.postgresflex.models.storage import Storage
class GetInstanceResponse(BaseModel):
"""
GetInstanceResponse
""" # noqa: E501
backup_schedule: StrictStr = Field(
description="The schedule for when the database backup will be created. Currently, ONLY daily schedules are supported (every 24 hours). The schedule is written as a cron schedule.",
alias="backupSchedule",
)
connection_info: InstanceConnectionInfo = Field(alias="connectionInfo")
encryption: Optional[InstanceEncryption] = None
flavor_id: StrictStr = Field(description="The id of the instance flavor.", alias="flavorId")
id: UUID = Field(description="The ID of the instance.")
is_deletable: StrictBool = Field(description="Whether the instance can be deleted or not.", alias="isDeletable")
labels: Optional[Dict[str, Optional[StrictStr]]] = Field(
default=None,
description="Key-value pairs, 63 characters max, begin and end with an alphanumerical character, may contain dashes (-), underscores (_), dots (.), and alphanumerics between. Key MUST be at least 1 character. Max 64 labels Regex for keys: ^(?=.{1,63}$)([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$ Regex for values: ^(?=.{0,63}$)(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])*$ The stackit- prefix is reserved and cannot be used for Keys. ",
)
name: Annotated[str, Field(min_length=3, strict=True, max_length=63)] = Field(
description="The name of the instance."
)
network: InstanceNetwork
retention_days: Optional[Annotated[int, Field(le=90, strict=True, ge=32)]] = Field(
description="How long backups are retained. The value can only be between 32 and 90 days.",
alias="retentionDays",
)
state: State
storage: Storage
version: StrictStr = Field(
description="The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3#tag/Version) for supported version parameters."
)
__properties: ClassVar[List[str]] = [
"backupSchedule",
"connectionInfo",
"encryption",
"flavorId",
"id",
"isDeletable",
"labels",
"name",
"network",
"retentionDays",
"state",
"storage",
"version",
]
model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=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"""
return json.dumps(to_jsonable_python(self.to_dict()))
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of GetInstanceResponse 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,
)
# override the default output from pydantic by calling `to_dict()` of connection_info
if self.connection_info:
_dict["connectionInfo"] = self.connection_info.to_dict()
# override the default output from pydantic by calling `to_dict()` of encryption
if self.encryption:
_dict["encryption"] = self.encryption.to_dict()
# override the default output from pydantic by calling `to_dict()` of network
if self.network:
_dict["network"] = self.network.to_dict()
# override the default output from pydantic by calling `to_dict()` of storage
if self.storage:
_dict["storage"] = self.storage.to_dict()
# set to None if retention_days (nullable) is None
# and model_fields_set contains the field
if self.retention_days is None and "retention_days" in self.model_fields_set:
_dict["retentionDays"] = None
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of GetInstanceResponse from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate(
{
"backupSchedule": obj.get("backupSchedule"),
"connectionInfo": (
InstanceConnectionInfo.from_dict(obj["connectionInfo"])
if obj.get("connectionInfo") is not None
else None
),
"encryption": (
InstanceEncryption.from_dict(obj["encryption"]) if obj.get("encryption") is not None else None
),
"flavorId": obj.get("flavorId"),
"id": obj.get("id"),
"isDeletable": obj.get("isDeletable"),
"labels": obj.get("labels"),
"name": obj.get("name"),
"network": InstanceNetwork.from_dict(obj["network"]) if obj.get("network") is not None else None,
"retentionDays": obj.get("retentionDays"),
"state": obj.get("state"),
"storage": Storage.from_dict(obj["storage"]) if obj.get("storage") is not None else None,
"version": obj.get("version"),
}
)
return _obj