diff --git a/packages/clients/src/api/redis/index.ts b/packages/clients/src/api/redis/index.ts index 12f24635c..73ddaf23c 100644 --- a/packages/clients/src/api/redis/index.ts +++ b/packages/clients/src/api/redis/index.ts @@ -1,2 +1 @@ -export * as v1alpha1 from './v1alpha1' export * as v1 from './v1/index.gen' diff --git a/packages/clients/src/api/redis/v1alpha1/api.gen.ts b/packages/clients/src/api/redis/v1alpha1/api.gen.ts deleted file mode 100644 index 31249d78b..000000000 --- a/packages/clients/src/api/redis/v1alpha1/api.gen.ts +++ /dev/null @@ -1,631 +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, - enrichForPagination, - unmarshalScwFile, - urlParams, - validatePathParam, - waitForResource, -} from '../../../bridge' -import type { ScwFile, WaitForOptions, Zone } from '../../../bridge' -import { CLUSTER_TRANSIENT_STATUSES } from './content.gen' -import { - marshalAddAclRulesRequest, - marshalAddClusterSettingsRequest, - marshalAddEndpointsRequest, - marshalCreateClusterRequest, - marshalDeleteClusterSettingRequest, - marshalMigrateClusterRequest, - marshalSetAclRulesRequest, - marshalSetClusterSettingsRequest, - marshalSetEndpointsRequest, - marshalUpdateClusterRequest, - marshalUpdateEndpointRequest, - unmarshalACLRule, - unmarshalAclRulesResponse, - unmarshalAddEndpointsResponse, - unmarshalCluster, - unmarshalClusterMetricsResponse, - unmarshalClusterSettingsResponse, - unmarshalEndpoint, - unmarshalListClustersResponse, - unmarshalListNodeTypesResponse, - unmarshalListVersionsResponse, - unmarshalSetEndpointsResponse, -} from './marshalling.gen' -import type { - ACLRule, - AclRulesResponse, - AddAclRulesRequest, - AddClusterSettingsRequest, - AddEndpointsRequest, - AddEndpointsResponse, - Cluster, - ClusterMetricsResponse, - ClusterSettingsResponse, - CreateClusterRequest, - DeleteAclRuleRequest, - DeleteClusterRequest, - DeleteClusterSettingRequest, - DeleteEndpointRequest, - Endpoint, - GetAclRuleRequest, - GetClusterCertificateRequest, - GetClusterMetricsRequest, - GetClusterRequest, - GetEndpointRequest, - ListClustersRequest, - ListClustersResponse, - ListNodeTypesRequest, - ListNodeTypesResponse, - ListVersionsRequest, - ListVersionsResponse, - MigrateClusterRequest, - RenewClusterCertificateRequest, - SetAclRulesRequest, - SetClusterSettingsRequest, - SetEndpointsRequest, - SetEndpointsResponse, - UpdateClusterRequest, - UpdateEndpointRequest, -} from './types.gen' - -const jsonContentHeaders = { - 'Content-Type': 'application/json; charset=utf-8', -} - -/** Managed Database for Redis™ API. */ -export class RedisV1Alpha1GenAPI extends API { - /** Lists the available zones of the API. */ - public static readonly LOCALITIES: Zone[] = [ - 'fr-par-1', - 'fr-par-2', - 'nl-ams-1', - 'pl-waw-1', - ] - - /** - * Create a cluster - * - * @param request - The request {@link CreateClusterRequest} - * @returns A Promise of Cluster - */ - createCluster = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalCreateClusterRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters`, - }, - unmarshalCluster, - ) - - /** - * Update a cluster - * - * @param request - The request {@link UpdateClusterRequest} - * @returns A Promise of Cluster - */ - updateCluster = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalUpdateClusterRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam('clusterId', request.clusterId)}`, - }, - unmarshalCluster, - ) - - /** - * Get a cluster - * - * @param request - The request {@link GetClusterRequest} - * @returns A Promise of Cluster - */ - getCluster = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam('clusterId', request.clusterId)}`, - }, - unmarshalCluster, - ) - - /** - * Waits for {@link Cluster} to be in a final state. - * - * @param request - The request {@link GetClusterRequest} - * @param options - The waiting options - * @returns A Promise of Cluster - */ - waitForCluster = ( - request: Readonly, - options?: Readonly>, - ) => - waitForResource( - options?.stop ?? - (res => - Promise.resolve(!CLUSTER_TRANSIENT_STATUSES.includes(res.status))), - this.getCluster, - request, - options, - ) - - protected pageOfListClusters = ( - request: Readonly = {}, - ) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters`, - urlParams: urlParams( - ['name', request.name], - ['order_by', request.orderBy ?? 'created_at_asc'], - [ - 'organization_id', - request.organizationId ?? - this.client.settings.defaultOrganizationId, - ], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - [ - 'project_id', - request.projectId ?? this.client.settings.defaultProjectId, - ], - ['tags', request.tags], - ), - }, - unmarshalListClustersResponse, - ) - - /** - * List clusters - * - * @param request - The request {@link ListClustersRequest} - * @returns A Promise of ListClustersResponse - */ - listClusters = (request: Readonly = {}) => - enrichForPagination('clusters', this.pageOfListClusters, request) - - /** - * Upgrade your Database for Redis® cluster to a new version or scale it - * vertically / horizontally. Please note: scaling horizontally your Database - * for Redis® cluster won't renew its TLS certificate. In order to refresh the - * SSL certificate, you have to use the dedicated api route. - * - * @param request - The request {@link MigrateClusterRequest} - * @returns A Promise of Cluster - */ - migrateCluster = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalMigrateClusterRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/migrate`, - }, - unmarshalCluster, - ) - - /** - * Delete a cluster - * - * @param request - The request {@link DeleteClusterRequest} - * @returns A Promise of Cluster - */ - deleteCluster = (request: Readonly) => - this.client.fetch( - { - method: 'DELETE', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam('clusterId', request.clusterId)}`, - }, - unmarshalCluster, - ) - - /** - * Get metrics of a cluster - * - * @param request - The request {@link GetClusterMetricsRequest} - * @returns A Promise of ClusterMetricsResponse - */ - getClusterMetrics = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/metrics`, - urlParams: urlParams( - ['end_date', request.endDate], - ['metric_name', request.metricName], - ['start_date', request.startDate], - ), - }, - unmarshalClusterMetricsResponse, - ) - - protected pageOfListNodeTypes = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/node-types`, - urlParams: urlParams( - ['include_disabled_types', request.includeDisabledTypes], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ), - }, - unmarshalListNodeTypesResponse, - ) - - /** - * List available node types - * - * @param request - The request {@link ListNodeTypesRequest} - * @returns A Promise of ListNodeTypesResponse - */ - listNodeTypes = (request: Readonly) => - enrichForPagination('nodeTypes', this.pageOfListNodeTypes, request) - - protected pageOfListVersions = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/versions`, - urlParams: urlParams( - ['include_beta', request.includeBeta], - ['include_deprecated', request.includeDeprecated], - ['include_disabled', request.includeDisabled], - ['page', request.page], - [ - 'page_size', - request.pageSize ?? this.client.settings.defaultPageSize, - ], - ['version_name', request.versionName], - ), - }, - unmarshalListVersionsResponse, - ) - - /** - * List available Redis™ versions - * - * @param request - The request {@link ListVersionsRequest} - * @returns A Promise of ListVersionsResponse - */ - listVersions = (request: Readonly) => - enrichForPagination('versions', this.pageOfListVersions, request) - - /** - * Get the TLS certificate of a cluster - * - * @param request - The request {@link GetClusterCertificateRequest} - * @returns A Promise of ScwFile - */ - getClusterCertificate = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/certificate`, - }, - unmarshalScwFile, - ) - - /** - * Renew the TLS certificate of a cluster - * - * @param request - The request {@link RenewClusterCertificateRequest} - */ - renewClusterCertificate = ( - request: Readonly, - ) => - this.client.fetch({ - body: '{}', - headers: jsonContentHeaders, - method: 'POST', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/renew-certificate`, - }) - - /** - * Add cluster settings - * - * @param request - The request {@link AddClusterSettingsRequest} - * @returns A Promise of ClusterSettingsResponse - */ - addClusterSettings = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalAddClusterSettingsRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/settings`, - }, - unmarshalClusterSettingsResponse, - ) - - /** - * Delete a cluster setting - * - * @param request - The request {@link DeleteClusterSettingRequest} - */ - deleteClusterSetting = (request: Readonly) => - this.client.fetch({ - body: JSON.stringify( - marshalDeleteClusterSettingRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'DELETE', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/settings`, - }) - - /** - * Set cluster settings - * - * @param request - The request {@link SetClusterSettingsRequest} - * @returns A Promise of ClusterSettingsResponse - */ - setClusterSettings = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalSetClusterSettingsRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PUT', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/settings`, - }, - unmarshalClusterSettingsResponse, - ) - - /** - * Set ACL rules for a given cluster - * - * @param request - The request {@link SetAclRulesRequest} - * @returns A Promise of AclRulesResponse - */ - setAclRules = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalSetAclRulesRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PUT', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam('clusterId', request.clusterId)}/acls`, - }, - unmarshalAclRulesResponse, - ) - - /** - * Add ACL rules for a given cluster - * - * @param request - The request {@link AddAclRulesRequest} - * @returns A Promise of AclRulesResponse - */ - addAclRules = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalAddAclRulesRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam('clusterId', request.clusterId)}/acls`, - }, - unmarshalAclRulesResponse, - ) - - /** - * Delete an ACL rule for a given cluster - * - * @param request - The request {@link DeleteAclRuleRequest} - */ - deleteAclRule = (request: Readonly) => - this.client.fetch({ - method: 'DELETE', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/acls/${validatePathParam('aclId', request.aclId)}`, - }) - - /** - * Get an ACL rule - * - * @param request - The request {@link GetAclRuleRequest} - * @returns A Promise of ACLRule - */ - getAclRule = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/acls/${validatePathParam('aclId', request.aclId)}`, - }, - unmarshalACLRule, - ) - - /** - * Set endpoints for a given cluster - * - * @param request - The request {@link SetEndpointsRequest} - * @returns A Promise of SetEndpointsResponse - */ - setEndpoints = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalSetEndpointsRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PUT', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/endpoints`, - }, - unmarshalSetEndpointsResponse, - ) - - /** - * Add endpoints for a given cluster - * - * @param request - The request {@link AddEndpointsRequest} - * @returns A Promise of AddEndpointsResponse - */ - addEndpoints = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalAddEndpointsRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'POST', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/clusters/${validatePathParam( - 'clusterId', - request.clusterId, - )}/endpoints`, - }, - unmarshalAddEndpointsResponse, - ) - - /** - * Delete an endpoint for a given cluster - * - * @param request - The request {@link DeleteEndpointRequest} - */ - deleteEndpoint = (request: Readonly) => - this.client.fetch({ - method: 'DELETE', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/endpoints/${validatePathParam('endpointId', request.endpointId)}`, - }) - - /** - * Get an endpoint - * - * @param request - The request {@link GetEndpointRequest} - * @returns A Promise of Endpoint - */ - getEndpoint = (request: Readonly) => - this.client.fetch( - { - method: 'GET', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/endpoints/${validatePathParam('endpointId', request.endpointId)}`, - }, - unmarshalEndpoint, - ) - - updateEndpoint = (request: Readonly) => - this.client.fetch( - { - body: JSON.stringify( - marshalUpdateEndpointRequest(request, this.client.settings), - ), - headers: jsonContentHeaders, - method: 'PATCH', - path: `/redis/v1alpha1/zones/${validatePathParam( - 'zone', - request.zone ?? this.client.settings.defaultZone, - )}/endpoints/${validatePathParam('endpointId', request.endpointId)}`, - }, - unmarshalEndpoint, - ) -} diff --git a/packages/clients/src/api/redis/v1alpha1/content.gen.ts b/packages/clients/src/api/redis/v1alpha1/content.gen.ts deleted file mode 100644 index ed8bec2a0..000000000 --- a/packages/clients/src/api/redis/v1alpha1/content.gen.ts +++ /dev/null @@ -1,12 +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 { ClusterStatus } from './types.gen' - -/** Lists transient statutes of the enum {@link ClusterStatus}. */ -export const CLUSTER_TRANSIENT_STATUSES: ClusterStatus[] = [ - 'provisioning', - 'configuring', - 'destroying', - 'autohealing', - 'initializing', -] diff --git a/packages/clients/src/api/redis/v1alpha1/index.ts b/packages/clients/src/api/redis/v1alpha1/index.ts deleted file mode 100644 index 01a73b38f..000000000 --- a/packages/clients/src/api/redis/v1alpha1/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { RedisV1Alpha1GenAPI as API } from './api.gen' -export * from './content.gen' -export * from './types.gen' diff --git a/packages/clients/src/api/redis/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/redis/v1alpha1/marshalling.gen.ts deleted file mode 100644 index 9a8c00272..000000000 --- a/packages/clients/src/api/redis/v1alpha1/marshalling.gen.ts +++ /dev/null @@ -1,460 +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, - resolveOneOf, - unmarshalArrayOfObject, - unmarshalDate, - unmarshalTimeSeries, -} from '../../../bridge' -import type { DefaultValues } from '../../../bridge' -import type { - ACLRule, - ACLRuleSpec, - AclRulesResponse, - AddAclRulesRequest, - AddClusterSettingsRequest, - AddEndpointsRequest, - AddEndpointsResponse, - AvailableClusterSetting, - Cluster, - ClusterMetricsResponse, - ClusterSetting, - ClusterSettingsResponse, - ClusterVersion, - CreateClusterRequest, - DeleteClusterSettingRequest, - Endpoint, - EndpointPublicNetwork, - EndpointSpec, - EndpointSpecPrivateNetworkSpec, - EndpointSpecPublicNetworkSpec, - ListClustersResponse, - ListNodeTypesResponse, - ListVersionsResponse, - MigrateClusterRequest, - NodeType, - PrivateNetwork, - SetAclRulesRequest, - SetClusterSettingsRequest, - SetEndpointsRequest, - SetEndpointsResponse, - UpdateClusterRequest, - UpdateEndpointRequest, -} from './types.gen' - -const unmarshalEndpointPublicNetwork = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'EndpointPublicNetwork' failed as data isn't a dictionary.`, - ) - } - - return {} as EndpointPublicNetwork -} - -const unmarshalPrivateNetwork = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'PrivateNetwork' failed as data isn't a dictionary.`, - ) - } - - return { - id: data.id, - serviceIps: data.service_ips, - zone: data.zone, - } as PrivateNetwork -} - -export const unmarshalACLRule = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ACLRule' failed as data isn't a dictionary.`, - ) - } - - return { description: data.description, id: data.id, ip: data.ip } as ACLRule -} - -const unmarshalAvailableClusterSetting = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'AvailableClusterSetting' failed as data isn't a dictionary.`, - ) - } - - return { - defaultValue: data.default_value, - deprecated: data.deprecated, - description: data.description, - maxValue: data.max_value, - minValue: data.min_value, - name: data.name, - regex: data.regex, - type: data.type, - } as AvailableClusterSetting -} - -const unmarshalClusterSetting = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ClusterSetting' failed as data isn't a dictionary.`, - ) - } - - return { name: data.name, value: data.value } as ClusterSetting -} - -export const unmarshalEndpoint = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`, - ) - } - - return { - id: data.id, - ips: data.ips, - port: data.port, - privateNetwork: data.private_network - ? unmarshalPrivateNetwork(data.private_network) - : undefined, - publicNetwork: data.public_network - ? unmarshalEndpointPublicNetwork(data.public_network) - : undefined, - } as Endpoint -} - -export const unmarshalCluster = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'Cluster' failed as data isn't a dictionary.`, - ) - } - - return { - aclRules: unmarshalArrayOfObject(data.acl_rules, unmarshalACLRule), - clusterSettings: unmarshalArrayOfObject( - data.cluster_settings, - unmarshalClusterSetting, - ), - clusterSize: data.cluster_size, - createdAt: unmarshalDate(data.created_at), - endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint), - id: data.id, - name: data.name, - nodeType: data.node_type, - projectId: data.project_id, - status: data.status, - tags: data.tags, - tlsEnabled: data.tls_enabled, - updatedAt: unmarshalDate(data.updated_at), - version: data.version, - zone: data.zone, - } as Cluster -} - -const unmarshalClusterVersion = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ClusterVersion' failed as data isn't a dictionary.`, - ) - } - - return { - availableSettings: unmarshalArrayOfObject( - data.available_settings, - unmarshalAvailableClusterSetting, - ), - eolDate: unmarshalDate(data.eol_date), - logoUrl: data.logo_url, - version: data.version, - zone: data.zone, - } as ClusterVersion -} - -const unmarshalNodeType = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`, - ) - } - - return { - beta: data.beta, - description: data.description, - disabled: data.disabled, - memory: data.memory, - name: data.name, - stockStatus: data.stock_status, - vcpus: data.vcpus, - zone: data.zone, - } as NodeType -} - -export const unmarshalAclRulesResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'AclRulesResponse' failed as data isn't a dictionary.`, - ) - } - - return { - aclRules: unmarshalArrayOfObject(data.acl_rules, unmarshalACLRule), - } as AclRulesResponse -} - -export const unmarshalAddEndpointsResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'AddEndpointsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint), - totalCount: data.total_count, - } as AddEndpointsResponse -} - -export const unmarshalClusterMetricsResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ClusterMetricsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - timeseries: unmarshalArrayOfObject(data.timeseries, unmarshalTimeSeries), - } as ClusterMetricsResponse -} - -export const unmarshalClusterSettingsResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ClusterSettingsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - settings: unmarshalArrayOfObject(data.settings, unmarshalClusterSetting), - } as ClusterSettingsResponse -} - -export const unmarshalListClustersResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListClustersResponse' failed as data isn't a dictionary.`, - ) - } - - return { - clusters: unmarshalArrayOfObject(data.clusters, unmarshalCluster), - totalCount: data.total_count, - } as ListClustersResponse -} - -export const unmarshalListNodeTypesResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`, - ) - } - - return { - nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType), - totalCount: data.total_count, - } as ListNodeTypesResponse -} - -export const unmarshalListVersionsResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - totalCount: data.total_count, - versions: unmarshalArrayOfObject(data.versions, unmarshalClusterVersion), - } as ListVersionsResponse -} - -export const unmarshalSetEndpointsResponse = (data: unknown) => { - if (!isJSONObject(data)) { - throw new TypeError( - `Unmarshalling the type 'SetEndpointsResponse' failed as data isn't a dictionary.`, - ) - } - - return { - endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint), - totalCount: data.total_count, - } as SetEndpointsResponse -} - -const marshalEndpointSpecPrivateNetworkSpec = ( - request: EndpointSpecPrivateNetworkSpec, - defaults: DefaultValues, -): Record => ({ - id: request.id, - service_ips: request.serviceIps, -}) - -const marshalEndpointSpecPublicNetworkSpec = ( - request: EndpointSpecPublicNetworkSpec, - defaults: DefaultValues, -): Record => ({}) - -const marshalACLRuleSpec = ( - request: ACLRuleSpec, - defaults: DefaultValues, -): Record => ({ - description: request.description, - ip: request.ip, -}) - -const marshalClusterSetting = ( - request: ClusterSetting, - defaults: DefaultValues, -): Record => ({ - name: request.name, - value: request.value, -}) - -const marshalEndpointSpec = ( - request: EndpointSpec, - defaults: DefaultValues, -): Record => ({ - ...resolveOneOf([ - { - param: 'private_network', - value: request.privateNetwork - ? marshalEndpointSpecPrivateNetworkSpec( - request.privateNetwork, - defaults, - ) - : undefined, - }, - { - param: 'public_network', - value: request.publicNetwork - ? marshalEndpointSpecPublicNetworkSpec(request.publicNetwork, defaults) - : undefined, - }, - ]), -}) - -export const marshalAddAclRulesRequest = ( - request: AddAclRulesRequest, - defaults: DefaultValues, -): Record => ({ - acl_rules: request.aclRules.map(elt => marshalACLRuleSpec(elt, defaults)), -}) - -export const marshalAddClusterSettingsRequest = ( - request: AddClusterSettingsRequest, - defaults: DefaultValues, -): Record => ({ - settings: request.settings.map(elt => marshalClusterSetting(elt, defaults)), -}) - -export const marshalAddEndpointsRequest = ( - request: AddEndpointsRequest, - defaults: DefaultValues, -): Record => ({ - endpoints: request.endpoints.map(elt => marshalEndpointSpec(elt, defaults)), -}) - -export const marshalCreateClusterRequest = ( - request: CreateClusterRequest, - defaults: DefaultValues, -): Record => ({ - acl_rules: request.aclRules - ? request.aclRules.map(elt => marshalACLRuleSpec(elt, defaults)) - : undefined, - cluster_settings: request.clusterSettings - ? request.clusterSettings.map(elt => marshalClusterSetting(elt, defaults)) - : undefined, - cluster_size: request.clusterSize, - endpoints: request.endpoints - ? request.endpoints.map(elt => marshalEndpointSpec(elt, defaults)) - : undefined, - name: request.name || randomName('ins'), - node_type: request.nodeType, - password: request.password, - project_id: request.projectId ?? defaults.defaultProjectId, - tags: request.tags, - tls_enabled: request.tlsEnabled, - user_name: request.userName, - version: request.version, -}) - -export const marshalDeleteClusterSettingRequest = ( - request: DeleteClusterSettingRequest, - defaults: DefaultValues, -): Record => ({ - settings_name: request.settingsName, -}) - -export const marshalMigrateClusterRequest = ( - request: MigrateClusterRequest, - defaults: DefaultValues, -): Record => ({ - ...resolveOneOf([ - { - param: 'version', - value: request.version, - }, - { - param: 'node_type', - value: request.nodeType, - }, - { - param: 'cluster_size', - value: request.clusterSize, - }, - ]), -}) - -export const marshalSetAclRulesRequest = ( - request: SetAclRulesRequest, - defaults: DefaultValues, -): Record => ({ - acl_rules: request.aclRules.map(elt => marshalACLRuleSpec(elt, defaults)), -}) - -export const marshalSetClusterSettingsRequest = ( - request: SetClusterSettingsRequest, - defaults: DefaultValues, -): Record => ({ - settings: request.settings.map(elt => marshalClusterSetting(elt, defaults)), -}) - -export const marshalSetEndpointsRequest = ( - request: SetEndpointsRequest, - defaults: DefaultValues, -): Record => ({ - endpoints: request.endpoints.map(elt => marshalEndpointSpec(elt, defaults)), -}) - -export const marshalUpdateClusterRequest = ( - request: UpdateClusterRequest, - defaults: DefaultValues, -): Record => ({ - name: request.name, - password: request.password, - tags: request.tags, - user_name: request.userName, -}) - -export const marshalUpdateEndpointRequest = ( - request: UpdateEndpointRequest, - defaults: DefaultValues, -): Record => ({ - endpoint: request.endpoint - ? marshalEndpointSpec(request.endpoint, defaults) - : undefined, -}) diff --git a/packages/clients/src/api/redis/v1alpha1/types.gen.ts b/packages/clients/src/api/redis/v1alpha1/types.gen.ts deleted file mode 100644 index 3606f426a..000000000 --- a/packages/clients/src/api/redis/v1alpha1/types.gen.ts +++ /dev/null @@ -1,520 +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 { TimeSeries, Zone } from '../../../bridge' - -export type AvailableClusterSettingPropertyType = 'BOOLEAN' | 'INT' | 'STRING' - -export type ClusterStatus = - | 'unknown' - | 'ready' - | 'provisioning' - | 'configuring' - | 'destroying' - | 'error' - | 'autohealing' - | 'locked' - | 'suspended' - | 'initializing' - -export type ListClustersRequestOrderBy = - | 'created_at_asc' - | 'created_at_desc' - | 'name_asc' - | 'name_desc' - -export type NodeTypeStock = - | 'unknown' - | 'low_stock' - | 'out_of_stock' - | 'available' - -/** Acl rule */ -export interface ACLRule { - /** ID of the rule */ - id: string - /** IPv4 network address of the rule */ - ip?: string - /** Description of the rule */ - description?: string -} - -/** Acl rule spec */ -export interface ACLRuleSpec { - /** IPv4 network address of the rule */ - ip: string - /** Description of the rule */ - description: string -} - -/** Acl rules response */ -export interface AclRulesResponse { - /** ACL Rules enabled on the cluster */ - aclRules: Array -} - -/** Add endpoints response */ -export interface AddEndpointsResponse { - /** Endpoints defined on the cluster */ - endpoints: Array - /** Total count of endpoints of the cluster */ - totalCount: number -} - -/** Available cluster setting */ -export interface AvailableClusterSetting { - /** Name of the setting */ - name: string - /** Default value of the setting */ - defaultValue?: string - /** Type of the setting */ - type: AvailableClusterSettingPropertyType - /** Description of the setting */ - description: string - /** Optional maximum value of the setting */ - maxValue?: number - /** Optional minimum value of the setting */ - minValue?: number - /** Optional validation rule of the setting */ - regex?: string - /** Whether the setting is deprecated */ - deprecated: boolean -} - -/** Cluster */ -export interface Cluster { - /** UUID of the cluster */ - id: string - /** Name of the cluster */ - name: string - /** Project ID the cluster belongs to */ - projectId: string - /** Status of the cluster */ - status: ClusterStatus - /** Redis™ engine version of the cluster */ - version: string - /** List of cluster endpoints */ - endpoints: Array - /** List of tags applied to the cluster */ - tags: Array - /** Node type of the cluster */ - nodeType: string - /** Creation date (Format ISO 8601) */ - createdAt?: Date - /** Update date (Format ISO 8601) */ - updatedAt?: Date - /** Whether or not TLS is enabled */ - tlsEnabled: boolean - /** List of cluster settings */ - clusterSettings: Array - /** List of acl rules */ - aclRules: Array - /** Number of nodes of the cluster */ - clusterSize: number - /** Zone of the cluster */ - zone: Zone -} - -/** Cluster metrics response */ -export interface ClusterMetricsResponse { - /** Time series of metrics of a given cluster */ - timeseries: Array -} - -/** Cluster setting */ -export interface ClusterSetting { - /** Value of the setting */ - value: string - /** Name of the setting */ - name: string -} - -/** Cluster settings response */ -export interface ClusterSettingsResponse { - /** Settings configured for a given cluster */ - settings: Array -} - -/** Cluster version */ -export interface ClusterVersion { - /** Redis™ engine version */ - version: string - /** End of life date */ - eolDate?: Date - /** Cluster settings available to be set */ - availableSettings: Array - /** Redis™ logo url */ - logoUrl: string - /** Zone of the Managed Database for Redis™ */ - zone: Zone -} - -/** Endpoint */ -export interface Endpoint { - /** TCP port of the endpoint */ - port: number - /** - * Private network details. - * - * One-of ('details'): at most one of 'privateNetwork', 'publicNetwork' could be set. - */ - privateNetwork?: PrivateNetwork - /** - * Public network details. - * - * One-of ('details'): at most one of 'privateNetwork', 'publicNetwork' could be set. - */ - publicNetwork?: EndpointPublicNetwork - /** Lis of IPv4 address of the endpoint */ - ips: Array - /** UUID of the endpoint */ - id: string -} - -export interface EndpointPublicNetwork {} - -/** Endpoint spec */ -export interface EndpointSpec { - /** - * Private network spec details. - * - * One-of ('endpointType'): at most one of 'privateNetwork', 'publicNetwork' - * could be set. - */ - privateNetwork?: EndpointSpecPrivateNetworkSpec - /** - * Public network spec details. - * - * One-of ('endpointType'): at most one of 'privateNetwork', 'publicNetwork' - * could be set. - */ - publicNetwork?: EndpointSpecPublicNetworkSpec -} - -/** Endpoint spec. private network spec */ -export interface EndpointSpecPrivateNetworkSpec { - /** UUID of the private network to be connected to the cluster */ - id: string - /** - * Endpoint IPv4 adress with a CIDR notation. You must provide at least one - * IPv4 per node. Check documentation about IP and subnet limitation. - */ - serviceIps: Array -} - -/** Endpoint spec. public network spec */ -export interface EndpointSpecPublicNetworkSpec {} - -/** List clusters response */ -export interface ListClustersResponse { - /** List all clusters */ - clusters: Array - /** Total count of clusters */ - totalCount: number -} - -/** List node types response */ -export interface ListNodeTypesResponse { - /** Types of the node */ - nodeTypes: Array - /** Total count of node-types available */ - totalCount: number -} - -/** List versions response */ -export interface ListVersionsResponse { - /** List of the available Redis™ engine versions */ - versions: Array - /** Total count of available Redis™ engine versions */ - totalCount: number -} - -/** Node type */ -export interface NodeType { - /** Node Type name identifier */ - name: string - /** Current stock status for the Node Type */ - stockStatus: NodeTypeStock - /** Current specs of the offer */ - description: string - /** Number of virtual CPUs */ - vcpus: number - /** Quantity of RAM */ - memory: number - /** The Node Type is currently disabled */ - disabled: boolean - /** The Node Type is currently in beta */ - beta: boolean - /** Zone the Node Type is in */ - zone: Zone -} - -/** Private network */ -export interface PrivateNetwork { - /** UUID of the private network */ - id: string - /** List of IPv4 CIDR notation addresses of the endpoint */ - serviceIps: Array - /** Private network zone */ - zone: Zone -} - -/** Set endpoints response */ -export interface SetEndpointsResponse { - /** Endpoints defined on the cluster */ - endpoints: Array - /** Total count of endpoints of the cluster */ - totalCount: number -} - -export type CreateClusterRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** The project ID on which to create the cluster */ - projectId?: string - /** Name of the cluster */ - name?: string - /** Redis™ engine version of the cluster */ - version: string - /** Tags to apply to the cluster */ - tags?: Array - /** Type of node to use for the cluster */ - nodeType: string - /** Name of the user created when the cluster is created */ - userName: string - /** Password of the user */ - password: string - /** Number of nodes for the cluster */ - clusterSize?: number - /** List of ACLRuleSpec used to secure your publicly exposed cluster */ - aclRules?: Array - /** - * Zero or multiple EndpointSpec used to expose your cluster publicly and - * inside private networks. If no EndpoindSpec is given the cluster will be - * publicly exposed by default. - */ - endpoints?: Array - /** Whether or not TLS is enabled */ - tlsEnabled: boolean - /** List of cluster settings to be set at cluster initialisation */ - clusterSettings?: Array -} - -export type UpdateClusterRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster to update */ - clusterId: string - /** Name of the cluster */ - name?: string - /** Tags of a given cluster */ - tags?: Array - /** Name of the cluster user */ - userName?: string - /** Password of the cluster user */ - password?: string -} - -export type GetClusterRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster */ - clusterId: string -} - -export type ListClustersRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** Tags of the clusters to filter upon */ - tags?: Array - /** Name of the clusters to filter upon */ - name?: string - /** Criteria to use when ordering cluster listing */ - orderBy?: ListClustersRequestOrderBy - /** Project ID to list the cluster of */ - projectId?: string - /** Organization ID to list the cluster of */ - organizationId?: string - page?: number - pageSize?: number -} - -export type MigrateClusterRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster to update */ - clusterId: string - /** - * Redis™ engine version of the cluster. - * - * One-of ('action'): at most one of 'version', 'nodeType', 'clusterSize' could be set. - */ - version?: string - /** - * Type of node to use for the cluster. - * - * One-of ('action'): at most one of 'version', 'nodeType', 'clusterSize' could be set. - */ - nodeType?: string - /** - * Number of nodes for the cluster. - * - * One-of ('action'): at most one of 'version', 'nodeType', 'clusterSize' could be set. - */ - clusterSize?: number -} - -export type DeleteClusterRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster to delete */ - clusterId: string -} - -export type GetClusterMetricsRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster */ - clusterId: string - /** Start date to gather metrics from */ - startDate?: Date - /** End date to gather metrics from */ - endDate?: Date - /** Name of the metric to gather */ - metricName?: string -} - -export type ListNodeTypesRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** Whether or not to include disabled types */ - includeDisabledTypes: boolean - page?: number - pageSize?: number -} - -export type ListVersionsRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** Whether or not to include disabled Redis™ engine versions */ - includeDisabled: boolean - /** Whether or not to include beta Redis™ engine versions */ - includeBeta: boolean - /** Whether or not to include deprecated Redis™ engine versions */ - includeDeprecated: boolean - /** List Redis™ engine versions that match a given name pattern */ - versionName?: string - page?: number - pageSize?: number -} - -export type GetClusterCertificateRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster */ - clusterId: string -} - -export type RenewClusterCertificateRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster */ - clusterId: string -} - -export type AddClusterSettingsRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster you want to add settings to */ - clusterId: string - /** Settings to add on the cluster */ - settings: Array -} - -export type DeleteClusterSettingRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster where the settings has to be set */ - clusterId: string - /** Setting name to delete */ - settingsName: string -} - -export type SetClusterSettingsRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster where the settings has to be set */ - clusterId: string - /** Settings to define for the cluster */ - settings: Array -} - -export type SetAclRulesRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster where the ACL rules has to be set */ - clusterId: string - /** ACLs rules to define for the cluster */ - aclRules: Array -} - -export type AddAclRulesRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster you want to add acl rules to */ - clusterId: string - /** ACLs rules to add to the cluster */ - aclRules: Array -} - -export type DeleteAclRuleRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the acl rule you want to delete */ - aclId: string -} - -export type GetAclRuleRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the acl rule you want to get */ - aclId: string -} - -export type SetEndpointsRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster where the endpoints has to be set */ - clusterId: string - /** Endpoints to define for the cluster */ - endpoints: Array -} - -export type AddEndpointsRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the cluster you want to add endpoints to */ - clusterId: string - /** Endpoints to add to the cluster */ - endpoints: Array -} - -export type DeleteEndpointRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the endpoint you want to delete */ - endpointId: string -} - -export type GetEndpointRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - /** UUID of the endpoint you want to get */ - endpointId: string -} - -export type UpdateEndpointRequest = { - /** Zone to target. If none is passed will use default zone from the config */ - zone?: Zone - endpointId: string - endpoint?: EndpointSpec -}