Skip to content

feat(audit_trail): add apple-silicon resources definition #1065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .types import ResourceType
from .types import AccountOrganizationInfo
from .types import AccountUserInfo
from .types import AppleSiliconServerInfo
from .types import InstanceServerInfo
from .types import KeyManagerKeyInfo
from .types import KubernetesACLInfo
Expand All @@ -28,6 +29,7 @@
"ResourceType",
"AccountOrganizationInfo",
"AccountUserInfo",
"AppleSiliconServerInfo",
"InstanceServerInfo",
"KeyManagerKeyInfo",
"KubernetesACLInfo",
Expand Down
40 changes: 30 additions & 10 deletions scaleway-async/scaleway_async/audit_trail/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .types import (
AccountOrganizationInfo,
AccountUserInfo,
AppleSiliconServerInfo,
InstanceServerInfo,
KeyManagerKeyInfo,
KubernetesACLInfo,
Expand Down Expand Up @@ -57,6 +58,25 @@ def unmarshal_AccountUserInfo(data: Any) -> AccountUserInfo:
return AccountUserInfo(**args)


def unmarshal_AppleSiliconServerInfo(data: Any) -> AppleSiliconServerInfo:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'AppleSiliconServerInfo' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("id", None)
if field is not None:
args["id"] = field

field = data.get("name", None)
if field is not None:
args["name"] = field

return AppleSiliconServerInfo(**args)


def unmarshal_InstanceServerInfo(data: Any) -> InstanceServerInfo:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -318,6 +338,12 @@ def unmarshal_Resource(data: Any) -> Resource:
else:
args["instance_server_info"] = None

field = data.get("apple_silicon_server_info", None)
if field is not None:
args["apple_silicon_server_info"] = unmarshal_AppleSiliconServerInfo(field)
else:
args["apple_silicon_server_info"] = None

return Resource(**args)


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

field = data.get("product_name", None)
if field is not None:
args["product_name"] = field

field = data.get("recorded_at", None)
if field is not None:
args["recorded_at"] = (
Expand All @@ -371,10 +401,6 @@ def unmarshal_Event(data: Any) -> Event:
else:
args["user_agent"] = None

field = data.get("product_name", None)
if field is not None:
args["product_name"] = field

field = data.get("service_name", None)
if field is not None:
args["service_name"] = field
Expand All @@ -397,12 +423,6 @@ def unmarshal_Event(data: Any) -> Event:
if field is not None:
args["status_code"] = field

field = data.get("resource", None)
if field is not None:
args["resource"] = unmarshal_Resource(field)
else:
args["resource"] = None

field = data.get("request_body", None)
if field is not None:
args["request_body"] = field
Expand Down
25 changes: 15 additions & 10 deletions scaleway-async/scaleway_async/audit_trail/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ResourceType(str, Enum, metaclass=StrEnumMeta):
ACCOUNT_USER = "account_user"
ACCOUNT_ORGANIZATION = "account_organization"
INSTANCE_SERVER = "instance_server"
APPLE_SILICON_SERVER = "apple_silicon_server"

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


@dataclass
class AppleSiliconServerInfo:
id: str

name: str


@dataclass
class InstanceServerInfo:
name: str
Expand Down Expand Up @@ -153,6 +161,8 @@ class Resource:

instance_server_info: Optional[InstanceServerInfo]

apple_silicon_server_info: Optional[AppleSiliconServerInfo]


@dataclass
class ProductService:
Expand Down Expand Up @@ -183,6 +193,11 @@ class Event:
IP address at the origin of the event.
"""

product_name: str
"""
Product name of the resource attached to the event.
"""

recorded_at: Optional[datetime]
"""
Timestamp of the event.
Expand All @@ -203,11 +218,6 @@ class Event:
User Agent at the origin of the event.
"""

product_name: str
"""
Product name of the resource attached to the event.
"""

service_name: str
"""
API name called to trigger the event.
Expand All @@ -233,11 +243,6 @@ class Event:
HTTP status code resulting of the API call.
"""

resource: Optional[Resource]
"""
Resource attached to the event.
"""

request_body: Optional[Dict[str, Any]]
"""
Request at the origin of the event.
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/audit_trail/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .types import ResourceType
from .types import AccountOrganizationInfo
from .types import AccountUserInfo
from .types import AppleSiliconServerInfo
from .types import InstanceServerInfo
from .types import KeyManagerKeyInfo
from .types import KubernetesACLInfo
Expand All @@ -28,6 +29,7 @@
"ResourceType",
"AccountOrganizationInfo",
"AccountUserInfo",
"AppleSiliconServerInfo",
"InstanceServerInfo",
"KeyManagerKeyInfo",
"KubernetesACLInfo",
Expand Down
40 changes: 30 additions & 10 deletions scaleway/scaleway/audit_trail/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .types import (
AccountOrganizationInfo,
AccountUserInfo,
AppleSiliconServerInfo,
InstanceServerInfo,
KeyManagerKeyInfo,
KubernetesACLInfo,
Expand Down Expand Up @@ -57,6 +58,25 @@ def unmarshal_AccountUserInfo(data: Any) -> AccountUserInfo:
return AccountUserInfo(**args)


def unmarshal_AppleSiliconServerInfo(data: Any) -> AppleSiliconServerInfo:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'AppleSiliconServerInfo' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("id", None)
if field is not None:
args["id"] = field

field = data.get("name", None)
if field is not None:
args["name"] = field

return AppleSiliconServerInfo(**args)


def unmarshal_InstanceServerInfo(data: Any) -> InstanceServerInfo:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -318,6 +338,12 @@ def unmarshal_Resource(data: Any) -> Resource:
else:
args["instance_server_info"] = None

field = data.get("apple_silicon_server_info", None)
if field is not None:
args["apple_silicon_server_info"] = unmarshal_AppleSiliconServerInfo(field)
else:
args["apple_silicon_server_info"] = None

return Resource(**args)


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

field = data.get("product_name", None)
if field is not None:
args["product_name"] = field

field = data.get("recorded_at", None)
if field is not None:
args["recorded_at"] = (
Expand All @@ -371,10 +401,6 @@ def unmarshal_Event(data: Any) -> Event:
else:
args["user_agent"] = None

field = data.get("product_name", None)
if field is not None:
args["product_name"] = field

field = data.get("service_name", None)
if field is not None:
args["service_name"] = field
Expand All @@ -397,12 +423,6 @@ def unmarshal_Event(data: Any) -> Event:
if field is not None:
args["status_code"] = field

field = data.get("resource", None)
if field is not None:
args["resource"] = unmarshal_Resource(field)
else:
args["resource"] = None

field = data.get("request_body", None)
if field is not None:
args["request_body"] = field
Expand Down
25 changes: 15 additions & 10 deletions scaleway/scaleway/audit_trail/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ResourceType(str, Enum, metaclass=StrEnumMeta):
ACCOUNT_USER = "account_user"
ACCOUNT_ORGANIZATION = "account_organization"
INSTANCE_SERVER = "instance_server"
APPLE_SILICON_SERVER = "apple_silicon_server"

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


@dataclass
class AppleSiliconServerInfo:
id: str

name: str


@dataclass
class InstanceServerInfo:
name: str
Expand Down Expand Up @@ -153,6 +161,8 @@ class Resource:

instance_server_info: Optional[InstanceServerInfo]

apple_silicon_server_info: Optional[AppleSiliconServerInfo]


@dataclass
class ProductService:
Expand Down Expand Up @@ -183,6 +193,11 @@ class Event:
IP address at the origin of the event.
"""

product_name: str
"""
Product name of the resource attached to the event.
"""

recorded_at: Optional[datetime]
"""
Timestamp of the event.
Expand All @@ -203,11 +218,6 @@ class Event:
User Agent at the origin of the event.
"""

product_name: str
"""
Product name of the resource attached to the event.
"""

service_name: str
"""
API name called to trigger the event.
Expand All @@ -233,11 +243,6 @@ class Event:
HTTP status code resulting of the API call.
"""

resource: Optional[Resource]
"""
Resource attached to the event.
"""

request_body: Optional[Dict[str, Any]]
"""
Request at the origin of the event.
Expand Down
Loading