Skip to content
Merged
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
27 changes: 27 additions & 0 deletions packages_generated/audit_trail/src/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import {
validatePathParam,
} from '@scaleway/sdk-client'
import {
marshalCreateExportJobRequest,
unmarshalExportJob,
unmarshalListAuthenticationEventsResponse,
unmarshalListCombinedEventsResponse,
unmarshalListEventsResponse,
unmarshalListProductsResponse,
} from './marshalling.gen'
import type {
CreateExportJobRequest,
ExportJob,
ListAuthenticationEventsRequest,
ListAuthenticationEventsResponse,
ListCombinedEventsRequest,
Expand All @@ -25,6 +29,10 @@ import type {
ListProductsResponse,
} from './types.gen'

const jsonContentHeaders = {
'Content-Type': 'application/json; charset=utf-8',
}

/**
* Audit Trail API.

Expand Down Expand Up @@ -154,4 +162,23 @@ export class API extends ParentAPI {
},
unmarshalListProductsResponse,
)

/**
* Create an export job. Create an export job for a specified organization. This allows you to export audit trail events to a destination, such as an S3 bucket. The request requires the organization ID, a name for the export, and a destination configuration.
*
* @param request - The request {@link CreateExportJobRequest}
* @returns A Promise of ExportJob
*/
createExportJob = (request: Readonly<CreateExportJobRequest>) =>
this.client.fetch<ExportJob>(
{
body: JSON.stringify(
marshalCreateExportJobRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/audit-trail/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/export-jobs`,
},
unmarshalExportJob,
)
}
3 changes: 3 additions & 0 deletions packages_generated/audit_trail/src/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ export type {
AuthenticationEventResult,
BaremetalServerInfo,
BaremetalSettingInfo,
CreateExportJobRequest,
Event,
EventPrincipal,
ExportJob,
ExportJobS3,
InstanceServerInfo,
IpamIpInfo,
KeyManagerKeyInfo,
Expand Down
67 changes: 67 additions & 0 deletions packages_generated/audit_trail/src/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.

import type { DefaultValues } from '@scaleway/sdk-client'
import {
isJSONObject,
resolveOneOf,
unmarshalArrayOfObject,
unmarshalDate,
} from '@scaleway/sdk-client'
Expand All @@ -13,8 +16,11 @@ import type {
AuthenticationEvent,
BaremetalServerInfo,
BaremetalSettingInfo,
CreateExportJobRequest,
Event,
EventPrincipal,
ExportJob,
ExportJobS3,
InstanceServerInfo,
IpamIpInfo,
KeyManagerKeyInfo,
Expand Down Expand Up @@ -42,6 +48,39 @@ import type {
SystemEvent,
} from './types.gen'

const unmarshalExportJobS3 = (data: unknown): ExportJobS3 => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ExportJobS3' failed as data isn't a dictionary.`,
)
}

return {
bucket: data.bucket,
prefix: data.prefix,
projectId: data.project_id,
region: data.region,
} as ExportJobS3
}

export const unmarshalExportJob = (data: unknown): ExportJob => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ExportJob' failed as data isn't a dictionary.`,
)
}

return {
createdAt: unmarshalDate(data.created_at),
id: data.id,
lastRunAt: unmarshalDate(data.last_run_at),
name: data.name,
organizationId: data.organization_id,
s3: data.s3 ? unmarshalExportJobS3(data.s3) : undefined,
tags: data.tags,
} as ExportJob
}

const unmarshalAccountOrganizationInfo = (
data: unknown,
): AccountOrganizationInfo => {
Expand Down Expand Up @@ -612,3 +651,31 @@ export const unmarshalListProductsResponse = (
totalCount: data.total_count,
} as ListProductsResponse
}

const marshalExportJobS3 = (
request: ExportJobS3,
defaults: DefaultValues,
): Record<string, unknown> => ({
bucket: request.bucket,
prefix: request.prefix,
project_id: request.projectId,
region: request.region,
})

export const marshalCreateExportJobRequest = (
request: CreateExportJobRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
name: request.name,
organization_id: request.organizationId ?? defaults.defaultOrganizationId,
tags: request.tags !== undefined ? request.tags : undefined,
...resolveOneOf([
{
param: 's3',
value:
request.s3 !== undefined
? marshalExportJobS3(request.s3, defaults)
: undefined,
},
]),
})
68 changes: 68 additions & 0 deletions packages_generated/audit_trail/src/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,16 @@ export interface ProductService {
methods: string[]
}

export interface ExportJobS3 {
bucket: string
/**
* Region to target. If none is passed will use default region from the config.
*/
region: ScwRegion
prefix?: string
projectId?: string
}

export interface ListCombinedEventsResponseCombinedEvent {
/**
*
Expand Down Expand Up @@ -482,6 +492,64 @@ export interface Product {
services: ProductService[]
}

export type CreateExportJobRequest = {
/**
* Region to target. If none is passed will use default region from the config.
*/
region?: ScwRegion
/**
* ID of the Organization to target.
*/
organizationId?: string
/**
* Name of the export.
*/
name: string
/**
* The configuration specifying the bucket where the audit trail events will be exported.
*
* One-of ('destination'): at most one of 's3' could be set.
*/
s3?: ExportJobS3
/**
* Tags of the export.
*/
tags?: Record<string, string>
}

export interface ExportJob {
/**
* ID of the export job.
*/
id: string
/**
* ID of the targeted Organization.
*/
organizationId: string
/**
* Name of the export.
*/
name: string
/**
* Destination in an S3 storage.
*
* One-of ('destination'): at most one of 's3' could be set.
*/
s3?: ExportJobS3
/**
* Export job creation date.
*/
createdAt?: Date
/**
* Last export date.
*/
lastRunAt?: Date
/**
* Tags of the export.
*/
tags: Record<string, string>
}

export type ListAuthenticationEventsRequest = {
/**
* Region to target. If none is passed will use default region from the config.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.

export const CreateExportJobRequest = {
name: {
maxLength: 255,
minLength: 1,
pattern: /^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$/,
},
}

export const ExportJobS3 = {
bucket: {
maxLength: 63,
minLength: 3,
pattern: /^[a-z0-9][a-z0-9.-]{2,}$/,
},
prefix: {
maxLength: 255,
pattern: /^[a-zA-Z0-9\._\-]+(?:\/[a-zA-Z0-9\._\-]+)*$/,
},
region: {
pattern: /^[a-z]{2}-[a-z]{3}$/,
},
}

export const ListAuthenticationEventsRequest = {
pageSize: {
greaterThanOrEqual: 1,
Expand Down
Loading