stackit-logs 0.1.0__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.
@@ -0,0 +1,113 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Logs API
5
+
6
+ This API provides endpoints for managing STACKIT Logs.
7
+
8
+ The version of the OpenAPI document: 1beta.0.3
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, StrictStr, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+
25
+ class CreateAccessTokenPayload(BaseModel):
26
+ """
27
+ CreateAccessTokenPayload
28
+ """ # noqa: E501
29
+
30
+ description: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(
31
+ default=None, description="The description of the access token."
32
+ )
33
+ display_name: Annotated[str, Field(min_length=1, strict=True, max_length=32)] = Field(
34
+ description="The displayed name of the access token.", alias="displayName"
35
+ )
36
+ lifetime: Optional[Annotated[int, Field(le=180, strict=True, ge=1)]] = Field(
37
+ default=None, description="A lifetime period for an access token in days. If unset the token will not expire."
38
+ )
39
+ permissions: List[StrictStr] = Field(description="The access permissions granted to the access token.")
40
+ __properties: ClassVar[List[str]] = ["description", "displayName", "lifetime", "permissions"]
41
+
42
+ @field_validator("display_name")
43
+ def display_name_validate_regular_expression(cls, value):
44
+ """Validates the regular expression"""
45
+ if not re.match(r"^[a-zA-Z][\w -]*$", value):
46
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/")
47
+ return value
48
+
49
+ @field_validator("permissions")
50
+ def permissions_validate_enum(cls, value):
51
+ """Validates the enum"""
52
+ for i in value:
53
+ if i not in set(["read", "write"]):
54
+ raise ValueError("each list item must be one of ('read', 'write')")
55
+ return value
56
+
57
+ model_config = ConfigDict(
58
+ populate_by_name=True,
59
+ validate_assignment=True,
60
+ protected_namespaces=(),
61
+ )
62
+
63
+ def to_str(self) -> str:
64
+ """Returns the string representation of the model using alias"""
65
+ return pprint.pformat(self.model_dump(by_alias=True))
66
+
67
+ def to_json(self) -> str:
68
+ """Returns the JSON representation of the model using alias"""
69
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
70
+ return json.dumps(self.to_dict())
71
+
72
+ @classmethod
73
+ def from_json(cls, json_str: str) -> Optional[Self]:
74
+ """Create an instance of CreateAccessTokenPayload from a JSON string"""
75
+ return cls.from_dict(json.loads(json_str))
76
+
77
+ def to_dict(self) -> Dict[str, Any]:
78
+ """Return the dictionary representation of the model using alias.
79
+
80
+ This has the following differences from calling pydantic's
81
+ `self.model_dump(by_alias=True)`:
82
+
83
+ * `None` is only added to the output dict for nullable fields that
84
+ were set at model initialization. Other fields with value `None`
85
+ are ignored.
86
+ """
87
+ excluded_fields: Set[str] = set([])
88
+
89
+ _dict = self.model_dump(
90
+ by_alias=True,
91
+ exclude=excluded_fields,
92
+ exclude_none=True,
93
+ )
94
+ return _dict
95
+
96
+ @classmethod
97
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98
+ """Create an instance of CreateAccessTokenPayload from a dict"""
99
+ if obj is None:
100
+ return None
101
+
102
+ if not isinstance(obj, dict):
103
+ return cls.model_validate(obj)
104
+
105
+ _obj = cls.model_validate(
106
+ {
107
+ "description": obj.get("description"),
108
+ "displayName": obj.get("displayName"),
109
+ "lifetime": obj.get("lifetime"),
110
+ "permissions": obj.get("permissions"),
111
+ }
112
+ )
113
+ return _obj
@@ -0,0 +1,105 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Logs API
5
+
6
+ This API provides endpoints for managing STACKIT Logs.
7
+
8
+ The version of the OpenAPI document: 1beta.0.3
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, StrictStr, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+
25
+ class CreateLogsInstancePayload(BaseModel):
26
+ """
27
+ CreateLogsInstancePayload
28
+ """ # noqa: E501
29
+
30
+ acl: Optional[List[StrictStr]] = Field(default=None, description="The access control list for the Logs instance.")
31
+ description: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(
32
+ default=None, description="The description of the access token."
33
+ )
34
+ display_name: Annotated[str, Field(min_length=1, strict=True, max_length=32)] = Field(
35
+ description="The displayed name to distinguish multiple Logs instances.", alias="displayName"
36
+ )
37
+ retention_days: Annotated[int, Field(le=180, strict=True, ge=1)] = Field(
38
+ description="The log retention time in days.", alias="retentionDays"
39
+ )
40
+ __properties: ClassVar[List[str]] = ["acl", "description", "displayName", "retentionDays"]
41
+
42
+ @field_validator("display_name")
43
+ def display_name_validate_regular_expression(cls, value):
44
+ """Validates the regular expression"""
45
+ if not re.match(r"^[a-zA-Z][\w -]*$", value):
46
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/")
47
+ return value
48
+
49
+ model_config = ConfigDict(
50
+ populate_by_name=True,
51
+ validate_assignment=True,
52
+ protected_namespaces=(),
53
+ )
54
+
55
+ def to_str(self) -> str:
56
+ """Returns the string representation of the model using alias"""
57
+ return pprint.pformat(self.model_dump(by_alias=True))
58
+
59
+ def to_json(self) -> str:
60
+ """Returns the JSON representation of the model using alias"""
61
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
62
+ return json.dumps(self.to_dict())
63
+
64
+ @classmethod
65
+ def from_json(cls, json_str: str) -> Optional[Self]:
66
+ """Create an instance of CreateLogsInstancePayload from a JSON string"""
67
+ return cls.from_dict(json.loads(json_str))
68
+
69
+ def to_dict(self) -> Dict[str, Any]:
70
+ """Return the dictionary representation of the model using alias.
71
+
72
+ This has the following differences from calling pydantic's
73
+ `self.model_dump(by_alias=True)`:
74
+
75
+ * `None` is only added to the output dict for nullable fields that
76
+ were set at model initialization. Other fields with value `None`
77
+ are ignored.
78
+ """
79
+ excluded_fields: Set[str] = set([])
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ return _dict
87
+
88
+ @classmethod
89
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
90
+ """Create an instance of CreateLogsInstancePayload from a dict"""
91
+ if obj is None:
92
+ return None
93
+
94
+ if not isinstance(obj, dict):
95
+ return cls.model_validate(obj)
96
+
97
+ _obj = cls.model_validate(
98
+ {
99
+ "acl": obj.get("acl"),
100
+ "description": obj.get("description"),
101
+ "displayName": obj.get("displayName"),
102
+ "retentionDays": obj.get("retentionDays"),
103
+ }
104
+ )
105
+ return _obj
@@ -0,0 +1,165 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Logs API
5
+
6
+ This API provides endpoints for managing STACKIT Logs.
7
+
8
+ The version of the OpenAPI document: 1beta.0.3
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 datetime import datetime
20
+ from typing import Any, ClassVar, Dict, List, Optional, Set
21
+
22
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
23
+ from typing_extensions import Annotated, Self
24
+
25
+
26
+ class LogsInstance(BaseModel):
27
+ """
28
+ LogsInstance
29
+ """ # noqa: E501
30
+
31
+ acl: Optional[List[StrictStr]] = Field(default=None, description="The access control list for the Logs instance.")
32
+ created: datetime = Field(description="The date and time the creation of the Logs instance was triggered.")
33
+ datasource_url: Optional[StrictStr] = Field(
34
+ default=None,
35
+ description="The Logs instance's datasource URL, can be used in Grafana as a datasource URL",
36
+ alias="datasourceUrl",
37
+ )
38
+ description: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(
39
+ default=None, description="The description of the Logs instance."
40
+ )
41
+ display_name: Annotated[str, Field(min_length=1, strict=True, max_length=32)] = Field(
42
+ description="The displayed name of the Logs instance.", alias="displayName"
43
+ )
44
+ id: StrictStr = Field(description="A auto generated unique id which identifies the Logs instance.")
45
+ ingest_otlp_url: Optional[StrictStr] = Field(
46
+ default=None, description="The Logs instance's ingest logs via OTLP URL", alias="ingestOtlpUrl"
47
+ )
48
+ ingest_url: Optional[StrictStr] = Field(
49
+ default=None, description="The Logs instance's ingest logs URL", alias="ingestUrl"
50
+ )
51
+ query_range_url: Optional[StrictStr] = Field(
52
+ default=None, description="The Logs instance's query range URL", alias="queryRangeUrl"
53
+ )
54
+ query_url: Optional[StrictStr] = Field(default=None, description="The Logs instance's query URL", alias="queryUrl")
55
+ retention_days: Annotated[int, Field(le=180, strict=True, ge=1)] = Field(
56
+ description="The log retention time in days.", alias="retentionDays"
57
+ )
58
+ status: StrictStr = Field(description="The current status of the Logs instance.")
59
+ __properties: ClassVar[List[str]] = [
60
+ "acl",
61
+ "created",
62
+ "datasourceUrl",
63
+ "description",
64
+ "displayName",
65
+ "id",
66
+ "ingestOtlpUrl",
67
+ "ingestUrl",
68
+ "queryRangeUrl",
69
+ "queryUrl",
70
+ "retentionDays",
71
+ "status",
72
+ ]
73
+
74
+ @field_validator("created", mode="before")
75
+ def created_change_year_zero_to_one(cls, value):
76
+ """Workaround which prevents year 0 issue"""
77
+ if isinstance(value, str):
78
+ # Check for year "0000" at the beginning of the string
79
+ # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
80
+ if value.startswith("0000-01-01T") and re.match(
81
+ r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
82
+ ):
83
+ # Workaround: Replace "0000" with "0001"
84
+ return "0001" + value[4:] # Take "0001" and append the rest of the string
85
+ return value
86
+
87
+ @field_validator("display_name")
88
+ def display_name_validate_regular_expression(cls, value):
89
+ """Validates the regular expression"""
90
+ if not re.match(r"^[a-zA-Z][\w -]*$", value):
91
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/")
92
+ return value
93
+
94
+ @field_validator("status")
95
+ def status_validate_enum(cls, value):
96
+ """Validates the enum"""
97
+ if value not in set(["active", "deleting", "reconciling"]):
98
+ raise ValueError("must be one of enum values ('active', 'deleting', 'reconciling')")
99
+ return value
100
+
101
+ model_config = ConfigDict(
102
+ populate_by_name=True,
103
+ validate_assignment=True,
104
+ protected_namespaces=(),
105
+ )
106
+
107
+ def to_str(self) -> str:
108
+ """Returns the string representation of the model using alias"""
109
+ return pprint.pformat(self.model_dump(by_alias=True))
110
+
111
+ def to_json(self) -> str:
112
+ """Returns the JSON representation of the model using alias"""
113
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
114
+ return json.dumps(self.to_dict())
115
+
116
+ @classmethod
117
+ def from_json(cls, json_str: str) -> Optional[Self]:
118
+ """Create an instance of LogsInstance from a JSON string"""
119
+ return cls.from_dict(json.loads(json_str))
120
+
121
+ def to_dict(self) -> Dict[str, Any]:
122
+ """Return the dictionary representation of the model using alias.
123
+
124
+ This has the following differences from calling pydantic's
125
+ `self.model_dump(by_alias=True)`:
126
+
127
+ * `None` is only added to the output dict for nullable fields that
128
+ were set at model initialization. Other fields with value `None`
129
+ are ignored.
130
+ """
131
+ excluded_fields: Set[str] = set([])
132
+
133
+ _dict = self.model_dump(
134
+ by_alias=True,
135
+ exclude=excluded_fields,
136
+ exclude_none=True,
137
+ )
138
+ return _dict
139
+
140
+ @classmethod
141
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
142
+ """Create an instance of LogsInstance from a dict"""
143
+ if obj is None:
144
+ return None
145
+
146
+ if not isinstance(obj, dict):
147
+ return cls.model_validate(obj)
148
+
149
+ _obj = cls.model_validate(
150
+ {
151
+ "acl": obj.get("acl"),
152
+ "created": obj.get("created"),
153
+ "datasourceUrl": obj.get("datasourceUrl"),
154
+ "description": obj.get("description"),
155
+ "displayName": obj.get("displayName"),
156
+ "id": obj.get("id"),
157
+ "ingestOtlpUrl": obj.get("ingestOtlpUrl"),
158
+ "ingestUrl": obj.get("ingestUrl"),
159
+ "queryRangeUrl": obj.get("queryRangeUrl"),
160
+ "queryUrl": obj.get("queryUrl"),
161
+ "retentionDays": obj.get("retentionDays"),
162
+ "status": obj.get("status"),
163
+ }
164
+ )
165
+ return _obj
@@ -0,0 +1,98 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Logs API
5
+
6
+ This API provides endpoints for managing STACKIT Logs.
7
+
8
+ The version of the OpenAPI document: 1beta.0.3
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
21
+ from typing_extensions import Self
22
+
23
+ from stackit.logs.models.logs_instance import LogsInstance
24
+
25
+
26
+ class LogsInstancesList(BaseModel):
27
+ """
28
+ LogsInstancesList
29
+ """ # noqa: E501
30
+
31
+ instances: List[LogsInstance]
32
+ __properties: ClassVar[List[str]] = ["instances"]
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 LogsInstancesList 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 instances (list)
72
+ _items = []
73
+ if self.instances:
74
+ for _item in self.instances:
75
+ if _item:
76
+ _items.append(_item.to_dict())
77
+ _dict["instances"] = _items
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of LogsInstancesList 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
+ "instances": (
92
+ [LogsInstance.from_dict(_item) for _item in obj["instances"]]
93
+ if obj.get("instances") is not None
94
+ else None
95
+ )
96
+ }
97
+ )
98
+ return _obj
@@ -0,0 +1,97 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Logs API
5
+
6
+ This API provides endpoints for managing STACKIT Logs.
7
+
8
+ The version of the OpenAPI document: 1beta.0.3
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
+
25
+ class UpdateAccessTokenPayload(BaseModel):
26
+ """
27
+ UpdateAccessTokenPayload
28
+ """ # noqa: E501
29
+
30
+ description: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(
31
+ default=None, description="The description of the access token."
32
+ )
33
+ display_name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=32)]] = Field(
34
+ default=None, description="The displayed name of the access token.", alias="displayName"
35
+ )
36
+ __properties: ClassVar[List[str]] = ["description", "displayName"]
37
+
38
+ @field_validator("display_name")
39
+ def display_name_validate_regular_expression(cls, value):
40
+ """Validates the regular expression"""
41
+ if value is None:
42
+ return value
43
+
44
+ if not re.match(r"^[a-zA-Z][\w -]*$", value):
45
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/")
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 UpdateAccessTokenPayload 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 UpdateAccessTokenPayload 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({"description": obj.get("description"), "displayName": obj.get("displayName")})
97
+ return _obj
@@ -0,0 +1,108 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Logs API
5
+
6
+ This API provides endpoints for managing STACKIT Logs.
7
+
8
+ The version of the OpenAPI document: 1beta.0.3
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, StrictStr, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+
25
+ class UpdateLogsInstancePayload(BaseModel):
26
+ """
27
+ UpdateLogsInstancePayload
28
+ """ # noqa: E501
29
+
30
+ acl: Optional[List[StrictStr]] = Field(default=None, description="The access control list for the Logs instance.")
31
+ description: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(
32
+ default=None, description="The description of the Logs instance."
33
+ )
34
+ display_name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=32)]] = Field(
35
+ default=None, description="The displayed name to distinguish multiple Logs instances.", alias="displayName"
36
+ )
37
+ retention_days: Optional[Annotated[int, Field(le=180, strict=True, ge=1)]] = Field(
38
+ default=None, description="The log retention time in days.", alias="retentionDays"
39
+ )
40
+ __properties: ClassVar[List[str]] = ["acl", "description", "displayName", "retentionDays"]
41
+
42
+ @field_validator("display_name")
43
+ def display_name_validate_regular_expression(cls, value):
44
+ """Validates the regular expression"""
45
+ if value is None:
46
+ return value
47
+
48
+ if not re.match(r"^[a-zA-Z][\w -]*$", value):
49
+ raise ValueError(r"must validate the regular expression /^[a-zA-Z][\w -]*$/")
50
+ return value
51
+
52
+ model_config = ConfigDict(
53
+ populate_by_name=True,
54
+ validate_assignment=True,
55
+ protected_namespaces=(),
56
+ )
57
+
58
+ def to_str(self) -> str:
59
+ """Returns the string representation of the model using alias"""
60
+ return pprint.pformat(self.model_dump(by_alias=True))
61
+
62
+ def to_json(self) -> str:
63
+ """Returns the JSON representation of the model using alias"""
64
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
65
+ return json.dumps(self.to_dict())
66
+
67
+ @classmethod
68
+ def from_json(cls, json_str: str) -> Optional[Self]:
69
+ """Create an instance of UpdateLogsInstancePayload from a JSON string"""
70
+ return cls.from_dict(json.loads(json_str))
71
+
72
+ def to_dict(self) -> Dict[str, Any]:
73
+ """Return the dictionary representation of the model using alias.
74
+
75
+ This has the following differences from calling pydantic's
76
+ `self.model_dump(by_alias=True)`:
77
+
78
+ * `None` is only added to the output dict for nullable fields that
79
+ were set at model initialization. Other fields with value `None`
80
+ are ignored.
81
+ """
82
+ excluded_fields: Set[str] = set([])
83
+
84
+ _dict = self.model_dump(
85
+ by_alias=True,
86
+ exclude=excluded_fields,
87
+ exclude_none=True,
88
+ )
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of UpdateLogsInstancePayload from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj)
99
+
100
+ _obj = cls.model_validate(
101
+ {
102
+ "acl": obj.get("acl"),
103
+ "description": obj.get("description"),
104
+ "displayName": obj.get("displayName"),
105
+ "retentionDays": obj.get("retentionDays"),
106
+ }
107
+ )
108
+ return _obj
stackit/logs/py.typed ADDED
File without changes