Skip to content

Commit 5141cd9

Browse files
authored
Merge branch 'main' into v1.5809.0
2 parents 2e3c2e4 + b696c1e commit 5141cd9

File tree

9 files changed

+488
-2
lines changed

9 files changed

+488
-2
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
import { API as ParentAPI, urlParams, validatePathParam } from '../../../bridge'
4+
import type { Region } from '../../../bridge'
5+
import {
6+
unmarshalListEventsResponse,
7+
unmarshalListProductsResponse,
8+
} from './marshalling.gen'
9+
import type {
10+
ListEventsRequest,
11+
ListEventsResponse,
12+
ListProductsRequest,
13+
ListProductsResponse,
14+
} from './types.gen'
15+
16+
/**
17+
* Audit Trail API.
18+
*
19+
* This API allows you to ensure accountability and security by recording events
20+
* and changes performed within your Scaleway Organization.
21+
*/
22+
export class API extends ParentAPI {
23+
/** Lists the available regions of the API. */
24+
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams']
25+
26+
/**
27+
* List events. Retrieve the list of Audit Trail events for a Scaleway
28+
* Organization and/or Project. You must specify the `organization_id` and
29+
* optionally, the `project_id`.
30+
*
31+
* @param request - The request {@link ListEventsRequest}
32+
* @returns A Promise of ListEventsResponse
33+
*/
34+
listEvents = (request: Readonly<ListEventsRequest> = {}) =>
35+
this.client.fetch<ListEventsResponse>(
36+
{
37+
method: 'GET',
38+
path: `/audit-trail/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/events`,
39+
urlParams: urlParams(
40+
['method_name', request.methodName],
41+
['order_by', request.orderBy],
42+
[
43+
'organization_id',
44+
request.organizationId ??
45+
this.client.settings.defaultOrganizationId,
46+
],
47+
[
48+
'page_size',
49+
request.pageSize ?? this.client.settings.defaultPageSize,
50+
],
51+
['page_token', request.pageToken],
52+
['product_name', request.productName],
53+
['project_id', request.projectId],
54+
['recorded_after', request.recordedAfter],
55+
['recorded_before', request.recordedBefore],
56+
['resource_type', request.resourceType],
57+
['status', request.status],
58+
),
59+
},
60+
unmarshalListEventsResponse,
61+
)
62+
63+
/**
64+
* Retrieve the list of Scaleway resources for which you have Audit Trail
65+
* events.
66+
*
67+
* @param request - The request {@link ListProductsRequest}
68+
* @returns A Promise of ListProductsResponse
69+
*/
70+
listProducts = (request: Readonly<ListProductsRequest> = {}) =>
71+
this.client.fetch<ListProductsResponse>(
72+
{
73+
method: 'GET',
74+
path: `/audit-trail/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/products`,
75+
},
76+
unmarshalListProductsResponse,
77+
)
78+
}
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
import {
4+
isJSONObject,
5+
unmarshalArrayOfObject,
6+
unmarshalDate,
7+
} from '../../../bridge'
8+
import type {
9+
Event,
10+
EventPrincipal,
11+
KubernetesClusterInfo,
12+
KubernetesNodeInfo,
13+
KubernetesPoolInfo,
14+
ListEventsResponse,
15+
ListProductsResponse,
16+
Product,
17+
Resource,
18+
SecretManagerSecretInfo,
19+
SecretManagerSecretVersionInfo,
20+
} from './types.gen'
21+
22+
const unmarshalKubernetesClusterInfo = (
23+
data: unknown,
24+
): KubernetesClusterInfo => {
25+
if (!isJSONObject(data)) {
26+
throw new TypeError(
27+
`Unmarshalling the type 'KubernetesClusterInfo' failed as data isn't a dictionary.`,
28+
)
29+
}
30+
31+
return {} as KubernetesClusterInfo
32+
}
33+
34+
const unmarshalKubernetesNodeInfo = (data: unknown): KubernetesNodeInfo => {
35+
if (!isJSONObject(data)) {
36+
throw new TypeError(
37+
`Unmarshalling the type 'KubernetesNodeInfo' failed as data isn't a dictionary.`,
38+
)
39+
}
40+
41+
return {
42+
id: data.id,
43+
name: data.name,
44+
} as KubernetesNodeInfo
45+
}
46+
47+
const unmarshalKubernetesPoolInfo = (data: unknown): KubernetesPoolInfo => {
48+
if (!isJSONObject(data)) {
49+
throw new TypeError(
50+
`Unmarshalling the type 'KubernetesPoolInfo' failed as data isn't a dictionary.`,
51+
)
52+
}
53+
54+
return {
55+
id: data.id,
56+
name: data.name,
57+
} as KubernetesPoolInfo
58+
}
59+
60+
const unmarshalSecretManagerSecretInfo = (
61+
data: unknown,
62+
): SecretManagerSecretInfo => {
63+
if (!isJSONObject(data)) {
64+
throw new TypeError(
65+
`Unmarshalling the type 'SecretManagerSecretInfo' failed as data isn't a dictionary.`,
66+
)
67+
}
68+
69+
return {
70+
path: data.path,
71+
} as SecretManagerSecretInfo
72+
}
73+
74+
const unmarshalSecretManagerSecretVersionInfo = (
75+
data: unknown,
76+
): SecretManagerSecretVersionInfo => {
77+
if (!isJSONObject(data)) {
78+
throw new TypeError(
79+
`Unmarshalling the type 'SecretManagerSecretVersionInfo' failed as data isn't a dictionary.`,
80+
)
81+
}
82+
83+
return {
84+
revision: data.revision,
85+
} as SecretManagerSecretVersionInfo
86+
}
87+
88+
const unmarshalEventPrincipal = (data: unknown): EventPrincipal => {
89+
if (!isJSONObject(data)) {
90+
throw new TypeError(
91+
`Unmarshalling the type 'EventPrincipal' failed as data isn't a dictionary.`,
92+
)
93+
}
94+
95+
return {
96+
id: data.id,
97+
} as EventPrincipal
98+
}
99+
100+
export const unmarshalResource = (data: unknown): Resource => {
101+
if (!isJSONObject(data)) {
102+
throw new TypeError(
103+
`Unmarshalling the type 'Resource' failed as data isn't a dictionary.`,
104+
)
105+
}
106+
107+
return {
108+
createdAt: unmarshalDate(data.created_at),
109+
deletedAt: unmarshalDate(data.deleted_at),
110+
id: data.id,
111+
kubeClusterInfo: data.kube_cluster_info
112+
? unmarshalKubernetesClusterInfo(data.kube_cluster_info)
113+
: undefined,
114+
kubeNodeInfo: data.kube_node_info
115+
? unmarshalKubernetesNodeInfo(data.kube_node_info)
116+
: undefined,
117+
kubePoolInfo: data.kube_pool_info
118+
? unmarshalKubernetesPoolInfo(data.kube_pool_info)
119+
: undefined,
120+
name: data.name,
121+
secmSecretInfo: data.secm_secret_info
122+
? unmarshalSecretManagerSecretInfo(data.secm_secret_info)
123+
: undefined,
124+
secmSecretVersionInfo: data.secm_secret_version_info
125+
? unmarshalSecretManagerSecretVersionInfo(data.secm_secret_version_info)
126+
: undefined,
127+
type: data.type,
128+
updatedAt: unmarshalDate(data.updated_at),
129+
} as Resource
130+
}
131+
132+
export const unmarshalEvent = (data: unknown): Event => {
133+
if (!isJSONObject(data)) {
134+
throw new TypeError(
135+
`Unmarshalling the type 'Event' failed as data isn't a dictionary.`,
136+
)
137+
}
138+
139+
return {
140+
id: data.id,
141+
locality: data.locality,
142+
methodName: data.method_name,
143+
organizationId: data.organization_id,
144+
principal: data.principal
145+
? unmarshalEventPrincipal(data.principal)
146+
: undefined,
147+
productName: data.product_name,
148+
projectId: data.project_id,
149+
recordedAt: unmarshalDate(data.recorded_at),
150+
requestBody: data.request_body,
151+
requestId: data.request_id,
152+
resource: data.resource ? unmarshalResource(data.resource) : undefined,
153+
serviceName: data.service_name,
154+
sourceIp: data.source_ip,
155+
statusCode: data.status_code,
156+
userAgent: data.user_agent,
157+
} as Event
158+
}
159+
160+
export const unmarshalListEventsResponse = (
161+
data: unknown,
162+
): ListEventsResponse => {
163+
if (!isJSONObject(data)) {
164+
throw new TypeError(
165+
`Unmarshalling the type 'ListEventsResponse' failed as data isn't a dictionary.`,
166+
)
167+
}
168+
169+
return {
170+
events: unmarshalArrayOfObject(data.events, unmarshalEvent),
171+
nextPageToken: data.next_page_token,
172+
} as ListEventsResponse
173+
}
174+
175+
const unmarshalProduct = (data: unknown): Product => {
176+
if (!isJSONObject(data)) {
177+
throw new TypeError(
178+
`Unmarshalling the type 'Product' failed as data isn't a dictionary.`,
179+
)
180+
}
181+
182+
return {
183+
name: data.name,
184+
title: data.title,
185+
} as Product
186+
}
187+
188+
export const unmarshalListProductsResponse = (
189+
data: unknown,
190+
): ListProductsResponse => {
191+
if (!isJSONObject(data)) {
192+
throw new TypeError(
193+
`Unmarshalling the type 'ListProductsResponse' failed as data isn't a dictionary.`,
194+
)
195+
}
196+
197+
return {
198+
products: unmarshalArrayOfObject(data.products, unmarshalProduct),
199+
totalCount: data.total_count,
200+
} as ListProductsResponse
201+
}

0 commit comments

Comments
 (0)