Skip to content

Commit 16d98b3

Browse files
authored
feat(audit_trail): add last status to export job (scaleway#1303)
1 parent 3221236 commit 16d98b3

File tree

6 files changed

+114
-6
lines changed

6 files changed

+114
-6
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .types import AuthenticationEventMethod
66
from .types import AuthenticationEventOrigin
77
from .types import AuthenticationEventResult
8+
from .types import ExportJobStatusCode
89
from .types import ListAuthenticationEventsRequestOrderBy
910
from .types import ListCombinedEventsRequestOrderBy
1011
from .types import ListEventsRequestOrderBy
@@ -39,6 +40,7 @@
3940
from .types import Event
4041
from .types import SystemEvent
4142
from .types import ExportJobS3
43+
from .types import ExportJobStatus
4244
from .types import ProductService
4345
from .types import ListCombinedEventsResponseCombinedEvent
4446
from .types import ExportJob
@@ -63,6 +65,7 @@
6365
"AuthenticationEventMethod",
6466
"AuthenticationEventOrigin",
6567
"AuthenticationEventResult",
68+
"ExportJobStatusCode",
6669
"ListAuthenticationEventsRequestOrderBy",
6770
"ListCombinedEventsRequestOrderBy",
6871
"ListEventsRequestOrderBy",
@@ -97,6 +100,7 @@
97100
"Event",
98101
"SystemEvent",
99102
"ExportJobS3",
103+
"ExportJobStatus",
100104
"ProductService",
101105
"ListCombinedEventsResponseCombinedEvent",
102106
"ExportJob",

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
AuthenticationEventOrigin,
1717
AuthenticationEventResult,
1818
ExportJobS3,
19+
ExportJobStatus,
1920
ExportJob,
2021
AccountOrganizationInfo,
2122
AccountProjectInfo,
@@ -94,6 +95,29 @@ def unmarshal_ExportJobS3(data: Any) -> ExportJobS3:
9495
return ExportJobS3(**args)
9596

9697

98+
def unmarshal_ExportJobStatus(data: Any) -> ExportJobStatus:
99+
if not isinstance(data, dict):
100+
raise TypeError(
101+
"Unmarshalling the type 'ExportJobStatus' failed as data isn't a dictionary."
102+
)
103+
104+
args: dict[str, Any] = {}
105+
106+
field = data.get("code", None)
107+
if field is not None:
108+
args["code"] = field
109+
else:
110+
args["code"] = None
111+
112+
field = data.get("message", None)
113+
if field is not None:
114+
args["message"] = field
115+
else:
116+
args["message"] = None
117+
118+
return ExportJobStatus(**args)
119+
120+
97121
def unmarshal_ExportJob(data: Any) -> ExportJob:
98122
if not isinstance(data, dict):
99123
raise TypeError(
@@ -146,6 +170,12 @@ def unmarshal_ExportJob(data: Any) -> ExportJob:
146170
else:
147171
args["last_run_at"] = None
148172

173+
field = data.get("last_status", None)
174+
if field is not None:
175+
args["last_status"] = unmarshal_ExportJobStatus(field)
176+
else:
177+
args["last_status"] = None
178+
149179
return ExportJob(**args)
150180

151181

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ def __str__(self) -> str:
6565
return str(self.value)
6666

6767

68+
class ExportJobStatusCode(str, Enum, metaclass=StrEnumMeta):
69+
UNKNOWN_CODE = "unknown_code"
70+
SUCCESS = "success"
71+
FAILURE = "failure"
72+
73+
def __str__(self) -> str:
74+
return str(self.value)
75+
76+
6877
class ListAuthenticationEventsRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
6978
RECORDED_AT_DESC = "recorded_at_desc"
7079
RECORDED_AT_ASC = "recorded_at_asc"
@@ -511,6 +520,12 @@ class ExportJobS3:
511520
project_id: Optional[str] = None
512521

513522

523+
@dataclass
524+
class ExportJobStatus:
525+
code: ExportJobStatusCode
526+
message: Optional[str] = None
527+
528+
514529
@dataclass
515530
class ProductService:
516531
name: str
@@ -540,12 +555,12 @@ class ExportJob:
540555

541556
name: str
542557
"""
543-
Name of the export.
558+
Name of the export job.
544559
"""
545560

546561
tags: dict[str, str]
547562
"""
548-
Tags of the export.
563+
Tags of the export job.
549564
"""
550565

551566
created_at: Optional[datetime] = None
@@ -555,7 +570,12 @@ class ExportJob:
555570

556571
last_run_at: Optional[datetime] = None
557572
"""
558-
Last export date.
573+
Last run of export job.
574+
"""
575+
576+
last_status: Optional[ExportJobStatus] = None
577+
"""
578+
Status of last export job.
559579
"""
560580

561581
s3: Optional[ExportJobS3] = None

scaleway/scaleway/audit_trail/v1alpha1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .types import AuthenticationEventMethod
66
from .types import AuthenticationEventOrigin
77
from .types import AuthenticationEventResult
8+
from .types import ExportJobStatusCode
89
from .types import ListAuthenticationEventsRequestOrderBy
910
from .types import ListCombinedEventsRequestOrderBy
1011
from .types import ListEventsRequestOrderBy
@@ -39,6 +40,7 @@
3940
from .types import Event
4041
from .types import SystemEvent
4142
from .types import ExportJobS3
43+
from .types import ExportJobStatus
4244
from .types import ProductService
4345
from .types import ListCombinedEventsResponseCombinedEvent
4446
from .types import ExportJob
@@ -63,6 +65,7 @@
6365
"AuthenticationEventMethod",
6466
"AuthenticationEventOrigin",
6567
"AuthenticationEventResult",
68+
"ExportJobStatusCode",
6669
"ListAuthenticationEventsRequestOrderBy",
6770
"ListCombinedEventsRequestOrderBy",
6871
"ListEventsRequestOrderBy",
@@ -97,6 +100,7 @@
97100
"Event",
98101
"SystemEvent",
99102
"ExportJobS3",
103+
"ExportJobStatus",
100104
"ProductService",
101105
"ListCombinedEventsResponseCombinedEvent",
102106
"ExportJob",

scaleway/scaleway/audit_trail/v1alpha1/marshalling.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
AuthenticationEventOrigin,
1717
AuthenticationEventResult,
1818
ExportJobS3,
19+
ExportJobStatus,
1920
ExportJob,
2021
AccountOrganizationInfo,
2122
AccountProjectInfo,
@@ -94,6 +95,29 @@ def unmarshal_ExportJobS3(data: Any) -> ExportJobS3:
9495
return ExportJobS3(**args)
9596

9697

98+
def unmarshal_ExportJobStatus(data: Any) -> ExportJobStatus:
99+
if not isinstance(data, dict):
100+
raise TypeError(
101+
"Unmarshalling the type 'ExportJobStatus' failed as data isn't a dictionary."
102+
)
103+
104+
args: dict[str, Any] = {}
105+
106+
field = data.get("code", None)
107+
if field is not None:
108+
args["code"] = field
109+
else:
110+
args["code"] = None
111+
112+
field = data.get("message", None)
113+
if field is not None:
114+
args["message"] = field
115+
else:
116+
args["message"] = None
117+
118+
return ExportJobStatus(**args)
119+
120+
97121
def unmarshal_ExportJob(data: Any) -> ExportJob:
98122
if not isinstance(data, dict):
99123
raise TypeError(
@@ -146,6 +170,12 @@ def unmarshal_ExportJob(data: Any) -> ExportJob:
146170
else:
147171
args["last_run_at"] = None
148172

173+
field = data.get("last_status", None)
174+
if field is not None:
175+
args["last_status"] = unmarshal_ExportJobStatus(field)
176+
else:
177+
args["last_status"] = None
178+
149179
return ExportJob(**args)
150180

151181

scaleway/scaleway/audit_trail/v1alpha1/types.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ def __str__(self) -> str:
6565
return str(self.value)
6666

6767

68+
class ExportJobStatusCode(str, Enum, metaclass=StrEnumMeta):
69+
UNKNOWN_CODE = "unknown_code"
70+
SUCCESS = "success"
71+
FAILURE = "failure"
72+
73+
def __str__(self) -> str:
74+
return str(self.value)
75+
76+
6877
class ListAuthenticationEventsRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
6978
RECORDED_AT_DESC = "recorded_at_desc"
7079
RECORDED_AT_ASC = "recorded_at_asc"
@@ -511,6 +520,12 @@ class ExportJobS3:
511520
project_id: Optional[str] = None
512521

513522

523+
@dataclass
524+
class ExportJobStatus:
525+
code: ExportJobStatusCode
526+
message: Optional[str] = None
527+
528+
514529
@dataclass
515530
class ProductService:
516531
name: str
@@ -540,12 +555,12 @@ class ExportJob:
540555

541556
name: str
542557
"""
543-
Name of the export.
558+
Name of the export job.
544559
"""
545560

546561
tags: dict[str, str]
547562
"""
548-
Tags of the export.
563+
Tags of the export job.
549564
"""
550565

551566
created_at: Optional[datetime] = None
@@ -555,7 +570,12 @@ class ExportJob:
555570

556571
last_run_at: Optional[datetime] = None
557572
"""
558-
Last export date.
573+
Last run of export job.
574+
"""
575+
576+
last_status: Optional[ExportJobStatus] = None
577+
"""
578+
Status of last export job.
559579
"""
560580

561581
s3: Optional[ExportJobS3] = None

0 commit comments

Comments
 (0)