From 5e3d2b171f64f708829efc0922997a027fec1c94 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Tue, 21 Nov 2023 11:33:24 +0100 Subject: [PATCH] fix(mnq): remove end of life v1alpha1 --- packages/clients/src/api/mnq/index.ts | 1 - .../clients/src/api/mnq/v1alpha1/api.gen.ts | 298 ------------------ .../clients/src/api/mnq/v1alpha1/index.gen.ts | 27 -- .../src/api/mnq/v1alpha1/marshalling.gen.ts | 227 ------------- .../clients/src/api/mnq/v1alpha1/types.gen.ts | 271 ---------------- 5 files changed, 824 deletions(-) delete mode 100644 packages/clients/src/api/mnq/v1alpha1/api.gen.ts delete mode 100644 packages/clients/src/api/mnq/v1alpha1/index.gen.ts delete mode 100644 packages/clients/src/api/mnq/v1alpha1/marshalling.gen.ts delete mode 100644 packages/clients/src/api/mnq/v1alpha1/types.gen.ts diff --git a/packages/clients/src/api/mnq/index.ts b/packages/clients/src/api/mnq/index.ts index 9198262d6..1984b471f 100644 --- a/packages/clients/src/api/mnq/index.ts +++ b/packages/clients/src/api/mnq/index.ts @@ -1,2 +1 @@ -export * as v1alpha1 from './v1alpha1/index.gen' export * as v1beta1 from './v1beta1/index.gen' diff --git a/packages/clients/src/api/mnq/v1alpha1/api.gen.ts b/packages/clients/src/api/mnq/v1alpha1/api.gen.ts deleted file mode 100644 index 052f372cf..000000000 --- a/packages/clients/src/api/mnq/v1alpha1/api.gen.ts +++ /dev/null @@ -1,298 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import { - API as ParentAPI, - enrichForPagination, - urlParams, - validatePathParam, -} from '../../../bridge' -import type { Region } from '../../../bridge' -import { - marshalCreateCredentialRequest, - marshalCreateNamespaceRequest, - marshalUpdateCredentialRequest, - marshalUpdateNamespaceRequest, - unmarshalCredential, - unmarshalListCredentialsResponse, - unmarshalListNamespacesResponse, - unmarshalNamespace, -} from './marshalling.gen' -import type { - CreateCredentialRequest, - CreateNamespaceRequest, - Credential, - DeleteCredentialRequest, - DeleteNamespaceRequest, - GetCredentialRequest, - GetNamespaceRequest, - ListCredentialsRequest, - ListCredentialsResponse, - ListNamespacesRequest, - ListNamespacesResponse, - Namespace, - UpdateCredentialRequest, - UpdateNamespaceRequest, -} from './types.gen' - -const jsonContentHeaders = { - 'Content-Type': 'application/json; charset=utf-8', -} - -/** - * Messaging and Queuing API. - * - * This API allows you to manage Scaleway Messaging and Queueing brokers. - */ -export class API extends ParentAPI { - /** Lists the available regions of the API. */ - public static readonly LOCALITIES: Region[] = ['fr-par'] - - protected pageOfListNamespaces = ( - request: Readonly = {}, - ) => - this.client.fetch( - { - method: 'GET', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/namespaces`, - urlParams: urlParams( - ['order_by', request.orderBy], - ['organization_id', request.organizationId], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ['project_id', request.projectId], - ), - }, - unmarshalListNamespacesResponse, - ) - - /** - * List namespaces. List all Messaging and Queuing namespaces in the specified - * region, for a Scaleway Organization or Project. By default, the namespaces - * returned in the list are ordered by creation date in ascending order, - * though this can be modified via the `order_by` field. - * - * @param request - The request {@link ListNamespacesRequest} - * @returns A Promise of ListNamespacesResponse - */ - listNamespaces = (request: Readonly = {}) => - enrichForPagination('namespaces', this.pageOfListNamespaces, request) - - /** - * Create a namespace. Create a Messaging and Queuing namespace, set to the - * desired protocol. - * - * @param request - The request {@link CreateNamespaceRequest} - * @returns A Promise of Namespace - */ - createNamespace = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCreateNamespaceRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/namespaces`, - }, - unmarshalNamespace, - ) - - /** - * Update the name of a namespace. Update the name of a Messaging and Queuing - * namespace, specified by its namespace ID. - * - * @param request - The request {@link UpdateNamespaceRequest} - * @returns A Promise of Namespace - */ - updateNamespace = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalUpdateNamespaceRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/namespaces`, - }, - unmarshalNamespace, - ) - - /** - * Get a namespace. Retrieve information about an existing Messaging and - * Queuing namespace, identified by its namespace ID. Its full details, - * including name, endpoint and protocol, are returned in the response. - * - * @param request - The request {@link GetNamespaceRequest} - * @returns A Promise of Namespace - */ - getNamespace = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/namespaces/${validatePathParam('namespaceId', request.namespaceId)}`, - }, - unmarshalNamespace, - ) - - /** - * Delete a namespace. Delete a Messaging and Queuing namespace, specified by - * its namespace ID. Note that deleting a namespace is irreversible, and any - * URLs, credentials and queued messages belonging to this namespace will also - * be deleted. - * - * @param request - The request {@link DeleteNamespaceRequest} - */ - deleteNamespace = (request: Readonly) => - this.client.fetch({ - method: 'DELETE', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/namespaces/${validatePathParam('namespaceId', request.namespaceId)}`, - }) - - /** - * Create credentials. Create a set of credentials for a Messaging and Queuing - * namespace, specified by its namespace ID. If creating credentials for a - * NATS namespace, the `permissions` object must not be included in the - * request. If creating credentials for an SQS/SNS namespace, the - * `permissions` object is required, with all three of its child attributes. - * - * @param request - The request {@link CreateCredentialRequest} - * @returns A Promise of Credential - */ - createCredential = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCreateCredentialRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/credentials`, - }, - unmarshalCredential, - ) - - /** - * Delete credentials. Delete a set of credentials, specified by their - * credential ID. Deleting credentials is irreversible and cannot be undone. - * The credentials can no longer be used to access the namespace. - * - * @param request - The request {@link DeleteCredentialRequest} - */ - deleteCredential = (request: Readonly) => - this.client.fetch({ - method: 'DELETE', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/credentials/${validatePathParam( - 'credentialId', - request.credentialId, - )}`, - }) - - protected pageOfListCredentials = ( - request: Readonly = {}, - ) => - this.client.fetch( - { - method: 'GET', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/credentials`, - urlParams: urlParams( - ['namespace_id', request.namespaceId], - ['order_by', request.orderBy], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ), - }, - unmarshalListCredentialsResponse, - ) - - /** - * List credentials. List existing credentials in the specified region. The - * response contains only the metadata for the credentials, not the - * credentials themselves (for this, use **Get Credentials**). - * - * @param request - The request {@link ListCredentialsRequest} - * @returns A Promise of ListCredentialsResponse - */ - listCredentials = (request: Readonly = {}) => - enrichForPagination('credentials', this.pageOfListCredentials, request) - - /** - * Update credentials. Update a set of credentials. You can update the - * credentials' name, or (in the case of SQS/SNS credentials only) their - * permissions. To update the name of NATS credentials, do not include the - * `permissions` object in your request. - * - * @param request - The request {@link UpdateCredentialRequest} - * @returns A Promise of Credential - */ - updateCredential = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalUpdateCredentialRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/credentials/${validatePathParam( - 'credentialId', - request.credentialId, - )}`, - }, - unmarshalCredential, - ) - - /** - * Get credentials. Retrieve an existing set of credentials, identified by the - * `credential_id`. The credentials themselves, as well as their metadata - * (protocol, namespace ID etc), are returned in the response. - * - * @param request - The request {@link GetCredentialRequest} - * @returns A Promise of Credential - */ - getCredential = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/mnq/v1alpha1/regions/${validatePathParam( - 'region', - request.region ?? this.client.settings.defaultRegion, - )}/credentials/${validatePathParam( - 'credentialId', - request.credentialId, - )}`, - }, - unmarshalCredential, - ) -} diff --git a/packages/clients/src/api/mnq/v1alpha1/index.gen.ts b/packages/clients/src/api/mnq/v1alpha1/index.gen.ts deleted file mode 100644 index a4d31541b..000000000 --- a/packages/clients/src/api/mnq/v1alpha1/index.gen.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -export { API } from './api.gen' -export type { - CreateCredentialRequest, - CreateNamespaceRequest, - Credential, - CredentialNATSCredsFile, - CredentialSQSSNSCreds, - CredentialSummary, - CredentialSummarySQSSNSCreds, - DeleteCredentialRequest, - DeleteNamespaceRequest, - GetCredentialRequest, - GetNamespaceRequest, - ListCredentialsRequest, - ListCredentialsRequestOrderBy, - ListCredentialsResponse, - ListNamespacesRequest, - ListNamespacesRequestOrderBy, - ListNamespacesResponse, - Namespace, - NamespaceProtocol, - Permissions, - UpdateCredentialRequest, - UpdateNamespaceRequest, -} from './types.gen' diff --git a/packages/clients/src/api/mnq/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/mnq/v1alpha1/marshalling.gen.ts deleted file mode 100644 index b6921e101..000000000 --- a/packages/clients/src/api/mnq/v1alpha1/marshalling.gen.ts +++ /dev/null @@ -1,227 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import randomName from '@scaleway/random-name' -import { - isJSONObject, - unmarshalArrayOfObject, - unmarshalDate, -} from '../../../bridge' -import type { DefaultValues } from '../../../bridge' -import type { - CreateCredentialRequest, - CreateNamespaceRequest, - Credential, - CredentialNATSCredsFile, - CredentialSQSSNSCreds, - CredentialSummary, - CredentialSummarySQSSNSCreds, - ListCredentialsResponse, - ListNamespacesResponse, - Namespace, - Permissions, - UpdateCredentialRequest, - UpdateNamespaceRequest, -} from './types.gen' - -export const unmarshalNamespace = (data: unknown): Namespace => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Namespace' failed as data isn't a dictionary.`, - ) - } - - return { - createdAt: unmarshalDate(data.created_at), - endpoint: data.endpoint, - id: data.id, - name: data.name, - projectId: data.project_id, - protocol: data.protocol, - region: data.region, - updatedAt: unmarshalDate(data.updated_at), - } as Namespace -} - -const unmarshalPermissions = (data: unknown): Permissions => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Permissions' failed as data isn't a dictionary.`, - ) - } - - return { - canManage: data.can_manage, - canPublish: data.can_publish, - canReceive: data.can_receive, - } as Permissions -} - -const unmarshalCredentialNATSCredsFile = ( - data: unknown, -): CredentialNATSCredsFile => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'CredentialNATSCredsFile' failed as data isn't a dictionary.`, - ) - } - - return { - content: data.content, - } as CredentialNATSCredsFile -} - -const unmarshalCredentialSQSSNSCreds = ( - data: unknown, -): CredentialSQSSNSCreds => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'CredentialSQSSNSCreds' failed as data isn't a dictionary.`, - ) - } - - return { - accessKey: data.access_key, - permissions: data.permissions - ? unmarshalPermissions(data.permissions) - : undefined, - secretKey: data.secret_key, - } as CredentialSQSSNSCreds -} - -export const unmarshalCredential = (data: unknown): Credential => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Credential' failed as data isn't a dictionary.`, - ) - } - - return { - id: data.id, - name: data.name, - namespaceId: data.namespace_id, - natsCredentials: data.nats_credentials - ? unmarshalCredentialNATSCredsFile(data.nats_credentials) - : undefined, - protocol: data.protocol, - sqsSnsCredentials: data.sqs_sns_credentials - ? unmarshalCredentialSQSSNSCreds(data.sqs_sns_credentials) - : undefined, - } as Credential -} - -const unmarshalCredentialSummarySQSSNSCreds = ( - data: unknown, -): CredentialSummarySQSSNSCreds => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'CredentialSummarySQSSNSCreds' failed as data isn't a dictionary.`, - ) - } - - return { - accessKey: data.access_key, - permissions: data.permissions - ? unmarshalPermissions(data.permissions) - : undefined, - } as CredentialSummarySQSSNSCreds -} - -const unmarshalCredentialSummary = (data: unknown): CredentialSummary => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'CredentialSummary' failed as data isn't a dictionary.`, - ) - } - - return { - id: data.id, - name: data.name, - namespaceId: data.namespace_id, - protocol: data.protocol, - sqsSnsCredentials: data.sqs_sns_credentials - ? unmarshalCredentialSummarySQSSNSCreds(data.sqs_sns_credentials) - : undefined, - } as CredentialSummary -} - -export const unmarshalListCredentialsResponse = ( - data: unknown, -): ListCredentialsResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListCredentialsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - credentials: unmarshalArrayOfObject( - data.credentials, - unmarshalCredentialSummary, - ), - totalCount: data.total_count, - } as ListCredentialsResponse -} - -export const unmarshalListNamespacesResponse = ( - data: unknown, -): ListNamespacesResponse => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListNamespacesResponse' failed as data isn't a dictionary.`, - ) - } - - return { - namespaces: unmarshalArrayOfObject(data.namespaces, unmarshalNamespace), - totalCount: data.total_count, - } as ListNamespacesResponse -} - -const marshalPermissions = ( - request: Permissions, - defaults: DefaultValues, -): Record => ({ - can_manage: request.canManage, - can_publish: request.canPublish, - can_receive: request.canReceive, -}) - -export const marshalCreateCredentialRequest = ( - request: CreateCredentialRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name || randomName('mnq'), - namespace_id: request.namespaceId, - permissions: - request.permissions !== undefined - ? marshalPermissions(request.permissions, defaults) - : undefined, -}) - -export const marshalCreateNamespaceRequest = ( - request: CreateNamespaceRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name || randomName('mnq'), - project_id: request.projectId ?? defaults.defaultProjectId, - protocol: request.protocol, -}) - -export const marshalUpdateCredentialRequest = ( - request: UpdateCredentialRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name, - permissions: - request.permissions !== undefined - ? marshalPermissions(request.permissions, defaults) - : undefined, -}) - -export const marshalUpdateNamespaceRequest = ( - request: UpdateNamespaceRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name, - namespace_id: request.namespaceId, -}) diff --git a/packages/clients/src/api/mnq/v1alpha1/types.gen.ts b/packages/clients/src/api/mnq/v1alpha1/types.gen.ts deleted file mode 100644 index 4dcf244e0..000000000 --- a/packages/clients/src/api/mnq/v1alpha1/types.gen.ts +++ /dev/null @@ -1,271 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. -import type { Region } from '../../../bridge' - -export type ListCredentialsRequestOrderBy = - | 'id_asc' - | 'id_desc' - | 'name_asc' - | 'name_desc' - -export type ListNamespacesRequestOrderBy = - | 'created_at_asc' - | 'created_at_desc' - | 'updated_at_asc' - | 'updated_at_desc' - | 'id_asc' - | 'id_desc' - | 'name_asc' - | 'name_desc' - | 'project_id_asc' - | 'project_id_desc' - -export type NamespaceProtocol = 'unknown' | 'nats' | 'sqs_sns' - -export interface Permissions { - /** - * Defines whether the credentials bearer can publish messages to the service - * (send messages to SQS queues or publish to SNS topics). - */ - canPublish?: boolean - /** - * Defines whether the credentials bearer can receive messages from the - * service. - */ - canReceive?: boolean - /** - * Defines whether the credentials bearer can manage the associated resources - * (SQS queues or SNS topics or subscriptions). - */ - canManage?: boolean -} - -export interface CredentialSummarySQSSNSCreds { - /** Access key ID. */ - accessKey: string - /** Permissions associated with these credentials. */ - permissions?: Permissions -} - -export interface CredentialNATSCredsFile { - /** Raw content of the NATS credentials file. */ - content: string -} - -export interface CredentialSQSSNSCreds { - /** Access key ID. */ - accessKey: string - /** Secret key ID. */ - secretKey?: string - /** Permissions associated with these credentials. */ - permissions?: Permissions -} - -export interface CredentialSummary { - /** ID of the credentials. */ - id: string - /** Name of the credentials. */ - name: string - /** Namespace containing the credentials. */ - namespaceId: string - /** Protocol associated with the credentials. */ - protocol: NamespaceProtocol - /** - * Object containing the credentials and their metadata, if the credentials - * are for an SQS/SNS namespace. - * - * One-of ('credentialType'): at most one of 'sqsSnsCredentials' could be set. - */ - sqsSnsCredentials?: CredentialSummarySQSSNSCreds -} - -export interface Namespace { - /** Namespace ID. */ - id: string - /** Namespace name. */ - name: string - /** Endpoint of the service matching the namespace's protocol. */ - endpoint: string - /** Namespace protocol. */ - protocol: NamespaceProtocol - /** Project ID of the Project containing the namespace. */ - projectId: string - /** Region where the namespace is deployed. */ - region: Region - /** Namespace creation date. */ - createdAt?: Date - /** Namespace last modification date. */ - updatedAt?: Date -} - -export type CreateCredentialRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** Namespace containing the credentials. */ - namespaceId: string - /** Name of the credentials. */ - name?: string - /** Permissions associated with these credentials. */ - permissions?: Permissions -} - -export type CreateNamespaceRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** Namespace name. */ - name?: string - /** - * Namespace protocol. You must specify a valid protocol (and not `unknown`) - * to avoid an error. - */ - protocol: NamespaceProtocol - /** Project containing the Namespace. */ - projectId?: string -} - -export interface Credential { - /** ID of the credentials. */ - id: string - /** Name of the credentials. */ - name: string - /** Namespace containing the credentials. */ - namespaceId: string - /** Protocol associated with the credentials. */ - protocol: NamespaceProtocol - /** - * Object containing the credentials, if the credentials are for a NATS - * namespace. - * - * One-of ('credentialType'): at most one of 'natsCredentials', - * 'sqsSnsCredentials' could be set. - */ - natsCredentials?: CredentialNATSCredsFile - /** - * Object containing the credentials and their metadata, if the credentials - * are for an SQS/SNS namespace. - * - * One-of ('credentialType'): at most one of 'natsCredentials', - * 'sqsSnsCredentials' could be set. - */ - sqsSnsCredentials?: CredentialSQSSNSCreds -} - -export type DeleteCredentialRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** ID of the credentials to delete. */ - credentialId: string -} - -export type DeleteNamespaceRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** ID of the namespace to delete. */ - namespaceId: string -} - -export type GetCredentialRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** ID of the credentials to get. */ - credentialId: string -} - -export type GetNamespaceRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** ID of the Namespace to get. */ - namespaceId: string -} - -export type ListCredentialsRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** Namespace containing the credentials. */ - namespaceId?: string - /** Page number to return. */ - page?: number - /** Maximum number of credentials to return per page. */ - pageSize?: number - /** Order in which to return results. */ - orderBy?: ListCredentialsRequestOrderBy -} - -export interface ListCredentialsResponse { - /** Total count of existing credentials (matching any filters specified). */ - totalCount: number - /** Credentials on this page. */ - credentials: CredentialSummary[] -} - -export type ListNamespacesRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** Include only namespaces in this Organization. */ - organizationId?: string - /** Include only namespaces in this Project. */ - projectId?: string - /** Page number to return. */ - page?: number - /** Maximum number of namespaces to return per page. */ - pageSize?: number - /** Order in which to return results. */ - orderBy?: ListNamespacesRequestOrderBy -} - -export interface ListNamespacesResponse { - /** Total count of existing namespaces (matching any filters specified). */ - totalCount: number - /** Namespaces on this page. */ - namespaces: Namespace[] -} - -export type UpdateCredentialRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** ID of the credentials to update. */ - credentialId: string - /** Name of the credentials. */ - name?: string - /** Permissions associated with these credentials. */ - permissions?: Permissions -} - -export type UpdateNamespaceRequest = { - /** - * Region to target. If none is passed will use default region from the - * config. - */ - region?: Region - /** ID of the Namespace to update. */ - namespaceId: string - /** Namespace name. */ - name?: string -}