From ea22fe054b0259b27f1a4a2beb9aa5821d350fa5 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 31 Oct 2024 09:12:17 +0000 Subject: [PATCH] feat: update generated APIs --- .../src/api/container/v1beta1/index.gen.ts | 3 + .../api/container/v1beta1/marshalling.gen.ts | 99 +++++++++++++++++++ .../src/api/container/v1beta1/types.gen.ts | 51 +++++++++- .../container/v1beta1/validation-rules.gen.ts | 14 +++ 4 files changed, 165 insertions(+), 2 deletions(-) diff --git a/packages/clients/src/api/container/v1beta1/index.gen.ts b/packages/clients/src/api/container/v1beta1/index.gen.ts index 9f501f6e8..db7ee347b 100644 --- a/packages/clients/src/api/container/v1beta1/index.gen.ts +++ b/packages/clients/src/api/container/v1beta1/index.gen.ts @@ -4,6 +4,9 @@ export { API } from './api.gen' export * from './content.gen' export type { Container, + ContainerHealthCheckSpec, + ContainerHealthCheckSpecHTTPProbe, + ContainerHealthCheckSpecTCPProbe, ContainerHttpOption, ContainerPrivacy, ContainerProtocol, diff --git a/packages/clients/src/api/container/v1beta1/marshalling.gen.ts b/packages/clients/src/api/container/v1beta1/marshalling.gen.ts index 9c9c48fcf..ce9921037 100644 --- a/packages/clients/src/api/container/v1beta1/marshalling.gen.ts +++ b/packages/clients/src/api/container/v1beta1/marshalling.gen.ts @@ -10,6 +10,9 @@ import { import type { DefaultValues } from '../../../bridge' import type { Container, + ContainerHealthCheckSpec, + ContainerHealthCheckSpecHTTPProbe, + ContainerHealthCheckSpecTCPProbe, ContainerScalingOption, CreateContainerRequest, CreateCronRequest, @@ -43,6 +46,53 @@ import type { UpdateTriggerRequestSqsClientConfig, } from './types.gen' +const unmarshalContainerHealthCheckSpecHTTPProbe = ( + data: unknown, +): ContainerHealthCheckSpecHTTPProbe => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContainerHealthCheckSpecHTTPProbe' failed as data isn't a dictionary.`, + ) + } + + return { + path: data.path, + } as ContainerHealthCheckSpecHTTPProbe +} + +const unmarshalContainerHealthCheckSpecTCPProbe = ( + data: unknown, +): ContainerHealthCheckSpecTCPProbe => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContainerHealthCheckSpecTCPProbe' failed as data isn't a dictionary.`, + ) + } + + return {} as ContainerHealthCheckSpecTCPProbe +} + +const unmarshalContainerHealthCheckSpec = ( + data: unknown, +): ContainerHealthCheckSpec => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContainerHealthCheckSpec' failed as data isn't a dictionary.`, + ) + } + + return { + failureThreshold: data.failure_threshold, + http: data.http + ? unmarshalContainerHealthCheckSpecHTTPProbe(data.http) + : undefined, + interval: data.interval, + tcp: data.tcp + ? unmarshalContainerHealthCheckSpecTCPProbe(data.tcp) + : undefined, + } as ContainerHealthCheckSpec +} + const unmarshalContainerScalingOption = ( data: unknown, ): ContainerScalingOption => { @@ -54,6 +104,7 @@ const unmarshalContainerScalingOption = ( return { concurrentRequestsThreshold: data.concurrent_requests_threshold, + cpuUsageThreshold: data.cpu_usage_threshold, } as ContainerScalingOption } @@ -84,6 +135,9 @@ export const unmarshalContainer = (data: unknown): Container => { domainName: data.domain_name, environmentVariables: data.environment_variables, errorMessage: data.error_message, + healthCheck: data.health_check + ? unmarshalContainerHealthCheckSpec(data.health_check) + : undefined, httpOption: data.http_option, id: data.id, localStorageLimit: data.local_storage_limit, @@ -362,6 +416,42 @@ export const unmarshalListTriggersResponse = ( } as ListTriggersResponse } +const marshalContainerHealthCheckSpecHTTPProbe = ( + request: ContainerHealthCheckSpecHTTPProbe, + defaults: DefaultValues, +): Record => ({ + path: request.path, +}) + +const marshalContainerHealthCheckSpecTCPProbe = ( + request: ContainerHealthCheckSpecTCPProbe, + defaults: DefaultValues, +): Record => ({}) + +const marshalContainerHealthCheckSpec = ( + request: ContainerHealthCheckSpec, + defaults: DefaultValues, +): Record => ({ + failure_threshold: request.failureThreshold, + interval: request.interval, + ...resolveOneOf([ + { + param: 'http', + value: + request.http !== undefined + ? marshalContainerHealthCheckSpecHTTPProbe(request.http, defaults) + : undefined, + }, + { + param: 'tcp', + value: + request.tcp !== undefined + ? marshalContainerHealthCheckSpecTCPProbe(request.tcp, defaults) + : undefined, + }, + ]), +}) + const marshalContainerScalingOption = ( request: ContainerScalingOption, defaults: DefaultValues, @@ -371,6 +461,7 @@ const marshalContainerScalingOption = ( param: 'concurrent_requests_threshold', value: request.concurrentRequestsThreshold, }, + { param: 'cpu_usage_threshold', value: request.cpuUsageThreshold }, ]), }) @@ -389,6 +480,10 @@ export const marshalCreateContainerRequest = ( cpu_limit: request.cpuLimit, description: request.description, environment_variables: request.environmentVariables, + health_check: + request.healthCheck !== undefined + ? marshalContainerHealthCheckSpec(request.healthCheck, defaults) + : undefined, http_option: request.httpOption, local_storage_limit: request.localStorageLimit, max_concurrency: request.maxConcurrency, @@ -539,6 +634,10 @@ export const marshalUpdateContainerRequest = ( cpu_limit: request.cpuLimit, description: request.description, environment_variables: request.environmentVariables, + health_check: + request.healthCheck !== undefined + ? marshalContainerHealthCheckSpec(request.healthCheck, defaults) + : undefined, http_option: request.httpOption, local_storage_limit: request.localStorageLimit, max_concurrency: request.maxConcurrency, diff --git a/packages/clients/src/api/container/v1beta1/types.gen.ts b/packages/clients/src/api/container/v1beta1/types.gen.ts index 83c85baea..0d6a0bfe2 100644 --- a/packages/clients/src/api/container/v1beta1/types.gen.ts +++ b/packages/clients/src/api/container/v1beta1/types.gen.ts @@ -95,12 +95,47 @@ export type TriggerStatus = | 'creating' | 'pending' +export interface ContainerHealthCheckSpecHTTPProbe { + /** Path to use for the HTTP health check. */ + path: string +} + +export interface ContainerHealthCheckSpecTCPProbe {} + +export interface ContainerHealthCheckSpec { + /** + * HTTP health check configuration. + * + * One-of ('probe'): at most one of 'http', 'tcp' could be set. + */ + http?: ContainerHealthCheckSpecHTTPProbe + /** + * TCP health check configuration. + * + * One-of ('probe'): at most one of 'http', 'tcp' could be set. + */ + tcp?: ContainerHealthCheckSpecTCPProbe + /** + * During a deployment, if a newly created container fails to pass the health + * check, the deployment is aborted. As a result, lowering this value can help + * to reduce the time it takes to detect a failed deployment. + */ + failureThreshold: number + /** Period between health checks. */ + interval?: string +} + export interface ContainerScalingOption { /** - * One-of ('scalingRule'): at most one of 'concurrentRequestsThreshold' could - * be set. + * One-of ('scalingRule'): at most one of 'concurrentRequestsThreshold', + * 'cpuUsageThreshold' could be set. */ concurrentRequestsThreshold?: number + /** + * One-of ('scalingRule'): at most one of 'concurrentRequestsThreshold', + * 'cpuUsageThreshold' could be set. + */ + cpuUsageThreshold?: number } export interface SecretHashedValue { @@ -236,8 +271,12 @@ export interface Container { * * - Concurrent_requests_threshold: Scale depending on the number of concurrent * requests being processed per container instance. + * - Cpu_usage_threshold: Scale depending on the CPU usage of a container + * instance. */ scalingOption?: ContainerScalingOption + /** Health check configuration of the container. */ + healthCheck?: ContainerHealthCheckSpec /** Creation date of the container. */ createdAt?: Date /** Last update date of the container. */ @@ -433,8 +472,12 @@ export type CreateContainerRequest = { * * - Concurrent_requests_threshold: Scale depending on the number of concurrent * requests being processed per container instance. + * - Cpu_usage_threshold: Scale depending on the CPU usage of a container + * instance. */ scalingOption?: ContainerScalingOption + /** Health check configuration of the container. */ + healthCheck?: ContainerHealthCheckSpec } export type CreateCronRequest = { @@ -894,8 +937,12 @@ export type UpdateContainerRequest = { * * - Concurrent_requests_threshold: Scale depending on the number of concurrent * requests being processed per container instance. + * - Cpu_usage_threshold: Scale depending on the CPU usage of a container + * instance. */ scalingOption?: ContainerScalingOption + /** Health check configuration of the container. */ + healthCheck?: ContainerHealthCheckSpec } export type UpdateCronRequest = { diff --git a/packages/clients/src/api/container/v1beta1/validation-rules.gen.ts b/packages/clients/src/api/container/v1beta1/validation-rules.gen.ts index 03c156a61..e50fd5e5c 100644 --- a/packages/clients/src/api/container/v1beta1/validation-rules.gen.ts +++ b/packages/clients/src/api/container/v1beta1/validation-rules.gen.ts @@ -1,6 +1,20 @@ // This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. +export const ContainerHealthCheckSpec = { + failureThreshold: { + greaterThanOrEqual: 3, + lessThanOrEqual: 50, + }, +} + +export const ContainerHealthCheckSpecHTTPProbe = { + path: { + maxLength: 100, + minLength: 1, + }, +} + export const ContainerScalingOption = {} export const CreateTriggerRequest = {