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
2 changes: 2 additions & 0 deletions packages/clients/src/api/lb/v1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export * from './content.gen'
export type {
Acl,
AclAction,
AclActionRedirect,
AclActionRedirectRedirectType,
AclActionType,
AclHttpFilter,
AclMatch,
Expand Down
34 changes: 33 additions & 1 deletion packages/clients/src/api/lb/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { DefaultValues } from '../../../bridge'
import type {
Acl,
AclAction,
AclActionRedirect,
AclMatch,
AclSpec,
AddBackendServersRequest,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -738,10 +758,22 @@ export const unmarshalSetAclsResponse = (data: unknown) => {
} as SetAclsResponse
}

const marshalAclActionRedirect = (
request: AclActionRedirect,
defaults: DefaultValues,
): Record<string, unknown> => ({
code: request.code,
target: request.target,
type: request.type,
})

const marshalAclAction = (
request: AclAction,
defaults: DefaultValues,
): Record<string, unknown> => ({
redirect: request.redirect
? marshalAclActionRedirect(request.redirect, defaults)
: undefined,
type: request.type,
})

Expand Down
31 changes: 30 additions & 1 deletion packages/clients/src/api/lb/v1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 */
Expand Down