From d56cb040dadb026363c8f2e70adf7d49137196ce Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 25 Jun 2024 14:44:58 +0000 Subject: [PATCH] feat: update generated APIs --- .../src/api/inference/v1beta1/api.gen.ts | 418 +++++++++++++++ .../src/api/inference/v1beta1/content.gen.ts | 10 + .../src/api/inference/v1beta1/index.gen.ts | 47 ++ .../api/inference/v1beta1/marshalling.gen.ts | 390 ++++++++++++++ .../src/api/inference/v1beta1/types.gen.ts | 494 ++++++++++++++++++ .../inference/v1beta1/validation-rules.gen.ts | 56 ++ 6 files changed, 1415 insertions(+) create mode 100644 packages/clients/src/api/inference/v1beta1/api.gen.ts create mode 100644 packages/clients/src/api/inference/v1beta1/content.gen.ts create mode 100644 packages/clients/src/api/inference/v1beta1/index.gen.ts create mode 100644 packages/clients/src/api/inference/v1beta1/marshalling.gen.ts create mode 100644 packages/clients/src/api/inference/v1beta1/types.gen.ts create mode 100644 packages/clients/src/api/inference/v1beta1/validation-rules.gen.ts diff --git a/packages/clients/src/api/inference/v1beta1/api.gen.ts b/packages/clients/src/api/inference/v1beta1/api.gen.ts new file mode 100644 index 000000000..39cc35ec7 --- /dev/null +++ b/packages/clients/src/api/inference/v1beta1/api.gen.ts @@ -0,0 +1,418 @@ +// 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, + waitForResource, +} from '../../../bridge' +import type { Region, WaitForOptions } from '../../../bridge' +import { DEPLOYMENT_TRANSIENT_STATUSES } from './content.gen' +import { + marshalAddDeploymentACLRulesRequest, + marshalCreateDeploymentRequest, + marshalCreateEndpointRequest, + marshalSetDeploymentACLRulesRequest, + marshalUpdateDeploymentRequest, + marshalUpdateEndpointRequest, + unmarshalAddDeploymentACLRulesResponse, + unmarshalDeployment, + unmarshalEndpoint, + unmarshalEula, + unmarshalListDeploymentACLRulesResponse, + unmarshalListDeploymentsResponse, + unmarshalListModelsResponse, + unmarshalListNodeTypesResponse, + unmarshalModel, + unmarshalSetDeploymentACLRulesResponse, +} from './marshalling.gen' +import type { + AddDeploymentACLRulesRequest, + AddDeploymentACLRulesResponse, + CreateDeploymentRequest, + CreateEndpointRequest, + DeleteDeploymentACLRuleRequest, + DeleteDeploymentRequest, + DeleteEndpointRequest, + Deployment, + Endpoint, + Eula, + GetDeploymentCertificateRequest, + GetDeploymentRequest, + GetModelEulaRequest, + GetModelRequest, + ListDeploymentACLRulesRequest, + ListDeploymentACLRulesResponse, + ListDeploymentsRequest, + ListDeploymentsResponse, + ListModelsRequest, + ListModelsResponse, + ListNodeTypesRequest, + ListNodeTypesResponse, + Model, + SetDeploymentACLRulesRequest, + SetDeploymentACLRulesResponse, + UpdateDeploymentRequest, + UpdateEndpointRequest, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Managed Inference API. + * + * This API allows you to manage your Inference services. + */ +export class API extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: Region[] = ['fr-par'] + + protected pageOfListDeployments = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ['tags', request.tags], + ), + }, + unmarshalListDeploymentsResponse, + ) + + /** + * List inference deployments. List all your inference deployments. + * + * @param request - The request {@link ListDeploymentsRequest} + * @returns A Promise of ListDeploymentsResponse + */ + listDeployments = (request: Readonly = {}) => + enrichForPagination('deployments', this.pageOfListDeployments, request) + + /** + * Get a deployment. Get the deployment for the given ID. + * + * @param request - The request {@link GetDeploymentRequest} + * @returns A Promise of Deployment + */ + getDeployment = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam('deploymentId', request.deploymentId)}`, + }, + unmarshalDeployment, + ) + + /** + * Waits for {@link Deployment} to be in a final state. + * + * @param request - The request {@link GetDeploymentRequest} + * @param options - The waiting options + * @returns A Promise of Deployment + */ + waitForDeployment = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!DEPLOYMENT_TRANSIENT_STATUSES.includes(res.status))), + this.getDeployment, + request, + options, + ) + + /** + * Create a deployment. Create a new inference deployment related to a + * specific model. + * + * @param request - The request {@link CreateDeploymentRequest} + * @returns A Promise of Deployment + */ + createDeployment = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateDeploymentRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments`, + }, + unmarshalDeployment, + ) + + /** + * Update a deployment. Update an existing inference deployment. + * + * @param request - The request {@link UpdateDeploymentRequest} + * @returns A Promise of Deployment + */ + updateDeployment = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateDeploymentRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam('deploymentId', request.deploymentId)}`, + }, + unmarshalDeployment, + ) + + /** + * Delete a deployment. Delete an existing inference deployment. + * + * @param request - The request {@link DeleteDeploymentRequest} + * @returns A Promise of Deployment + */ + deleteDeployment = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam('deploymentId', request.deploymentId)}`, + }, + unmarshalDeployment, + ) + + /** + * Get the CA certificate. Get the CA certificate used for the deployment of + * private endpoints. The CA certificate will be returned as a PEM file. + * + * @param request - The request {@link GetDeploymentCertificateRequest} + * @returns A Promise of Blob + */ + getDeploymentCertificate = ( + request: Readonly, + ) => + this.client.fetch({ + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam('deploymentId', request.deploymentId)}/certificate`, + urlParams: urlParams(['dl', 1]), + responseType: 'blob', + }) + + /** + * Create an endpoint. Create a new Endpoint related to a specific deployment. + * + * @param request - The request {@link CreateEndpointRequest} + * @returns A Promise of Endpoint + */ + createEndpoint = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateEndpointRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/endpoints`, + }, + unmarshalEndpoint, + ) + + /** + * Update an endpoint. Update an existing Endpoint. + * + * @param request - The request {@link UpdateEndpointRequest} + * @returns A Promise of Endpoint + */ + updateEndpoint = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateEndpointRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam('endpointId', request.endpointId)}`, + }, + unmarshalEndpoint, + ) + + /** + * Delete an endpoint. Delete an existing Endpoint. + * + * @param request - The request {@link DeleteEndpointRequest} + */ + deleteEndpoint = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam('endpointId', request.endpointId)}`, + }) + + protected pageOfListDeploymentACLRules = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam('deploymentId', request.deploymentId)}/acls`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListDeploymentACLRulesResponse, + ) + + /** + * List your ACLs. List ACLs for a specific deployment. + * + * @param request - The request {@link ListDeploymentACLRulesRequest} + * @returns A Promise of ListDeploymentACLRulesResponse + */ + listDeploymentACLRules = (request: Readonly) => + enrichForPagination('rules', this.pageOfListDeploymentACLRules, request) + + /** + * Add new ACLs. Add new ACL rules for a specific deployment. + * + * @param request - The request {@link AddDeploymentACLRulesRequest} + * @returns A Promise of AddDeploymentACLRulesResponse + */ + addDeploymentACLRules = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAddDeploymentACLRulesRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam('deploymentId', request.deploymentId)}/acls`, + }, + unmarshalAddDeploymentACLRulesResponse, + ) + + /** + * Set new ACL. Set new ACL rules for a specific deployment. + * + * @param request - The request {@link SetDeploymentACLRulesRequest} + * @returns A Promise of SetDeploymentACLRulesResponse + */ + setDeploymentACLRules = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalSetDeploymentACLRulesRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PUT', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam('deploymentId', request.deploymentId)}/acls`, + }, + unmarshalSetDeploymentACLRulesResponse, + ) + + /** + * Delete an exising ACL. + * + * @param request - The request {@link DeleteDeploymentACLRuleRequest} + */ + deleteDeploymentACLRule = ( + request: Readonly, + ) => + this.client.fetch({ + method: 'DELETE', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/acls/${validatePathParam('aclId', request.aclId)}`, + }) + + protected pageOfListModels = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/models`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ['tags', request.tags], + ), + }, + unmarshalListModelsResponse, + ) + + /** + * List models. List all available models. + * + * @param request - The request {@link ListModelsRequest} + * @returns A Promise of ListModelsResponse + */ + listModels = (request: Readonly = {}) => + enrichForPagination('models', this.pageOfListModels, request) + + /** + * Get a model. Get the model for the given ID. + * + * @param request - The request {@link GetModelRequest} + * @returns A Promise of Model + */ + getModel = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/models/${validatePathParam('modelId', request.modelId)}`, + }, + unmarshalModel, + ) + + getModelEula = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/models/${validatePathParam('modelId', request.modelId)}/eula`, + }, + unmarshalEula, + ) + + protected pageOfListNodeTypes = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/inference/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/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. List all available node types. By default, the + * node types 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 ListNodeTypesRequest} + * @returns A Promise of ListNodeTypesResponse + */ + listNodeTypes = (request: Readonly) => + enrichForPagination('nodeTypes', this.pageOfListNodeTypes, request) +} diff --git a/packages/clients/src/api/inference/v1beta1/content.gen.ts b/packages/clients/src/api/inference/v1beta1/content.gen.ts new file mode 100644 index 000000000..ac29b7180 --- /dev/null +++ b/packages/clients/src/api/inference/v1beta1/content.gen.ts @@ -0,0 +1,10 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { DeploymentStatus } from './types.gen' + +/** Lists transient statutes of the enum {@link DeploymentStatus}. */ +export const DEPLOYMENT_TRANSIENT_STATUSES: DeploymentStatus[] = [ + 'creating', + 'deploying', + 'deleting', +] diff --git a/packages/clients/src/api/inference/v1beta1/index.gen.ts b/packages/clients/src/api/inference/v1beta1/index.gen.ts new file mode 100644 index 000000000..2da1e7d79 --- /dev/null +++ b/packages/clients/src/api/inference/v1beta1/index.gen.ts @@ -0,0 +1,47 @@ +// 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 * from './content.gen' +export type { + ACLRule, + ACLRuleRequest, + AddDeploymentACLRulesRequest, + AddDeploymentACLRulesResponse, + CreateDeploymentRequest, + CreateEndpointRequest, + DeleteDeploymentACLRuleRequest, + DeleteDeploymentRequest, + DeleteEndpointRequest, + Deployment, + DeploymentStatus, + Endpoint, + EndpointPrivateNetworkDetails, + EndpointPublicAccessDetails, + EndpointSpec, + EndpointSpecPrivateNetwork, + EndpointSpecPublic, + Eula, + GetDeploymentCertificateRequest, + GetDeploymentRequest, + GetModelEulaRequest, + GetModelRequest, + ListDeploymentACLRulesRequest, + ListDeploymentACLRulesResponse, + ListDeploymentsRequest, + ListDeploymentsRequestOrderBy, + ListDeploymentsResponse, + ListModelsRequest, + ListModelsRequestOrderBy, + ListModelsResponse, + ListNodeTypesRequest, + ListNodeTypesResponse, + Model, + ModelS3Model, + NodeType, + NodeTypeStock, + SetDeploymentACLRulesRequest, + SetDeploymentACLRulesResponse, + UpdateDeploymentRequest, + UpdateEndpointRequest, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages/clients/src/api/inference/v1beta1/marshalling.gen.ts b/packages/clients/src/api/inference/v1beta1/marshalling.gen.ts new file mode 100644 index 000000000..d7d0122ba --- /dev/null +++ b/packages/clients/src/api/inference/v1beta1/marshalling.gen.ts @@ -0,0 +1,390 @@ +// 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, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + ACLRule, + ACLRuleRequest, + AddDeploymentACLRulesRequest, + AddDeploymentACLRulesResponse, + CreateDeploymentRequest, + CreateEndpointRequest, + Deployment, + Endpoint, + EndpointPrivateNetworkDetails, + EndpointPublicAccessDetails, + EndpointSpec, + EndpointSpecPrivateNetwork, + EndpointSpecPublic, + Eula, + ListDeploymentACLRulesResponse, + ListDeploymentsResponse, + ListModelsResponse, + ListNodeTypesResponse, + Model, + ModelS3Model, + NodeType, + SetDeploymentACLRulesRequest, + SetDeploymentACLRulesResponse, + UpdateDeploymentRequest, + UpdateEndpointRequest, +} from './types.gen' + +const unmarshalEndpointPrivateNetworkDetails = ( + data: unknown, +): EndpointPrivateNetworkDetails => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`, + ) + } + + return { + privateNetworkId: data.private_network_id, + } as EndpointPrivateNetworkDetails +} + +const unmarshalEndpointPublicAccessDetails = ( + data: unknown, +): EndpointPublicAccessDetails => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EndpointPublicAccessDetails' failed as data isn't a dictionary.`, + ) + } + + return {} as EndpointPublicAccessDetails +} + +export const unmarshalEndpoint = (data: unknown): Endpoint => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`, + ) + } + + return { + disableAuth: data.disable_auth, + id: data.id, + privateNetwork: data.private_network + ? unmarshalEndpointPrivateNetworkDetails(data.private_network) + : undefined, + publicAccess: data.public_access + ? unmarshalEndpointPublicAccessDetails(data.public_access) + : undefined, + url: data.url, + } as Endpoint +} + +export const unmarshalDeployment = (data: unknown): Deployment => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Deployment' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint), + errorMessage: data.error_message, + id: data.id, + maxSize: data.max_size, + minSize: data.min_size, + modelId: data.model_id, + modelName: data.model_name, + name: data.name, + nodeType: data.node_type, + projectId: data.project_id, + region: data.region, + size: data.size, + status: data.status, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + } as Deployment +} + +const unmarshalModelS3Model = (data: unknown): ModelS3Model => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ModelS3Model' failed as data isn't a dictionary.`, + ) + } + + return { + nodeType: data.node_type, + pythonDependencies: data.python_dependencies, + s3Url: data.s3_url, + tritonServerVersion: data.triton_server_version, + } as ModelS3Model +} + +export const unmarshalModel = (data: unknown): Model => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Model' failed as data isn't a dictionary.`, + ) + } + + return { + compatibleNodeTypes: data.compatible_node_types, + createdAt: unmarshalDate(data.created_at), + description: data.description, + hasEula: data.has_eula, + id: data.id, + isPublic: data.is_public, + name: data.name, + projectId: data.project_id, + provider: data.provider, + quantizationLevel: data.quantization_level, + region: data.region, + s3Model: data.s3_model ? unmarshalModelS3Model(data.s3_model) : undefined, + tags: data.tags, + updatedAt: unmarshalDate(data.updated_at), + } as Model +} + +const unmarshalACLRule = (data: unknown): ACLRule => { + 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 +} + +export const unmarshalAddDeploymentACLRulesResponse = ( + data: unknown, +): AddDeploymentACLRulesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'AddDeploymentACLRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule), + } as AddDeploymentACLRulesResponse +} + +export const unmarshalEula = (data: unknown): Eula => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Eula' failed as data isn't a dictionary.`, + ) + } + + return { + content: data.content, + } as Eula +} + +export const unmarshalListDeploymentACLRulesResponse = ( + data: unknown, +): ListDeploymentACLRulesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListDeploymentACLRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule), + totalCount: data.total_count, + } as ListDeploymentACLRulesResponse +} + +export const unmarshalListDeploymentsResponse = ( + data: unknown, +): ListDeploymentsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListDeploymentsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + deployments: unmarshalArrayOfObject(data.deployments, unmarshalDeployment), + totalCount: data.total_count, + } as ListDeploymentsResponse +} + +export const unmarshalListModelsResponse = ( + data: unknown, +): ListModelsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListModelsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + models: unmarshalArrayOfObject(data.models, unmarshalModel), + totalCount: data.total_count, + } as ListModelsResponse +} + +const unmarshalNodeType = (data: unknown): NodeType => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`, + ) + } + + return { + beta: data.beta, + createdAt: unmarshalDate(data.created_at), + description: data.description, + disabled: data.disabled, + gpus: data.gpus, + memory: data.memory, + name: data.name, + region: data.region, + stockStatus: data.stock_status, + updatedAt: unmarshalDate(data.updated_at), + vcpus: data.vcpus, + vram: data.vram, + } as NodeType +} + +export const unmarshalListNodeTypesResponse = ( + data: unknown, +): ListNodeTypesResponse => { + 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 unmarshalSetDeploymentACLRulesResponse = ( + data: unknown, +): SetDeploymentACLRulesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SetDeploymentACLRulesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule), + } as SetDeploymentACLRulesResponse +} + +const marshalACLRuleRequest = ( + request: ACLRuleRequest, + defaults: DefaultValues, +): Record => ({ + description: request.description, + ip: request.ip, +}) + +export const marshalAddDeploymentACLRulesRequest = ( + request: AddDeploymentACLRulesRequest, + defaults: DefaultValues, +): Record => ({ + acls: + request.acls !== undefined + ? request.acls.map(elt => marshalACLRuleRequest(elt, defaults)) + : undefined, +}) + +const marshalEndpointSpecPrivateNetwork = ( + request: EndpointSpecPrivateNetwork, + defaults: DefaultValues, +): Record => ({ + private_network_id: request.privateNetworkId, +}) + +const marshalEndpointSpecPublic = ( + request: EndpointSpecPublic, + defaults: DefaultValues, +): Record => ({}) + +const marshalEndpointSpec = ( + request: EndpointSpec, + defaults: DefaultValues, +): Record => ({ + disable_auth: request.disableAuth, + ...resolveOneOf([ + { + param: 'public', + value: + request.public !== undefined + ? marshalEndpointSpecPublic(request.public, defaults) + : undefined, + }, + { + param: 'private_network', + value: + request.privateNetwork !== undefined + ? marshalEndpointSpecPrivateNetwork(request.privateNetwork, defaults) + : undefined, + }, + ]), +}) + +export const marshalCreateDeploymentRequest = ( + request: CreateDeploymentRequest, + defaults: DefaultValues, +): Record => ({ + accept_eula: request.acceptEula, + endpoints: request.endpoints.map(elt => marshalEndpointSpec(elt, defaults)), + max_size: request.maxSize, + min_size: request.minSize, + model_name: request.modelName, + name: request.name || randomName('inference'), + node_type: request.nodeType, + project_id: request.projectId ?? defaults.defaultProjectId, + tags: request.tags, +}) + +export const marshalCreateEndpointRequest = ( + request: CreateEndpointRequest, + defaults: DefaultValues, +): Record => ({ + deployment_id: request.deploymentId, + endpoint: marshalEndpointSpec(request.endpoint, defaults), +}) + +export const marshalSetDeploymentACLRulesRequest = ( + request: SetDeploymentACLRulesRequest, + defaults: DefaultValues, +): Record => ({ + acls: + request.acls !== undefined + ? request.acls.map(elt => marshalACLRuleRequest(elt, defaults)) + : undefined, +}) + +export const marshalUpdateDeploymentRequest = ( + request: UpdateDeploymentRequest, + defaults: DefaultValues, +): Record => ({ + max_size: request.maxSize, + min_size: request.minSize, + name: request.name, + tags: request.tags, +}) + +export const marshalUpdateEndpointRequest = ( + request: UpdateEndpointRequest, + defaults: DefaultValues, +): Record => ({ + disable_auth: request.disableAuth, +}) diff --git a/packages/clients/src/api/inference/v1beta1/types.gen.ts b/packages/clients/src/api/inference/v1beta1/types.gen.ts new file mode 100644 index 000000000..59481c499 --- /dev/null +++ b/packages/clients/src/api/inference/v1beta1/types.gen.ts @@ -0,0 +1,494 @@ +// 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 DeploymentStatus = + | 'unknown_status' + | 'creating' + | 'deploying' + | 'ready' + | 'error' + | 'deleting' + | 'locked' + +export type ListDeploymentsRequestOrderBy = + | 'created_at_desc' + | 'created_at_asc' + | 'name_asc' + | 'name_desc' + +export type ListModelsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export type NodeTypeStock = + | 'unknown_stock' + | 'low_stock' + | 'out_of_stock' + | 'available' + +export interface EndpointPrivateNetworkDetails { + /** ID of the Private Network. */ + privateNetworkId: string +} + +export interface EndpointPublicAccessDetails {} + +export interface EndpointSpecPrivateNetwork { + /** ID of the Private Network. */ + privateNetworkId: string +} + +export interface EndpointSpecPublic {} + +export interface Endpoint { + /** Unique identifier. */ + id: string + /** + * For private endpoints, the URL will be accessible only from the Private + * Network. In addition, private endpoints will expose a CA certificate that + * can be used to verify the server's identity. This CA certificate can be + * retrieved using the `GetDeploymentCertificate` API call. + */ + url: string + /** + * Defines whether the endpoint is public. + * + * One-of ('details'): at most one of 'publicAccess', 'privateNetwork' could + * be set. + */ + publicAccess?: EndpointPublicAccessDetails + /** + * Details of the Private Network. + * + * One-of ('details'): at most one of 'publicAccess', 'privateNetwork' could + * be set. + */ + privateNetwork?: EndpointPrivateNetworkDetails + /** Defines whether the authentication is disabled. */ + disableAuth: boolean +} + +export interface ModelS3Model { + s3Url: string + pythonDependencies: Record + nodeType?: string + tritonServerVersion?: string +} + +export interface ACLRuleRequest { + /** + * It can be specified as a single IP address or a range of IP addresses in + * CIDR notation. + */ + ip: string + /** Description of the ACL rule. */ + description: string +} + +export interface ACLRule { + /** Unique identifier. */ + id: string + /** Allowed IP address or CIDR range. */ + ip: string + /** Description of the ACL rule. */ + description: string +} + +export interface EndpointSpec { + /** + * Set the endpoint as public. + * + * One-of ('spec'): at most one of 'public', 'privateNetwork' could be set. + */ + public?: EndpointSpecPublic + /** + * Private endpoints are only accessible from the Private Network. + * + * One-of ('spec'): at most one of 'public', 'privateNetwork' could be set. + */ + privateNetwork?: EndpointSpecPrivateNetwork + /** + * By default, deployments are protected by IAM authentication. When setting + * this field to true, the authentication will be disabled. + */ + disableAuth: boolean +} + +export interface Deployment { + /** Unique identifier. */ + id: string + /** Name of the deployment. */ + name: string + /** Project ID. */ + projectId: string + /** Status of the deployment. */ + status: DeploymentStatus + /** List of tags applied to the deployment. */ + tags: string[] + /** Node type of the deployment. */ + nodeType: string + /** List of endpoints. */ + endpoints: Endpoint[] + /** Current size of the pool. */ + size: number + /** Defines the minimum size of the pool. */ + minSize: number + /** Defines the maximum size of the pool. */ + maxSize: number + /** Displays information if your deployment is in error state. */ + errorMessage?: string + /** The inference model used for the deployment. */ + modelName: string + /** ID of the model used for the deployment. */ + modelId: string + /** Creation date of the deployment. */ + createdAt?: Date + /** Last modification date of the deployment. */ + updatedAt?: Date + /** Region of the deployment. */ + region: Region +} + +export interface Model { + /** Unique identifier. */ + id: string + /** Unique Name identifier. */ + name: string + /** Project ID. */ + projectId: string + /** Name of the model provider. */ + provider: string + /** List of tags applied to the model. */ + tags: string[] + /** Purpose of the model. */ + description: string + /** Defines whether the model has an end user licence agreement. */ + hasEula: boolean + /** Creation date of the model. */ + createdAt?: Date + /** Last modification date of the model. */ + updatedAt?: Date + /** Region of the model. */ + region: Region + /** + * S3 URL pointing to the model source weight. + * + * One-of ('source'): at most one of 's3Model' could be set. + */ + s3Model?: ModelS3Model + /** Defines whether the model is public or not. */ + isPublic: boolean + /** Names of the node types compatible with the model. */ + compatibleNodeTypes: string[] + /** Quantization level of the model. */ + quantizationLevel: string +} + +export interface NodeType { + /** Name of the node type. */ + 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 + /** Quantity of GPU RAM. */ + vram: number + /** The node type is currently disabled. */ + disabled: boolean + /** The node type is currently in beta. */ + beta: boolean + /** Creation date of the node type. */ + createdAt?: Date + /** Last modification date of the node type. */ + updatedAt?: Date + /** Number of GPUs. */ + gpus: number + /** Region of the node type. */ + region: Region +} + +export type AddDeploymentACLRulesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the deployment to add ACL rules to. */ + deploymentId: string + /** List of ACL rules to add. */ + acls?: ACLRuleRequest[] +} + +export interface AddDeploymentACLRulesResponse { + /** List of ACL rules added. */ + rules: ACLRule[] +} + +export type CreateDeploymentRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Name of the deployment. */ + name?: string + /** ID of the Project to create the deployment in. */ + projectId?: string + /** Name of the model to use. */ + modelName: string + /** + * If the model has an EULA, you must accept it before proceeding. The terms + * of the EULA can be retrieved using the `GetModelEula` API call. + */ + acceptEula?: boolean + /** Name of the node type to use. */ + nodeType: string + /** List of tags to apply to the deployment. */ + tags?: string[] + /** Defines the minimum size of the pool. */ + minSize?: number + /** Defines the maximum size of the pool. */ + maxSize?: number + /** List of endpoints to create. */ + endpoints: EndpointSpec[] +} + +export type CreateEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the deployment to create the endpoint for. */ + deploymentId: string + /** Specification of the endpoint. */ + endpoint: EndpointSpec +} + +export type DeleteDeploymentACLRuleRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the ACL rule to delete. */ + aclId: string +} + +export type DeleteDeploymentRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the deployment to delete. */ + deploymentId: string +} + +export type DeleteEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the endpoint to delete. */ + endpointId: string +} + +export interface Eula { + /** Content of the end user licence agreement. */ + content: string +} + +export type GetDeploymentCertificateRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + deploymentId: string +} + +export type GetDeploymentRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the deployment to get. */ + deploymentId: string +} + +export type GetModelEulaRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + modelId: string +} + +export type GetModelRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the model to get. */ + modelId: string +} + +export type ListDeploymentACLRulesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the deployment to list ACL rules for. */ + deploymentId: string + /** Page number to return. */ + page?: number + /** Maximum number of ACL rules to return per page. */ + pageSize?: number +} + +export interface ListDeploymentACLRulesResponse { + /** List of ACL rules on the current page. */ + rules: ACLRule[] + /** Total number of ACL rules. */ + totalCount: number +} + +export type ListDeploymentsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number to return. */ + page?: number + /** Maximum number of deployments to return per page. */ + pageSize?: number + /** Order in which to return results. */ + orderBy?: ListDeploymentsRequestOrderBy + /** Filter by Project ID. */ + projectId?: string + /** Filter by Organization ID. */ + organizationId?: string + /** Filter by deployment name. */ + name?: string + /** Filter by tags. */ + tags?: string[] +} + +export interface ListDeploymentsResponse { + /** List of deployments on the current page. */ + deployments: Deployment[] + /** Total number of deployments. */ + totalCount: number +} + +export type ListModelsRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Order in which to return results. */ + orderBy?: ListModelsRequestOrderBy + /** Page number to return. */ + page?: number + /** Maximum number of models to return per page. */ + pageSize?: number + /** Filter by Project ID. */ + projectId?: string + /** Filter by model name. */ + name?: string + /** Filter by tags. */ + tags?: string[] +} + +export interface ListModelsResponse { + /** List of models on the current page. */ + models: Model[] + /** Total number of models. */ + totalCount: number +} + +export type ListNodeTypesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number to return. */ + page?: number + /** Maximum number of node types to return per page. */ + pageSize?: number + /** Include disabled node types in the response. */ + includeDisabledTypes: boolean +} + +export interface ListNodeTypesResponse { + /** List of node types. */ + nodeTypes: NodeType[] + /** Total number of node types. */ + totalCount: number +} + +export type SetDeploymentACLRulesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the deployment to set ACL rules for. */ + deploymentId: string + /** All existing ACL rules will be replaced by the new ones. */ + acls?: ACLRuleRequest[] +} + +export interface SetDeploymentACLRulesResponse { + /** List of ACL rules that were set. */ + rules: ACLRule[] +} + +export type UpdateDeploymentRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the deployment to update. */ + deploymentId: string + /** Name of the deployment. */ + name?: string + /** List of tags to apply to the deployment. */ + tags?: string[] + /** Defines the new minimum size of the pool. */ + minSize?: number + /** Defines the new maximum size of the pool. */ + maxSize?: number +} + +export type UpdateEndpointRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** ID of the endpoint to update. */ + endpointId: string + /** + * By default, deployments are protected by IAM authentication. When setting + * this field to true, the authentication will be disabled. + */ + disableAuth?: boolean +} diff --git a/packages/clients/src/api/inference/v1beta1/validation-rules.gen.ts b/packages/clients/src/api/inference/v1beta1/validation-rules.gen.ts new file mode 100644 index 000000000..73b90090d --- /dev/null +++ b/packages/clients/src/api/inference/v1beta1/validation-rules.gen.ts @@ -0,0 +1,56 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const CreateDeploymentRequest = { + maxSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 50, + }, + minSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 50, + }, + modelName: { + maxLength: 255, + minLength: 0, + pattern: /^[\w-_]+\/[\w-_.]+(:[\w]+)?$/, + }, + name: { + maxLength: 255, + minLength: 1, + pattern: /^[A-Za-z0-9-_]+$/, + }, + nodeType: { + maxLength: 64, + minLength: 1, + }, +} + +export const ListDeploymentsRequest = { + name: { + maxLength: 255, + minLength: 1, + }, +} + +export const ListModelsRequest = { + name: { + maxLength: 255, + minLength: 1, + }, +} + +export const UpdateDeploymentRequest = { + maxSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 50, + }, + minSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 50, + }, + name: { + maxLength: 255, + minLength: 1, + }, +}