diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f9d83ffd1..06b071005 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,8 +20,7 @@ jobs: check-latest: true cache: 'pnpm' - run: pnpm install - - run: pnpm run build - - run: pnpm tsc --noEmit + - run: pnpm typecheck lint: runs-on: ubuntu-24.04 steps: diff --git a/.gitignore b/.gitignore index 4f94b19d2..08056c2e7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,15 @@ yarn.lock # lint .eslintcache +# turbo +.turbo +!.turbo/config.json +packages/*/.turbo +packages/*/dist +packages_generated/*/.turbo +packages_generated/*/.dist + + # test & build .reports docs diff --git a/eslint.config.mjs b/eslint.config.mjs index 4080e3cd9..6f7c8cb76 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -19,6 +19,7 @@ export default [ 'packages/clients/src/vendor/base64/index.js', 'packages/client/src/vendor/base64/index.js', 'packages/configuration-loader/.eslintrc.cjs', + 'scripts/generatePackages.ts', ], }, { @@ -82,7 +83,12 @@ export default [ ...scwTypescript.map(config => ({ ...config, - files: ['**/*.test.ts', '__tests__/**/*.ts', '**/vite.config.ts'], + files: [ + '**/*.test.ts', + '__tests__/**/*.ts', + '**/vite.config.ts', + 'vitest.config.ts', + ], rules: { ...config.rules, 'import/no-extraneous-dependencies': 'off', @@ -91,7 +97,10 @@ export default [ ...scwTypescript.map(config => ({ ...config, - files: ['packages/clients/src/api/dedibox/v1/*.ts'], + files: [ + 'packages_generated/dedibox/src/v1/*.ts', + 'packages/clients/src/api/dedibox/v1/*.ts', + ], rules: { ...config.rules, 'no-use-before-define': 'off', diff --git a/package.json b/package.json index 78a193591..0928fbc50 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "root", "private": true, "workspaces": [ - "packages/*" + "packages/*", + "packages_generated/*" ], "engines": { "node": ">=18.0", @@ -10,7 +11,11 @@ }, "type": "module", "scripts": { - "build": "pnpm recursive run build", + "generateIndex": "pnpm dlx tsx ./scripts/generatePackages.ts", + "generateGlobalSdkPackage": "pnpm dlx tsx ./scripts/updateGlobalSdkPackage.ts", + "prebuild": "pnpm run generateIndex && pnpm run generateGlobalSdkPackage && pnpm format", + "build": "pnpm turbo build", + "typecheck": "pnpm turbo typecheck", "build:profile": "cross-env PROFILE=true pnpm run build", "commit": "npx git-cz -a", "doc": "typedoc", @@ -26,7 +31,7 @@ "lint-staged": { "*.ts": [ "pnpm run format", - "eslint --fix ." + "eslint --fix --quiet ." ], "*.json": [ "pnpm run format" @@ -56,9 +61,9 @@ "@scaleway/eslint-config-react": "4.0.9", "@scaleway/random-name": "5.1.1", "@typescript-eslint/eslint-plugin": "latest", - "@vitest/coverage-istanbul": "2.1.9", - "@vitest/coverage-v8": "2.1.9", - "@vitest/ui": "2.1.9", + "@vitest/coverage-istanbul": "3.1.1", + "@vitest/coverage-v8": "3.1.1", + "@vitest/ui": "3.1.1", "babel-plugin-annotate-pure-calls": "0.5.0", "browserslist": "4.24.4", "cross-env": "7.0.3", @@ -75,10 +80,11 @@ "react": "^19.0.0", "read-pkg": "9.0.1", "tsc-alias": "^1.8.10", + "turbo": "2.5.0", "typedoc": "0.27.6", - "typescript": "5.7.3", - "vite": "5.4.18", - "vitest": "2.1.9" + "typescript": "5.8.3", + "vite": "6.2.6", + "vitest": "3.1.1" }, "packageManager": "pnpm@9.4.0" } diff --git a/packages/sdk/.npmignore b/packages/sdk/.npmignore new file mode 100644 index 000000000..5600eef5f --- /dev/null +++ b/packages/sdk/.npmignore @@ -0,0 +1,5 @@ +**/__tests__/** +examples/ +src +.eslintrc.cjs +!.npmignore diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/packages/sdk/CHANGELOG.md @@ -0,0 +1 @@ + diff --git a/packages/sdk/package.json b/packages/sdk/package.json new file mode 100644 index 000000000..c84d9326d --- /dev/null +++ b/packages/sdk/package.json @@ -0,0 +1,91 @@ +{ + "name": "@scaleway/sdk-ts", + "private": "true", + "version": "2.0.0", + "description": "Scaleway SDK TS.", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "type": "module", + "exports": { + ".": { + "types": "./dist/index.gen.d.ts", + "import": "./dist/index.gen.js", + "require": "./dist/index.gen.cjs", + "default": "./dist/index.gen.js" + }, + "./*": { + "types": "./dist/*/index.gen.d.ts", + "import": "./dist/*/index.gen.js", + "require": "./dist/*/index.gen.cjs", + "default": "./dist/*/index.gen.js" + } + }, + "repository": { + "type": "git", + "directory": "packages/sdk" + }, + "engines": { + "node": ">=20.19.0" + }, + "scripts": { + "package:check": "pnpm publint", + "typecheck": "tsc --noEmit", + "type:generate": "tsc --declaration -p tsconfig.build.json", + "build": "vite build --config vite.config.ts && pnpm run type:generate", + "build:profile": "npx vite-bundle-visualizer -c vite.config.ts" + }, + "dependencies": { + "@scaleway/random-name": "5.1.1", + "@scaleway/sdk-account": "workspace:*", + "@scaleway/sdk-applesilicon": "workspace:*", + "@scaleway/sdk-audit-trail": "workspace:*", + "@scaleway/sdk-baremetal": "workspace:*", + "@scaleway/sdk-billing": "workspace:*", + "@scaleway/sdk-block": "workspace:*", + "@scaleway/sdk-cockpit": "workspace:*", + "@scaleway/sdk-container": "workspace:*", + "@scaleway/sdk-dedibox": "workspace:*", + "@scaleway/sdk-domain": "workspace:*", + "@scaleway/sdk-edge-services": "workspace:*", + "@scaleway/sdk-file": "workspace:*", + "@scaleway/sdk-flexibleip": "workspace:*", + "@scaleway/sdk-function": "workspace:*", + "@scaleway/sdk-iam": "workspace:*", + "@scaleway/sdk-inference": "workspace:*", + "@scaleway/sdk-instance": "workspace:*", + "@scaleway/sdk-interlink": "workspace:*", + "@scaleway/sdk-iot": "workspace:*", + "@scaleway/sdk-ipam": "workspace:*", + "@scaleway/sdk-jobs": "workspace:*", + "@scaleway/sdk-k8s": "workspace:*", + "@scaleway/sdk-key-manager": "workspace:*", + "@scaleway/sdk-lb": "workspace:*", + "@scaleway/sdk-marketplace": "workspace:*", + "@scaleway/sdk-mnq": "workspace:*", + "@scaleway/sdk-mongodb": "workspace:*", + "@scaleway/sdk-product-catalog": "workspace:*", + "@scaleway/sdk-qaas": "workspace:*", + "@scaleway/sdk-rdb": "workspace:*", + "@scaleway/sdk-redis": "workspace:*", + "@scaleway/sdk-registry": "workspace:*", + "@scaleway/sdk-secret": "workspace:*", + "@scaleway/sdk-serverless-sqldb": "workspace:*", + "@scaleway/sdk-std": "workspace:*", + "@scaleway/sdk-tem": "workspace:*", + "@scaleway/sdk-test": "workspace:*", + "@scaleway/sdk-vpc": "workspace:*", + "@scaleway/sdk-vpcgw": "workspace:*", + "@scaleway/sdk-webhosting": "workspace:*" + }, + "devDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "peerDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "bundledDependencies": [ + "@scaleway/random-name" + ] +} \ No newline at end of file diff --git a/packages/sdk/src/index.gen.ts b/packages/sdk/src/index.gen.ts new file mode 100644 index 000000000..a3e67078d --- /dev/null +++ b/packages/sdk/src/index.gen.ts @@ -0,0 +1,42 @@ +// Auto-generated exports from all SDK packages + +export * from '@scaleway/sdk-account' +export * from '@scaleway/sdk-applesilicon' +export * from '@scaleway/sdk-audit-trail' +export * from '@scaleway/sdk-baremetal' +export * from '@scaleway/sdk-billing' +export * from '@scaleway/sdk-block' +export * from '@scaleway/sdk-cockpit' +export * from '@scaleway/sdk-container' +export * from '@scaleway/sdk-dedibox' +export * from '@scaleway/sdk-domain' +export * from '@scaleway/sdk-edge-services' +export * from '@scaleway/sdk-file' +export * from '@scaleway/sdk-flexibleip' +export * from '@scaleway/sdk-function' +export * from '@scaleway/sdk-iam' +export * from '@scaleway/sdk-inference' +export * from '@scaleway/sdk-instance' +export * from '@scaleway/sdk-interlink' +export * from '@scaleway/sdk-iot' +export * from '@scaleway/sdk-ipam' +export * from '@scaleway/sdk-jobs' +export * from '@scaleway/sdk-k8s' +export * from '@scaleway/sdk-key-manager' +export * from '@scaleway/sdk-lb' +export * from '@scaleway/sdk-marketplace' +export * from '@scaleway/sdk-mnq' +export * from '@scaleway/sdk-mongodb' +export * from '@scaleway/sdk-product-catalog' +export * from '@scaleway/sdk-qaas' +export * from '@scaleway/sdk-rdb' +export * from '@scaleway/sdk-redis' +export * from '@scaleway/sdk-registry' +export * from '@scaleway/sdk-secret' +export * from '@scaleway/sdk-serverless-sqldb' +export * from '@scaleway/sdk-std' +export * from '@scaleway/sdk-tem' +export * from '@scaleway/sdk-test' +export * from '@scaleway/sdk-vpc' +export * from '@scaleway/sdk-vpcgw' +export * from '@scaleway/sdk-webhosting' diff --git a/packages/sdk/tsconfig.build.json b/packages/sdk/tsconfig.build.json new file mode 100644 index 000000000..19ca82000 --- /dev/null +++ b/packages/sdk/tsconfig.build.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "emitDeclarationOnly": true, + "rootDir": "src", + "outDir": "dist" + }, + "exclude": [ + "dist/*", + "*.config.ts", + "*.setup.ts", + "**/__tests__", + "**/__mocks__", + "src/**/*.test.tsx" + ] +} diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json new file mode 100644 index 000000000..7c2b0759a --- /dev/null +++ b/packages/sdk/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*.ts", "src/**/*.tsx", "*.config.ts"] +} diff --git a/packages/sdk/vite.config.ts b/packages/sdk/vite.config.ts new file mode 100644 index 000000000..5c0513828 --- /dev/null +++ b/packages/sdk/vite.config.ts @@ -0,0 +1,14 @@ +/* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable import/no-default-export */ +/* eslint-disable import/no-relative-packages */ +/* eslint-disable import/no-extraneous-dependencies */ +import { defineConfig, mergeConfig } from 'vite' +import { defaultConfig } from '../../vite.config' + +export default mergeConfig(defineConfig(defaultConfig), { + build: { + lib: { + entry: 'src/index.gen.ts', + }, + }, +}) diff --git a/packages_generated/account/package.json b/packages_generated/account/package.json new file mode 100644 index 000000000..acb5fae9a --- /dev/null +++ b/packages_generated/account/package.json @@ -0,0 +1,51 @@ +{ + "name": "@scaleway/sdk-account", + "version": "1.0.0", + "description": "Scaleway SDK account", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "type": "module", + "exports": { + ".": { + "types": "./dist/index.gen.d.ts", + "import": "./dist/index.gen.js", + "require": "./dist/index.gen.cjs", + "default": "./dist/index.gen.js" + }, + "./*": { + "types": "./dist/*/index.gen.d.ts", + "import": "./dist/*/index.gen.js", + "require": "./dist/*/index.gen.cjs", + "default": "./dist/*/index.gen.js" + } + }, + "repository": { + "type": "git", + "directory": "packages_generated/account" + }, + "engines": { + "node": ">=20.18.3" + }, + "scripts": { + "package:check": "pnpm publint", + "typecheck": "tsc --noEmit", + "type:generate": "tsc --declaration -p tsconfig.build.json", + "build": "vite build --config vite.config.ts && pnpm run type:generate", + "build:profile": "npx vite-bundle-visualizer -c vite.config.ts" + }, + "dependencies": { + "@scaleway/random-name": "5.1.1", + "@scaleway/sdk-std": "workspace:*" + }, + "peerDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "devDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "bundledDependencies": [ + "@scaleway/random-name" + ] +} \ No newline at end of file diff --git a/packages_generated/account/src/index.gen.ts b/packages_generated/account/src/index.gen.ts new file mode 100644 index 000000000..0f3d97ae0 --- /dev/null +++ b/packages_generated/account/src/index.gen.ts @@ -0,0 +1,6 @@ +/** + * This file is automatically generated + * PLEASE DO NOT EDIT HERE + */ + +export * as Accountv3 from './v3/index.gen' diff --git a/packages_generated/account/src/v3/api.gen.ts b/packages_generated/account/src/v3/api.gen.ts new file mode 100644 index 000000000..35cd2a496 --- /dev/null +++ b/packages_generated/account/src/v3/api.gen.ts @@ -0,0 +1,303 @@ +// 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 '@scaleway/sdk-client' +import { + marshalContractApiCheckContractSignatureRequest, + marshalContractApiCreateContractSignatureRequest, + marshalProjectApiCreateProjectRequest, + marshalProjectApiSetProjectQualificationRequest, + marshalProjectApiUpdateProjectRequest, + unmarshalCheckContractSignatureResponse, + unmarshalContractSignature, + unmarshalListContractSignaturesResponse, + unmarshalListProjectsResponse, + unmarshalProject, + unmarshalProjectQualification, +} from './marshalling.gen' +import type { + CheckContractSignatureResponse, + ContractApiCheckContractSignatureRequest, + ContractApiCreateContractSignatureRequest, + ContractApiDownloadContractSignatureRequest, + ContractApiListContractSignaturesRequest, + ContractApiValidateContractSignatureRequest, + ContractSignature, + ListContractSignaturesResponse, + ListProjectsResponse, + Project, + ProjectApiCreateProjectRequest, + ProjectApiDeleteProjectRequest, + ProjectApiGetProjectRequest, + ProjectApiListProjectsRequest, + ProjectApiSetProjectQualificationRequest, + ProjectApiUpdateProjectRequest, + ProjectQualification, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Contract API. + +The Contract API allows you to manage contracts. + */ +export class ContractAPI extends ParentAPI { + /** + * Download a contract content. + * + * @param request - The request {@link ContractApiDownloadContractSignatureRequest} + * @returns A Promise of Blob + */ + downloadContractSignature = ( + request: Readonly, + ) => + this.client.fetch({ + method: 'GET', + path: `/account/v3/contract-signatures/${validatePathParam('contractSignatureId', request.contractSignatureId)}/download`, + urlParams: urlParams(['dl', 1], ['locale', request.locale]), + responseType: 'blob', + }) + + /** + * Create a signature for your Organization for the latest version of the requested contract. + * + * @param request - The request {@link ContractApiCreateContractSignatureRequest} + * @returns A Promise of ContractSignature + */ + createContractSignature = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalContractApiCreateContractSignatureRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/account/v3/contract-signatures`, + }, + unmarshalContractSignature, + ) + + /** + * Sign a contract for your Organization. + * + * @param request - The request {@link ContractApiValidateContractSignatureRequest} + * @returns A Promise of ContractSignature + */ + validateContractSignature = ( + request: Readonly, + ) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/account/v3/contract-signatures/${validatePathParam('contractSignatureId', request.contractSignatureId)}/validate`, + }, + unmarshalContractSignature, + ) + + /** + * Check if a contract is signed for your Organization. + * + * @param request - The request {@link ContractApiCheckContractSignatureRequest} + * @returns A Promise of CheckContractSignatureResponse + */ + checkContractSignature = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalContractApiCheckContractSignatureRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/account/v3/contract-signatures/check`, + }, + unmarshalCheckContractSignatureResponse, + ) + + protected pageOfListContractSignatures = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/account/v3/contract-signatures`, + urlParams: urlParams( + ['order_by', request.orderBy], + [ + 'organization_id', + request.organizationId ?? + this.client.settings.defaultOrganizationId, + ], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListContractSignaturesResponse, + ) + + /** + * List contract signatures for an Organization. + * + * @param request - The request {@link ContractApiListContractSignaturesRequest} + * @returns A Promise of ListContractSignaturesResponse + */ + listContractSignatures = ( + request: Readonly = {}, + ) => + enrichForPagination( + 'contractSignatures', + this.pageOfListContractSignatures, + request, + ) +} + +/** + * Account API. + +This API allows you to manage your Scaleway Projects. + */ +export class ProjectAPI extends ParentAPI { + /** + * Create a new Project for an Organization. Generate a new Project for an Organization, specifying its configuration including name and description. + * + * @param request - The request {@link ProjectApiCreateProjectRequest} + * @returns A Promise of Project + */ + createProject = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalProjectApiCreateProjectRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/account/v3/projects`, + }, + unmarshalProject, + ) + + protected pageOfListProjects = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/account/v3/projects`, + urlParams: urlParams( + ['name', request.name], + ['order_by', request.orderBy], + [ + 'organization_id', + request.organizationId ?? + this.client.settings.defaultOrganizationId, + ], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_ids', request.projectIds], + ), + }, + unmarshalListProjectsResponse, + ) + + /** + * List all Projects of an Organization. List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names, and IDs. Other information includes the creation and update date of the Project. + * + * @param request - The request {@link ProjectApiListProjectsRequest} + * @returns A Promise of ListProjectsResponse + */ + listProjects = (request: Readonly = {}) => + enrichForPagination('projects', this.pageOfListProjects, request) + + /** + * Get an existing Project. Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object. + * + * @param request - The request {@link ProjectApiGetProjectRequest} + * @returns A Promise of Project + */ + getProject = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/account/v3/projects/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`, + }, + unmarshalProject, + ) + + /** + * Delete an existing Project. Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone. + * + * @param request - The request {@link ProjectApiDeleteProjectRequest} + */ + deleteProject = (request: Readonly = {}) => + this.client.fetch({ + method: 'DELETE', + path: `/account/v3/projects/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`, + }) + + /** + * Update Project. Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description. + * + * @param request - The request {@link ProjectApiUpdateProjectRequest} + * @returns A Promise of Project + */ + updateProject = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalProjectApiUpdateProjectRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/account/v3/projects/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`, + }, + unmarshalProject, + ) + + /** + * Set project use case. Set the project use case for a new or existing Project, specified by its Project ID. You can customize the use case, sub use case, and architecture type you want to use in the Project. + * + * @param request - The request {@link ProjectApiSetProjectQualificationRequest} + * @returns A Promise of ProjectQualification + */ + setProjectQualification = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalProjectApiSetProjectQualificationRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/account/v3/projects/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}/project-qualification`, + }, + unmarshalProjectQualification, + ) +} diff --git a/packages_generated/account/src/v3/index.gen.ts b/packages_generated/account/src/v3/index.gen.ts new file mode 100644 index 000000000..a7e6ba2d5 --- /dev/null +++ b/packages_generated/account/src/v3/index.gen.ts @@ -0,0 +1,51 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +export { + ContractAPI, + ProjectAPI, +} from './api.gen' +export * from './marshalling.gen' +export type { + CheckContractSignatureResponse, + Contract, + ContractApiCheckContractSignatureRequest, + ContractApiCreateContractSignatureRequest, + ContractApiDownloadContractSignatureRequest, + ContractApiListContractSignaturesRequest, + ContractApiValidateContractSignatureRequest, + ContractSignature, + ContractType, + ListContractSignaturesRequestOrderBy, + ListContractSignaturesResponse, + ListProjectsRequestOrderBy, + ListProjectsResponse, + Project, + ProjectApiCreateProjectRequest, + ProjectApiDeleteProjectRequest, + ProjectApiGetProjectRequest, + ProjectApiListProjectsRequest, + ProjectApiSetProjectQualificationRequest, + ProjectApiUpdateProjectRequest, + ProjectQualification, + Qualification, + QualificationAiMachine, + QualificationAiMachineSubUseCase, + QualificationArchitectureType, + QualificationArchiveData, + QualificationArchiveDataSubUseCase, + QualificationContainer, + QualificationContainerSubUseCase, + QualificationDeploySoftware, + QualificationDeploySoftwareSubUseCase, + QualificationHostApplication, + QualificationHostApplicationSubUseCase, + QualificationHostWebsite, + QualificationHostWebsiteSubUseCase, + QualificationOtherUseCase, + QualificationOtherUseCaseSubUseCase, + QualificationSetScalewayEnvironment, + QualificationSetScalewayEnvironmentSubUseCase, + QualificationShareData, + QualificationShareDataSubUseCase, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages_generated/account/src/v3/marshalling.gen.ts b/packages_generated/account/src/v3/marshalling.gen.ts new file mode 100644 index 000000000..144669d7e --- /dev/null +++ b/packages_generated/account/src/v3/marshalling.gen.ts @@ -0,0 +1,509 @@ +// 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 '@scaleway/sdk-client' +import type { DefaultValues } from '@scaleway/sdk-client' +import type { + CheckContractSignatureResponse, + Contract, + ContractApiCheckContractSignatureRequest, + ContractApiCreateContractSignatureRequest, + ContractSignature, + ListContractSignaturesResponse, + ListProjectsResponse, + Project, + ProjectApiCreateProjectRequest, + ProjectApiSetProjectQualificationRequest, + ProjectApiUpdateProjectRequest, + ProjectQualification, + Qualification, + QualificationAiMachine, + QualificationArchiveData, + QualificationContainer, + QualificationDeploySoftware, + QualificationHostApplication, + QualificationHostWebsite, + QualificationOtherUseCase, + QualificationSetScalewayEnvironment, + QualificationShareData, +} from './types.gen' + +const unmarshalContract = (data: unknown): Contract => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Contract' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + type: data.type, + updatedAt: unmarshalDate(data.updated_at), + version: data.version, + } as Contract +} + +export const unmarshalContractSignature = ( + data: unknown, +): ContractSignature => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContractSignature' failed as data isn't a dictionary.`, + ) + } + + return { + contract: data.contract ? unmarshalContract(data.contract) : undefined, + createdAt: unmarshalDate(data.created_at), + expiresAt: unmarshalDate(data.expires_at), + id: data.id, + organizationId: data.organization_id, + signedAt: unmarshalDate(data.signed_at), + } as ContractSignature +} + +const unmarshalQualificationAiMachine = ( + data: unknown, +): QualificationAiMachine => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationAiMachine' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationAiMachine +} + +const unmarshalQualificationArchiveData = ( + data: unknown, +): QualificationArchiveData => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationArchiveData' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationArchiveData +} + +const unmarshalQualificationContainer = ( + data: unknown, +): QualificationContainer => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationContainer' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationContainer +} + +const unmarshalQualificationDeploySoftware = ( + data: unknown, +): QualificationDeploySoftware => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationDeploySoftware' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationDeploySoftware +} + +const unmarshalQualificationHostApplication = ( + data: unknown, +): QualificationHostApplication => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationHostApplication' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationHostApplication +} + +const unmarshalQualificationHostWebsite = ( + data: unknown, +): QualificationHostWebsite => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationHostWebsite' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationHostWebsite +} + +const unmarshalQualificationOtherUseCase = ( + data: unknown, +): QualificationOtherUseCase => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationOtherUseCase' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationOtherUseCase +} + +const unmarshalQualificationSetScalewayEnvironment = ( + data: unknown, +): QualificationSetScalewayEnvironment => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationSetScalewayEnvironment' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationSetScalewayEnvironment +} + +const unmarshalQualificationShareData = ( + data: unknown, +): QualificationShareData => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'QualificationShareData' failed as data isn't a dictionary.`, + ) + } + + return { + subUseCase: data.sub_use_case, + } as QualificationShareData +} + +const unmarshalQualification = (data: unknown): Qualification => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Qualification' failed as data isn't a dictionary.`, + ) + } + + return { + aiMachine: data.ai_machine + ? unmarshalQualificationAiMachine(data.ai_machine) + : undefined, + architectureType: data.architecture_type, + archiveData: data.archive_data + ? unmarshalQualificationArchiveData(data.archive_data) + : undefined, + container: data.container + ? unmarshalQualificationContainer(data.container) + : undefined, + deploySoftware: data.deploy_software + ? unmarshalQualificationDeploySoftware(data.deploy_software) + : undefined, + hostApplication: data.host_application + ? unmarshalQualificationHostApplication(data.host_application) + : undefined, + hostWebsite: data.host_website + ? unmarshalQualificationHostWebsite(data.host_website) + : undefined, + otherUseCase: data.other_use_case + ? unmarshalQualificationOtherUseCase(data.other_use_case) + : undefined, + setScalewayEnvironment: data.set_scaleway_environment + ? unmarshalQualificationSetScalewayEnvironment( + data.set_scaleway_environment, + ) + : undefined, + shareData: data.share_data + ? unmarshalQualificationShareData(data.share_data) + : undefined, + } as Qualification +} + +export const unmarshalProject = (data: unknown): Project => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Project' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + description: data.description, + id: data.id, + name: data.name, + organizationId: data.organization_id, + qualification: data.qualification + ? unmarshalQualification(data.qualification) + : undefined, + updatedAt: unmarshalDate(data.updated_at), + } as Project +} + +export const unmarshalCheckContractSignatureResponse = ( + data: unknown, +): CheckContractSignatureResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'CheckContractSignatureResponse' failed as data isn't a dictionary.`, + ) + } + + return { + created: data.created, + validated: data.validated, + } as CheckContractSignatureResponse +} + +export const unmarshalListContractSignaturesResponse = ( + data: unknown, +): ListContractSignaturesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListContractSignaturesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + contractSignatures: unmarshalArrayOfObject( + data.contract_signatures, + unmarshalContractSignature, + ), + totalCount: data.total_count, + } as ListContractSignaturesResponse +} + +export const unmarshalListProjectsResponse = ( + data: unknown, +): ListProjectsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + projects: unmarshalArrayOfObject(data.projects, unmarshalProject), + totalCount: data.total_count, + } as ListProjectsResponse +} + +export const unmarshalProjectQualification = ( + data: unknown, +): ProjectQualification => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ProjectQualification' failed as data isn't a dictionary.`, + ) + } + + return { + projectId: data.project_id, + qualification: data.qualification + ? unmarshalQualification(data.qualification) + : undefined, + } as ProjectQualification +} + +export const marshalContractApiCheckContractSignatureRequest = ( + request: ContractApiCheckContractSignatureRequest, + defaults: DefaultValues, +): Record => ({ + contract_name: request.contractName, + contract_type: request.contractType, + organization_id: request.organizationId ?? defaults.defaultOrganizationId, +}) + +export const marshalContractApiCreateContractSignatureRequest = ( + request: ContractApiCreateContractSignatureRequest, + defaults: DefaultValues, +): Record => ({ + contract_name: request.contractName, + contract_type: request.contractType, + organization_id: request.organizationId ?? defaults.defaultOrganizationId, + validated: request.validated, +}) + +export const marshalProjectApiCreateProjectRequest = ( + request: ProjectApiCreateProjectRequest, + defaults: DefaultValues, +): Record => ({ + description: request.description, + name: request.name || randomName('proj'), + organization_id: request.organizationId ?? defaults.defaultOrganizationId, +}) + +const marshalQualificationAiMachine = ( + request: QualificationAiMachine, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationArchiveData = ( + request: QualificationArchiveData, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationContainer = ( + request: QualificationContainer, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationDeploySoftware = ( + request: QualificationDeploySoftware, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationHostApplication = ( + request: QualificationHostApplication, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationHostWebsite = ( + request: QualificationHostWebsite, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationOtherUseCase = ( + request: QualificationOtherUseCase, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationSetScalewayEnvironment = ( + request: QualificationSetScalewayEnvironment, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualificationShareData = ( + request: QualificationShareData, + defaults: DefaultValues, +): Record => ({ + sub_use_case: request.subUseCase, +}) + +const marshalQualification = ( + request: Qualification, + defaults: DefaultValues, +): Record => ({ + architecture_type: request.architectureType, + ...resolveOneOf([ + { + param: 'host_website', + value: + request.hostWebsite !== undefined + ? marshalQualificationHostWebsite(request.hostWebsite, defaults) + : undefined, + }, + { + param: 'host_application', + value: + request.hostApplication !== undefined + ? marshalQualificationHostApplication( + request.hostApplication, + defaults, + ) + : undefined, + }, + { + param: 'deploy_software', + value: + request.deploySoftware !== undefined + ? marshalQualificationDeploySoftware(request.deploySoftware, defaults) + : undefined, + }, + { + param: 'set_scaleway_environment', + value: + request.setScalewayEnvironment !== undefined + ? marshalQualificationSetScalewayEnvironment( + request.setScalewayEnvironment, + defaults, + ) + : undefined, + }, + { + param: 'ai_machine', + value: + request.aiMachine !== undefined + ? marshalQualificationAiMachine(request.aiMachine, defaults) + : undefined, + }, + { + param: 'container', + value: + request.container !== undefined + ? marshalQualificationContainer(request.container, defaults) + : undefined, + }, + { + param: 'archive_data', + value: + request.archiveData !== undefined + ? marshalQualificationArchiveData(request.archiveData, defaults) + : undefined, + }, + { + param: 'share_data', + value: + request.shareData !== undefined + ? marshalQualificationShareData(request.shareData, defaults) + : undefined, + }, + { + param: 'other_use_case', + value: + request.otherUseCase !== undefined + ? marshalQualificationOtherUseCase(request.otherUseCase, defaults) + : undefined, + }, + ]), +}) + +export const marshalProjectApiSetProjectQualificationRequest = ( + request: ProjectApiSetProjectQualificationRequest, + defaults: DefaultValues, +): Record => ({ + qualification: + request.qualification !== undefined + ? marshalQualification(request.qualification, defaults) + : undefined, +}) + +export const marshalProjectApiUpdateProjectRequest = ( + request: ProjectApiUpdateProjectRequest, + defaults: DefaultValues, +): Record => ({ + description: request.description, + name: request.name, +}) diff --git a/packages_generated/account/src/v3/types.gen.ts b/packages_generated/account/src/v3/types.gen.ts new file mode 100644 index 000000000..d4122f634 --- /dev/null +++ b/packages_generated/account/src/v3/types.gen.ts @@ -0,0 +1,433 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { LanguageCode as StdLanguageCode } from '@scaleway/sdk-std' + +export type ContractType = + | 'unknown_type' + | 'global' + | 'k8s' + | 'instance' + | 'container' + | 'baremetal' + +export type ListContractSignaturesRequestOrderBy = + | 'signed_at_asc' + | 'signed_at_desc' + | 'expires_at_asc' + | 'expires_at_desc' + | 'name_asc' + | 'name_desc' + +export type ListProjectsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +export type QualificationAiMachineSubUseCase = 'unknown_sub_use_case' + +export type QualificationArchitectureType = + | 'unknown_architecture_type' + | 'object_storage' + | 'web_hosting' + | 'instance' + | 'elastic' + | 'kubernetes' + | 'serverless' + | 'dedicated_server' + | 'other_architecture_type' + +export type QualificationArchiveDataSubUseCase = 'unknown_sub_use_case' + +export type QualificationContainerSubUseCase = 'unknown_sub_use_case' + +export type QualificationDeploySoftwareSubUseCase = 'unknown_sub_use_case' + +export type QualificationHostApplicationSubUseCase = + | 'unknown_sub_use_case' + | 'saas_app' + | 'government_app' + +export type QualificationHostWebsiteSubUseCase = + | 'unknown_sub_use_case' + | 'information_website' + | 'ecommerce_website' + | 'high_website' + | 'other_sub_use_case' + +export type QualificationOtherUseCaseSubUseCase = 'unknown_sub_use_case' + +export type QualificationSetScalewayEnvironmentSubUseCase = + 'unknown_sub_use_case' + +export type QualificationShareDataSubUseCase = 'unknown_sub_use_case' + +export interface QualificationAiMachine { + subUseCase: QualificationAiMachineSubUseCase +} + +export interface QualificationArchiveData { + subUseCase: QualificationArchiveDataSubUseCase +} + +export interface QualificationContainer { + subUseCase: QualificationContainerSubUseCase +} + +export interface QualificationDeploySoftware { + subUseCase: QualificationDeploySoftwareSubUseCase +} + +export interface QualificationHostApplication { + subUseCase: QualificationHostApplicationSubUseCase +} + +export interface QualificationHostWebsite { + subUseCase: QualificationHostWebsiteSubUseCase +} + +export interface QualificationOtherUseCase { + subUseCase: QualificationOtherUseCaseSubUseCase +} + +export interface QualificationSetScalewayEnvironment { + subUseCase: QualificationSetScalewayEnvironmentSubUseCase +} + +export interface QualificationShareData { + subUseCase: QualificationShareDataSubUseCase +} + +export interface Contract { + /** + * ID of the contract. + */ + id: string + /** + * The type of the contract. + */ + type: ContractType + /** + * The name of the contract. + */ + name: string + /** + * The version of the contract. + */ + version: number + /** + * The creation date of the contract. + */ + createdAt?: Date + /** + * The last modification date of the contract. + */ + updatedAt?: Date +} + +export interface Qualification { + /** + * Architecture type of the qualification. + */ + architectureType: QualificationArchitectureType + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + hostWebsite?: QualificationHostWebsite + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + hostApplication?: QualificationHostApplication + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + deploySoftware?: QualificationDeploySoftware + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + setScalewayEnvironment?: QualificationSetScalewayEnvironment + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + aiMachine?: QualificationAiMachine + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + container?: QualificationContainer + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + archiveData?: QualificationArchiveData + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + shareData?: QualificationShareData + /** + * + * One-of ('useCase'): at most one of 'hostWebsite', 'hostApplication', 'deploySoftware', 'setScalewayEnvironment', 'aiMachine', 'container', 'archiveData', 'shareData', 'otherUseCase' could be set. + */ + otherUseCase?: QualificationOtherUseCase +} + +export interface ContractSignature { + /** + * ID of the contract signature. + */ + id: string + /** + * The Organization ID which signed the contract. + */ + organizationId: string + /** + * The creation date of the contract signature. + */ + createdAt?: Date + /** + * The signing date of the contract signature. + */ + signedAt?: Date + /** + * The expiration date of the contract signature. + */ + expiresAt?: Date + /** + * The contract signed. + */ + contract?: Contract +} + +export interface Project { + /** + * ID of the Project. + */ + id: string + /** + * Name of the Project. + */ + name: string + /** + * Organization ID of the Project. + */ + organizationId: string + /** + * Creation date of the Project. + */ + createdAt?: Date + /** + * Update date of the Project. + */ + updatedAt?: Date + /** + * Description of the Project. + */ + description: string + /** + * Qualification of the Project. + */ + qualification?: Qualification +} + +export interface CheckContractSignatureResponse { + /** + * Whether a signature has been requested for this contract. + */ + created: boolean + /** + * Whether the signature for this contract has been validated. + */ + validated: boolean +} + +export type ContractApiCheckContractSignatureRequest = { + /** + * ID of the Organization to check the contract signature for. + */ + organizationId?: string + /** + * Filter on contract type. + */ + contractType?: ContractType + /** + * Filter on contract name. + */ + contractName: string +} + +export type ContractApiCreateContractSignatureRequest = { + /** + * The type of the contract. + */ + contractType?: ContractType + /** + * The name of the contract. + */ + contractName: string + /** + * Whether the contract is validated at creation. + */ + validated: boolean + /** + * ID of the Organization. + */ + organizationId?: string +} + +export type ContractApiDownloadContractSignatureRequest = { + /** + * The contract signature ID. + */ + contractSignatureId: string + /** + * The locale requested for the content of the contract. + */ + locale?: StdLanguageCode +} + +export type ContractApiListContractSignaturesRequest = { + /** + * The page number for the returned contracts. + */ + page?: number + /** + * The maximum number of contracts per page. + */ + pageSize?: number + /** + * How the contracts are ordered in the response. + */ + orderBy?: ListContractSignaturesRequestOrderBy + /** + * Filter on Organization ID. + */ + organizationId?: string +} + +export type ContractApiValidateContractSignatureRequest = { + /** + * The contract linked to your Organization you want to sign. + */ + contractSignatureId: string +} + +export interface ListContractSignaturesResponse { + /** + * The total number of contract signatures. + */ + totalCount: number + /** + * The paginated returned contract signatures. + */ + contractSignatures: ContractSignature[] +} + +export interface ListProjectsResponse { + /** + * Total number of Projects. + */ + totalCount: number + /** + * Paginated returned Projects. + */ + projects: Project[] +} + +export type ProjectApiCreateProjectRequest = { + /** + * Name of the Project. + */ + name?: string + /** + * Organization ID of the Project. + */ + organizationId?: string + /** + * Description of the Project. + */ + description: string +} + +export type ProjectApiDeleteProjectRequest = { + /** + * Project ID of the Project. + */ + projectId?: string +} + +export type ProjectApiGetProjectRequest = { + /** + * Project ID of the Project. + */ + projectId?: string +} + +export type ProjectApiListProjectsRequest = { + /** + * Organization ID of the Project. + */ + organizationId?: string + /** + * Name of the Project. + */ + name?: string + /** + * Page number for the returned Projects. + */ + page?: number + /** + * Maximum number of Project per page. + */ + pageSize?: number + /** + * Sort order of the returned Projects. + */ + orderBy?: ListProjectsRequestOrderBy + /** + * Project IDs to filter for. The results will be limited to any Projects with an ID in this array. + */ + projectIds?: string[] +} + +export type ProjectApiSetProjectQualificationRequest = { + /** + * Project ID. + */ + projectId?: string + /** + * Use case chosen for the Project. + */ + qualification?: Qualification +} + +export type ProjectApiUpdateProjectRequest = { + /** + * Project ID of the Project. + */ + projectId?: string + /** + * Name of the Project. + */ + name?: string + /** + * Description of the Project. + */ + description?: string +} + +export interface ProjectQualification { + /** + * Project ID. + */ + projectId: string + /** + * Qualification of the Project. + */ + qualification?: Qualification +} diff --git a/packages_generated/account/src/v3/validation-rules.gen.ts b/packages_generated/account/src/v3/validation-rules.gen.ts new file mode 100644 index 000000000..574b1d235 --- /dev/null +++ b/packages_generated/account/src/v3/validation-rules.gen.ts @@ -0,0 +1,61 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const ContractApiCheckContractSignatureRequest = { + contractName: { + minLength: 1, + }, +} + +export const ContractApiCreateContractSignatureRequest = { + contractName: { + minLength: 1, + }, +} + +export const ContractApiListContractSignaturesRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 100, + }, +} + +export const ProjectApiCreateProjectRequest = { + description: { + maxLength: 200, + }, + name: { + maxLength: 64, + minLength: 1, + pattern: /^[a-zA-Z0-9\._\- ]+$/, + }, +} + +export const ProjectApiListProjectsRequest = { + name: { + maxLength: 64, + minLength: 1, + pattern: /^[a-zA-Z0-9\._\- ]+$/, + }, + page: { + greaterThan: 0, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 100, + }, +} + +export const ProjectApiUpdateProjectRequest = { + description: { + maxLength: 200, + }, + name: { + maxLength: 64, + minLength: 1, + pattern: /^[a-zA-Z0-9\._\- ]+$/, + }, +} diff --git a/packages_generated/account/tsconfig.build.json b/packages_generated/account/tsconfig.build.json new file mode 100644 index 000000000..19ca82000 --- /dev/null +++ b/packages_generated/account/tsconfig.build.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "emitDeclarationOnly": true, + "rootDir": "src", + "outDir": "dist" + }, + "exclude": [ + "dist/*", + "*.config.ts", + "*.setup.ts", + "**/__tests__", + "**/__mocks__", + "src/**/*.test.tsx" + ] +} diff --git a/packages_generated/account/tsconfig.json b/packages_generated/account/tsconfig.json new file mode 100644 index 000000000..7c2b0759a --- /dev/null +++ b/packages_generated/account/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*.ts", "src/**/*.tsx", "*.config.ts"] +} diff --git a/packages_generated/account/vite.config.ts b/packages_generated/account/vite.config.ts new file mode 100644 index 000000000..5c0513828 --- /dev/null +++ b/packages_generated/account/vite.config.ts @@ -0,0 +1,14 @@ +/* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable import/no-default-export */ +/* eslint-disable import/no-relative-packages */ +/* eslint-disable import/no-extraneous-dependencies */ +import { defineConfig, mergeConfig } from 'vite' +import { defaultConfig } from '../../vite.config' + +export default mergeConfig(defineConfig(defaultConfig), { + build: { + lib: { + entry: 'src/index.gen.ts', + }, + }, +}) diff --git a/packages_generated/applesilicon/package.json b/packages_generated/applesilicon/package.json new file mode 100644 index 000000000..8dc823ee4 --- /dev/null +++ b/packages_generated/applesilicon/package.json @@ -0,0 +1,51 @@ +{ + "name": "@scaleway/sdk-applesilicon", + "version": "1.0.0", + "description": "Scaleway SDK applesilicon", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "type": "module", + "exports": { + ".": { + "types": "./dist/index.gen.d.ts", + "import": "./dist/index.gen.js", + "require": "./dist/index.gen.cjs", + "default": "./dist/index.gen.js" + }, + "./*": { + "types": "./dist/*/index.gen.d.ts", + "import": "./dist/*/index.gen.js", + "require": "./dist/*/index.gen.cjs", + "default": "./dist/*/index.gen.js" + } + }, + "repository": { + "type": "git", + "directory": "packages_generated/applesilicon" + }, + "engines": { + "node": ">=20.18.3" + }, + "scripts": { + "package:check": "pnpm publint", + "typecheck": "tsc --noEmit", + "type:generate": "tsc --declaration -p tsconfig.build.json", + "build": "vite build --config vite.config.ts && pnpm run type:generate", + "build:profile": "npx vite-bundle-visualizer -c vite.config.ts" + }, + "dependencies": { + "@scaleway/random-name": "5.1.1", + "@scaleway/sdk-std": "workspace:*" + }, + "peerDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "devDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "bundledDependencies": [ + "@scaleway/random-name" + ] +} \ No newline at end of file diff --git a/packages_generated/applesilicon/src/index.gen.ts b/packages_generated/applesilicon/src/index.gen.ts new file mode 100644 index 000000000..b1e66d2b5 --- /dev/null +++ b/packages_generated/applesilicon/src/index.gen.ts @@ -0,0 +1,6 @@ +/** + * This file is automatically generated + * PLEASE DO NOT EDIT HERE + */ + +export * as Applesiliconv1alpha1 from './v1alpha1/index.gen' diff --git a/packages_generated/applesilicon/src/v1alpha1/api.gen.ts b/packages_generated/applesilicon/src/v1alpha1/api.gen.ts new file mode 100644 index 000000000..44e13d811 --- /dev/null +++ b/packages_generated/applesilicon/src/v1alpha1/api.gen.ts @@ -0,0 +1,472 @@ +// 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 '@scaleway/sdk-client' +import type { Zone as ScwZone, WaitForOptions } from '@scaleway/sdk-client' +import { + SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES as SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES_APPLESILICON, + SERVER_TRANSIENT_STATUSES as SERVER_TRANSIENT_STATUSES_APPLESILICON, +} from './content.gen' +import { + marshalCreateServerRequest, + marshalPrivateNetworkApiAddServerPrivateNetworkRequest, + marshalPrivateNetworkApiSetServerPrivateNetworksRequest, + marshalReinstallServerRequest, + marshalStartConnectivityDiagnosticRequest, + marshalUpdateServerRequest, + unmarshalConnectivityDiagnostic, + unmarshalListOSResponse, + unmarshalListServerPrivateNetworksResponse, + unmarshalListServerTypesResponse, + unmarshalListServersResponse, + unmarshalOS, + unmarshalServer, + unmarshalServerPrivateNetwork, + unmarshalServerType, + unmarshalSetServerPrivateNetworksResponse, + unmarshalStartConnectivityDiagnosticResponse, +} from './marshalling.gen' +import type { + ConnectivityDiagnostic, + CreateServerRequest, + DeleteServerRequest, + GetConnectivityDiagnosticRequest, + GetOSRequest, + GetServerRequest, + GetServerTypeRequest, + ListOSRequest, + ListOSResponse, + ListServerPrivateNetworksResponse, + ListServerTypesRequest, + ListServerTypesResponse, + ListServersRequest, + ListServersResponse, + OS, + PrivateNetworkApiAddServerPrivateNetworkRequest, + PrivateNetworkApiDeleteServerPrivateNetworkRequest, + PrivateNetworkApiGetServerPrivateNetworkRequest, + PrivateNetworkApiListServerPrivateNetworksRequest, + PrivateNetworkApiSetServerPrivateNetworksRequest, + RebootServerRequest, + ReinstallServerRequest, + Server, + ServerPrivateNetwork, + ServerType, + SetServerPrivateNetworksResponse, + StartConnectivityDiagnosticRequest, + StartConnectivityDiagnosticResponse, + UpdateServerRequest, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Apple silicon API. + +This API allows you to manage your Apple silicon machines. + */ +export class API extends ParentAPI { + /** Lists the available zones of the API. */ + public static readonly LOCALITIES: ScwZone[] = ['fr-par-3'] + + /** + * List server types. List all technical details about Apple silicon server types available in the specified zone. Since there is only one Availability Zone for Apple silicon servers, the targeted value is `fr-par-3`. + * + * @param request - The request {@link ListServerTypesRequest} + * @returns A Promise of ListServerTypesResponse + */ + listServerTypes = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/server-types`, + }, + unmarshalListServerTypesResponse, + ) + + /** + * Get a server type. Get technical details (CPU, disk size etc.) of a server type. + * + * @param request - The request {@link GetServerTypeRequest} + * @returns A Promise of ServerType + */ + getServerType = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/server-type/${validatePathParam('serverType', request.serverType)}`, + }, + unmarshalServerType, + ) + + /** + * Create a server. Create a new server in the targeted zone, specifying its configuration including name and type. + * + * @param request - The request {@link CreateServerRequest} + * @returns A Promise of Server + */ + createServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers`, + }, + unmarshalServer, + ) + + protected pageOfListServers = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers`, + 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], + ), + }, + unmarshalListServersResponse, + ) + + /** + * List all servers. List all servers in the specified zone. By default, returned servers 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 ListServersRequest} + * @returns A Promise of ListServersResponse + */ + listServers = (request: Readonly = {}) => + enrichForPagination('servers', this.pageOfListServers, request) + + protected pageOfListOS = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/os`, + urlParams: urlParams( + ['name', request.name], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['server_type', request.serverType], + ), + }, + unmarshalListOSResponse, + ) + + /** + * List all Operating Systems (OS). List all Operating Systems (OS). The response will include the total number of OS as well as their associated IDs, names and labels. + * + * @param request - The request {@link ListOSRequest} + * @returns A Promise of ListOSResponse + */ + listOS = (request: Readonly = {}) => + enrichForPagination('os', this.pageOfListOS, request) + + /** + * Get an Operating System (OS). Get an Operating System (OS). The response will include the OS's unique ID as well as its name and label. + * + * @param request - The request {@link GetOSRequest} + * @returns A Promise of OS + */ + getOS = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/os/${validatePathParam('osId', request.osId)}`, + }, + unmarshalOS, + ) + + /** + * Get a server. Retrieve information about an existing Apple silicon server, specified by its server ID. Its full details, including name, status and IP address, are returned in the response object. + * + * @param request - The request {@link GetServerRequest} + * @returns A Promise of Server + */ + getServer = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`, + }, + unmarshalServer, + ) + + /** + * Waits for {@link Server} to be in a final state. + * + * @param request - The request {@link GetServerRequest} + * @param options - The waiting options + * @returns A Promise of Server + */ + waitForServer = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !SERVER_TRANSIENT_STATUSES_APPLESILICON.includes(res.status), + )), + this.getServer, + request, + options, + ) + + /** + * Update a server. Update the parameters of an existing Apple silicon server, specified by its server ID. + * + * @param request - The request {@link UpdateServerRequest} + * @returns A Promise of Server + */ + updateServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`, + }, + unmarshalServer, + ) + + /** + * Delete a server. Delete an existing Apple silicon server, specified by its server ID. Deleting a server is permanent, and cannot be undone. Note that the minimum allocation period for Apple silicon-as-a-service is 24 hours, meaning you cannot delete your server prior to that. + * + * @param request - The request {@link DeleteServerRequest} + */ + deleteServer = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`, + }) + + /** + * Reboot a server. Reboot an existing Apple silicon server, specified by its server ID. + * + * @param request - The request {@link RebootServerRequest} + * @returns A Promise of Server + */ + rebootServer = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reboot`, + }, + unmarshalServer, + ) + + /** + * Reinstall a server. Reinstall an existing Apple silicon server (specified by its server ID) from a new image (OS). All the data on the disk is deleted and all configuration is reset to the defailt configuration values of the image (OS). + * + * @param request - The request {@link ReinstallServerRequest} + * @returns A Promise of Server + */ + reinstallServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalReinstallServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reinstall`, + }, + unmarshalServer, + ) + + startConnectivityDiagnostic = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalStartConnectivityDiagnosticRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/connectivity-diagnostics`, + }, + unmarshalStartConnectivityDiagnosticResponse, + ) + + getConnectivityDiagnostic = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/connectivity-diagnostics/${validatePathParam('diagnosticId', request.diagnosticId)}`, + }, + unmarshalConnectivityDiagnostic, + ) +} + +/** + * Apple silicon - Private Networks API. + */ +export class PrivateNetworkAPI extends ParentAPI { + /** Lists the available zones of the API. */ + public static readonly LOCALITIES: ScwZone[] = ['fr-par-1', 'fr-par-3'] + + getServerPrivateNetwork = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`, + }, + unmarshalServerPrivateNetwork, + ) + + /** + * Waits for {@link ServerPrivateNetwork} to be in a final state. + * + * @param request - The request {@link PrivateNetworkApiGetServerPrivateNetworkRequest} + * @param options - The waiting options + * @returns A Promise of ServerPrivateNetwork + */ + waitForServerPrivateNetwork = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES_APPLESILICON.includes( + res.status, + ), + )), + this.getServerPrivateNetwork, + request, + options, + ) + + /** + * Add a server to a Private Network. Add an Apple silicon server to a Private Network. + * + * @param request - The request {@link PrivateNetworkApiAddServerPrivateNetworkRequest} + * @returns A Promise of ServerPrivateNetwork + */ + addServerPrivateNetwork = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalPrivateNetworkApiAddServerPrivateNetworkRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks`, + }, + unmarshalServerPrivateNetwork, + ) + + /** + * Set multiple Private Networks on a server. Configure multiple Private Networks on an Apple silicon server. + * + * @param request - The request {@link PrivateNetworkApiSetServerPrivateNetworksRequest} + * @returns A Promise of SetServerPrivateNetworksResponse + */ + setServerPrivateNetworks = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalPrivateNetworkApiSetServerPrivateNetworksRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'PUT', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks`, + }, + unmarshalSetServerPrivateNetworksResponse, + ) + + protected pageOfListServerPrivateNetworks = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/server-private-networks`, + urlParams: urlParams( + ['ipam_ip_ids', request.ipamIpIds], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['private_network_id', request.privateNetworkId], + ['project_id', request.projectId], + ['server_id', request.serverId], + ), + }, + unmarshalListServerPrivateNetworksResponse, + ) + + /** + * List the Private Networks of a server. List the Private Networks of an Apple silicon server. + * + * @param request - The request {@link PrivateNetworkApiListServerPrivateNetworksRequest} + * @returns A Promise of ListServerPrivateNetworksResponse + */ + listServerPrivateNetworks = ( + request: Readonly = {}, + ) => + enrichForPagination( + 'serverPrivateNetworks', + this.pageOfListServerPrivateNetworks, + request, + ) + + /** + * Delete a Private Network. + * + * @param request - The request {@link PrivateNetworkApiDeleteServerPrivateNetworkRequest} + */ + deleteServerPrivateNetwork = ( + request: Readonly, + ) => + this.client.fetch({ + method: 'DELETE', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`, + }) +} diff --git a/packages_generated/applesilicon/src/v1alpha1/content.gen.ts b/packages_generated/applesilicon/src/v1alpha1/content.gen.ts new file mode 100644 index 000000000..32e6d1259 --- /dev/null +++ b/packages_generated/applesilicon/src/v1alpha1/content.gen.ts @@ -0,0 +1,26 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { + ServerPrivateNetworkServerStatus, + ServerPrivateNetworkStatus, + ServerStatus, +} from './types.gen' + +/** Lists transient statutes of the enum {@link ServerPrivateNetworkServerStatus}. */ +export const SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES: ServerPrivateNetworkServerStatus[] = + ['attaching', 'detaching'] + +/** Lists transient statutes of the enum {@link ServerPrivateNetworkStatus}. */ +export const SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES: ServerPrivateNetworkStatus[] = + ['vpc_updating'] + +/** Lists transient statutes of the enum {@link ServerStatus}. */ +export const SERVER_TRANSIENT_STATUSES: ServerStatus[] = [ + 'starting', + 'rebooting', + 'updating', + 'locking', + 'unlocking', + 'reinstalling', + 'busy', +] diff --git a/packages_generated/applesilicon/src/v1alpha1/index.gen.ts b/packages_generated/applesilicon/src/v1alpha1/index.gen.ts new file mode 100644 index 000000000..9bf295e69 --- /dev/null +++ b/packages_generated/applesilicon/src/v1alpha1/index.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 { + API, + PrivateNetworkAPI, +} from './api.gen' +export * from './content.gen' +export * from './marshalling.gen' +export type { + Commitment, + CommitmentType, + CommitmentTypeValue, + ConnectivityDiagnostic, + ConnectivityDiagnosticActionType, + ConnectivityDiagnosticDiagnosticStatus, + ConnectivityDiagnosticServerHealth, + CreateServerRequest, + DeleteServerRequest, + GetConnectivityDiagnosticRequest, + GetOSRequest, + GetServerRequest, + GetServerTypeRequest, + ListOSRequest, + ListOSResponse, + ListServerPrivateNetworksRequestOrderBy, + ListServerPrivateNetworksResponse, + ListServerTypesRequest, + ListServerTypesResponse, + ListServersRequest, + ListServersRequestOrderBy, + ListServersResponse, + OS, + PrivateNetworkApiAddServerPrivateNetworkRequest, + PrivateNetworkApiDeleteServerPrivateNetworkRequest, + PrivateNetworkApiGetServerPrivateNetworkRequest, + PrivateNetworkApiListServerPrivateNetworksRequest, + PrivateNetworkApiSetServerPrivateNetworksRequest, + RebootServerRequest, + ReinstallServerRequest, + Server, + ServerPrivateNetwork, + ServerPrivateNetworkServerStatus, + ServerPrivateNetworkStatus, + ServerStatus, + ServerType, + ServerTypeCPU, + ServerTypeDisk, + ServerTypeGPU, + ServerTypeMemory, + ServerTypeNetwork, + ServerTypeStock, + SetServerPrivateNetworksResponse, + StartConnectivityDiagnosticRequest, + StartConnectivityDiagnosticResponse, + UpdateServerRequest, +} from './types.gen' diff --git a/packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts b/packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts new file mode 100644 index 000000000..a6b76829a --- /dev/null +++ b/packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts @@ -0,0 +1,402 @@ +// 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 '@scaleway/sdk-client' +import type { DefaultValues } from '@scaleway/sdk-client' +import type { + Commitment, + CommitmentTypeValue, + ConnectivityDiagnostic, + ConnectivityDiagnosticServerHealth, + CreateServerRequest, + ListOSResponse, + ListServerPrivateNetworksResponse, + ListServerTypesResponse, + ListServersResponse, + OS, + PrivateNetworkApiAddServerPrivateNetworkRequest, + PrivateNetworkApiSetServerPrivateNetworksRequest, + ReinstallServerRequest, + Server, + ServerPrivateNetwork, + ServerType, + ServerTypeCPU, + ServerTypeDisk, + ServerTypeGPU, + ServerTypeMemory, + ServerTypeNetwork, + SetServerPrivateNetworksResponse, + StartConnectivityDiagnosticRequest, + StartConnectivityDiagnosticResponse, + UpdateServerRequest, +} from './types.gen' + +export const unmarshalOS = (data: unknown): OS => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'OS' failed as data isn't a dictionary.`, + ) + } + + return { + compatibleServerTypes: data.compatible_server_types, + family: data.family, + id: data.id, + imageUrl: data.image_url, + isBeta: data.is_beta, + label: data.label, + name: data.name, + version: data.version, + xcodeVersion: data.xcode_version, + } as OS +} + +export const unmarshalServerPrivateNetwork = ( + data: unknown, +): ServerPrivateNetwork => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerPrivateNetwork' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + ipamIpIds: data.ipam_ip_ids, + privateNetworkId: data.private_network_id, + projectId: data.project_id, + serverId: data.server_id, + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + vlan: data.vlan, + } as ServerPrivateNetwork +} + +const unmarshalServerTypeCPU = (data: unknown): ServerTypeCPU => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerTypeCPU' failed as data isn't a dictionary.`, + ) + } + + return { + coreCount: data.core_count, + frequency: data.frequency, + name: data.name, + } as ServerTypeCPU +} + +const unmarshalServerTypeDisk = (data: unknown): ServerTypeDisk => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerTypeDisk' failed as data isn't a dictionary.`, + ) + } + + return { + capacity: data.capacity, + type: data.type, + } as ServerTypeDisk +} + +const unmarshalServerTypeGPU = (data: unknown): ServerTypeGPU => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerTypeGPU' failed as data isn't a dictionary.`, + ) + } + + return { + count: data.count, + } as ServerTypeGPU +} + +const unmarshalServerTypeMemory = (data: unknown): ServerTypeMemory => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerTypeMemory' failed as data isn't a dictionary.`, + ) + } + + return { + capacity: data.capacity, + type: data.type, + } as ServerTypeMemory +} + +const unmarshalServerTypeNetwork = (data: unknown): ServerTypeNetwork => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerTypeNetwork' failed as data isn't a dictionary.`, + ) + } + + return { + publicBandwidthBps: data.public_bandwidth_bps, + } as ServerTypeNetwork +} + +export const unmarshalServerType = (data: unknown): ServerType => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ServerType' failed as data isn't a dictionary.`, + ) + } + + return { + cpu: data.cpu ? unmarshalServerTypeCPU(data.cpu) : undefined, + defaultOs: data.default_os ? unmarshalOS(data.default_os) : undefined, + disk: data.disk ? unmarshalServerTypeDisk(data.disk) : undefined, + gpu: data.gpu ? unmarshalServerTypeGPU(data.gpu) : undefined, + memory: data.memory ? unmarshalServerTypeMemory(data.memory) : undefined, + minimumLeaseDuration: data.minimum_lease_duration, + name: data.name, + network: data.network + ? unmarshalServerTypeNetwork(data.network) + : undefined, + stock: data.stock, + } as ServerType +} + +const unmarshalCommitment = (data: unknown): Commitment => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Commitment' failed as data isn't a dictionary.`, + ) + } + + return { + cancelled: data.cancelled, + type: data.type, + } as Commitment +} + +export const unmarshalServer = (data: unknown): Server => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Server' failed as data isn't a dictionary.`, + ) + } + + return { + commitment: data.commitment + ? unmarshalCommitment(data.commitment) + : undefined, + createdAt: unmarshalDate(data.created_at), + deletableAt: unmarshalDate(data.deletable_at), + deletionScheduled: data.deletion_scheduled, + delivered: data.delivered, + id: data.id, + ip: data.ip, + name: data.name, + organizationId: data.organization_id, + os: data.os ? unmarshalOS(data.os) : undefined, + projectId: data.project_id, + sshUsername: data.ssh_username, + status: data.status, + sudoPassword: data.sudo_password, + type: data.type, + updatedAt: unmarshalDate(data.updated_at), + vncPort: data.vnc_port, + vncUrl: data.vnc_url, + vpcStatus: data.vpc_status, + zone: data.zone, + } as Server +} + +const unmarshalConnectivityDiagnosticServerHealth = ( + data: unknown, +): ConnectivityDiagnosticServerHealth => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ConnectivityDiagnosticServerHealth' failed as data isn't a dictionary.`, + ) + } + + return { + isAgentAlive: data.is_agent_alive, + isMdmAlive: data.is_mdm_alive, + isServerAlive: data.is_server_alive, + isSshPortUp: data.is_ssh_port_up, + isVncPortUp: data.is_vnc_port_up, + lastCheckinDate: unmarshalDate(data.last_checkin_date), + } as ConnectivityDiagnosticServerHealth +} + +export const unmarshalConnectivityDiagnostic = ( + data: unknown, +): ConnectivityDiagnostic => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ConnectivityDiagnostic' failed as data isn't a dictionary.`, + ) + } + + return { + errorMessage: data.error_message, + healthDetails: data.health_details + ? unmarshalConnectivityDiagnosticServerHealth(data.health_details) + : undefined, + id: data.id, + isHealthy: data.is_healthy, + status: data.status, + supportedActions: data.supported_actions, + } as ConnectivityDiagnostic +} + +export const unmarshalListOSResponse = (data: unknown): ListOSResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListOSResponse' failed as data isn't a dictionary.`, + ) + } + + return { + os: unmarshalArrayOfObject(data.os, unmarshalOS), + totalCount: data.total_count, + } as ListOSResponse +} + +export const unmarshalListServerPrivateNetworksResponse = ( + data: unknown, +): ListServerPrivateNetworksResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListServerPrivateNetworksResponse' failed as data isn't a dictionary.`, + ) + } + + return { + serverPrivateNetworks: unmarshalArrayOfObject( + data.server_private_networks, + unmarshalServerPrivateNetwork, + ), + totalCount: data.total_count, + } as ListServerPrivateNetworksResponse +} + +export const unmarshalListServerTypesResponse = ( + data: unknown, +): ListServerTypesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListServerTypesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + serverTypes: unmarshalArrayOfObject(data.server_types, unmarshalServerType), + } as ListServerTypesResponse +} + +export const unmarshalListServersResponse = ( + data: unknown, +): ListServersResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListServersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + servers: unmarshalArrayOfObject(data.servers, unmarshalServer), + totalCount: data.total_count, + } as ListServersResponse +} + +export const unmarshalSetServerPrivateNetworksResponse = ( + data: unknown, +): SetServerPrivateNetworksResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SetServerPrivateNetworksResponse' failed as data isn't a dictionary.`, + ) + } + + return { + serverPrivateNetworks: unmarshalArrayOfObject( + data.server_private_networks, + unmarshalServerPrivateNetwork, + ), + } as SetServerPrivateNetworksResponse +} + +export const unmarshalStartConnectivityDiagnosticResponse = ( + data: unknown, +): StartConnectivityDiagnosticResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'StartConnectivityDiagnosticResponse' failed as data isn't a dictionary.`, + ) + } + + return { + diagnosticId: data.diagnostic_id, + } as StartConnectivityDiagnosticResponse +} + +export const marshalCreateServerRequest = ( + request: CreateServerRequest, + defaults: DefaultValues, +): Record => ({ + commitment_type: request.commitmentType, + enable_vpc: request.enableVpc, + name: request.name || randomName('as'), + os_id: request.osId, + project_id: request.projectId ?? defaults.defaultProjectId, + type: request.type, +}) + +export const marshalPrivateNetworkApiAddServerPrivateNetworkRequest = ( + request: PrivateNetworkApiAddServerPrivateNetworkRequest, + defaults: DefaultValues, +): Record => ({ + ipam_ip_ids: request.ipamIpIds, + private_network_id: request.privateNetworkId, +}) + +export const marshalPrivateNetworkApiSetServerPrivateNetworksRequest = ( + request: PrivateNetworkApiSetServerPrivateNetworksRequest, + defaults: DefaultValues, +): Record => ({ + per_private_network_ipam_ip_ids: request.perPrivateNetworkIpamIpIds, +}) + +export const marshalReinstallServerRequest = ( + request: ReinstallServerRequest, + defaults: DefaultValues, +): Record => ({ + os_id: request.osId, +}) + +export const marshalStartConnectivityDiagnosticRequest = ( + request: StartConnectivityDiagnosticRequest, + defaults: DefaultValues, +): Record => ({ + server_id: request.serverId, +}) + +const marshalCommitmentTypeValue = ( + request: CommitmentTypeValue, + defaults: DefaultValues, +): Record => ({ + commitment_type: request.commitmentType, +}) + +export const marshalUpdateServerRequest = ( + request: UpdateServerRequest, + defaults: DefaultValues, +): Record => ({ + commitment_type: + request.commitmentType !== undefined + ? marshalCommitmentTypeValue(request.commitmentType, defaults) + : undefined, + enable_vpc: request.enableVpc, + name: request.name, + schedule_deletion: request.scheduleDeletion, +}) diff --git a/packages_generated/applesilicon/src/v1alpha1/types.gen.ts b/packages_generated/applesilicon/src/v1alpha1/types.gen.ts new file mode 100644 index 000000000..596d61f67 --- /dev/null +++ b/packages_generated/applesilicon/src/v1alpha1/types.gen.ts @@ -0,0 +1,647 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { Zone as ScwZone } from '@scaleway/sdk-client' + +export type CommitmentType = 'duration_24h' | 'renewed_monthly' | 'none' + +export type ConnectivityDiagnosticActionType = + | 'reboot_server' + | 'reinstall_server' + +export type ConnectivityDiagnosticDiagnosticStatus = + | 'unknown_status' + | 'processing' + | 'error' + | 'completed' + +export type ListServerPrivateNetworksRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'updated_at_asc' + | 'updated_at_desc' + +export type ListServersRequestOrderBy = 'created_at_asc' | 'created_at_desc' + +export type ServerPrivateNetworkServerStatus = + | 'unknown_status' + | 'attaching' + | 'attached' + | 'error' + | 'detaching' + | 'locked' + +export type ServerPrivateNetworkStatus = + | 'vpc_unknown_status' + | 'vpc_enabled' + | 'vpc_updating' + | 'vpc_disabled' + +export type ServerStatus = + | 'unknown_status' + | 'starting' + | 'ready' + | 'error' + | 'rebooting' + | 'updating' + | 'locking' + | 'locked' + | 'unlocking' + | 'reinstalling' + | 'busy' + +export type ServerTypeStock = + | 'unknown_stock' + | 'no_stock' + | 'low_stock' + | 'high_stock' + +export interface OS { + /** + * Unique ID of the OS. + */ + id: string + /** + * OS name. + */ + name: string + /** + * OS name as it should be displayed. + */ + label: string + /** + * URL of the image. + */ + imageUrl: string + /** + * The OS family to which this OS belongs, eg. 13 or 14. + */ + family: string + /** + * Describes if the OS is in beta. + */ + isBeta: boolean + /** + * The OS version number, eg. Sonoma has version number 14.3. + */ + version: string + /** + * The current xcode version for this OS. + */ + xcodeVersion: string + /** + * List of compatible server types. + */ + compatibleServerTypes: string[] +} + +export interface ServerTypeCPU { + name: string + coreCount: number + frequency: number +} + +export interface ServerTypeDisk { + capacity: number + type: string +} + +export interface ServerTypeGPU { + count: number +} + +export interface ServerTypeMemory { + capacity: number + type: string +} + +export interface ServerTypeNetwork { + publicBandwidthBps: number +} + +export interface Commitment { + type: CommitmentType + cancelled: boolean +} + +export interface ConnectivityDiagnosticServerHealth { + lastCheckinDate?: Date + isServerAlive: boolean + isAgentAlive: boolean + isMdmAlive: boolean + isSshPortUp: boolean + isVncPortUp: boolean +} + +export interface ServerPrivateNetwork { + /** + * ID of the Server-to-Private Network mapping. + */ + id: string + /** + * Private Network Project ID. + */ + projectId: string + /** + * Apple silicon server ID. + */ + serverId: string + /** + * Private Network ID. + */ + privateNetworkId: string + /** + * ID of the VLAN associated with the Private Network. + */ + vlan?: number + /** + * Configuration status of the Private Network. + */ + status: ServerPrivateNetworkServerStatus + /** + * Private Network creation date. + */ + createdAt?: Date + /** + * Date the Private Network was last modified. + */ + updatedAt?: Date + /** + * IPAM IP IDs of the server, if it has any. + */ + ipamIpIds: string[] +} + +export interface ServerType { + /** + * CPU description. + */ + cpu?: ServerTypeCPU + /** + * Size of the local disk of the server. + */ + disk?: ServerTypeDisk + /** + * Name of the type. + */ + name: string + /** + * Size of memory available. + */ + memory?: ServerTypeMemory + /** + * Current stock. + */ + stock: ServerTypeStock + /** + * Minimum duration of the lease in seconds (example. 3.4s). + */ + minimumLeaseDuration?: string + /** + * GPU description. + */ + gpu?: ServerTypeGPU + /** + * Network description. + */ + network?: ServerTypeNetwork + /** + * The default OS for this server type. + */ + defaultOs?: OS +} + +export interface Server { + /** + * UUID of the server. + */ + id: string + /** + * Type of the server. + */ + type: string + /** + * Name of the server. + */ + name: string + /** + * Project this server is associated with. + */ + projectId: string + /** + * Organization this server is associated with. + */ + organizationId: string + /** + * IPv4 address of the server. + */ + ip: string + /** + * Vnc:// URL to access Apple Remote Desktop. + */ + vncUrl: string + /** + * SSH Username for remote shell. + */ + sshUsername: string + /** + * Admin password required to execute commands. + */ + sudoPassword: string + /** + * VNC port to use for remote desktop connection. + */ + vncPort: number + /** + * Initially installed OS, this does not necessarily reflect the current OS version. + */ + os?: OS + /** + * Current status of the server. + */ + status: ServerStatus + /** + * Date on which the server was created. + */ + createdAt?: Date + /** + * Date on which the server was last updated. + */ + updatedAt?: Date + /** + * Date from which the server can be deleted. + */ + deletableAt?: Date + /** + * Set to true to mark the server for automatic deletion depending on `deletable_at` date. Set to false to cancel an existing deletion schedule. Leave unset otherwise. + */ + deletionScheduled: boolean + /** + * Zone of the server. + */ + zone: ScwZone + /** + * Set to true once the server has completed its provisioning steps and is ready to use. Some OS configurations might require a reinstallation of the server before delivery depending on the available stock. A reinstallation after the initial delivery will not change this flag and can be tracked using the server status. + */ + delivered: boolean + /** + * Activation status of optional Private Network feature support for this server. + */ + vpcStatus: ServerPrivateNetworkStatus + /** + * Commitment scheme applied to this server. + */ + commitment?: Commitment +} + +export interface CommitmentTypeValue { + commitmentType: CommitmentType +} + +export interface ConnectivityDiagnostic { + id: string + status: ConnectivityDiagnosticDiagnosticStatus + isHealthy: boolean + healthDetails?: ConnectivityDiagnosticServerHealth + supportedActions: ConnectivityDiagnosticActionType[] + errorMessage: string +} + +export type CreateServerRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * Create a server with this given name. + */ + name?: string + /** + * Create a server in the given project ID. + */ + projectId?: string + /** + * Create a server of the given type. + */ + type: string + /** + * Create a server & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time. + */ + osId?: string + /** + * Activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API. + */ + enableVpc: boolean + /** + * Activate commitment for this server. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. + */ + commitmentType?: CommitmentType +} + +export type DeleteServerRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * UUID of the server you want to delete. + */ + serverId: string +} + +export type GetConnectivityDiagnosticRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + diagnosticId: string +} + +export type GetOSRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * UUID of the OS you want to get. + */ + osId: string +} + +export type GetServerRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * UUID of the server you want to get. + */ + serverId: string +} + +export type GetServerTypeRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * Server type identifier. + */ + serverType: string +} + +export type ListOSRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * Positive integer to choose the page to return. + */ + page?: number + /** + * Positive integer lower or equal to 100 to select the number of items to return. + */ + pageSize?: number + /** + * List of compatible server types. + */ + serverType?: string + /** + * Filter OS by name (note that "11.1" will return "11.1.2" and "11.1" but not "12")). + */ + name?: string +} + +export interface ListOSResponse { + /** + * Total number of OS. + */ + totalCount: number + /** + * List of OS. + */ + os: OS[] +} + +export interface ListServerPrivateNetworksResponse { + serverPrivateNetworks: ServerPrivateNetwork[] + totalCount: number +} + +export type ListServerTypesRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone +} + +export interface ListServerTypesResponse { + /** + * Available server types. + */ + serverTypes: ServerType[] +} + +export type ListServersRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * Sort order of the returned servers. + */ + orderBy?: ListServersRequestOrderBy + /** + * Only list servers of this project ID. + */ + projectId?: string + /** + * Only list servers of this Organization ID. + */ + organizationId?: string + /** + * Positive integer to choose the page to return. + */ + page?: number + /** + * Positive integer lower or equal to 100 to select the number of items to return. + */ + pageSize?: number +} + +export interface ListServersResponse { + /** + * Total number of servers. + */ + totalCount: number + /** + * Paginated returned servers. + */ + servers: Server[] +} + +export type PrivateNetworkApiAddServerPrivateNetworkRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * ID of the server. + */ + serverId: string + /** + * ID of the Private Network. + */ + privateNetworkId: string + /** + * IPAM IDs of IPs to attach to the server. + */ + ipamIpIds?: string[] +} + +export type PrivateNetworkApiDeleteServerPrivateNetworkRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * ID of the server. + */ + serverId: string + /** + * ID of the Private Network. + */ + privateNetworkId: string +} + +export type PrivateNetworkApiGetServerPrivateNetworkRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + serverId: string + privateNetworkId: string +} + +export type PrivateNetworkApiListServerPrivateNetworksRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * Sort order for the returned Private Networks. + */ + orderBy?: ListServerPrivateNetworksRequestOrderBy + /** + * Page number for the returned Private Networks. + */ + page?: number + /** + * Maximum number of Private Networks per page. + */ + pageSize?: number + /** + * Filter Private Networks by server ID. + */ + serverId?: string + /** + * Filter Private Networks by Private Network ID. + */ + privateNetworkId?: string + /** + * Filter Private Networks by Organization ID. + */ + organizationId?: string + /** + * Filter Private Networks by Project ID. + */ + projectId?: string + /** + * Filter Private Networks by IPAM IP IDs. + */ + ipamIpIds?: string[] +} + +export type PrivateNetworkApiSetServerPrivateNetworksRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * ID of the server. + */ + serverId: string + /** + * Object where the keys are the IDs of Private Networks and the values are arrays of IPAM IDs representing the IPs to assign to this Apple silicon server on the Private Network. If the array supplied for a Private Network is empty, the next available IP from the Private Network's CIDR block will automatically be used for attachment. + */ + perPrivateNetworkIpamIpIds: Record +} + +export type RebootServerRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * UUID of the server you want to reboot. + */ + serverId: string +} + +export type ReinstallServerRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * UUID of the server you want to reinstall. + */ + serverId: string + /** + * Reinstall the server with the target OS, when no os_id provided the default OS for the server type is used. + */ + osId?: string +} + +export interface SetServerPrivateNetworksResponse { + serverPrivateNetworks: ServerPrivateNetwork[] +} + +export type StartConnectivityDiagnosticRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + serverId: string +} + +export interface StartConnectivityDiagnosticResponse { + diagnosticId: string +} + +export type UpdateServerRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * UUID of the server you want to update. + */ + serverId: string + /** + * Updated name for your server. + */ + name?: string + /** + * Specify whether the server should be flagged for automatic deletion. + */ + scheduleDeletion?: boolean + /** + * Activate or deactivate Private Network support for this server. + */ + enableVpc?: boolean + /** + * Change commitment. Use 'none' to automatically cancel a renewing commitment. + */ + commitmentType?: CommitmentTypeValue +} diff --git a/packages_generated/applesilicon/tsconfig.build.json b/packages_generated/applesilicon/tsconfig.build.json new file mode 100644 index 000000000..19ca82000 --- /dev/null +++ b/packages_generated/applesilicon/tsconfig.build.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "emitDeclarationOnly": true, + "rootDir": "src", + "outDir": "dist" + }, + "exclude": [ + "dist/*", + "*.config.ts", + "*.setup.ts", + "**/__tests__", + "**/__mocks__", + "src/**/*.test.tsx" + ] +} diff --git a/packages_generated/applesilicon/tsconfig.json b/packages_generated/applesilicon/tsconfig.json new file mode 100644 index 000000000..7c2b0759a --- /dev/null +++ b/packages_generated/applesilicon/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*.ts", "src/**/*.tsx", "*.config.ts"] +} diff --git a/packages_generated/applesilicon/vite.config.ts b/packages_generated/applesilicon/vite.config.ts new file mode 100644 index 000000000..5c0513828 --- /dev/null +++ b/packages_generated/applesilicon/vite.config.ts @@ -0,0 +1,14 @@ +/* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable import/no-default-export */ +/* eslint-disable import/no-relative-packages */ +/* eslint-disable import/no-extraneous-dependencies */ +import { defineConfig, mergeConfig } from 'vite' +import { defaultConfig } from '../../vite.config' + +export default mergeConfig(defineConfig(defaultConfig), { + build: { + lib: { + entry: 'src/index.gen.ts', + }, + }, +}) diff --git a/packages_generated/audit_trail/package.json b/packages_generated/audit_trail/package.json new file mode 100644 index 000000000..d5e160310 --- /dev/null +++ b/packages_generated/audit_trail/package.json @@ -0,0 +1,51 @@ +{ + "name": "@scaleway/sdk-audit-trail", + "version": "1.0.0", + "description": "Scaleway SDK audit-trail", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "type": "module", + "exports": { + ".": { + "types": "./dist/index.gen.d.ts", + "import": "./dist/index.gen.js", + "require": "./dist/index.gen.cjs", + "default": "./dist/index.gen.js" + }, + "./*": { + "types": "./dist/*/index.gen.d.ts", + "import": "./dist/*/index.gen.js", + "require": "./dist/*/index.gen.cjs", + "default": "./dist/*/index.gen.js" + } + }, + "repository": { + "type": "git", + "directory": "packages_generated/audit-trail" + }, + "engines": { + "node": ">=20.18.3" + }, + "scripts": { + "package:check": "pnpm publint", + "typecheck": "tsc --noEmit", + "type:generate": "tsc --declaration -p tsconfig.build.json", + "build": "vite build --config vite.config.ts && pnpm run type:generate", + "build:profile": "npx vite-bundle-visualizer -c vite.config.ts" + }, + "dependencies": { + "@scaleway/random-name": "5.1.1", + "@scaleway/sdk-std": "workspace:*" + }, + "peerDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "devDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "bundledDependencies": [ + "@scaleway/random-name" + ] +} \ No newline at end of file diff --git a/packages_generated/audit_trail/src/index.gen.ts b/packages_generated/audit_trail/src/index.gen.ts new file mode 100644 index 000000000..d3be480c3 --- /dev/null +++ b/packages_generated/audit_trail/src/index.gen.ts @@ -0,0 +1,6 @@ +/** + * This file is automatically generated + * PLEASE DO NOT EDIT HERE + */ + +export * as AuditTrailv1alpha1 from './v1alpha1/index.gen' diff --git a/packages_generated/audit_trail/src/v1alpha1/api.gen.ts b/packages_generated/audit_trail/src/v1alpha1/api.gen.ts new file mode 100644 index 000000000..b8001301b --- /dev/null +++ b/packages_generated/audit_trail/src/v1alpha1/api.gen.ts @@ -0,0 +1,83 @@ +// 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, + urlParams, + validatePathParam, +} from '@scaleway/sdk-client' +import type { Region as ScwRegion } from '@scaleway/sdk-client' +import { + unmarshalListEventsResponse, + unmarshalListProductsResponse, +} from './marshalling.gen' +import type { + ListEventsRequest, + ListEventsResponse, + ListProductsRequest, + ListProductsResponse, +} from './types.gen' + +/** + * Audit Trail API. + +This API allows you to ensure accountability and security by recording events and changes performed within your Scaleway Organization. + */ +export class API extends ParentAPI { + /** Lists the available regions of the API. */ + public static readonly LOCALITIES: ScwRegion[] = ['fr-par', 'nl-ams'] + + /** + * List events. Retrieve the list of Audit Trail events for a Scaleway Organization and/or Project. You must specify the `organization_id` and optionally, the `project_id`. + * + * @param request - The request {@link ListEventsRequest} + * @returns A Promise of ListEventsResponse + */ + listEvents = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/audit-trail/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/events`, + urlParams: urlParams( + ['method_name', request.methodName], + ['order_by', request.orderBy], + [ + 'organization_id', + request.organizationId ?? + this.client.settings.defaultOrganizationId, + ], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['page_token', request.pageToken], + ['product_name', request.productName], + ['project_id', request.projectId], + ['recorded_after', request.recordedAfter], + ['recorded_before', request.recordedBefore], + ['resource_type', request.resourceType], + ['service_name', request.serviceName], + ['status', request.status], + ), + }, + unmarshalListEventsResponse, + ) + + /** + * Retrieve the list of Scaleway resources for which you have Audit Trail events. + * + * @param request - The request {@link ListProductsRequest} + * @returns A Promise of ListProductsResponse + */ + listProducts = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/audit-trail/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/products`, + urlParams: urlParams([ + 'organization_id', + request.organizationId ?? this.client.settings.defaultOrganizationId, + ]), + }, + unmarshalListProductsResponse, + ) +} diff --git a/packages_generated/audit_trail/src/v1alpha1/index.gen.ts b/packages_generated/audit_trail/src/v1alpha1/index.gen.ts new file mode 100644 index 000000000..13a163525 --- /dev/null +++ b/packages_generated/audit_trail/src/v1alpha1/index.gen.ts @@ -0,0 +1,25 @@ +// 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 './marshalling.gen' +export type { + Event, + EventPrincipal, + KeyManagerKeyInfo, + KubernetesACLInfo, + KubernetesClusterInfo, + KubernetesNodeInfo, + KubernetesPoolInfo, + ListEventsRequest, + ListEventsRequestOrderBy, + ListEventsResponse, + ListProductsRequest, + ListProductsResponse, + Product, + ProductService, + Resource, + ResourceType, + SecretManagerSecretInfo, + SecretManagerSecretVersionInfo, +} from './types.gen' +export * as ValidationRules from './validation-rules.gen' diff --git a/packages_generated/audit_trail/src/v1alpha1/marshalling.gen.ts b/packages_generated/audit_trail/src/v1alpha1/marshalling.gen.ts new file mode 100644 index 000000000..021e723f6 --- /dev/null +++ b/packages_generated/audit_trail/src/v1alpha1/marshalling.gen.ts @@ -0,0 +1,256 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + isJSONObject, + unmarshalArrayOfObject, + unmarshalDate, +} from '@scaleway/sdk-client' +import type { + Event, + EventPrincipal, + KeyManagerKeyInfo, + KubernetesACLInfo, + KubernetesClusterInfo, + KubernetesNodeInfo, + KubernetesPoolInfo, + ListEventsResponse, + ListProductsResponse, + Product, + ProductService, + Resource, + SecretManagerSecretInfo, + SecretManagerSecretVersionInfo, +} from './types.gen' + +const unmarshalKeyManagerKeyInfo = (data: unknown): KeyManagerKeyInfo => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'KeyManagerKeyInfo' failed as data isn't a dictionary.`, + ) + } + + return {} as KeyManagerKeyInfo +} + +const unmarshalKubernetesACLInfo = (data: unknown): KubernetesACLInfo => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'KubernetesACLInfo' failed as data isn't a dictionary.`, + ) + } + + return {} as KubernetesACLInfo +} + +const unmarshalKubernetesClusterInfo = ( + data: unknown, +): KubernetesClusterInfo => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'KubernetesClusterInfo' failed as data isn't a dictionary.`, + ) + } + + return {} as KubernetesClusterInfo +} + +const unmarshalKubernetesNodeInfo = (data: unknown): KubernetesNodeInfo => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'KubernetesNodeInfo' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + name: data.name, + } as KubernetesNodeInfo +} + +const unmarshalKubernetesPoolInfo = (data: unknown): KubernetesPoolInfo => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'KubernetesPoolInfo' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + name: data.name, + } as KubernetesPoolInfo +} + +const unmarshalSecretManagerSecretInfo = ( + data: unknown, +): SecretManagerSecretInfo => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SecretManagerSecretInfo' failed as data isn't a dictionary.`, + ) + } + + return { + path: data.path, + } as SecretManagerSecretInfo +} + +const unmarshalSecretManagerSecretVersionInfo = ( + data: unknown, +): SecretManagerSecretVersionInfo => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'SecretManagerSecretVersionInfo' failed as data isn't a dictionary.`, + ) + } + + return { + revision: data.revision, + } as SecretManagerSecretVersionInfo +} + +const unmarshalEventPrincipal = (data: unknown): EventPrincipal => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'EventPrincipal' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + } as EventPrincipal +} + +export const unmarshalResource = (data: unknown): Resource => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Resource' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + deletedAt: unmarshalDate(data.deleted_at), + id: data.id, + keyManagerKeyInfo: data.key_manager_key_info + ? unmarshalKeyManagerKeyInfo(data.key_manager_key_info) + : undefined, + keymKeyInfo: data.keym_key_info + ? unmarshalKeyManagerKeyInfo(data.keym_key_info) + : undefined, + kubeAclInfo: data.kube_acl_info + ? unmarshalKubernetesACLInfo(data.kube_acl_info) + : undefined, + kubeClusterInfo: data.kube_cluster_info + ? unmarshalKubernetesClusterInfo(data.kube_cluster_info) + : undefined, + kubeNodeInfo: data.kube_node_info + ? unmarshalKubernetesNodeInfo(data.kube_node_info) + : undefined, + kubePoolInfo: data.kube_pool_info + ? unmarshalKubernetesPoolInfo(data.kube_pool_info) + : undefined, + name: data.name, + secmSecretInfo: data.secm_secret_info + ? unmarshalSecretManagerSecretInfo(data.secm_secret_info) + : undefined, + secmSecretVersionInfo: data.secm_secret_version_info + ? unmarshalSecretManagerSecretVersionInfo(data.secm_secret_version_info) + : undefined, + secretManagerSecretInfo: data.secret_manager_secret_info + ? unmarshalSecretManagerSecretInfo(data.secret_manager_secret_info) + : undefined, + secretManagerVersionInfo: data.secret_manager_version_info + ? unmarshalSecretManagerSecretVersionInfo( + data.secret_manager_version_info, + ) + : undefined, + type: data.type, + updatedAt: unmarshalDate(data.updated_at), + } as Resource +} + +export const unmarshalEvent = (data: unknown): Event => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Event' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + locality: data.locality, + methodName: data.method_name, + organizationId: data.organization_id, + principal: data.principal + ? unmarshalEventPrincipal(data.principal) + : undefined, + productName: data.product_name, + projectId: data.project_id, + recordedAt: unmarshalDate(data.recorded_at), + requestBody: data.request_body, + requestId: data.request_id, + resource: data.resource ? unmarshalResource(data.resource) : undefined, + resources: unmarshalArrayOfObject(data.resources, unmarshalResource), + serviceName: data.service_name, + sourceIp: data.source_ip, + statusCode: data.status_code, + userAgent: data.user_agent, + } as Event +} + +export const unmarshalListEventsResponse = ( + data: unknown, +): ListEventsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListEventsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + events: unmarshalArrayOfObject(data.events, unmarshalEvent), + nextPageToken: data.next_page_token, + } as ListEventsResponse +} + +const unmarshalProductService = (data: unknown): ProductService => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ProductService' failed as data isn't a dictionary.`, + ) + } + + return { + methods: data.methods, + name: data.name, + } as ProductService +} + +const unmarshalProduct = (data: unknown): Product => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Product' failed as data isn't a dictionary.`, + ) + } + + return { + name: data.name, + services: unmarshalArrayOfObject(data.services, unmarshalProductService), + title: data.title, + } as Product +} + +export const unmarshalListProductsResponse = ( + data: unknown, +): ListProductsResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListProductsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + products: unmarshalArrayOfObject(data.products, unmarshalProduct), + totalCount: data.total_count, + } as ListProductsResponse +} diff --git a/packages_generated/audit_trail/src/v1alpha1/types.gen.ts b/packages_generated/audit_trail/src/v1alpha1/types.gen.ts new file mode 100644 index 000000000..abf15d69b --- /dev/null +++ b/packages_generated/audit_trail/src/v1alpha1/types.gen.ts @@ -0,0 +1,281 @@ +// 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 as ScwRegion } from '@scaleway/sdk-client' + +export type ListEventsRequestOrderBy = 'recorded_at_desc' | 'recorded_at_asc' + +export type ResourceType = + | 'unknown_type' + | 'secm_secret' + | 'secm_secret_version' + | 'kube_cluster' + | 'kube_pool' + | 'kube_node' + | 'kube_acl' + | 'keym_key' + | 'iam_user' + | 'iam_application' + | 'iam_group' + | 'iam_policy' + | 'iam_api_key' + | 'iam_ssh_key' + | 'iam_rule' + | 'secret_manager_secret' + | 'secret_manager_version' + | 'key_manager_key' + +export interface KeyManagerKeyInfo {} + +export interface KubernetesACLInfo {} + +export interface KubernetesClusterInfo {} + +export interface KubernetesNodeInfo { + id: string + name: string +} + +export interface KubernetesPoolInfo { + id: string + name: string +} + +export interface SecretManagerSecretInfo { + path: string +} + +export interface SecretManagerSecretVersionInfo { + revision: number +} + +export interface EventPrincipal { + id: string +} + +export interface Resource { + id: string + type: ResourceType + createdAt?: Date + updatedAt?: Date + deletedAt?: Date + name?: string + /** + * @deprecated + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + secmSecretInfo?: SecretManagerSecretInfo + /** + * @deprecated + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + secmSecretVersionInfo?: SecretManagerSecretVersionInfo + /** + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + kubeClusterInfo?: KubernetesClusterInfo + /** + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + kubePoolInfo?: KubernetesPoolInfo + /** + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + kubeNodeInfo?: KubernetesNodeInfo + /** + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + kubeAclInfo?: KubernetesACLInfo + /** + * @deprecated + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + keymKeyInfo?: KeyManagerKeyInfo + /** + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + secretManagerSecretInfo?: SecretManagerSecretInfo + /** + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + secretManagerVersionInfo?: SecretManagerSecretVersionInfo + /** + * + * One-of ('info'): at most one of 'secmSecretInfo', 'secmSecretVersionInfo', 'kubeClusterInfo', 'kubePoolInfo', 'kubeNodeInfo', 'kubeAclInfo', 'keymKeyInfo', 'secretManagerSecretInfo', 'secretManagerVersionInfo', 'keyManagerKeyInfo' could be set. + */ + keyManagerKeyInfo?: KeyManagerKeyInfo +} + +export interface ProductService { + name: string + methods: string[] +} + +export interface Event { + /** + * ID of the event. + */ + id: string + /** + * Timestamp of the event. + */ + recordedAt?: Date + /** + * Locality of the resource attached to the event. + */ + locality: string + /** + * User or IAM application at the origin of the event. + */ + principal?: EventPrincipal + /** + * Organization ID containing the event. + */ + organizationId: string + /** + * (Optional) Project of the resource attached to the event. + */ + projectId?: string + /** + * IP address at the origin of the event. + */ + sourceIp: string + /** + * User Agent at the origin of the event. + */ + userAgent?: string + /** + * Product name of the resource attached to the event. + */ + productName: string + /** + * API name called to trigger the event. + */ + serviceName: string + /** + * API method called to trigger the event. + */ + methodName: string + /** + * @deprecated Resource attached to the event. + */ + resource?: Resource + /** + * Resources attached to the event. + */ + resources: Resource[] + /** + * Unique identifier of the request at the origin of the event. + */ + requestId: string + /** + * Request at the origin of the event. + */ + requestBody?: Record + /** + * HTTP status code resulting of the API call. + */ + statusCode: number +} + +export interface Product { + /** + * Product title. + */ + title: string + /** + * Product name. + */ + name: string + /** + * Specifies the API versions of the products integrated with Audit Trail. Each version defines the methods logged by Audit Trail. + */ + services: ProductService[] +} + +export type ListEventsRequest = { + /** + * Region to target. If none is passed will use default region from the config. + */ + region?: ScwRegion + /** + * (Optional) ID of the Project containing the Audit Trail events. + */ + projectId?: string + /** + * ID of the Organization containing the Audit Trail events. + */ + organizationId?: string + /** + * (Optional) Returns a paginated list of Scaleway resources' features. + */ + resourceType?: ResourceType + /** + * (Optional) Name of the method of the API call performed. + */ + methodName?: string + /** + * (Optional) HTTP status code of the request. Returns either `200` if the request was successful or `403` if the permission was denied. + */ + status?: number + /** + * (Optional) The `recorded_after` parameter defines the earliest timestamp from which Audit Trail events are retrieved. Returns `one hour ago` by default. + */ + recordedAfter?: Date + /** + * (Optional) The `recorded_before` parameter defines the latest timestamp up to which Audit Trail events are retrieved. Returns `now` by default. + */ + recordedBefore?: Date + orderBy?: ListEventsRequestOrderBy + pageSize?: number + pageToken?: string + /** + * (Optional) Name of the Scaleway resource in a hyphenated format. + */ + productName?: string + /** + * (Optional) Name of the service of the API call performed. + */ + serviceName?: string +} + +export interface ListEventsResponse { + /** + * Single page of events matching the requested criteria. + */ + events: Event[] + /** + * Page token to use in following calls to keep listing. + */ + nextPageToken?: string +} + +export type ListProductsRequest = { + /** + * Region to target. If none is passed will use default region from the config. + */ + region?: ScwRegion + /** + * ID of the Organization containing the Audit Trail events. + */ + organizationId?: string +} + +export interface ListProductsResponse { + /** + * List of all products integrated with Audit Trail. + */ + products: Product[] + /** + * Number of integrated products. + */ + totalCount: number +} diff --git a/packages_generated/audit_trail/src/v1alpha1/validation-rules.gen.ts b/packages_generated/audit_trail/src/v1alpha1/validation-rules.gen.ts new file mode 100644 index 000000000..fa8165043 --- /dev/null +++ b/packages_generated/audit_trail/src/v1alpha1/validation-rules.gen.ts @@ -0,0 +1,22 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export const ListEventsRequest = { + methodName: { + pattern: /^[a-zA-Z][a-zA-Z0-9_]*$/, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 1000, + }, + productName: { + pattern: /^[a-z]+(-[a-z]+)*$/, + }, + serviceName: { + pattern: /^scaleway(\.[a-zA-Z0-9_-]*)*$/, + }, + status: { + greaterThanOrEqual: 200, + lessThan: 600, + }, +} diff --git a/packages_generated/audit_trail/tsconfig.build.json b/packages_generated/audit_trail/tsconfig.build.json new file mode 100644 index 000000000..19ca82000 --- /dev/null +++ b/packages_generated/audit_trail/tsconfig.build.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "emitDeclarationOnly": true, + "rootDir": "src", + "outDir": "dist" + }, + "exclude": [ + "dist/*", + "*.config.ts", + "*.setup.ts", + "**/__tests__", + "**/__mocks__", + "src/**/*.test.tsx" + ] +} diff --git a/packages_generated/audit_trail/tsconfig.json b/packages_generated/audit_trail/tsconfig.json new file mode 100644 index 000000000..7c2b0759a --- /dev/null +++ b/packages_generated/audit_trail/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*.ts", "src/**/*.tsx", "*.config.ts"] +} diff --git a/packages_generated/audit_trail/vite.config.ts b/packages_generated/audit_trail/vite.config.ts new file mode 100644 index 000000000..5c0513828 --- /dev/null +++ b/packages_generated/audit_trail/vite.config.ts @@ -0,0 +1,14 @@ +/* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable import/no-default-export */ +/* eslint-disable import/no-relative-packages */ +/* eslint-disable import/no-extraneous-dependencies */ +import { defineConfig, mergeConfig } from 'vite' +import { defaultConfig } from '../../vite.config' + +export default mergeConfig(defineConfig(defaultConfig), { + build: { + lib: { + entry: 'src/index.gen.ts', + }, + }, +}) diff --git a/packages_generated/baremetal/package.json b/packages_generated/baremetal/package.json new file mode 100644 index 000000000..fb1970529 --- /dev/null +++ b/packages_generated/baremetal/package.json @@ -0,0 +1,51 @@ +{ + "name": "@scaleway/sdk-baremetal", + "version": "1.0.0", + "description": "Scaleway SDK baremetal", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "type": "module", + "exports": { + ".": { + "types": "./dist/index.gen.d.ts", + "import": "./dist/index.gen.js", + "require": "./dist/index.gen.cjs", + "default": "./dist/index.gen.js" + }, + "./*": { + "types": "./dist/*/index.gen.d.ts", + "import": "./dist/*/index.gen.js", + "require": "./dist/*/index.gen.cjs", + "default": "./dist/*/index.gen.js" + } + }, + "repository": { + "type": "git", + "directory": "packages_generated/baremetal" + }, + "engines": { + "node": ">=20.18.3" + }, + "scripts": { + "package:check": "pnpm publint", + "typecheck": "tsc --noEmit", + "type:generate": "tsc --declaration -p tsconfig.build.json", + "build": "vite build --config vite.config.ts && pnpm run type:generate", + "build:profile": "npx vite-bundle-visualizer -c vite.config.ts" + }, + "dependencies": { + "@scaleway/random-name": "5.1.1", + "@scaleway/sdk-std": "workspace:*" + }, + "peerDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "devDependencies": { + "@scaleway/sdk-client": "^1.1.1" + }, + "bundledDependencies": [ + "@scaleway/random-name" + ] +} \ No newline at end of file diff --git a/packages_generated/baremetal/src/index.gen.ts b/packages_generated/baremetal/src/index.gen.ts new file mode 100644 index 000000000..12455ea36 --- /dev/null +++ b/packages_generated/baremetal/src/index.gen.ts @@ -0,0 +1,7 @@ +/** + * This file is automatically generated + * PLEASE DO NOT EDIT HERE + */ + +export * as Baremetalv1 from './v1/index.gen' +export * as Baremetalv3 from './v3/index.gen' diff --git a/packages_generated/baremetal/src/v1/api.gen.ts b/packages_generated/baremetal/src/v1/api.gen.ts new file mode 100644 index 000000000..063922a81 --- /dev/null +++ b/packages_generated/baremetal/src/v1/api.gen.ts @@ -0,0 +1,794 @@ +// 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 '@scaleway/sdk-client' +import type { Zone as ScwZone, WaitForOptions } from '@scaleway/sdk-client' +import { SERVER_TRANSIENT_STATUSES as SERVER_TRANSIENT_STATUSES_BAREMETAL } from './content.gen' +import { + marshalAddOptionServerRequest, + marshalCreateServerRequest, + marshalInstallServerRequest, + marshalPrivateNetworkApiAddServerPrivateNetworkRequest, + marshalPrivateNetworkApiSetServerPrivateNetworksRequest, + marshalRebootServerRequest, + marshalStartBMCAccessRequest, + marshalStartServerRequest, + marshalUpdateIPRequest, + marshalUpdateServerRequest, + marshalUpdateSettingRequest, + marshalValidatePartitioningSchemaRequest, + unmarshalBMCAccess, + unmarshalGetServerMetricsResponse, + unmarshalIP, + unmarshalListOSResponse, + unmarshalListOffersResponse, + unmarshalListOptionsResponse, + unmarshalListServerEventsResponse, + unmarshalListServerPrivateNetworksResponse, + unmarshalListServersResponse, + unmarshalListSettingsResponse, + unmarshalOS, + unmarshalOffer, + unmarshalOption, + unmarshalSchema, + unmarshalServer, + unmarshalServerPrivateNetwork, + unmarshalSetServerPrivateNetworksResponse, + unmarshalSetting, +} from './marshalling.gen' +import type { + AddOptionServerRequest, + BMCAccess, + CreateServerRequest, + DeleteOptionServerRequest, + DeleteServerRequest, + GetBMCAccessRequest, + GetDefaultPartitioningSchemaRequest, + GetOSRequest, + GetOfferRequest, + GetOptionRequest, + GetServerMetricsRequest, + GetServerMetricsResponse, + GetServerRequest, + IP, + InstallServerRequest, + ListOSRequest, + ListOSResponse, + ListOffersRequest, + ListOffersResponse, + ListOptionsRequest, + ListOptionsResponse, + ListServerEventsRequest, + ListServerEventsResponse, + ListServerPrivateNetworksResponse, + ListServersRequest, + ListServersResponse, + ListSettingsRequest, + ListSettingsResponse, + MigrateServerToMonthlyOfferRequest, + OS, + Offer, + Option, + PrivateNetworkApiAddServerPrivateNetworkRequest, + PrivateNetworkApiDeleteServerPrivateNetworkRequest, + PrivateNetworkApiListServerPrivateNetworksRequest, + PrivateNetworkApiSetServerPrivateNetworksRequest, + RebootServerRequest, + Schema, + Server, + ServerPrivateNetwork, + SetServerPrivateNetworksResponse, + Setting, + StartBMCAccessRequest, + StartServerRequest, + StopBMCAccessRequest, + StopServerRequest, + UpdateIPRequest, + UpdateServerRequest, + UpdateSettingRequest, + ValidatePartitioningSchemaRequest, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Elastic Metal API. + +This API allows you to manage your Elastic Metal servers. + */ +export class API extends ParentAPI { + /** Lists the available zones of the API. */ + public static readonly LOCALITIES: ScwZone[] = [ + 'fr-par-1', + 'fr-par-2', + 'nl-ams-1', + 'nl-ams-2', + 'pl-waw-2', + 'pl-waw-3', + ] + + protected pageOfListServers = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers`, + urlParams: urlParams( + ['name', request.name], + ['option_id', request.optionId], + ['order_by', request.orderBy], + ['organization_id', request.organizationId], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['project_id', request.projectId], + ['status', request.status], + ['tags', request.tags], + ), + }, + unmarshalListServersResponse, + ) + + /** + * List Elastic Metal servers for an Organization. List Elastic Metal servers for a specific Organization. + * + * @param request - The request {@link ListServersRequest} + * @returns A Promise of ListServersResponse + */ + listServers = (request: Readonly = {}) => + enrichForPagination('servers', this.pageOfListServers, request) + + /** + * Get a specific Elastic Metal server. Get full details of an existing Elastic Metal server associated with the ID. + * + * @param request - The request {@link GetServerRequest} + * @returns A Promise of Server + */ + getServer = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`, + }, + unmarshalServer, + ) + + /** + * Waits for {@link Server} to be in a final state. + * + * @param request - The request {@link GetServerRequest} + * @param options - The waiting options + * @returns A Promise of Server + */ + waitForServer = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !SERVER_TRANSIENT_STATUSES_BAREMETAL.includes(res.status), + )), + this.getServer, + request, + options, + ) + + /** + * Create an Elastic Metal server. Create a new Elastic Metal server. Once the server is created, proceed with the [installation of an OS](#post-3e949e). + * + * @param request - The request {@link CreateServerRequest} + * @returns A Promise of Server + */ + createServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers`, + }, + unmarshalServer, + ) + + /** + * Update an Elastic Metal server. Update the server associated with the ID. You can update parameters such as the server's name, tags and description. Any parameters left null in the request body are not updated. + * + * @param request - The request {@link UpdateServerRequest} + * @returns A Promise of Server + */ + updateServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`, + }, + unmarshalServer, + ) + + /** + * Install an Elastic Metal server. Install an Operating System (OS) on the Elastic Metal server with a specific ID. + * + * @param request - The request {@link InstallServerRequest} + * @returns A Promise of Server + */ + installServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalInstallServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/install`, + }, + unmarshalServer, + ) + + /** + * Return server metrics. Get the ping status of the server associated with the ID. + * + * @param request - The request {@link GetServerMetricsRequest} + * @returns A Promise of GetServerMetricsResponse + */ + getServerMetrics = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/metrics`, + }, + unmarshalGetServerMetricsResponse, + ) + + /** + * Delete an Elastic Metal server. Delete the server associated with the ID. + * + * @param request - The request {@link DeleteServerRequest} + * @returns A Promise of Server + */ + deleteServer = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`, + }, + unmarshalServer, + ) + + /** + * Reboot an Elastic Metal server. Reboot the Elastic Metal server associated with the ID, use the `boot_type` `rescue` to reboot the server in rescue mode. + * + * @param request - The request {@link RebootServerRequest} + * @returns A Promise of Server + */ + rebootServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalRebootServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reboot`, + }, + unmarshalServer, + ) + + /** + * Start an Elastic Metal server. Start the server associated with the ID. + * + * @param request - The request {@link StartServerRequest} + * @returns A Promise of Server + */ + startServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalStartServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/start`, + }, + unmarshalServer, + ) + + /** + * Stop an Elastic Metal server. Stop the server associated with the ID. The server remains allocated to your account and all data remains on the local storage of the server. + * + * @param request - The request {@link StopServerRequest} + * @returns A Promise of Server + */ + stopServer = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/stop`, + }, + unmarshalServer, + ) + + protected pageOfListServerEvents = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/events`, + urlParams: urlParams( + ['order_by', request.orderBy], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListServerEventsResponse, + ) + + /** + * List server events. List event (i.e. start/stop/reboot) associated to the server ID. + * + * @param request - The request {@link ListServerEventsRequest} + * @returns A Promise of ListServerEventsResponse + */ + listServerEvents = (request: Readonly) => + enrichForPagination('events', this.pageOfListServerEvents, request) + + /** + * Get default partitioning schema. Get the default partitioning schema for the given offer ID and OS ID. + * + * @param request - The request {@link GetDefaultPartitioningSchemaRequest} + * @returns A Promise of Schema + */ + getDefaultPartitioningSchema = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/partitioning-schemas/default`, + urlParams: urlParams( + ['offer_id', request.offerId], + ['os_id', request.osId], + ), + }, + unmarshalSchema, + ) + + /** + * Validate client partitioning schema. Validate the incoming partitioning schema from a user before installing the server. Return default ErrorCode if invalid. + * + * @param request - The request {@link ValidatePartitioningSchemaRequest} + */ + validatePartitioningSchema = ( + request: Readonly, + ) => + this.client.fetch({ + body: JSON.stringify( + marshalValidatePartitioningSchemaRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/partitioning-schemas/validate`, + }) + + /** + * Start BMC access. Start BMC (Baseboard Management Controller) access associated with the ID. +The BMC (Baseboard Management Controller) access is available one hour after the installation of the server. +You need first to create an option Remote Access. You will find the ID and the price with a call to listOffers (https://developers.scaleway.com/en/products/baremetal/api/#get-78db92). Then add the option https://developers.scaleway.com/en/products/baremetal/api/#post-b14abd. +After adding the BMC option, you need to Get Remote Access to get the login/password https://developers.scaleway.com/en/products/baremetal/api/#get-cefc0f. Do not forget to delete the Option after use. + * + * @param request - The request {@link StartBMCAccessRequest} + * @returns A Promise of BMCAccess + */ + startBMCAccess = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalStartBMCAccessRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/bmc-access`, + }, + unmarshalBMCAccess, + ) + + /** + * Get BMC access. Get the BMC (Baseboard Management Controller) access associated with the ID, including the URL and login information needed to connect. + * + * @param request - The request {@link GetBMCAccessRequest} + * @returns A Promise of BMCAccess + */ + getBMCAccess = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/bmc-access`, + }, + unmarshalBMCAccess, + ) + + /** + * Stop BMC access. Stop BMC (Baseboard Management Controller) access associated with the ID. + * + * @param request - The request {@link StopBMCAccessRequest} + */ + stopBMCAccess = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/bmc-access`, + }) + + /** + * Update IP. Configure the IP address associated with the server ID and IP ID. You can use this method to set a reverse DNS for an IP address. + * + * @param request - The request {@link UpdateIPRequest} + * @returns A Promise of IP + */ + updateIP = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateIPRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/ips/${validatePathParam('ipId', request.ipId)}`, + }, + unmarshalIP, + ) + + /** + * Add server option. Add an option, such as Private Networks, to a specific server. + * + * @param request - The request {@link AddOptionServerRequest} + * @returns A Promise of Server + */ + addOptionServer = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalAddOptionServerRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/options/${validatePathParam('optionId', request.optionId)}`, + }, + unmarshalServer, + ) + + /** + * Delete server option. Delete an option from a specific server. + * + * @param request - The request {@link DeleteOptionServerRequest} + * @returns A Promise of Server + */ + deleteOptionServer = (request: Readonly) => + this.client.fetch( + { + method: 'DELETE', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/options/${validatePathParam('optionId', request.optionId)}`, + }, + unmarshalServer, + ) + + /** + * Migrate server offer. Migrate server with hourly offer to monthly offer. + * + * @param request - The request {@link MigrateServerToMonthlyOfferRequest} + * @returns A Promise of Server + */ + migrateServerToMonthlyOffer = ( + request: Readonly, + ) => + this.client.fetch( + { + method: 'POST', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/migrate-offer-monthly`, + }, + unmarshalServer, + ) + + protected pageOfListOffers = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/offers`, + urlParams: urlParams( + ['name', request.name], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ['subscription_period', request.subscriptionPeriod], + ), + }, + unmarshalListOffersResponse, + ) + + /** + * List offers. List all available Elastic Metal server configurations. + * + * @param request - The request {@link ListOffersRequest} + * @returns A Promise of ListOffersResponse + */ + listOffers = (request: Readonly = {}) => + enrichForPagination('offers', this.pageOfListOffers, request) + + /** + * Get offer. Get details of an offer identified by its offer ID. + * + * @param request - The request {@link GetOfferRequest} + * @returns A Promise of Offer + */ + getOffer = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/offers/${validatePathParam('offerId', request.offerId)}`, + }, + unmarshalOffer, + ) + + /** + * Get option. Return specific option for the ID. + * + * @param request - The request {@link GetOptionRequest} + * @returns A Promise of Option + */ + getOption = (request: Readonly) => + this.client.fetch