stackit-auditlog 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,239 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Audit Log API
5
+
6
+ API Endpoints to retrieve recorded actions and resulting changes in the system. ### Documentation The user documentation with explanations how to use the api can be found [here](https://docs.stackit.cloud/stackit/en/retrieve-audit-log-per-api-request-134415907.html). ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 60 requests per minute.
7
+
8
+ The version of the OpenAPI document: 2.0
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 datetime import datetime
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
+ from stackit.auditlog.models.audit_log_entry_context_response import (
25
+ AuditLogEntryContextResponse,
26
+ )
27
+ from stackit.auditlog.models.audit_log_entry_initiator_response import (
28
+ AuditLogEntryInitiatorResponse,
29
+ )
30
+ from stackit.auditlog.models.audit_log_entry_request_response import (
31
+ AuditLogEntryRequestResponse,
32
+ )
33
+ from stackit.auditlog.models.audit_log_entry_service_account_delegation_info_response import (
34
+ AuditLogEntryServiceAccountDelegationInfoResponse,
35
+ )
36
+
37
+
38
+ class AuditLogEntryResponse(BaseModel):
39
+ """
40
+ AuditLogEntryResponse
41
+ """ # noqa: E501
42
+
43
+ context: Optional[AuditLogEntryContextResponse] = None
44
+ correlation_id: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(
45
+ default=None,
46
+ description="Unique ID which identifies the request from the sender point of view.",
47
+ alias="correlationId",
48
+ )
49
+ details: Optional[Dict[str, Any]] = Field(
50
+ default=None,
51
+ description="Additional information about the event that is not part of the request or response. May contain arbitrary data.",
52
+ )
53
+ event_name: Annotated[str, Field(min_length=1, strict=True, max_length=255)] = Field(
54
+ description="Name of the operation this event represents.", alias="eventName"
55
+ )
56
+ event_source: StrictStr = Field(
57
+ description="The service in which the causing event was handled.", alias="eventSource"
58
+ )
59
+ event_time_stamp: datetime = Field(
60
+ description="Timestamp at which the event was triggered.", alias="eventTimeStamp"
61
+ )
62
+ event_type: StrictStr = Field(
63
+ description='Type that can be assigned to the event. For example, an event "Organization created" can be assigned to the type ADMIN_EVENT',
64
+ alias="eventType",
65
+ )
66
+ event_version: StrictStr = Field(description="Version of the log event format.", alias="eventVersion")
67
+ id: StrictStr = Field(description="Unique ID generated by the audit log.")
68
+ initiator: AuditLogEntryInitiatorResponse
69
+ received_time_stamp: datetime = Field(
70
+ description="Timestamp at which the event was received by the audit log.", alias="receivedTimeStamp"
71
+ )
72
+ region: StrictStr = Field(description="Region from which the event has been emitted.")
73
+ request: AuditLogEntryRequestResponse
74
+ resource_id: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(
75
+ default=None, description="Unique id of the resource that is target of the operation", alias="resourceId"
76
+ )
77
+ resource_name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(
78
+ default=None, description="Name of the resource that is target of the operation", alias="resourceName"
79
+ )
80
+ result: Optional[Dict[str, Any]] = Field(
81
+ default=None,
82
+ description="Object representing the change resulting from this event. May be omitted if no change has been applied. May contain arbitrary data.",
83
+ )
84
+ service_account_delegation_info: Optional[AuditLogEntryServiceAccountDelegationInfoResponse] = Field(
85
+ default=None, alias="serviceAccountDelegationInfo"
86
+ )
87
+ severity: StrictStr = Field(description="The severity of this request.")
88
+ source_ip_address: StrictStr = Field(
89
+ description="IP address that the request was made from", alias="sourceIpAddress"
90
+ )
91
+ user_agent: Annotated[str, Field(min_length=1, strict=True, max_length=255)] = Field(
92
+ description="Agent through which the request was made from (e.g. Portal, CLI, SDK, ...) ", alias="userAgent"
93
+ )
94
+ visibility: StrictStr = Field(
95
+ description="PUBLIC for entries that are intended for end users, while PRIVATE entries can only be viewed with system privileges."
96
+ )
97
+ __properties: ClassVar[List[str]] = [
98
+ "context",
99
+ "correlationId",
100
+ "details",
101
+ "eventName",
102
+ "eventSource",
103
+ "eventTimeStamp",
104
+ "eventType",
105
+ "eventVersion",
106
+ "id",
107
+ "initiator",
108
+ "receivedTimeStamp",
109
+ "region",
110
+ "request",
111
+ "resourceId",
112
+ "resourceName",
113
+ "result",
114
+ "serviceAccountDelegationInfo",
115
+ "severity",
116
+ "sourceIpAddress",
117
+ "userAgent",
118
+ "visibility",
119
+ ]
120
+
121
+ @field_validator("event_type")
122
+ def event_type_validate_enum(cls, value):
123
+ """Validates the enum"""
124
+ if value not in set(["ADMIN_ACTIVITY", "SYSTEM_EVENT", "POLICY_DENIED"]):
125
+ raise ValueError("must be one of enum values ('ADMIN_ACTIVITY', 'SYSTEM_EVENT', 'POLICY_DENIED')")
126
+ return value
127
+
128
+ @field_validator("severity")
129
+ def severity_validate_enum(cls, value):
130
+ """Validates the enum"""
131
+ if value not in set(["INFO", "ERROR"]):
132
+ raise ValueError("must be one of enum values ('INFO', 'ERROR')")
133
+ return value
134
+
135
+ @field_validator("visibility")
136
+ def visibility_validate_enum(cls, value):
137
+ """Validates the enum"""
138
+ if value not in set(["PUBLIC", "PRIVATE"]):
139
+ raise ValueError("must be one of enum values ('PUBLIC', 'PRIVATE')")
140
+ return value
141
+
142
+ model_config = ConfigDict(
143
+ populate_by_name=True,
144
+ validate_assignment=True,
145
+ protected_namespaces=(),
146
+ )
147
+
148
+ def to_str(self) -> str:
149
+ """Returns the string representation of the model using alias"""
150
+ return pprint.pformat(self.model_dump(by_alias=True))
151
+
152
+ def to_json(self) -> str:
153
+ """Returns the JSON representation of the model using alias"""
154
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
155
+ return json.dumps(self.to_dict())
156
+
157
+ @classmethod
158
+ def from_json(cls, json_str: str) -> Optional[Self]:
159
+ """Create an instance of AuditLogEntryResponse from a JSON string"""
160
+ return cls.from_dict(json.loads(json_str))
161
+
162
+ def to_dict(self) -> Dict[str, Any]:
163
+ """Return the dictionary representation of the model using alias.
164
+
165
+ This has the following differences from calling pydantic's
166
+ `self.model_dump(by_alias=True)`:
167
+
168
+ * `None` is only added to the output dict for nullable fields that
169
+ were set at model initialization. Other fields with value `None`
170
+ are ignored.
171
+ """
172
+ excluded_fields: Set[str] = set([])
173
+
174
+ _dict = self.model_dump(
175
+ by_alias=True,
176
+ exclude=excluded_fields,
177
+ exclude_none=True,
178
+ )
179
+ # override the default output from pydantic by calling `to_dict()` of context
180
+ if self.context:
181
+ _dict["context"] = self.context.to_dict()
182
+ # override the default output from pydantic by calling `to_dict()` of initiator
183
+ if self.initiator:
184
+ _dict["initiator"] = self.initiator.to_dict()
185
+ # override the default output from pydantic by calling `to_dict()` of request
186
+ if self.request:
187
+ _dict["request"] = self.request.to_dict()
188
+ # override the default output from pydantic by calling `to_dict()` of service_account_delegation_info
189
+ if self.service_account_delegation_info:
190
+ _dict["serviceAccountDelegationInfo"] = self.service_account_delegation_info.to_dict()
191
+ return _dict
192
+
193
+ @classmethod
194
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
195
+ """Create an instance of AuditLogEntryResponse from a dict"""
196
+ if obj is None:
197
+ return None
198
+
199
+ if not isinstance(obj, dict):
200
+ return cls.model_validate(obj)
201
+
202
+ _obj = cls.model_validate(
203
+ {
204
+ "context": (
205
+ AuditLogEntryContextResponse.from_dict(obj["context"]) if obj.get("context") is not None else None
206
+ ),
207
+ "correlationId": obj.get("correlationId"),
208
+ "details": obj.get("details"),
209
+ "eventName": obj.get("eventName"),
210
+ "eventSource": obj.get("eventSource"),
211
+ "eventTimeStamp": obj.get("eventTimeStamp"),
212
+ "eventType": obj.get("eventType"),
213
+ "eventVersion": obj.get("eventVersion"),
214
+ "id": obj.get("id"),
215
+ "initiator": (
216
+ AuditLogEntryInitiatorResponse.from_dict(obj["initiator"])
217
+ if obj.get("initiator") is not None
218
+ else None
219
+ ),
220
+ "receivedTimeStamp": obj.get("receivedTimeStamp"),
221
+ "region": obj.get("region"),
222
+ "request": (
223
+ AuditLogEntryRequestResponse.from_dict(obj["request"]) if obj.get("request") is not None else None
224
+ ),
225
+ "resourceId": obj.get("resourceId"),
226
+ "resourceName": obj.get("resourceName"),
227
+ "result": obj.get("result"),
228
+ "serviceAccountDelegationInfo": (
229
+ AuditLogEntryServiceAccountDelegationInfoResponse.from_dict(obj["serviceAccountDelegationInfo"])
230
+ if obj.get("serviceAccountDelegationInfo") is not None
231
+ else None
232
+ ),
233
+ "severity": obj.get("severity"),
234
+ "sourceIpAddress": obj.get("sourceIpAddress"),
235
+ "userAgent": obj.get("userAgent"),
236
+ "visibility": obj.get("visibility"),
237
+ }
238
+ )
239
+ return _obj
@@ -0,0 +1,102 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Audit Log API
5
+
6
+ API Endpoints to retrieve recorded actions and resulting changes in the system. ### Documentation The user documentation with explanations how to use the api can be found [here](https://docs.stackit.cloud/stackit/en/retrieve-audit-log-per-api-request-134415907.html). ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 60 requests per minute.
7
+
8
+ The version of the OpenAPI document: 2.0
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, Field
21
+ from typing_extensions import Self
22
+
23
+ from stackit.auditlog.models.service_account_delegation_info_principal_response import (
24
+ ServiceAccountDelegationInfoPrincipalResponse,
25
+ )
26
+
27
+
28
+ class AuditLogEntryServiceAccountDelegationInfoResponse(BaseModel):
29
+ """
30
+ Information about service account delegation
31
+ """ # noqa: E501
32
+
33
+ principals: List[ServiceAccountDelegationInfoPrincipalResponse] = Field(
34
+ description="Delegation chain for the service account"
35
+ )
36
+ __properties: ClassVar[List[str]] = ["principals"]
37
+
38
+ model_config = ConfigDict(
39
+ populate_by_name=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+ def to_str(self) -> str:
45
+ """Returns the string representation of the model using alias"""
46
+ return pprint.pformat(self.model_dump(by_alias=True))
47
+
48
+ def to_json(self) -> str:
49
+ """Returns the JSON representation of the model using alias"""
50
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
51
+ return json.dumps(self.to_dict())
52
+
53
+ @classmethod
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
55
+ """Create an instance of AuditLogEntryServiceAccountDelegationInfoResponse from a JSON string"""
56
+ return cls.from_dict(json.loads(json_str))
57
+
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ """Return the dictionary representation of the model using alias.
60
+
61
+ This has the following differences from calling pydantic's
62
+ `self.model_dump(by_alias=True)`:
63
+
64
+ * `None` is only added to the output dict for nullable fields that
65
+ were set at model initialization. Other fields with value `None`
66
+ are ignored.
67
+ """
68
+ excluded_fields: Set[str] = set([])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # override the default output from pydantic by calling `to_dict()` of each item in principals (list)
76
+ _items = []
77
+ if self.principals:
78
+ for _item in self.principals:
79
+ if _item:
80
+ _items.append(_item.to_dict())
81
+ _dict["principals"] = _items
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of AuditLogEntryServiceAccountDelegationInfoResponse from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate(
94
+ {
95
+ "principals": (
96
+ [ServiceAccountDelegationInfoPrincipalResponse.from_dict(_item) for _item in obj["principals"]]
97
+ if obj.get("principals") is not None
98
+ else None
99
+ )
100
+ }
101
+ )
102
+ return _obj
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Audit Log API
5
+
6
+ API Endpoints to retrieve recorded actions and resulting changes in the system. ### Documentation The user documentation with explanations how to use the api can be found [here](https://docs.stackit.cloud/stackit/en/retrieve-audit-log-per-api-request-134415907.html). ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 60 requests per minute.
7
+
8
+ The version of the OpenAPI document: 2.0
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 datetime import datetime
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set, Union
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
22
+ from typing_extensions import Self
23
+
24
+
25
+ class ErrorResponse(BaseModel):
26
+ """
27
+ ErrorResponse
28
+ """ # noqa: E501
29
+
30
+ message: Optional[StrictStr] = Field(default=None, description="Description of the error.")
31
+ path: Optional[StrictStr] = Field(default=None, description="Path which was called.")
32
+ status: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Http status code.")
33
+ timestamp: Optional[datetime] = Field(default=None, description="Timestamp at which the error occurred.")
34
+ __properties: ClassVar[List[str]] = ["message", "path", "status", "timestamp"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of ErrorResponse from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of ErrorResponse from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate(
85
+ {
86
+ "message": obj.get("message"),
87
+ "path": obj.get("path"),
88
+ "status": obj.get("status"),
89
+ "timestamp": obj.get("timestamp"),
90
+ }
91
+ )
92
+ return _obj
@@ -0,0 +1,82 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Audit Log API
5
+
6
+ API Endpoints to retrieve recorded actions and resulting changes in the system. ### Documentation The user documentation with explanations how to use the api can be found [here](https://docs.stackit.cloud/stackit/en/retrieve-audit-log-per-api-request-134415907.html). ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 60 requests per minute.
7
+
8
+ The version of the OpenAPI document: 2.0
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, Union
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
21
+ from typing_extensions import Self
22
+
23
+
24
+ class GatewayErrorResponse(BaseModel):
25
+ """
26
+ GatewayErrorResponse
27
+ """ # noqa: E501
28
+
29
+ message: Optional[StrictStr] = Field(default=None, description="Description of the error.")
30
+ status: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Http status code.")
31
+ __properties: ClassVar[List[str]] = ["message", "status"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+ def to_str(self) -> str:
40
+ """Returns the string representation of the model using alias"""
41
+ return pprint.pformat(self.model_dump(by_alias=True))
42
+
43
+ def to_json(self) -> str:
44
+ """Returns the JSON representation of the model using alias"""
45
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46
+ return json.dumps(self.to_dict())
47
+
48
+ @classmethod
49
+ def from_json(cls, json_str: str) -> Optional[Self]:
50
+ """Create an instance of GatewayErrorResponse from a JSON string"""
51
+ return cls.from_dict(json.loads(json_str))
52
+
53
+ def to_dict(self) -> Dict[str, Any]:
54
+ """Return the dictionary representation of the model using alias.
55
+
56
+ This has the following differences from calling pydantic's
57
+ `self.model_dump(by_alias=True)`:
58
+
59
+ * `None` is only added to the output dict for nullable fields that
60
+ were set at model initialization. Other fields with value `None`
61
+ are ignored.
62
+ """
63
+ excluded_fields: Set[str] = set([])
64
+
65
+ _dict = self.model_dump(
66
+ by_alias=True,
67
+ exclude=excluded_fields,
68
+ exclude_none=True,
69
+ )
70
+ return _dict
71
+
72
+ @classmethod
73
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
74
+ """Create an instance of GatewayErrorResponse from a dict"""
75
+ if obj is None:
76
+ return None
77
+
78
+ if not isinstance(obj, dict):
79
+ return cls.model_validate(obj)
80
+
81
+ _obj = cls.model_validate({"message": obj.get("message"), "status": obj.get("status")})
82
+ return _obj
@@ -0,0 +1,104 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Audit Log API
5
+
6
+ API Endpoints to retrieve recorded actions and resulting changes in the system. ### Documentation The user documentation with explanations how to use the api can be found [here](https://docs.stackit.cloud/stackit/en/retrieve-audit-log-per-api-request-134415907.html). ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit log. ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at once is 24 hours. Requests are rate limited - the current maximum is 60 requests per minute.
7
+
8
+ The version of the OpenAPI document: 2.0
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, Union
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
21
+ from typing_extensions import Self
22
+
23
+ from stackit.auditlog.models.audit_log_entry_response import AuditLogEntryResponse
24
+
25
+
26
+ class ListAuditLogEntriesResponse(BaseModel):
27
+ """
28
+ ListAuditLogEntriesResponse
29
+ """ # noqa: E501
30
+
31
+ cursor: Optional[StrictStr] = Field(default=None, description="Optional cursor if more entries are available")
32
+ items: Optional[List[AuditLogEntryResponse]] = None
33
+ limit: Optional[Union[StrictFloat, StrictInt]] = Field(
34
+ default=50, description="Maximum amount of entries requested."
35
+ )
36
+ __properties: ClassVar[List[str]] = ["cursor", "items", "limit"]
37
+
38
+ model_config = ConfigDict(
39
+ populate_by_name=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+ def to_str(self) -> str:
45
+ """Returns the string representation of the model using alias"""
46
+ return pprint.pformat(self.model_dump(by_alias=True))
47
+
48
+ def to_json(self) -> str:
49
+ """Returns the JSON representation of the model using alias"""
50
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
51
+ return json.dumps(self.to_dict())
52
+
53
+ @classmethod
54
+ def from_json(cls, json_str: str) -> Optional[Self]:
55
+ """Create an instance of ListAuditLogEntriesResponse from a JSON string"""
56
+ return cls.from_dict(json.loads(json_str))
57
+
58
+ def to_dict(self) -> Dict[str, Any]:
59
+ """Return the dictionary representation of the model using alias.
60
+
61
+ This has the following differences from calling pydantic's
62
+ `self.model_dump(by_alias=True)`:
63
+
64
+ * `None` is only added to the output dict for nullable fields that
65
+ were set at model initialization. Other fields with value `None`
66
+ are ignored.
67
+ """
68
+ excluded_fields: Set[str] = set([])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
76
+ _items = []
77
+ if self.items:
78
+ for _item in self.items:
79
+ if _item:
80
+ _items.append(_item.to_dict())
81
+ _dict["items"] = _items
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of ListAuditLogEntriesResponse from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate(
94
+ {
95
+ "cursor": obj.get("cursor"),
96
+ "items": (
97
+ [AuditLogEntryResponse.from_dict(_item) for _item in obj["items"]]
98
+ if obj.get("items") is not None
99
+ else None
100
+ ),
101
+ "limit": obj.get("limit") if obj.get("limit") is not None else 50,
102
+ }
103
+ )
104
+ return _obj