Skip to content

Commit 6254073

Browse files
feat(audit_trail): add apple-silicon resources definition (#1065)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 034a780 commit 6254073

File tree

6 files changed

+94
-40
lines changed

6 files changed

+94
-40
lines changed

scaleway-async/scaleway_async/audit_trail/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .types import ResourceType
55
from .types import AccountOrganizationInfo
66
from .types import AccountUserInfo
7+
from .types import AppleSiliconServerInfo
78
from .types import InstanceServerInfo
89
from .types import KeyManagerKeyInfo
910
from .types import KubernetesACLInfo
@@ -28,6 +29,7 @@
2829
"ResourceType",
2930
"AccountOrganizationInfo",
3031
"AccountUserInfo",
32+
"AppleSiliconServerInfo",
3133
"InstanceServerInfo",
3234
"KeyManagerKeyInfo",
3335
"KubernetesACLInfo",

scaleway-async/scaleway_async/audit_trail/v1alpha1/marshalling.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .types import (
88
AccountOrganizationInfo,
99
AccountUserInfo,
10+
AppleSiliconServerInfo,
1011
InstanceServerInfo,
1112
KeyManagerKeyInfo,
1213
KubernetesACLInfo,
@@ -57,6 +58,25 @@ def unmarshal_AccountUserInfo(data: Any) -> AccountUserInfo:
5758
return AccountUserInfo(**args)
5859

5960

61+
def unmarshal_AppleSiliconServerInfo(data: Any) -> AppleSiliconServerInfo:
62+
if not isinstance(data, dict):
63+
raise TypeError(
64+
"Unmarshalling the type 'AppleSiliconServerInfo' failed as data isn't a dictionary."
65+
)
66+
67+
args: Dict[str, Any] = {}
68+
69+
field = data.get("id", None)
70+
if field is not None:
71+
args["id"] = field
72+
73+
field = data.get("name", None)
74+
if field is not None:
75+
args["name"] = field
76+
77+
return AppleSiliconServerInfo(**args)
78+
79+
6080
def unmarshal_InstanceServerInfo(data: Any) -> InstanceServerInfo:
6181
if not isinstance(data, dict):
6282
raise TypeError(
@@ -318,6 +338,12 @@ def unmarshal_Resource(data: Any) -> Resource:
318338
else:
319339
args["instance_server_info"] = None
320340

341+
field = data.get("apple_silicon_server_info", None)
342+
if field is not None:
343+
args["apple_silicon_server_info"] = unmarshal_AppleSiliconServerInfo(field)
344+
else:
345+
args["apple_silicon_server_info"] = None
346+
321347
return Resource(**args)
322348

323349

@@ -345,6 +371,10 @@ def unmarshal_Event(data: Any) -> Event:
345371
if field is not None:
346372
args["source_ip"] = field
347373

374+
field = data.get("product_name", None)
375+
if field is not None:
376+
args["product_name"] = field
377+
348378
field = data.get("recorded_at", None)
349379
if field is not None:
350380
args["recorded_at"] = (
@@ -371,10 +401,6 @@ def unmarshal_Event(data: Any) -> Event:
371401
else:
372402
args["user_agent"] = None
373403

374-
field = data.get("product_name", None)
375-
if field is not None:
376-
args["product_name"] = field
377-
378404
field = data.get("service_name", None)
379405
if field is not None:
380406
args["service_name"] = field
@@ -397,12 +423,6 @@ def unmarshal_Event(data: Any) -> Event:
397423
if field is not None:
398424
args["status_code"] = field
399425

400-
field = data.get("resource", None)
401-
if field is not None:
402-
args["resource"] = unmarshal_Resource(field)
403-
else:
404-
args["resource"] = None
405-
406426
field = data.get("request_body", None)
407427
if field is not None:
408428
args["request_body"] = field

scaleway-async/scaleway_async/audit_trail/v1alpha1/types.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ResourceType(str, Enum, metaclass=StrEnumMeta):
4545
ACCOUNT_USER = "account_user"
4646
ACCOUNT_ORGANIZATION = "account_organization"
4747
INSTANCE_SERVER = "instance_server"
48+
APPLE_SILICON_SERVER = "apple_silicon_server"
4849

4950
def __str__(self) -> str:
5051
return str(self.value)
@@ -62,6 +63,13 @@ class AccountUserInfo:
6263
phone_number: Optional[str]
6364

6465

66+
@dataclass
67+
class AppleSiliconServerInfo:
68+
id: str
69+
70+
name: str
71+
72+
6573
@dataclass
6674
class InstanceServerInfo:
6775
name: str
@@ -153,6 +161,8 @@ class Resource:
153161

154162
instance_server_info: Optional[InstanceServerInfo]
155163

164+
apple_silicon_server_info: Optional[AppleSiliconServerInfo]
165+
156166

157167
@dataclass
158168
class ProductService:
@@ -183,6 +193,11 @@ class Event:
183193
IP address at the origin of the event.
184194
"""
185195

196+
product_name: str
197+
"""
198+
Product name of the resource attached to the event.
199+
"""
200+
186201
recorded_at: Optional[datetime]
187202
"""
188203
Timestamp of the event.
@@ -203,11 +218,6 @@ class Event:
203218
User Agent at the origin of the event.
204219
"""
205220

206-
product_name: str
207-
"""
208-
Product name of the resource attached to the event.
209-
"""
210-
211221
service_name: str
212222
"""
213223
API name called to trigger the event.
@@ -233,11 +243,6 @@ class Event:
233243
HTTP status code resulting of the API call.
234244
"""
235245

236-
resource: Optional[Resource]
237-
"""
238-
Resource attached to the event.
239-
"""
240-
241246
request_body: Optional[Dict[str, Any]]
242247
"""
243248
Request at the origin of the event.

scaleway/scaleway/audit_trail/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .types import ResourceType
55
from .types import AccountOrganizationInfo
66
from .types import AccountUserInfo
7+
from .types import AppleSiliconServerInfo
78
from .types import InstanceServerInfo
89
from .types import KeyManagerKeyInfo
910
from .types import KubernetesACLInfo
@@ -28,6 +29,7 @@
2829
"ResourceType",
2930
"AccountOrganizationInfo",
3031
"AccountUserInfo",
32+
"AppleSiliconServerInfo",
3133
"InstanceServerInfo",
3234
"KeyManagerKeyInfo",
3335
"KubernetesACLInfo",

scaleway/scaleway/audit_trail/v1alpha1/marshalling.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .types import (
88
AccountOrganizationInfo,
99
AccountUserInfo,
10+
AppleSiliconServerInfo,
1011
InstanceServerInfo,
1112
KeyManagerKeyInfo,
1213
KubernetesACLInfo,
@@ -57,6 +58,25 @@ def unmarshal_AccountUserInfo(data: Any) -> AccountUserInfo:
5758
return AccountUserInfo(**args)
5859

5960

61+
def unmarshal_AppleSiliconServerInfo(data: Any) -> AppleSiliconServerInfo:
62+
if not isinstance(data, dict):
63+
raise TypeError(
64+
"Unmarshalling the type 'AppleSiliconServerInfo' failed as data isn't a dictionary."
65+
)
66+
67+
args: Dict[str, Any] = {}
68+
69+
field = data.get("id", None)
70+
if field is not None:
71+
args["id"] = field
72+
73+
field = data.get("name", None)
74+
if field is not None:
75+
args["name"] = field
76+
77+
return AppleSiliconServerInfo(**args)
78+
79+
6080
def unmarshal_InstanceServerInfo(data: Any) -> InstanceServerInfo:
6181
if not isinstance(data, dict):
6282
raise TypeError(
@@ -318,6 +338,12 @@ def unmarshal_Resource(data: Any) -> Resource:
318338
else:
319339
args["instance_server_info"] = None
320340

341+
field = data.get("apple_silicon_server_info", None)
342+
if field is not None:
343+
args["apple_silicon_server_info"] = unmarshal_AppleSiliconServerInfo(field)
344+
else:
345+
args["apple_silicon_server_info"] = None
346+
321347
return Resource(**args)
322348

323349

@@ -345,6 +371,10 @@ def unmarshal_Event(data: Any) -> Event:
345371
if field is not None:
346372
args["source_ip"] = field
347373

374+
field = data.get("product_name", None)
375+
if field is not None:
376+
args["product_name"] = field
377+
348378
field = data.get("recorded_at", None)
349379
if field is not None:
350380
args["recorded_at"] = (
@@ -371,10 +401,6 @@ def unmarshal_Event(data: Any) -> Event:
371401
else:
372402
args["user_agent"] = None
373403

374-
field = data.get("product_name", None)
375-
if field is not None:
376-
args["product_name"] = field
377-
378404
field = data.get("service_name", None)
379405
if field is not None:
380406
args["service_name"] = field
@@ -397,12 +423,6 @@ def unmarshal_Event(data: Any) -> Event:
397423
if field is not None:
398424
args["status_code"] = field
399425

400-
field = data.get("resource", None)
401-
if field is not None:
402-
args["resource"] = unmarshal_Resource(field)
403-
else:
404-
args["resource"] = None
405-
406426
field = data.get("request_body", None)
407427
if field is not None:
408428
args["request_body"] = field

scaleway/scaleway/audit_trail/v1alpha1/types.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ResourceType(str, Enum, metaclass=StrEnumMeta):
4545
ACCOUNT_USER = "account_user"
4646
ACCOUNT_ORGANIZATION = "account_organization"
4747
INSTANCE_SERVER = "instance_server"
48+
APPLE_SILICON_SERVER = "apple_silicon_server"
4849

4950
def __str__(self) -> str:
5051
return str(self.value)
@@ -62,6 +63,13 @@ class AccountUserInfo:
6263
phone_number: Optional[str]
6364

6465

66+
@dataclass
67+
class AppleSiliconServerInfo:
68+
id: str
69+
70+
name: str
71+
72+
6573
@dataclass
6674
class InstanceServerInfo:
6775
name: str
@@ -153,6 +161,8 @@ class Resource:
153161

154162
instance_server_info: Optional[InstanceServerInfo]
155163

164+
apple_silicon_server_info: Optional[AppleSiliconServerInfo]
165+
156166

157167
@dataclass
158168
class ProductService:
@@ -183,6 +193,11 @@ class Event:
183193
IP address at the origin of the event.
184194
"""
185195

196+
product_name: str
197+
"""
198+
Product name of the resource attached to the event.
199+
"""
200+
186201
recorded_at: Optional[datetime]
187202
"""
188203
Timestamp of the event.
@@ -203,11 +218,6 @@ class Event:
203218
User Agent at the origin of the event.
204219
"""
205220

206-
product_name: str
207-
"""
208-
Product name of the resource attached to the event.
209-
"""
210-
211221
service_name: str
212222
"""
213223
API name called to trigger the event.
@@ -233,11 +243,6 @@ class Event:
233243
HTTP status code resulting of the API call.
234244
"""
235245

236-
resource: Optional[Resource]
237-
"""
238-
Resource attached to the event.
239-
"""
240-
241246
request_body: Optional[Dict[str, Any]]
242247
"""
243248
Request at the origin of the event.

0 commit comments

Comments
 (0)