From c443b9173142bd8598ae6a37dd183fec6395e9f7 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 24 Jan 2023 13:18:48 +0000 Subject: [PATCH] feat: update generated APIs --- packages/clients/src/api/lb/v1/index.gen.ts | 2 ++ .../clients/src/api/lb/v1/marshalling.gen.ts | 34 ++++++++++++++++++- packages/clients/src/api/lb/v1/types.gen.ts | 31 ++++++++++++++++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/packages/clients/src/api/lb/v1/index.gen.ts b/packages/clients/src/api/lb/v1/index.gen.ts index ed561bc55..f003b4bfb 100644 --- a/packages/clients/src/api/lb/v1/index.gen.ts +++ b/packages/clients/src/api/lb/v1/index.gen.ts @@ -5,6 +5,8 @@ export * from './content.gen' export type { Acl, AclAction, + AclActionRedirect, + AclActionRedirectRedirectType, AclActionType, AclHttpFilter, AclMatch, diff --git a/packages/clients/src/api/lb/v1/marshalling.gen.ts b/packages/clients/src/api/lb/v1/marshalling.gen.ts index ddd50d4b7..81c55d2ed 100644 --- a/packages/clients/src/api/lb/v1/marshalling.gen.ts +++ b/packages/clients/src/api/lb/v1/marshalling.gen.ts @@ -11,6 +11,7 @@ import type { DefaultValues } from '../../../bridge' import type { Acl, AclAction, + AclActionRedirect, AclMatch, AclSpec, AddBackendServersRequest, @@ -328,6 +329,20 @@ export const unmarshalLb = (data: unknown) => { } as Lb } +const unmarshalAclActionRedirect = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'AclActionRedirect' failed as data isn't a dictionary.`, + ) + } + + return { + code: data.code, + target: data.target, + type: data.type, + } as AclActionRedirect +} + export const unmarshalBackend = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -393,7 +408,12 @@ const unmarshalAclAction = (data: unknown) => { ) } - return { type: data.type } as AclAction + return { + redirect: data.redirect + ? unmarshalAclActionRedirect(data.redirect) + : undefined, + type: data.type, + } as AclAction } const unmarshalAclMatch = (data: unknown) => { @@ -738,10 +758,22 @@ export const unmarshalSetAclsResponse = (data: unknown) => { } as SetAclsResponse } +const marshalAclActionRedirect = ( + request: AclActionRedirect, + defaults: DefaultValues, +): Record => ({ + code: request.code, + target: request.target, + type: request.type, +}) + const marshalAclAction = ( request: AclAction, defaults: DefaultValues, ): Record => ({ + redirect: request.redirect + ? marshalAclActionRedirect(request.redirect, defaults) + : undefined, type: request.type, }) diff --git a/packages/clients/src/api/lb/v1/types.gen.ts b/packages/clients/src/api/lb/v1/types.gen.ts index 27d5c3336..376c897e5 100644 --- a/packages/clients/src/api/lb/v1/types.gen.ts +++ b/packages/clients/src/api/lb/v1/types.gen.ts @@ -2,7 +2,9 @@ // If you have any remark or suggestion do not hesitate to open an issue. import type { Region, Zone } from '../../../bridge' -export type AclActionType = 'allow' | 'deny' +export type AclActionRedirectRedirectType = 'location' | 'scheme' + +export type AclActionType = 'allow' | 'deny' | 'redirect' export type AclHttpFilter = | 'acl_http_filter_none' @@ -164,6 +166,33 @@ export interface Acl { export interface AclAction { /** The action type */ type: AclActionType + /** Redirect parameters when using an ACL with `redirect` action */ + redirect?: AclActionRedirect +} + +/** Acl action redirect */ +export interface AclActionRedirect { + /** Redirect type */ + type: AclActionRedirectRedirectType + /** + * An URL can be used in case of a location redirect (e.g. + * `https://scaleway.com` will redirect to this same URL). A scheme name (e.g. + * `https`, `http`, `ftp`, `git`) will replace the request's original scheme. + * This can be useful to implement HTTP to HTTPS redirects. Placeholders can + * be used when using a `location` redirect in order to insert original + * request's parts, these are: + * + * - `{{ host }}` for the current request's Host header + * - `{{ query }}` for the current request's query string + * - `{{ path }}` for the current request's URL path + * - `{{ scheme }}` for the current request's scheme + */ + target: string + /** + * HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. + * Default value is 302 + */ + code?: number } /** Acl match */