From 97a283001743bfe601ef5c3c33a3f2d15816f583 Mon Sep 17 00:00:00 2001 From: Theophilus Okwugwuni Date: Tue, 7 May 2024 13:58:34 +0100 Subject: [PATCH] [GPS-400] setup (#1) * generate client * setup ci * fix ci * add check workflow * update check action * update readme * add error handling to readme * remove dry-run --- .github/workflows/check.yaml | 40 + .github/workflows/release.yaml | 47 + .gitignore | 132 ++ .nvmrc | 1 + README.md | 171 ++ generate.mjs | 51 + package.json | 27 + pnpm-lock.yaml | 600 +++++++ src/GenesisCloudClient.ts | 64 + src/core/ApiError.ts | 25 + src/core/ApiRequestOptions.ts | 20 + src/core/ApiResult.ts | 7 + src/core/BaseHttpRequest.ts | 9 + src/core/CancelablePromise.ts | 126 ++ src/core/FetchHttpRequest.ts | 21 + src/core/OpenAPI.ts | 53 + src/core/request.ts | 389 +++++ src/index.ts | 10 + src/models/Catalog.ts | 43 + src/models/Catalog_Fields.ts | 11 + src/models/Error.ts | 17 + src/models/Filesystem.ts | 39 + src/models/FilesystemId.ts | 10 + src/models/FilesystemType.ts | 9 + src/models/Filesystem_Status.ts | 6 + src/models/FloatingIP.ts | 57 + src/models/FloatingIp_Status.ts | 9 + src/models/Image.ts | 32 + src/models/ImageId.ts | 9 + src/models/Image_Type.ts | 13 + src/models/Instance.ts | 97 ++ src/models/Instance_Action.ts | 6 + src/models/Instance_BillingType.ts | 15 + src/models/Instance_DestroyOnShutdown.ts | 10 + src/models/Instance_FloatingIp.ts | 9 + src/models/Instance_Hostname.ts | 9 + src/models/Instance_IsProtected.ts | 12 + src/models/Instance_Name.ts | 9 + src/models/Instance_PublicIpv6.ts | 10 + .../Instance_ReuseLongTermSubscription.ts | 11 + src/models/Instance_SSHKeyId.ts | 9 + src/models/Instance_SecurityGroupId.ts | 9 + src/models/Instance_SecurityGroupIds.ts | 14 + src/models/Instance_Status.ts | 25 + src/models/Instance_Type.ts | 9 + src/models/Instance_UserData.ts | 10 + src/models/InstancesAvailability.ts | 20 + src/models/OSType.ts | 9 + src/models/PageQueryParameter.ts | 6 + src/models/PerPageQueryParameter.ts | 6 + src/models/Region.ts | 9 + src/models/SSHKey.ts | 41 + src/models/SecurityGroup.ts | 33 + src/models/SecurityGroup_Rule.ts | 20 + src/models/SecurityGroup_Rule_Direction.ts | 9 + src/models/SecurityGroup_Rule_Protocol.ts | 9 + src/models/SecurityGroup_Status.ts | 14 + src/models/Snapshot.ts | 37 + src/models/Snapshot_Status.ts | 15 + src/models/Timestamp.ts | 6 + src/models/Volume.ts | 44 + src/models/VolumeId.ts | 10 + src/models/VolumeType.ts | 9 + src/models/Volume_Status.ts | 13 + src/schemas.gen.ts | 1008 ++++++++++++ src/services.gen.ts | 904 +++++++++++ src/services/AvailabilityService.ts | 37 + src/services/CatalogService.ts | 39 + src/services/FilesystemsService.ts | 160 ++ src/services/FloatingIPsService.ts | 155 ++ src/services/ImagesService.ts | 43 + src/services/InstancesService.ts | 318 ++++ src/services/SecurityGroupsService.ts | 157 ++ src/services/SnapshotsService.ts | 153 ++ src/services/SshKeysService.ts | 137 ++ src/services/VolumesService.ts | 152 ++ src/types.gen.ts | 1430 +++++++++++++++++ tsconfig.json | 21 + 78 files changed, 7336 insertions(+) create mode 100644 .github/workflows/check.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .gitignore create mode 100644 .nvmrc create mode 100644 README.md create mode 100644 generate.mjs create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 src/GenesisCloudClient.ts create mode 100644 src/core/ApiError.ts create mode 100644 src/core/ApiRequestOptions.ts create mode 100644 src/core/ApiResult.ts create mode 100644 src/core/BaseHttpRequest.ts create mode 100644 src/core/CancelablePromise.ts create mode 100644 src/core/FetchHttpRequest.ts create mode 100644 src/core/OpenAPI.ts create mode 100644 src/core/request.ts create mode 100644 src/index.ts create mode 100644 src/models/Catalog.ts create mode 100644 src/models/Catalog_Fields.ts create mode 100644 src/models/Error.ts create mode 100644 src/models/Filesystem.ts create mode 100644 src/models/FilesystemId.ts create mode 100644 src/models/FilesystemType.ts create mode 100644 src/models/Filesystem_Status.ts create mode 100644 src/models/FloatingIP.ts create mode 100644 src/models/FloatingIp_Status.ts create mode 100644 src/models/Image.ts create mode 100644 src/models/ImageId.ts create mode 100644 src/models/Image_Type.ts create mode 100644 src/models/Instance.ts create mode 100644 src/models/Instance_Action.ts create mode 100644 src/models/Instance_BillingType.ts create mode 100644 src/models/Instance_DestroyOnShutdown.ts create mode 100644 src/models/Instance_FloatingIp.ts create mode 100644 src/models/Instance_Hostname.ts create mode 100644 src/models/Instance_IsProtected.ts create mode 100644 src/models/Instance_Name.ts create mode 100644 src/models/Instance_PublicIpv6.ts create mode 100644 src/models/Instance_ReuseLongTermSubscription.ts create mode 100644 src/models/Instance_SSHKeyId.ts create mode 100644 src/models/Instance_SecurityGroupId.ts create mode 100644 src/models/Instance_SecurityGroupIds.ts create mode 100644 src/models/Instance_Status.ts create mode 100644 src/models/Instance_Type.ts create mode 100644 src/models/Instance_UserData.ts create mode 100644 src/models/InstancesAvailability.ts create mode 100644 src/models/OSType.ts create mode 100644 src/models/PageQueryParameter.ts create mode 100644 src/models/PerPageQueryParameter.ts create mode 100644 src/models/Region.ts create mode 100644 src/models/SSHKey.ts create mode 100644 src/models/SecurityGroup.ts create mode 100644 src/models/SecurityGroup_Rule.ts create mode 100644 src/models/SecurityGroup_Rule_Direction.ts create mode 100644 src/models/SecurityGroup_Rule_Protocol.ts create mode 100644 src/models/SecurityGroup_Status.ts create mode 100644 src/models/Snapshot.ts create mode 100644 src/models/Snapshot_Status.ts create mode 100644 src/models/Timestamp.ts create mode 100644 src/models/Volume.ts create mode 100644 src/models/VolumeId.ts create mode 100644 src/models/VolumeType.ts create mode 100644 src/models/Volume_Status.ts create mode 100644 src/schemas.gen.ts create mode 100644 src/services.gen.ts create mode 100644 src/services/AvailabilityService.ts create mode 100644 src/services/CatalogService.ts create mode 100644 src/services/FilesystemsService.ts create mode 100644 src/services/FloatingIPsService.ts create mode 100644 src/services/ImagesService.ts create mode 100644 src/services/InstancesService.ts create mode 100644 src/services/SecurityGroupsService.ts create mode 100644 src/services/SnapshotsService.ts create mode 100644 src/services/SshKeysService.ts create mode 100644 src/services/VolumesService.ts create mode 100644 src/types.gen.ts create mode 100644 tsconfig.json diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..b1e3566 --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,40 @@ +name: Check + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 9 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache-dir-path + run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - run: pnpm build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..9f441f2 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,47 @@ +name: Release + +on: + push: + tags: ["*"] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 9 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache-dir-path + run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + - name: Publish + run: pnpm publish --access public --no-git-checks + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b295889 --- /dev/null +++ b/.gitignore @@ -0,0 +1,132 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +.DS_Store diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/README.md b/README.md new file mode 100644 index 0000000..d5ed5cc --- /dev/null +++ b/README.md @@ -0,0 +1,171 @@ +# Genesis Cloud JavaScript Client + +The JavaScript library for the [Genesis Cloud](http://genesiscloud.com) API offers an easy way to manage resources like instances, volumes, snapshots, filesystems, floating IPs, security groups and more in your JavaScript or TypeScript applications. + +## Installation + +You can install the Genesis Cloud SDK using your preferred node package manager: + +```bash +npm install @genesiscloud/genesiscloud-js +# or +yarn add @genesiscloud/genesiscloud-js +# or +pnpm add @genesiscloud/genesiscloud-js +``` + +## Configuration + +Before you start, you'll need to configure the client with your Genesis Cloud API token. You can generate your API token from the [Genesis Cloud console](https://console.genesiscloud.com/dashboard). + +Here's how to configure the SDK: + +```typescript +const genesiscloud = new GenesisCloudClient({ + TOKEN: process.env.GENESISCLOUD_TOKEN, +}); +``` + +## Examples + +### Error handling + +Error handling can be done using the try/catch with the async/await syntax. The Genesis Cloud errors are of [this format](/src/core/ApiError.ts). + +```typescript +try { + const instance = await genesiscloud.instances.createInstance({ + requestBody: { + // ... + }, + }); + //... do something with instance +} catch (error) { + if (error instanceof ApiError) { + const { code, message } = error.body; + // ... handle genesiscloud error + } else { + // ... handle other errors + } +} +``` + +### Managing Instances + +Listing Instances: + +```typescript +const { instances } = await genesiscloud.instances.listInstances({ + page: 1, + perPage: 100, +}); +``` + +Creating a new Instance: + +```typescript +const instance = await genesiscloud.instances.createInstance({ + requestBody: { + name: "test instance", + hostname: "test instance", + type: "vcpu-192_memory-1920g_nvidia-h100-sxm5-8", + image: "ubuntu-ml-nvidia-pytorch", + region: "NORD-NO-KRS-1", + ssh_keys: ["ssh_key_id_here"], + }, +}); +``` + +Updating an Instance: + +```typescript +const updatedInstance = await genesiscloud.instances.updateInstance({ + instanceId: "your_instance_id", + requestBody: { + name: "New Instance Name", + volumes: ["volume_id_here"], + }, +}); +``` + +Deleting an Instance: + +```typescript +await genesiscloud.instances.deleteInstance({ + instanceId: "your_instance_id", +}); +``` + +### Managing Volumes + +Creating a Volume + +```typescript +const volume = await genesiscloud.volumes.createVolume({ + requestBody: { + name: "volume name", + description: "volume description", + type: "ssd", + size: 10, // in GiB + region: "NORD-NO-KRS-1", + }, +}); +``` + +Deleting a Volume + +```typescript +await genesiscloud.volumes.deleteVolume({ + volumeId: "your_volume_id", +}); +``` + +### Managing Snapshots + +Creating a Snapshot from an instance: + +```typescript +const snapshot = await genesiscloud.instances.createInstanceSnapshot({ + instanceId: "your_instance_id", + requestBody: { + name: "Test snapshot", + }, +}); +``` + +Deleting a Snapshot: + +```typescript +await genesiscloud.snapshots.deleteSnapshot({ + snapshotId: "your_snapshot_id", +}); +``` + +### Managing SSH Keys + +Listing SSH Keys: + +```typescript +const sshKeys = await genesiscloud.sshKeys.listSshKeys({}); +``` + +Creating an SSH Key: + +```typescript +const sshKey = await genesiscloud.sshKeys.createSshKey({ + requestBody: { + name: "test key", + value: "ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXX...", + }, +}); +``` + +Deleting an SSH Key: + +```typescript +await genesiscloud.sshKeys.deleteSshKey({ + sshKeyId: "your-ssh-key-id", +}); +``` + +For more detailed information on the Genesis Cloud API refer to the [Genesis Cloud API documentation](https://developers.genesiscloud.com/). diff --git a/generate.mjs b/generate.mjs new file mode 100644 index 0000000..3c6f2fa --- /dev/null +++ b/generate.mjs @@ -0,0 +1,51 @@ +import { createClient } from "@hey-api/openapi-ts"; +import childProcess from "child_process"; +import fs from "fs/promises"; +import YAML from "yaml"; + +async function main() { + const response = await fetch("https://api.genesiscloud.com/compute/v1/openapi.yaml"); + + const file = await response.text(); + + const spec = YAML.parse(file); + + for (const [_, path] of Object.entries(spec.paths)) { + for (const [methodname, method] of Object.entries(path)) { + if (methodname !== "parameters") { + delete method.responses.default; + } + } + } + + await createClient({ + input: spec, + output: `./src`, + client: "fetch", + name: "GenesisCloudClient", + useOptions: true, + }); + + childProcess.execSync(`prettier -w ./src`); + + // Until https://github.com/ferdikoomen/openapi-typescript-codegen/pull/494 gets merged + { + const src = `./src/models/Timestamp.ts`; + + if ( + await fs + .access(src) + .then(() => true) + .catch(() => false) + ) { + let file = (await fs.readFile(src)).toString(); + + file = file.replaceAll("string", "Date"); + + await fs.writeFile(src, file); + } + } +} + +// eslint-disable-next-line no-floating-promise/no-floating-promise +main(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..6c4f9c7 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "@genesiscloud/genesiscloud-js", + "version": "0.1.0", + "description": "JavaScript client for the Genesis Cloud API", + "main": "dist/index.js", + "type": "commonjs", + "scripts": { + "generate": "node generate.mjs", + "build": "tsc" + }, + "keywords": [ + "genesiscloud", + "instance", + "gpu", + "typescript", + "JavaScript" + ], + "repository": "https://github.com/genesiscloud/genesiscloud-js", + "author": "", + "license": "ISC", + "devDependencies": { + "@hey-api/openapi-ts": "^0.41.0", + "prettier": "^3.2.5", + "typescript": "^5.4.5", + "yaml": "^2.4.1" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..9473fc8 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,600 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@hey-api/openapi-ts': + specifier: ^0.41.0 + version: 0.41.0(typescript@5.4.5) + prettier: + specifier: ^3.2.5 + version: 3.2.5 + typescript: + specifier: ^5.4.5 + version: 5.4.5 + yaml: + specifier: ^2.4.1 + version: 2.4.1 + +packages: + + '@apidevtools/json-schema-ref-parser@11.5.5': + resolution: {integrity: sha512-hv/aXDILyroHioVW27etFMV+IX6FyNn41YwbeGIAt5h/7fUTQvHI5w3ols8qYAT8aQt3kzexq5ZwxFDxNHIhdQ==} + engines: {node: '>= 16'} + + '@hey-api/openapi-ts@0.41.0': + resolution: {integrity: sha512-yASbQMHtt9QlxE5ch/X8JUwI8z3c0soyOTyJv4eKv4EPbJ3U4EzSLECQ81AYL+vv0ZzHjq7ik4UPpuf95H95Rw==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + typescript: ^5.x + + '@jsdevtools/ono@7.1.3': + resolution: {integrity: sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==} + + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + + acorn@8.11.3: + resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} + engines: {node: '>=0.4.0'} + hasBin: true + + anymatch@3.1.3: + resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} + engines: {node: '>= 8'} + + argparse@2.0.1: + resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + + binary-extensions@2.3.0: + resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} + engines: {node: '>=8'} + + braces@3.0.2: + resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} + engines: {node: '>=8'} + + c12@1.10.0: + resolution: {integrity: sha512-0SsG7UDhoRWcuSvKWHaXmu5uNjDCDN3nkQLRL4Q42IlFy+ze58FcCoI3uPwINXinkz7ZinbhEgyzYFw9u9ZV8g==} + + camelcase@8.0.0: + resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==} + engines: {node: '>=16'} + + chokidar@3.6.0: + resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} + engines: {node: '>= 8.10.0'} + + chownr@2.0.0: + resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} + engines: {node: '>=10'} + + citty@0.1.6: + resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==} + + commander@12.0.0: + resolution: {integrity: sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==} + engines: {node: '>=18'} + + confbox@0.1.7: + resolution: {integrity: sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==} + + consola@3.2.3: + resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} + engines: {node: ^14.18.0 || >=16.10.0} + + cross-spawn@7.0.3: + resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + engines: {node: '>= 8'} + + defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} + + destr@2.0.3: + resolution: {integrity: sha512-2N3BOUU4gYMpTP24s5rF5iP7BDr7uNTCs4ozw3kf/eKfvWSIu93GEBi5m427YoyJoeOzQ5smuu4nNAPGb8idSQ==} + + dotenv@16.4.5: + resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} + engines: {node: '>=12'} + + execa@8.0.1: + resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} + engines: {node: '>=16.17'} + + fill-range@7.0.1: + resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} + engines: {node: '>=8'} + + fs-minipass@2.1.0: + resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} + engines: {node: '>= 8'} + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + get-stream@8.0.1: + resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} + engines: {node: '>=16'} + + giget@1.2.3: + resolution: {integrity: sha512-8EHPljDvs7qKykr6uw8b+lqLiUc/vUg+KVTI0uND4s63TdsZM2Xus3mflvF0DDG9SiM4RlCkFGL+7aAjRmV7KA==} + hasBin: true + + glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + + handlebars@4.7.8: + resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==} + engines: {node: '>=0.4.7'} + hasBin: true + + human-signals@5.0.0: + resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} + engines: {node: '>=16.17.0'} + + is-binary-path@2.1.0: + resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} + engines: {node: '>=8'} + + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + + is-stream@3.0.0: + resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + jiti@1.21.0: + resolution: {integrity: sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==} + hasBin: true + + js-yaml@4.1.0: + resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} + hasBin: true + + merge-stream@2.0.0: + resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + + mimic-fn@4.0.0: + resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} + engines: {node: '>=12'} + + minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + minipass@3.3.6: + resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} + engines: {node: '>=8'} + + minipass@5.0.0: + resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} + engines: {node: '>=8'} + + minizlib@2.1.2: + resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} + engines: {node: '>= 8'} + + mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + + mlly@1.6.1: + resolution: {integrity: sha512-vLgaHvaeunuOXHSmEbZ9izxPx3USsk8KCQ8iC+aTlp5sKRSoZvwhHh5L9VbKSaVC6sJDqbyohIS76E2VmHIPAA==} + + neo-async@2.6.2: + resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + + node-fetch-native@1.6.4: + resolution: {integrity: sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==} + + normalize-path@3.0.0: + resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} + engines: {node: '>=0.10.0'} + + npm-run-path@5.3.0: + resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + nypm@0.3.8: + resolution: {integrity: sha512-IGWlC6So2xv6V4cIDmoV0SwwWx7zLG086gyqkyumteH2fIgCAM4nDVFB2iDRszDvmdSVW9xb1N+2KjQ6C7d4og==} + engines: {node: ^14.16.0 || >=16.10.0} + hasBin: true + + ohash@1.1.3: + resolution: {integrity: sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw==} + + onetime@6.0.0: + resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} + engines: {node: '>=12'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-key@4.0.0: + resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} + engines: {node: '>=12'} + + pathe@1.1.2: + resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} + + perfect-debounce@1.0.0: + resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==} + + picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + + pkg-types@1.1.0: + resolution: {integrity: sha512-/RpmvKdxKf8uILTtoOhAgf30wYbP2Qw+L9p3Rvshx1JZVX+XQNZQFjlbmGHEGIm4CkVPlSn+NXmIM8+9oWQaSA==} + + prettier@3.2.5: + resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} + engines: {node: '>=14'} + hasBin: true + + rc9@2.1.2: + resolution: {integrity: sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==} + + readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + signal-exit@4.1.0: + resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} + engines: {node: '>=14'} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + strip-final-newline@3.0.0: + resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} + engines: {node: '>=12'} + + tar@6.2.1: + resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} + engines: {node: '>=10'} + + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + + typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + engines: {node: '>=14.17'} + hasBin: true + + ufo@1.5.3: + resolution: {integrity: sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==} + + uglify-js@3.17.4: + resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==} + engines: {node: '>=0.8.0'} + hasBin: true + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + wordwrap@1.0.0: + resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} + + yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + + yaml@2.4.1: + resolution: {integrity: sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==} + engines: {node: '>= 14'} + hasBin: true + +snapshots: + + '@apidevtools/json-schema-ref-parser@11.5.5': + dependencies: + '@jsdevtools/ono': 7.1.3 + '@types/json-schema': 7.0.15 + js-yaml: 4.1.0 + + '@hey-api/openapi-ts@0.41.0(typescript@5.4.5)': + dependencies: + '@apidevtools/json-schema-ref-parser': 11.5.5 + c12: 1.10.0 + camelcase: 8.0.0 + commander: 12.0.0 + handlebars: 4.7.8 + typescript: 5.4.5 + + '@jsdevtools/ono@7.1.3': {} + + '@types/json-schema@7.0.15': {} + + acorn@8.11.3: {} + + anymatch@3.1.3: + dependencies: + normalize-path: 3.0.0 + picomatch: 2.3.1 + + argparse@2.0.1: {} + + binary-extensions@2.3.0: {} + + braces@3.0.2: + dependencies: + fill-range: 7.0.1 + + c12@1.10.0: + dependencies: + chokidar: 3.6.0 + confbox: 0.1.7 + defu: 6.1.4 + dotenv: 16.4.5 + giget: 1.2.3 + jiti: 1.21.0 + mlly: 1.6.1 + ohash: 1.1.3 + pathe: 1.1.2 + perfect-debounce: 1.0.0 + pkg-types: 1.1.0 + rc9: 2.1.2 + + camelcase@8.0.0: {} + + chokidar@3.6.0: + dependencies: + anymatch: 3.1.3 + braces: 3.0.2 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.3 + + chownr@2.0.0: {} + + citty@0.1.6: + dependencies: + consola: 3.2.3 + + commander@12.0.0: {} + + confbox@0.1.7: {} + + consola@3.2.3: {} + + cross-spawn@7.0.3: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + defu@6.1.4: {} + + destr@2.0.3: {} + + dotenv@16.4.5: {} + + execa@8.0.1: + dependencies: + cross-spawn: 7.0.3 + get-stream: 8.0.1 + human-signals: 5.0.0 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.3.0 + onetime: 6.0.0 + signal-exit: 4.1.0 + strip-final-newline: 3.0.0 + + fill-range@7.0.1: + dependencies: + to-regex-range: 5.0.1 + + fs-minipass@2.1.0: + dependencies: + minipass: 3.3.6 + + fsevents@2.3.3: + optional: true + + get-stream@8.0.1: {} + + giget@1.2.3: + dependencies: + citty: 0.1.6 + consola: 3.2.3 + defu: 6.1.4 + node-fetch-native: 1.6.4 + nypm: 0.3.8 + ohash: 1.1.3 + pathe: 1.1.2 + tar: 6.2.1 + + glob-parent@5.1.2: + dependencies: + is-glob: 4.0.3 + + handlebars@4.7.8: + dependencies: + minimist: 1.2.8 + neo-async: 2.6.2 + source-map: 0.6.1 + wordwrap: 1.0.0 + optionalDependencies: + uglify-js: 3.17.4 + + human-signals@5.0.0: {} + + is-binary-path@2.1.0: + dependencies: + binary-extensions: 2.3.0 + + is-extglob@2.1.1: {} + + is-glob@4.0.3: + dependencies: + is-extglob: 2.1.1 + + is-number@7.0.0: {} + + is-stream@3.0.0: {} + + isexe@2.0.0: {} + + jiti@1.21.0: {} + + js-yaml@4.1.0: + dependencies: + argparse: 2.0.1 + + merge-stream@2.0.0: {} + + mimic-fn@4.0.0: {} + + minimist@1.2.8: {} + + minipass@3.3.6: + dependencies: + yallist: 4.0.0 + + minipass@5.0.0: {} + + minizlib@2.1.2: + dependencies: + minipass: 3.3.6 + yallist: 4.0.0 + + mkdirp@1.0.4: {} + + mlly@1.6.1: + dependencies: + acorn: 8.11.3 + pathe: 1.1.2 + pkg-types: 1.1.0 + ufo: 1.5.3 + + neo-async@2.6.2: {} + + node-fetch-native@1.6.4: {} + + normalize-path@3.0.0: {} + + npm-run-path@5.3.0: + dependencies: + path-key: 4.0.0 + + nypm@0.3.8: + dependencies: + citty: 0.1.6 + consola: 3.2.3 + execa: 8.0.1 + pathe: 1.1.2 + ufo: 1.5.3 + + ohash@1.1.3: {} + + onetime@6.0.0: + dependencies: + mimic-fn: 4.0.0 + + path-key@3.1.1: {} + + path-key@4.0.0: {} + + pathe@1.1.2: {} + + perfect-debounce@1.0.0: {} + + picomatch@2.3.1: {} + + pkg-types@1.1.0: + dependencies: + confbox: 0.1.7 + mlly: 1.6.1 + pathe: 1.1.2 + + prettier@3.2.5: {} + + rc9@2.1.2: + dependencies: + defu: 6.1.4 + destr: 2.0.3 + + readdirp@3.6.0: + dependencies: + picomatch: 2.3.1 + + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + + signal-exit@4.1.0: {} + + source-map@0.6.1: {} + + strip-final-newline@3.0.0: {} + + tar@6.2.1: + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 5.0.0 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + + to-regex-range@5.0.1: + dependencies: + is-number: 7.0.0 + + typescript@5.4.5: {} + + ufo@1.5.3: {} + + uglify-js@3.17.4: + optional: true + + which@2.0.2: + dependencies: + isexe: 2.0.0 + + wordwrap@1.0.0: {} + + yallist@4.0.0: {} + + yaml@2.4.1: {} diff --git a/src/GenesisCloudClient.ts b/src/GenesisCloudClient.ts new file mode 100644 index 0000000..eb00797 --- /dev/null +++ b/src/GenesisCloudClient.ts @@ -0,0 +1,64 @@ +import type { BaseHttpRequest } from "./core/BaseHttpRequest"; +import type { OpenAPIConfig } from "./core/OpenAPI"; +import { Interceptors } from "./core/OpenAPI"; +import { FetchHttpRequest } from "./core/FetchHttpRequest"; + +import { AvailabilityService } from "./services.gen"; +import { CatalogService } from "./services.gen"; +import { FilesystemsService } from "./services.gen"; +import { FloatingIpsService } from "./services.gen"; +import { ImagesService } from "./services.gen"; +import { InstancesService } from "./services.gen"; +import { SecurityGroupsService } from "./services.gen"; +import { SnapshotsService } from "./services.gen"; +import { SshKeysService } from "./services.gen"; +import { VolumesService } from "./services.gen"; + +type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; + +export class GenesisCloudClient { + public readonly availability: AvailabilityService; + public readonly catalog: CatalogService; + public readonly filesystems: FilesystemsService; + public readonly floatingIps: FloatingIpsService; + public readonly images: ImagesService; + public readonly instances: InstancesService; + public readonly securityGroups: SecurityGroupsService; + public readonly snapshots: SnapshotsService; + public readonly sshKeys: SshKeysService; + public readonly volumes: VolumesService; + + public readonly request: BaseHttpRequest; + + constructor( + config?: Partial, + HttpRequest: HttpRequestConstructor = FetchHttpRequest, + ) { + this.request = new HttpRequest({ + BASE: config?.BASE ?? "https://api.genesiscloud.com/compute/v1", + VERSION: config?.VERSION ?? "1.0.0", + WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false, + CREDENTIALS: config?.CREDENTIALS ?? "include", + TOKEN: config?.TOKEN, + USERNAME: config?.USERNAME, + PASSWORD: config?.PASSWORD, + HEADERS: config?.HEADERS, + ENCODE_PATH: config?.ENCODE_PATH, + interceptors: { + request: config?.interceptors?.request ?? new Interceptors(), + response: config?.interceptors?.response ?? new Interceptors(), + }, + }); + + this.availability = new AvailabilityService(this.request); + this.catalog = new CatalogService(this.request); + this.filesystems = new FilesystemsService(this.request); + this.floatingIps = new FloatingIpsService(this.request); + this.images = new ImagesService(this.request); + this.instances = new InstancesService(this.request); + this.securityGroups = new SecurityGroupsService(this.request); + this.snapshots = new SnapshotsService(this.request); + this.sshKeys = new SshKeysService(this.request); + this.volumes = new VolumesService(this.request); + } +} diff --git a/src/core/ApiError.ts b/src/core/ApiError.ts new file mode 100644 index 0000000..1d07bb3 --- /dev/null +++ b/src/core/ApiError.ts @@ -0,0 +1,25 @@ +import type { ApiRequestOptions } from "./ApiRequestOptions"; +import type { ApiResult } from "./ApiResult"; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: unknown; + public readonly request: ApiRequestOptions; + + constructor( + request: ApiRequestOptions, + response: ApiResult, + message: string, + ) { + super(message); + + this.name = "ApiError"; + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + this.request = request; + } +} diff --git a/src/core/ApiRequestOptions.ts b/src/core/ApiRequestOptions.ts new file mode 100644 index 0000000..28e1917 --- /dev/null +++ b/src/core/ApiRequestOptions.ts @@ -0,0 +1,20 @@ +export type ApiRequestOptions = { + readonly method: + | "GET" + | "PUT" + | "POST" + | "DELETE" + | "OPTIONS" + | "HEAD" + | "PATCH"; + readonly url: string; + readonly path?: Record; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}; diff --git a/src/core/ApiResult.ts b/src/core/ApiResult.ts new file mode 100644 index 0000000..05040ba --- /dev/null +++ b/src/core/ApiResult.ts @@ -0,0 +1,7 @@ +export type ApiResult = { + readonly body: TData; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly url: string; +}; diff --git a/src/core/BaseHttpRequest.ts b/src/core/BaseHttpRequest.ts new file mode 100644 index 0000000..cf68a62 --- /dev/null +++ b/src/core/BaseHttpRequest.ts @@ -0,0 +1,9 @@ +import type { ApiRequestOptions } from "./ApiRequestOptions"; +import type { CancelablePromise } from "./CancelablePromise"; +import type { OpenAPIConfig } from "./OpenAPI"; + +export abstract class BaseHttpRequest { + constructor(public readonly config: OpenAPIConfig) {} + + public abstract request(options: ApiRequestOptions): CancelablePromise; +} diff --git a/src/core/CancelablePromise.ts b/src/core/CancelablePromise.ts new file mode 100644 index 0000000..0640e98 --- /dev/null +++ b/src/core/CancelablePromise.ts @@ -0,0 +1,126 @@ +export class CancelError extends Error { + constructor(message: string) { + super(message); + this.name = "CancelError"; + } + + public get isCancelled(): boolean { + return true; + } +} + +export interface OnCancel { + readonly isResolved: boolean; + readonly isRejected: boolean; + readonly isCancelled: boolean; + + (cancelHandler: () => void): void; +} + +export class CancelablePromise implements Promise { + private _isResolved: boolean; + private _isRejected: boolean; + private _isCancelled: boolean; + readonly cancelHandlers: (() => void)[]; + readonly promise: Promise; + private _resolve?: (value: T | PromiseLike) => void; + private _reject?: (reason?: unknown) => void; + + constructor( + executor: ( + resolve: (value: T | PromiseLike) => void, + reject: (reason?: unknown) => void, + onCancel: OnCancel, + ) => void, + ) { + this._isResolved = false; + this._isRejected = false; + this._isCancelled = false; + this.cancelHandlers = []; + this.promise = new Promise((resolve, reject) => { + this._resolve = resolve; + this._reject = reject; + + const onResolve = (value: T | PromiseLike): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isResolved = true; + if (this._resolve) this._resolve(value); + }; + + const onReject = (reason?: unknown): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isRejected = true; + if (this._reject) this._reject(reason); + }; + + const onCancel = (cancelHandler: () => void): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this.cancelHandlers.push(cancelHandler); + }; + + Object.defineProperty(onCancel, "isResolved", { + get: (): boolean => this._isResolved, + }); + + Object.defineProperty(onCancel, "isRejected", { + get: (): boolean => this._isRejected, + }); + + Object.defineProperty(onCancel, "isCancelled", { + get: (): boolean => this._isCancelled, + }); + + return executor(onResolve, onReject, onCancel as OnCancel); + }); + } + + get [Symbol.toStringTag]() { + return "Cancellable Promise"; + } + + public then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onRejected?: ((reason: unknown) => TResult2 | PromiseLike) | null, + ): Promise { + return this.promise.then(onFulfilled, onRejected); + } + + public catch( + onRejected?: ((reason: unknown) => TResult | PromiseLike) | null, + ): Promise { + return this.promise.catch(onRejected); + } + + public finally(onFinally?: (() => void) | null): Promise { + return this.promise.finally(onFinally); + } + + public cancel(): void { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isCancelled = true; + if (this.cancelHandlers.length) { + try { + for (const cancelHandler of this.cancelHandlers) { + cancelHandler(); + } + } catch (error) { + console.warn("Cancellation threw an error", error); + return; + } + } + this.cancelHandlers.length = 0; + if (this._reject) this._reject(new CancelError("Request aborted")); + } + + public get isCancelled(): boolean { + return this._isCancelled; + } +} diff --git a/src/core/FetchHttpRequest.ts b/src/core/FetchHttpRequest.ts new file mode 100644 index 0000000..20f7a65 --- /dev/null +++ b/src/core/FetchHttpRequest.ts @@ -0,0 +1,21 @@ +import type { ApiRequestOptions } from "./ApiRequestOptions"; +import { BaseHttpRequest } from "./BaseHttpRequest"; +import type { CancelablePromise } from "./CancelablePromise"; +import type { OpenAPIConfig } from "./OpenAPI"; +import { request as __request } from "./request"; + +export class FetchHttpRequest extends BaseHttpRequest { + constructor(config: OpenAPIConfig) { + super(config); + } + + /** + * Request method + * @param options The request options from the service + * @returns CancelablePromise + * @throws ApiError + */ + public override request(options: ApiRequestOptions): CancelablePromise { + return __request(this.config, options); + } +} diff --git a/src/core/OpenAPI.ts b/src/core/OpenAPI.ts new file mode 100644 index 0000000..f66d020 --- /dev/null +++ b/src/core/OpenAPI.ts @@ -0,0 +1,53 @@ +import type { ApiRequestOptions } from "./ApiRequestOptions"; + +type Headers = Record; +type Middleware = (value: T) => T | Promise; +type Resolver = (options: ApiRequestOptions) => Promise; + +export class Interceptors { + _fns: Middleware[]; + + constructor() { + this._fns = []; + } + + eject(fn: Middleware) { + const index = this._fns.indexOf(fn); + if (index !== -1) { + this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + } + } + + use(fn: Middleware) { + this._fns = [...this._fns, fn]; + } +} + +export type OpenAPIConfig = { + BASE: string; + CREDENTIALS: "include" | "omit" | "same-origin"; + ENCODE_PATH?: ((path: string) => string) | undefined; + HEADERS?: Headers | Resolver | undefined; + PASSWORD?: string | Resolver | undefined; + TOKEN?: string | Resolver | undefined; + USERNAME?: string | Resolver | undefined; + VERSION: string; + WITH_CREDENTIALS: boolean; + interceptors: { + request: Interceptors; + response: Interceptors; + }; +}; + +export const OpenAPI: OpenAPIConfig = { + BASE: "https://api.genesiscloud.com/compute/v1", + CREDENTIALS: "include", + ENCODE_PATH: undefined, + HEADERS: undefined, + PASSWORD: undefined, + TOKEN: undefined, + USERNAME: undefined, + VERSION: "1.0.0", + WITH_CREDENTIALS: false, + interceptors: { request: new Interceptors(), response: new Interceptors() }, +}; diff --git a/src/core/request.ts b/src/core/request.ts new file mode 100644 index 0000000..dc68ec8 --- /dev/null +++ b/src/core/request.ts @@ -0,0 +1,389 @@ +import { ApiError } from "./ApiError"; +import type { ApiRequestOptions } from "./ApiRequestOptions"; +import type { ApiResult } from "./ApiResult"; +import { CancelablePromise } from "./CancelablePromise"; +import type { OnCancel } from "./CancelablePromise"; +import type { OpenAPIConfig } from "./OpenAPI"; + +export const isString = (value: unknown): value is string => { + return typeof value === "string"; +}; + +export const isStringWithValue = (value: unknown): value is string => { + return isString(value) && value !== ""; +}; + +export const isBlob = (value: any): value is Blob => { + return value instanceof Blob; +}; + +export const isFormData = (value: unknown): value is FormData => { + return value instanceof FormData; +}; + +export const base64 = (str: string): string => { + try { + return btoa(str); + } catch (err) { + // @ts-ignore + return Buffer.from(str).toString("base64"); + } +}; + +export const getQueryString = (params: Record): string => { + const qs: string[] = []; + + const append = (key: string, value: unknown) => { + qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); + }; + + const encodePair = (key: string, value: unknown) => { + if (value === undefined || value === null) { + return; + } + + if (Array.isArray(value)) { + value.forEach((v) => encodePair(key, v)); + } else if (typeof value === "object") { + Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); + } else { + append(key, value); + } + }; + + Object.entries(params).forEach(([key, value]) => encodePair(key, value)); + + return qs.length ? `?${qs.join("&")}` : ""; +}; + +const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { + const encoder = config.ENCODE_PATH || encodeURI; + + const path = options.url + .replace("{api-version}", config.VERSION) + .replace(/{(.*?)}/g, (substring: string, group: string) => { + if (options.path?.hasOwnProperty(group)) { + return encoder(String(options.path[group])); + } + return substring; + }); + + const url = config.BASE + path; + return options.query ? url + getQueryString(options.query) : url; +}; + +export const getFormData = ( + options: ApiRequestOptions, +): FormData | undefined => { + if (options.formData) { + const formData = new FormData(); + + const process = (key: string, value: unknown) => { + if (isString(value) || isBlob(value)) { + formData.append(key, value); + } else { + formData.append(key, JSON.stringify(value)); + } + }; + + Object.entries(options.formData) + .filter(([, value]) => value !== undefined && value !== null) + .forEach(([key, value]) => { + if (Array.isArray(value)) { + value.forEach((v) => process(key, v)); + } else { + process(key, value); + } + }); + + return formData; + } + return undefined; +}; + +type Resolver = (options: ApiRequestOptions) => Promise; + +export const resolve = async ( + options: ApiRequestOptions, + resolver?: T | Resolver, +): Promise => { + if (typeof resolver === "function") { + return (resolver as Resolver)(options); + } + return resolver; +}; + +export const getHeaders = async ( + config: OpenAPIConfig, + options: ApiRequestOptions, +): Promise => { + const [token, username, password, additionalHeaders] = await Promise.all([ + resolve(options, config.TOKEN), + resolve(options, config.USERNAME), + resolve(options, config.PASSWORD), + resolve(options, config.HEADERS), + ]); + + const headers = Object.entries({ + Accept: "application/json", + ...additionalHeaders, + ...options.headers, + }) + .filter(([, value]) => value !== undefined && value !== null) + .reduce( + (headers, [key, value]) => ({ + ...headers, + [key]: String(value), + }), + {} as Record, + ); + + if (isStringWithValue(token)) { + headers["Authorization"] = `Bearer ${token}`; + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = base64(`${username}:${password}`); + headers["Authorization"] = `Basic ${credentials}`; + } + + if (options.body !== undefined) { + if (options.mediaType) { + headers["Content-Type"] = options.mediaType; + } else if (isBlob(options.body)) { + headers["Content-Type"] = options.body.type || "application/octet-stream"; + } else if (isString(options.body)) { + headers["Content-Type"] = "text/plain"; + } else if (!isFormData(options.body)) { + headers["Content-Type"] = "application/json"; + } + } + + return new Headers(headers); +}; + +export const getRequestBody = (options: ApiRequestOptions): unknown => { + if (options.body !== undefined) { + if ( + options.mediaType?.includes("application/json") || + options.mediaType?.includes("+json") + ) { + return JSON.stringify(options.body); + } else if ( + isString(options.body) || + isBlob(options.body) || + isFormData(options.body) + ) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +}; + +export const sendRequest = async ( + config: OpenAPIConfig, + options: ApiRequestOptions, + url: string, + body: any, + formData: FormData | undefined, + headers: Headers, + onCancel: OnCancel, +): Promise => { + const controller = new AbortController(); + + let request: RequestInit = { + headers, + body: body ?? formData, + method: options.method, + signal: controller.signal, + }; + + if (config.WITH_CREDENTIALS) { + request.credentials = config.CREDENTIALS; + } + + for (const fn of config.interceptors.request._fns) { + request = await fn(request); + } + + onCancel(() => controller.abort()); + + return await fetch(url, request); +}; + +export const getResponseHeader = ( + response: Response, + responseHeader?: string, +): string | undefined => { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return undefined; +}; + +export const getResponseBody = async (response: Response): Promise => { + if (response.status !== 204) { + try { + const contentType = response.headers.get("Content-Type"); + if (contentType) { + const binaryTypes = [ + "application/octet-stream", + "application/pdf", + "application/zip", + "audio/", + "image/", + "video/", + ]; + if ( + contentType.includes("application/json") || + contentType.includes("+json") + ) { + return await response.json(); + } else if (binaryTypes.some((type) => contentType.includes(type))) { + return await response.blob(); + } else if (contentType.includes("multipart/form-data")) { + return await response.formData(); + } else if (contentType.includes("text/")) { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } + } + return undefined; +}; + +export const catchErrorCodes = ( + options: ApiRequestOptions, + result: ApiResult, +): void => { + const errors: Record = { + 400: "Bad Request", + 401: "Unauthorized", + 402: "Payment Required", + 403: "Forbidden", + 404: "Not Found", + 405: "Method Not Allowed", + 406: "Not Acceptable", + 407: "Proxy Authentication Required", + 408: "Request Timeout", + 409: "Conflict", + 410: "Gone", + 411: "Length Required", + 412: "Precondition Failed", + 413: "Payload Too Large", + 414: "URI Too Long", + 415: "Unsupported Media Type", + 416: "Range Not Satisfiable", + 417: "Expectation Failed", + 418: "Im a teapot", + 421: "Misdirected Request", + 422: "Unprocessable Content", + 423: "Locked", + 424: "Failed Dependency", + 425: "Too Early", + 426: "Upgrade Required", + 428: "Precondition Required", + 429: "Too Many Requests", + 431: "Request Header Fields Too Large", + 451: "Unavailable For Legal Reasons", + 500: "Internal Server Error", + 501: "Not Implemented", + 502: "Bad Gateway", + 503: "Service Unavailable", + 504: "Gateway Timeout", + 505: "HTTP Version Not Supported", + 506: "Variant Also Negotiates", + 507: "Insufficient Storage", + 508: "Loop Detected", + 510: "Not Extended", + 511: "Network Authentication Required", + ...options.errors, + }; + + const error = errors[result.status]; + if (error) { + throw new ApiError(options, result, error); + } + + if (!result.ok) { + const errorStatus = result.status ?? "unknown"; + const errorStatusText = result.statusText ?? "unknown"; + const errorBody = (() => { + try { + return JSON.stringify(result.body, null, 2); + } catch (e) { + return undefined; + } + })(); + + throw new ApiError( + options, + result, + `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`, + ); + } +}; + +/** + * Request method + * @param config The OpenAPI configuration object + * @param options The request options from the service + * @returns CancelablePromise + * @throws ApiError + */ +export const request = ( + config: OpenAPIConfig, + options: ApiRequestOptions, +): CancelablePromise => { + return new CancelablePromise(async (resolve, reject, onCancel) => { + try { + const url = getUrl(config, options); + const formData = getFormData(options); + const body = getRequestBody(options); + const headers = await getHeaders(config, options); + + if (!onCancel.isCancelled) { + let response = await sendRequest( + config, + options, + url, + body, + formData, + headers, + onCancel, + ); + + for (const fn of config.interceptors.response._fns) { + response = await fn(response); + } + + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader( + response, + options.responseHeader, + ); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader ?? responseBody, + }; + + catchErrorCodes(options, result); + + resolve(result.body); + } + } catch (error) { + reject(error); + } + }); +}; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..0af874e --- /dev/null +++ b/src/index.ts @@ -0,0 +1,10 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export { GenesisCloudClient } from "./GenesisCloudClient"; +export { ApiError } from "./core/ApiError"; +export { BaseHttpRequest } from "./core/BaseHttpRequest"; +export { CancelablePromise, CancelError } from "./core/CancelablePromise"; +export { OpenAPI, type OpenAPIConfig } from "./core/OpenAPI"; +export * from "./schemas.gen"; +export * from "./services.gen"; +export * from "./types.gen"; diff --git a/src/models/Catalog.ts b/src/models/Catalog.ts new file mode 100644 index 0000000..ed64b08 --- /dev/null +++ b/src/models/Catalog.ts @@ -0,0 +1,43 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Catalog_Fields } from "./Catalog_Fields"; +import type { Timestamp } from "./Timestamp"; + +export type Catalog = { + /** + * A unique identifier for each catalog. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the catalog. + * + */ + name: string; + /** + * The human-readable description for the catalog. + * + */ + description: string; + /** + * The url of the catalog + * + */ + logo_url: string; + /** + * The image catalog requires driver + * + */ + requires_driver: boolean; + base_image_ids: Array; + images: Array<{ + id: string; + name: string; + }>; + fields: Catalog_Fields; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/Catalog_Fields.ts b/src/models/Catalog_Fields.ts new file mode 100644 index 0000000..addbbcb --- /dev/null +++ b/src/models/Catalog_Fields.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Catalog_Fields = Array<{ + key: string; + label: string; + type: string; + env: string; +}>; diff --git a/src/models/Error.ts b/src/models/Error.ts new file mode 100644 index 0000000..5094768 --- /dev/null +++ b/src/models/Error.ts @@ -0,0 +1,17 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Error = { + /** + * The Genesis Cloud error code. + * Check the [developer documentation](https://developers.com/#error-codes) for more information on error codes. + * + */ + code: string; + /** + * An explanation of what went wrong. + */ + message: string; +}; diff --git a/src/models/Filesystem.ts b/src/models/Filesystem.ts new file mode 100644 index 0000000..03b806c --- /dev/null +++ b/src/models/Filesystem.ts @@ -0,0 +1,39 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Filesystem_Status } from "./Filesystem_Status"; +import type { FilesystemId } from "./FilesystemId"; +import type { FilesystemType } from "./FilesystemType"; +import type { Region } from "./Region"; +import type { Timestamp } from "./Timestamp"; + +export type Filesystem = { + id: FilesystemId; + /** + * The human-readable name for the filesystem. + */ + name: string; + /** + * The human-readable description for the filesystem. + */ + description: string; + type: FilesystemType; + /** + * The storage size of this filesystem given in GiB. + */ + size: number; + region: Region; + status: Filesystem_Status; + /** + * The mount endpoint range of the filesystem. + */ + mount_endpoint_range: Array | null; + /** + * The mount base path of the filesystem. + */ + mount_base_path: string | null; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/FilesystemId.ts b/src/models/FilesystemId.ts new file mode 100644 index 0000000..3665d35 --- /dev/null +++ b/src/models/FilesystemId.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * A unique identifier for each filesystem. This is automatically generated. + * + */ +export type FilesystemId = string; diff --git a/src/models/FilesystemType.ts b/src/models/FilesystemType.ts new file mode 100644 index 0000000..bbd903a --- /dev/null +++ b/src/models/FilesystemType.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The filesystem type. + */ +export type FilesystemType = "vast"; diff --git a/src/models/Filesystem_Status.ts b/src/models/Filesystem_Status.ts new file mode 100644 index 0000000..2fc1e3d --- /dev/null +++ b/src/models/Filesystem_Status.ts @@ -0,0 +1,6 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Filesystem_Status = "creating" | "created" | "deleting"; diff --git a/src/models/FloatingIP.ts b/src/models/FloatingIP.ts new file mode 100644 index 0000000..4a5944e --- /dev/null +++ b/src/models/FloatingIP.ts @@ -0,0 +1,57 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { FloatingIp_Status } from "./FloatingIp_Status"; +import type { Region } from "./Region"; +import type { Timestamp } from "./Timestamp"; + +export type FloatingIP = { + /** + * A unique identifier for each floating IP. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the floating IP. + * + */ + name: string; + /** + * The human-readable description for the floating IP. + * + */ + description: string; + /** + * The IP address of the floating IP. + * + */ + ip_address: string | null; + /** + * A boolean value indicating whether the floating IP is public or private. + * + */ + is_public: boolean; + /** + * The IP version of the floating IP. + * + */ + version: "ipv4" | "ipv6"; + region: Region; + status: FloatingIp_Status; + created_at: Timestamp; + updated_at: Timestamp; + instance: { + /** + * A unique identifier for the attached instance. + * + */ + id: string; + /** + * The name of the attached instance. + * + */ + name: string; + } | null; +}; diff --git a/src/models/FloatingIp_Status.ts b/src/models/FloatingIp_Status.ts new file mode 100644 index 0000000..3b28e7f --- /dev/null +++ b/src/models/FloatingIp_Status.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The floating ip status. + */ +export type FloatingIp_Status = "creating" | "created" | "deleting" | "error"; diff --git a/src/models/Image.ts b/src/models/Image.ts new file mode 100644 index 0000000..dcb0283 --- /dev/null +++ b/src/models/Image.ts @@ -0,0 +1,32 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Image_Type } from "./Image_Type"; +import type { ImageId } from "./ImageId"; +import type { OSType } from "./OSType"; +import type { Region } from "./Region"; +import type { Timestamp } from "./Timestamp"; + +export type Image = { + id: ImageId; + type: Image_Type; + family: string | null; + /** + * The display name that has been given to an image. This is what is shown in the control panel and is generally a descriptive title for the image in question. + */ + name: string; + os_type: OSType; + slug: string | null; + /** + * The list of versions if this is a cloud-image otherwise empty. + */ + versions: Array | null; + /** + * The list of regions in which this image can be used in. + */ + regions: Array; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/ImageId.ts b/src/models/ImageId.ts new file mode 100644 index 0000000..f1c413d --- /dev/null +++ b/src/models/ImageId.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * A unique number that can be used to identify and reference a specific image. + */ +export type ImageId = string; diff --git a/src/models/Image_Type.ts b/src/models/Image_Type.ts new file mode 100644 index 0000000..192626e --- /dev/null +++ b/src/models/Image_Type.ts @@ -0,0 +1,13 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Describes the kind of image. + */ +export type Image_Type = + | "base-os" + | "cloud-image" + | "preconfigured" + | "snapshot"; diff --git a/src/models/Instance.ts b/src/models/Instance.ts new file mode 100644 index 0000000..2611a78 --- /dev/null +++ b/src/models/Instance.ts @@ -0,0 +1,97 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ImageId } from "./ImageId"; +import type { Instance_Hostname } from "./Instance_Hostname"; +import type { Instance_Name } from "./Instance_Name"; +import type { Instance_SecurityGroupId } from "./Instance_SecurityGroupId"; +import type { Instance_SSHKeyId } from "./Instance_SSHKeyId"; +import type { Instance_Status } from "./Instance_Status"; +import type { Instance_Type } from "./Instance_Type"; +import type { OSType } from "./OSType"; +import type { Region } from "./Region"; +import type { Timestamp } from "./Timestamp"; +import type { VolumeId } from "./VolumeId"; + +export type Instance = { + /** + * The unique ID of the instance. + */ + id: string; + name: Instance_Name; + hostname: Instance_Hostname; + type: Instance_Type; + os_type: OSType; + /** + * The public IPv4 IP-Address (IPv4 address). + */ + public_ip: string | null; + /** + * The private IPv4 IP-Address (IPv4 address). + */ + private_ip: string | null; + status: Instance_Status; + /** + * The ssh keys of the instance. + */ + ssh_keys: Array<{ + id: Instance_SSHKeyId; + /** + * The name of the ssh key. + */ + name: string; + }>; + /** + * The image of the instance. + */ + image: { + id: ImageId; + /** + * The image name. + */ + name: string; + }; + /** + * The floating IP attached to the instance. + */ + floating_ip?: { + /** + * The ID of the floating IP. + */ + id: string; + /** + * The name of the floating IP. + */ + name: string; + } | null; + /** + * The security groups of the instance. + */ + security_groups: Array<{ + id: Instance_SecurityGroupId; + /** + * The name of the security group. + */ + name: string; + }>; + /** + * The volumes of the instance + */ + volumes: Array<{ + id: VolumeId; + /** + * The volume name. + */ + name: string; + }>; + region: Region; + /** + * The placement option identifier in which instances are physically located relative to each other within a zone. + * + */ + placement_option: string; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/Instance_Action.ts b/src/models/Instance_Action.ts new file mode 100644 index 0000000..0a0c9c0 --- /dev/null +++ b/src/models/Instance_Action.ts @@ -0,0 +1,6 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Instance_Action = "start" | "stop" | "reset"; diff --git a/src/models/Instance_BillingType.ts b/src/models/Instance_BillingType.ts new file mode 100644 index 0000000..b2d6135 --- /dev/null +++ b/src/models/Instance_BillingType.ts @@ -0,0 +1,15 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The billing type of the instance. + * + */ +export type Instance_BillingType = + | "on-demand" + | "prepaid-monthly" + | "prepaid-3-month" + | "prepaid-6-month" + | "prepaid-12-month"; diff --git a/src/models/Instance_DestroyOnShutdown.ts b/src/models/Instance_DestroyOnShutdown.ts new file mode 100644 index 0000000..df5b15e --- /dev/null +++ b/src/models/Instance_DestroyOnShutdown.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Option that you can set at instance creation that will allow the instance to destroy on shutdown command + * + */ +export type Instance_DestroyOnShutdown = boolean; diff --git a/src/models/Instance_FloatingIp.ts b/src/models/Instance_FloatingIp.ts new file mode 100644 index 0000000..5138b4e --- /dev/null +++ b/src/models/Instance_FloatingIp.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The id of the floating IP to attach to the instance. + */ +export type Instance_FloatingIp = string; diff --git a/src/models/Instance_Hostname.ts b/src/models/Instance_Hostname.ts new file mode 100644 index 0000000..7c8a53b --- /dev/null +++ b/src/models/Instance_Hostname.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The hostname of your instance. + */ +export type Instance_Hostname = string; diff --git a/src/models/Instance_IsProtected.ts b/src/models/Instance_IsProtected.ts new file mode 100644 index 0000000..6eae006 --- /dev/null +++ b/src/models/Instance_IsProtected.ts @@ -0,0 +1,12 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Specifies if the instance is termination protected. + * When set to `true`, it"s not possible to destroy the instance until it"s switched to `false`. + * Set to `true` automatically for long-term billed instances. + * + */ +export type Instance_IsProtected = boolean; diff --git a/src/models/Instance_Name.ts b/src/models/Instance_Name.ts new file mode 100644 index 0000000..9748802 --- /dev/null +++ b/src/models/Instance_Name.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The human-readable name set for the instance. + */ +export type Instance_Name = string; diff --git a/src/models/Instance_PublicIpv6.ts b/src/models/Instance_PublicIpv6.ts new file mode 100644 index 0000000..8ac7fcd --- /dev/null +++ b/src/models/Instance_PublicIpv6.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * A boolean value indicating whether the instance should have an ipv6 address or not. + * + */ +export type Instance_PublicIpv6 = boolean; diff --git a/src/models/Instance_ReuseLongTermSubscription.ts b/src/models/Instance_ReuseLongTermSubscription.ts new file mode 100644 index 0000000..b0b169c --- /dev/null +++ b/src/models/Instance_ReuseLongTermSubscription.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The long term subscription id to be used for this instance. + * If not provided, the billing_type will default to on-demand. + * + */ +export type Instance_ReuseLongTermSubscription = string; diff --git a/src/models/Instance_SSHKeyId.ts b/src/models/Instance_SSHKeyId.ts new file mode 100644 index 0000000..d2fe509 --- /dev/null +++ b/src/models/Instance_SSHKeyId.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The ssh key ID. + */ +export type Instance_SSHKeyId = string; diff --git a/src/models/Instance_SecurityGroupId.ts b/src/models/Instance_SecurityGroupId.ts new file mode 100644 index 0000000..62c4578 --- /dev/null +++ b/src/models/Instance_SecurityGroupId.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The security group ID. + */ +export type Instance_SecurityGroupId = string; diff --git a/src/models/Instance_SecurityGroupIds.ts b/src/models/Instance_SecurityGroupIds.ts new file mode 100644 index 0000000..32006f1 --- /dev/null +++ b/src/models/Instance_SecurityGroupIds.ts @@ -0,0 +1,14 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Instance_SecurityGroupId } from "./Instance_SecurityGroupId"; + +/** + * An array of security group ids. + * **Please Note**: By default the **standard security group** is set if you don"t specify any Security Groups. + * You can override this behavior by providing a different Security Group. + * + */ +export type Instance_SecurityGroupIds = Array; diff --git a/src/models/Instance_Status.ts b/src/models/Instance_Status.ts new file mode 100644 index 0000000..1f6edde --- /dev/null +++ b/src/models/Instance_Status.ts @@ -0,0 +1,25 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The instance status + */ +export type Instance_Status = + | "creating" + | "pending_payment" + | "active" + | "stopping" + | "stopped" + | "starting" + | "resetting" + | "error" + | "deleting" + | "enqueued" + | "copying" + | "build" + | "restarting" + | "shutoff" + | "updating" + | "unknown"; diff --git a/src/models/Instance_Type.ts b/src/models/Instance_Type.ts new file mode 100644 index 0000000..a15c7f9 --- /dev/null +++ b/src/models/Instance_Type.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The instance type identifier. + */ +export type Instance_Type = string; diff --git a/src/models/Instance_UserData.ts b/src/models/Instance_UserData.ts new file mode 100644 index 0000000..efd59f3 --- /dev/null +++ b/src/models/Instance_UserData.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Instance_UserData = Array<{ + type: string; + filename?: string; + content: string; +}>; diff --git a/src/models/InstancesAvailability.ts b/src/models/InstancesAvailability.ts new file mode 100644 index 0000000..8a85910 --- /dev/null +++ b/src/models/InstancesAvailability.ts @@ -0,0 +1,20 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Instance_Type } from "./Instance_Type"; +import type { Region } from "./Region"; + +export type InstancesAvailability = { + availability: { + type: string; + region: Region; + placement?: string; + instance_types: Array<{ + type: Instance_Type; + available: boolean; + count?: number; + }>; + }; +}; diff --git a/src/models/OSType.ts b/src/models/OSType.ts new file mode 100644 index 0000000..156ca91 --- /dev/null +++ b/src/models/OSType.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The OS type. + */ +export type OSType = "linux" | "windows"; diff --git a/src/models/PageQueryParameter.ts b/src/models/PageQueryParameter.ts new file mode 100644 index 0000000..bc6ef60 --- /dev/null +++ b/src/models/PageQueryParameter.ts @@ -0,0 +1,6 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type PageQueryParameter = number | null; diff --git a/src/models/PerPageQueryParameter.ts b/src/models/PerPageQueryParameter.ts new file mode 100644 index 0000000..ae0be18 --- /dev/null +++ b/src/models/PerPageQueryParameter.ts @@ -0,0 +1,6 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type PerPageQueryParameter = number | null; diff --git a/src/models/Region.ts b/src/models/Region.ts new file mode 100644 index 0000000..1bf49cb --- /dev/null +++ b/src/models/Region.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The region identifier. + */ +export type Region = "ARC-IS-HAF-1" | "EUC-DE-MUC-1" | "NORD-NO-KRS-1"; diff --git a/src/models/SSHKey.ts b/src/models/SSHKey.ts new file mode 100644 index 0000000..cf19422 --- /dev/null +++ b/src/models/SSHKey.ts @@ -0,0 +1,41 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Timestamp } from "./Timestamp"; + +export type SSHKey = { + /** + * A unique identifier for each SSH key. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the SSH key. + * + */ + name: string; + /** + * SSH public key. + * + */ + value: string; + /** + * The fingerprint of the SSH key. + * + */ + fingerprint: string; + /** + * The encryption algorithm type of the SSH key. + * + */ + type: string; + /** + * The length of the SSH key. + * + */ + size: number; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/SecurityGroup.ts b/src/models/SecurityGroup.ts new file mode 100644 index 0000000..4fdb463 --- /dev/null +++ b/src/models/SecurityGroup.ts @@ -0,0 +1,33 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Region } from "./Region"; +import type { SecurityGroup_Rule } from "./SecurityGroup_Rule"; +import type { SecurityGroup_Status } from "./SecurityGroup_Status"; +import type { Timestamp } from "./Timestamp"; + +export type SecurityGroup = { + /** + * A unique identifier for each security group. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the security group. + * + */ + name: string; + /** + * The human-readable description for the security group. + * + */ + description: string; + is_internal: boolean; + region: Region; + status: SecurityGroup_Status; + rules: Array; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/SecurityGroup_Rule.ts b/src/models/SecurityGroup_Rule.ts new file mode 100644 index 0000000..007059c --- /dev/null +++ b/src/models/SecurityGroup_Rule.ts @@ -0,0 +1,20 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { SecurityGroup_Rule_Direction } from "./SecurityGroup_Rule_Direction"; +import type { SecurityGroup_Rule_Protocol } from "./SecurityGroup_Rule_Protocol"; + +export type SecurityGroup_Rule = { + protocol: SecurityGroup_Rule_Protocol; + direction: SecurityGroup_Rule_Direction; + /** + * The minimum port number of the rule. + */ + port_range_min?: number | null; + /** + * The maximum port number of the rule. + */ + port_range_max?: number | null; +}; diff --git a/src/models/SecurityGroup_Rule_Direction.ts b/src/models/SecurityGroup_Rule_Direction.ts new file mode 100644 index 0000000..aa887dc --- /dev/null +++ b/src/models/SecurityGroup_Rule_Direction.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The direction of the rule. + */ +export type SecurityGroup_Rule_Direction = "ingress" | "egress"; diff --git a/src/models/SecurityGroup_Rule_Protocol.ts b/src/models/SecurityGroup_Rule_Protocol.ts new file mode 100644 index 0000000..48cee62 --- /dev/null +++ b/src/models/SecurityGroup_Rule_Protocol.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The protocol of the rule. + */ +export type SecurityGroup_Rule_Protocol = "tcp" | "udp" | "icmp" | "all"; diff --git a/src/models/SecurityGroup_Status.ts b/src/models/SecurityGroup_Status.ts new file mode 100644 index 0000000..5853f94 --- /dev/null +++ b/src/models/SecurityGroup_Status.ts @@ -0,0 +1,14 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The security group status. + */ +export type SecurityGroup_Status = + | "creating" + | "created" + | "deleting" + | "updating" + | "error"; diff --git a/src/models/Snapshot.ts b/src/models/Snapshot.ts new file mode 100644 index 0000000..304463f --- /dev/null +++ b/src/models/Snapshot.ts @@ -0,0 +1,37 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { OSType } from "./OSType"; +import type { Region } from "./Region"; +import type { Snapshot_Status } from "./Snapshot_Status"; +import type { Timestamp } from "./Timestamp"; + +export type Snapshot = { + /** + * A unique identifier for each snapshot. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the snapshot. + * + */ + name: string; + /** + * The storage size of this snapshot given in GiB. + * + */ + size: number; + /** + * The id of the resource (e.g. instance) that was snapshotted. + * + */ + resource_id: string; + region: Region; + status: Snapshot_Status; + os_type: OSType; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/Snapshot_Status.ts b/src/models/Snapshot_Status.ts new file mode 100644 index 0000000..98f385d --- /dev/null +++ b/src/models/Snapshot_Status.ts @@ -0,0 +1,15 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The snapshot status. + */ +export type Snapshot_Status = + | "creating" + | "created" + | "pending_delete" + | "deleting" + | "active" + | "error"; diff --git a/src/models/Timestamp.ts b/src/models/Timestamp.ts new file mode 100644 index 0000000..3901c1a --- /dev/null +++ b/src/models/Timestamp.ts @@ -0,0 +1,6 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Timestamp = Date; diff --git a/src/models/Volume.ts b/src/models/Volume.ts new file mode 100644 index 0000000..c706bbb --- /dev/null +++ b/src/models/Volume.ts @@ -0,0 +1,44 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Region } from "./Region"; +import type { Timestamp } from "./Timestamp"; +import type { Volume_Status } from "./Volume_Status"; +import type { VolumeId } from "./VolumeId"; +import type { VolumeType } from "./VolumeType"; + +export type Volume = { + id: VolumeId; + /** + * The human-readable name for the volume. + */ + name: string; + /** + * The human-readable description for the volume. + */ + description: string; + type: VolumeType; + /** + * The storage size of this volume given in GiB. + */ + size: number; + region: Region; + /** + * The attached instances. + */ + instances: Array<{ + /** + * The id of the attached instance. + */ + id?: string; + /** + * The name of the attached instance. + */ + name?: string; + }>; + status: Volume_Status; + created_at: Timestamp; + updated_at: Timestamp; +}; diff --git a/src/models/VolumeId.ts b/src/models/VolumeId.ts new file mode 100644 index 0000000..4dbe62b --- /dev/null +++ b/src/models/VolumeId.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * A unique identifier for each volume. This is automatically generated. + * + */ +export type VolumeId = string; diff --git a/src/models/VolumeType.ts b/src/models/VolumeType.ts new file mode 100644 index 0000000..7a541e7 --- /dev/null +++ b/src/models/VolumeType.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * The volume type. + */ +export type VolumeType = "ssd" | "hdd"; diff --git a/src/models/Volume_Status.ts b/src/models/Volume_Status.ts new file mode 100644 index 0000000..9ef758f --- /dev/null +++ b/src/models/Volume_Status.ts @@ -0,0 +1,13 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Volume_Status = + | "creating" + | "created" + | "pending_delete" + | "deleting" + | "available" + | "in-use" + | "error"; diff --git a/src/schemas.gen.ts b/src/schemas.gen.ts new file mode 100644 index 0000000..6c3ffdc --- /dev/null +++ b/src/schemas.gen.ts @@ -0,0 +1,1008 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export const $Timestamp = { + type: "string", + format: "date-time", +} as const; + +export const $Error = { + type: "object", + properties: { + code: { + type: "string", + examples: [2001], + description: `The Genesis Cloud error code. +Check the [developer documentation](https://developers.com/#error-codes) for more information on error codes. +`, + }, + message: { + type: "string", + examples: ["Invalid route"], + description: "An explanation of what went wrong.", + }, + }, + required: ["code", "message"], +} as const; + +export const $Image = { + type: "object", + properties: { + id: { + $ref: "#/components/schemas/ImageId", + }, + type: { + $ref: "#/components/schemas/Image.Type", + }, + family: { + type: "string", + nullable: true, + }, + name: { + type: "string", + description: + "The display name that has been given to an image. This is what is shown in the control panel and is generally a descriptive title for the image in question.", + }, + os_type: { + $ref: "#/components/schemas/OSType", + }, + slug: { + type: "string", + nullable: true, + }, + versions: { + description: + "The list of versions if this is a cloud-image otherwise empty.", + type: "array", + nullable: true, + items: { + type: "string", + }, + }, + regions: { + description: "The list of regions in which this image can be used in.", + type: "array", + items: { + $ref: "#/components/schemas/Region", + }, + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "type", + "family", + "name", + "os_type", + "slug", + "versions", + "regions", + "created_at", + "updated_at", + ], +} as const; + +export const $Image_Type = { + type: "string", + description: "Describes the kind of image.", + enum: ["base-os", "cloud-image", "preconfigured", "snapshot"], +} as const; + +export const $Snapshot = { + type: "object", + properties: { + id: { + type: "string", + description: `A unique identifier for each snapshot. This is automatically generated. +`, + }, + name: { + type: "string", + description: `The human-readable name for the snapshot. +`, + }, + size: { + type: "integer", + description: `The storage size of this snapshot given in GiB. +`, + }, + resource_id: { + type: "string", + description: `The id of the resource (e.g. instance) that was snapshotted. +`, + }, + region: { + $ref: "#/components/schemas/Region", + }, + status: { + $ref: "#/components/schemas/Snapshot.Status", + }, + os_type: { + $ref: "#/components/schemas/OSType", + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "name", + "size", + "resource_id", + "region", + "status", + "os_type", + "created_at", + "updated_at", + ], +} as const; + +export const $Snapshot_Status = { + type: "string", + description: "The snapshot status.", + enum: [ + "creating", + "created", + "pending_delete", + "deleting", + "active", + "error", + ], +} as const; + +export const $VolumeId = { + type: "string", + description: `A unique identifier for each volume. This is automatically generated. +`, +} as const; + +export const $Volume = { + type: "object", + properties: { + id: { + $ref: "#/components/schemas/VolumeId", + }, + name: { + type: "string", + description: "The human-readable name for the volume.", + }, + description: { + type: "string", + description: "The human-readable description for the volume.", + }, + type: { + $ref: "#/components/schemas/VolumeType", + }, + size: { + type: "integer", + description: "The storage size of this volume given in GiB.", + }, + region: { + $ref: "#/components/schemas/Region", + }, + instances: { + type: "array", + description: "The attached instances.", + items: { + type: "object", + properties: { + id: { + type: "string", + description: "The id of the attached instance.", + }, + name: { + type: "string", + description: "The name of the attached instance.", + }, + }, + }, + }, + status: { + $ref: "#/components/schemas/Volume.Status", + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "name", + "description", + "type", + "size", + "region", + "instances", + "status", + "created_at", + "updated_at", + ], +} as const; + +export const $Volume_Status = { + type: "string", + enum: [ + "creating", + "created", + "pending_delete", + "deleting", + "available", + "in-use", + "error", + ], +} as const; + +export const $FilesystemId = { + type: "string", + description: `A unique identifier for each filesystem. This is automatically generated. +`, +} as const; + +export const $Filesystem = { + type: "object", + properties: { + id: { + $ref: "#/components/schemas/FilesystemId", + }, + name: { + type: "string", + description: "The human-readable name for the filesystem.", + }, + description: { + type: "string", + description: "The human-readable description for the filesystem.", + }, + type: { + $ref: "#/components/schemas/FilesystemType", + }, + size: { + type: "integer", + description: "The storage size of this filesystem given in GiB.", + }, + region: { + $ref: "#/components/schemas/Region", + }, + status: { + $ref: "#/components/schemas/Filesystem.Status", + }, + mount_endpoint_range: { + type: "array", + items: { + type: "string", + }, + minItems: 2, + maxItems: 2, + nullable: true, + description: "The mount endpoint range of the filesystem.", + }, + mount_base_path: { + type: "string", + nullable: true, + description: "The mount base path of the filesystem.", + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "name", + "description", + "type", + "size", + "region", + "status", + "mount_endpoint_range", + "mount_base_path", + "created_at", + "updated_at", + ], +} as const; + +export const $Filesystem_Status = { + type: "string", + enum: ["creating", "created", "deleting"], +} as const; + +export const $SecurityGroup = { + type: "object", + properties: { + id: { + type: "string", + description: `A unique identifier for each security group. This is automatically generated. +`, + }, + name: { + type: "string", + description: `The human-readable name for the security group. +`, + }, + description: { + type: "string", + description: `The human-readable description for the security group. +`, + }, + is_internal: { + type: "boolean", + }, + region: { + $ref: "#/components/schemas/Region", + }, + status: { + $ref: "#/components/schemas/SecurityGroup.Status", + }, + rules: { + type: "array", + items: { + $ref: "#/components/schemas/SecurityGroup.Rule", + }, + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "name", + "description", + "is_internal", + "region", + "status", + "rules", + "created_at", + "updated_at", + ], +} as const; + +export const $SecurityGroup_Status = { + type: "string", + description: "The security group status.", + enum: ["creating", "created", "deleting", "updating", "error"], +} as const; + +export const $SecurityGroup_Rule = { + type: "object", + properties: { + protocol: { + $ref: "#/components/schemas/SecurityGroup.Rule.Protocol", + }, + direction: { + $ref: "#/components/schemas/SecurityGroup.Rule.Direction", + }, + port_range_min: { + description: "The minimum port number of the rule.", + type: "integer", + nullable: true, + }, + port_range_max: { + description: "The maximum port number of the rule.", + type: "integer", + nullable: true, + }, + }, + required: ["protocol", "direction"], +} as const; + +export const $SecurityGroup_Rule_Direction = { + description: "The direction of the rule.", + type: "string", + enum: ["ingress", "egress"], +} as const; + +export const $SecurityGroup_Rule_Protocol = { + description: "The protocol of the rule.", + type: "string", + enum: ["tcp", "udp", "icmp", "all"], +} as const; + +export const $Instance = { + type: "object", + properties: { + id: { + type: "string", + description: "The unique ID of the instance.", + }, + name: { + $ref: "#/components/schemas/Instance.Name", + }, + hostname: { + $ref: "#/components/schemas/Instance.Hostname", + }, + type: { + $ref: "#/components/schemas/Instance.Type", + }, + os_type: { + $ref: "#/components/schemas/OSType", + }, + public_ip: { + type: "string", + description: "The public IPv4 IP-Address (IPv4 address).", + examples: ["1.2.3.4"], + nullable: true, + }, + private_ip: { + type: "string", + description: "The private IPv4 IP-Address (IPv4 address).", + examples: ["1.2.3.4"], + nullable: true, + }, + status: { + $ref: "#/components/schemas/Instance.Status", + }, + ssh_keys: { + type: "array", + description: "The ssh keys of the instance.", + items: { + type: "object", + description: "The ssh key.", + properties: { + id: { + $ref: "#/components/schemas/Instance.SSHKeyId", + }, + name: { + type: "string", + description: "The name of the ssh key.", + }, + }, + required: ["id", "name"], + }, + }, + image: { + type: "object", + description: "The image of the instance.", + properties: { + id: { + $ref: "#/components/schemas/ImageId", + }, + name: { + type: "string", + description: "The image name.", + }, + }, + required: ["id", "name"], + }, + floating_ip: { + type: "object", + description: "The floating IP attached to the instance.", + nullable: true, + properties: { + id: { + type: "string", + description: "The ID of the floating IP.", + }, + name: { + type: "string", + description: "The name of the floating IP.", + }, + }, + required: ["id", "name"], + }, + security_groups: { + type: "array", + description: "The security groups of the instance.", + items: { + type: "object", + properties: { + id: { + $ref: "#/components/schemas/Instance.SecurityGroupId", + }, + name: { + type: "string", + description: "The name of the security group.", + }, + }, + required: ["id", "name"], + }, + }, + volumes: { + type: "array", + description: "The volumes of the instance", + items: { + type: "object", + properties: { + id: { + $ref: "#/components/schemas/VolumeId", + }, + name: { + type: "string", + description: "The volume name.", + }, + }, + required: ["id", "name"], + }, + }, + region: { + $ref: "#/components/schemas/Region", + }, + disk_size: { + $ref: "#/components/schemas/Instance.DiskSize", + }, + placement_option: { + type: "string", + description: `The placement option identifier in which instances are physically located relative to each other within a zone. +`, + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "name", + "hostname", + "type", + "os_type", + "public_ip", + "private_ip", + "status", + "ssh_keys", + "image", + "security_groups", + "volumes", + "region", + "placement_option", + "created_at", + "updated_at", + ], +} as const; + +export const $Instance_Name = { + type: "string", + description: "The human-readable name set for the instance.", +} as const; + +export const $Instance_Hostname = { + type: "string", + description: "The hostname of your instance.", +} as const; + +export const $ImageId = { + type: "string", + description: + "A unique number that can be used to identify and reference a specific image.", +} as const; + +export const $Instance_SSHKeyId = { + type: "string", + description: "The ssh key ID.", +} as const; + +export const $Instance_SecurityGroupIds = { + type: "array", + description: `An array of security group ids. +**Please Note**: By default the **standard security group** is set if you don"t specify any Security Groups. +You can override this behavior by providing a different Security Group. +`, + minItems: 1, + items: { + $ref: "#/components/schemas/Instance.SecurityGroupId", + }, +} as const; + +export const $Instance_SecurityGroupId = { + type: "string", + description: "The security group ID.", +} as const; + +export const $Instance_DiskSize = { + type: "integer", + description: `The storage size of the instance's boot volume given in GiB (Min: 80GiB). +`, +} as const; + +export const $Instance_IsProtected = { + type: "boolean", + default: false, + description: `Specifies if the instance is termination protected. +When set to \`true\`, it"s not possible to destroy the instance until it"s switched to \`false\`. +Set to \`true\` automatically for long-term billed instances. +`, +} as const; + +export const $Instance_DestroyOnShutdown = { + type: "boolean", + default: false, + description: `Option that you can set at instance creation that will allow the instance to destroy on shutdown command +`, +} as const; + +export const $Instance_Action = { + type: "string", + enum: ["start", "stop", "reset"], +} as const; + +export const $Instance_Status = { + type: "string", + description: "The instance status", + enum: [ + "creating", + "pending_payment", + "active", + "stopping", + "stopped", + "starting", + "resetting", + "error", + "deleting", + "enqueued", + "copying", + "build", + "restarting", + "shutoff", + "updating", + "unknown", + ], +} as const; + +export const $Instance_FloatingIp = { + type: "string", + description: "The id of the floating IP to attach to the instance.", +} as const; + +export const $Instance_PublicIpv6 = { + type: "boolean", + description: `A boolean value indicating whether the instance should have an ipv6 address or not. +`, + default: false, +} as const; + +export const $Instance_Type = { + type: "string", + description: "The instance type identifier.", + examples: ["vcpu-4_memory-24g_disk-80g_nvidia3090-1"], +} as const; + +export const $Instance_UserData = { + type: "array", + items: { + type: "object", + properties: { + type: { + type: "string", + }, + filename: { + type: "string", + }, + content: { + type: "string", + }, + }, + required: ["type", "content"], + }, +} as const; + +export const $Instance_BillingType = { + type: "string", + enum: [ + "on-demand", + "prepaid-monthly", + "prepaid-3-month", + "prepaid-6-month", + "prepaid-12-month", + ], + description: `The billing type of the instance. +`, +} as const; + +export const $Instance_ReuseLongTermSubscription = { + type: "string", + description: `The long term subscription id to be used for this instance. +If not provided, the billing_type will default to on-demand. +`, +} as const; + +export const $SSHKey = { + type: "object", + properties: { + id: { + type: "string", + description: `A unique identifier for each SSH key. This is automatically generated. +`, + }, + name: { + type: "string", + description: `The human-readable name for the SSH key. +`, + }, + value: { + type: "string", + description: `SSH public key. +`, + }, + fingerprint: { + type: "string", + description: `The fingerprint of the SSH key. +`, + }, + type: { + type: "string", + description: `The encryption algorithm type of the SSH key. +`, + }, + size: { + type: "integer", + description: `The length of the SSH key. +`, + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "name", + "value", + "fingerprint", + "type", + "size", + "created_at", + "updated_at", + ], +} as const; + +export const $FloatingIP = { + type: "object", + properties: { + id: { + type: "string", + description: `A unique identifier for each floating IP. This is automatically generated. +`, + }, + name: { + type: "string", + description: `The human-readable name for the floating IP. +`, + }, + description: { + type: "string", + description: `The human-readable description for the floating IP. +`, + }, + ip_address: { + type: "string", + nullable: true, + description: `The IP address of the floating IP. +`, + }, + is_public: { + type: "boolean", + description: `A boolean value indicating whether the floating IP is public or private. +`, + }, + version: { + type: "string", + enum: ["ipv4", "ipv6"], + description: `The IP version of the floating IP. +`, + }, + region: { + $ref: "#/components/schemas/Region", + }, + status: { + $ref: "#/components/schemas/FloatingIp.Status", + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + instance: { + type: "object", + nullable: true, + properties: { + id: { + type: "string", + description: `A unique identifier for the attached instance. +`, + }, + name: { + type: "string", + description: `The name of the attached instance. +`, + }, + }, + required: ["id", "name"], + }, + }, + required: [ + "id", + "name", + "description", + "is_public", + "region", + "status", + "created_at", + "updated_at", + "ip_address", + "version", + "instance", + ], +} as const; + +export const $FloatingIp_Status = { + type: "string", + description: "The floating ip status.", + enum: ["creating", "created", "deleting", "error"], +} as const; + +export const $Catalog = { + type: "object", + properties: { + id: { + type: "string", + description: `A unique identifier for each catalog. This is automatically generated. +`, + }, + name: { + type: "string", + description: `The human-readable name for the catalog. +`, + }, + description: { + type: "string", + description: `The human-readable description for the catalog. +`, + }, + logo_url: { + type: "string", + description: `The url of the catalog +`, + }, + requires_driver: { + type: "boolean", + description: `The image catalog requires driver +`, + }, + base_image_ids: { + type: "array", + items: { + type: "string", + }, + }, + images: { + type: "array", + items: { + type: "object", + properties: { + id: { + type: "string", + }, + name: { + type: "string", + }, + }, + required: ["id", "name"], + }, + }, + fields: { + $ref: "#/components/schemas/Catalog.Fields", + }, + created_at: { + $ref: "#/components/schemas/Timestamp", + }, + updated_at: { + $ref: "#/components/schemas/Timestamp", + }, + }, + required: [ + "id", + "name", + "description", + "logo_url", + "requires_driver", + "images", + "base_image_ids", + "fields", + "created_at", + "updated_at", + ], +} as const; + +export const $Catalog_Fields = { + type: "array", + items: { + type: "object", + properties: { + key: { + type: "string", + }, + label: { + type: "string", + }, + type: { + type: "string", + }, + env: { + type: "string", + }, + }, + required: ["key", "label", "type", "env"], + }, +} as const; + +export const $InstancesAvailability = { + type: "object", + properties: { + availability: { + type: "object", + properties: { + type: { + type: "string", + examples: ["instances"], + }, + region: { + $ref: "#/components/schemas/Region", + }, + placement: { + type: "string", + }, + instance_types: { + type: "array", + items: { + type: "object", + properties: { + type: { + $ref: "#/components/schemas/Instance.Type", + }, + available: { + type: "boolean", + }, + count: { + type: "number", + }, + }, + required: ["type", "available"], + }, + }, + }, + required: ["type", "region", "instance_types"], + }, + }, + required: ["availability"], +} as const; + +export const $Region = { + type: "string", + description: "The region identifier.", + enum: ["ARC-IS-HAF-1", "EUC-DE-MUC-1", "NORD-NO-KRS-1"], +} as const; + +export const $VolumeType = { + type: "string", + description: "The volume type.", + enum: ["ssd", "hdd"], +} as const; + +export const $FilesystemType = { + type: "string", + description: "The filesystem type.", + enum: ["vast"], +} as const; + +export const $OSType = { + type: "string", + description: "The OS type.", + enum: ["linux", "windows"], +} as const; diff --git a/src/services.gen.ts b/src/services.gen.ts new file mode 100644 index 0000000..ee77ae0 --- /dev/null +++ b/src/services.gen.ts @@ -0,0 +1,904 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { CancelablePromise } from "./core/CancelablePromise"; +import type { BaseHttpRequest } from "./core/BaseHttpRequest"; +import type { $OpenApiTs } from "./types.gen"; + +export class ImagesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List images + * @returns unknown PaginatedImagesResponse + * @throws ApiError + */ + public listImages( + data: $OpenApiTs["/images"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/images"]["get"]["res"][200]> { + const { page, perPage, type } = data; + return this.httpRequest.request({ + method: "GET", + url: "/images", + query: { + page, + per_page: perPage, + type, + }, + }); + } +} + +export class SnapshotsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Create snapshot + * @returns unknown SingleSnapshotResponse + * @throws ApiError + */ + public createSnapshot( + data: $OpenApiTs["/snapshots"]["post"]["req"], + ): CancelablePromise<$OpenApiTs["/snapshots"]["post"]["res"][201]> { + const { requestBody } = data; + return this.httpRequest.request({ + method: "POST", + url: "/snapshots", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List Snapshots + * @returns unknown PaginatedSnapshotsResponse + * @throws ApiError + */ + public listSnapshots( + data: $OpenApiTs["/snapshots"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/snapshots"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/snapshots", + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Get snapshot + * Get details of a snapshot with the given ID + * @returns unknown SingleSnapshotResponse + * @throws ApiError + */ + public getSnapshot( + data: $OpenApiTs["/snapshots/{snapshot_id}"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/snapshots/{snapshot_id}"]["get"]["res"][200] + > { + const { snapshotId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/snapshots/{snapshot_id}", + path: { + snapshot_id: snapshotId, + }, + }); + } + + /** + * Update snapshot + * Update the details of a snapshot with the given ID + * @returns unknown SingleSnapshotResponse + * @throws ApiError + */ + public updateSnapshot( + data: $OpenApiTs["/snapshots/{snapshot_id}"]["patch"]["req"], + ): CancelablePromise< + $OpenApiTs["/snapshots/{snapshot_id}"]["patch"]["res"][200] + > { + const { requestBody, snapshotId } = data; + return this.httpRequest.request({ + method: "PATCH", + url: "/snapshots/{snapshot_id}", + path: { + snapshot_id: snapshotId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete snapshot + * Delete a snapshot with the given ID + * @returns void success + * @throws ApiError + */ + public deleteSnapshot( + data: $OpenApiTs["/snapshots/{snapshot_id}"]["delete"]["req"], + ): CancelablePromise< + $OpenApiTs["/snapshots/{snapshot_id}"]["delete"]["res"][204] + > { + const { snapshotId } = data; + return this.httpRequest.request({ + method: "DELETE", + url: "/snapshots/{snapshot_id}", + path: { + snapshot_id: snapshotId, + }, + }); + } +} + +export class VolumesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Create volume + * @returns unknown SingleVolumeResponse + * @throws ApiError + */ + public createVolume( + data: $OpenApiTs["/volumes"]["post"]["req"], + ): CancelablePromise<$OpenApiTs["/volumes"]["post"]["res"][201]> { + const { requestBody } = data; + return this.httpRequest.request({ + method: "POST", + url: "/volumes", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List volumes + * @returns unknown PaginatedVolumesResponse + * @throws ApiError + */ + public listVolumes( + data: $OpenApiTs["/volumes"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/volumes"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/volumes", + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Get volume + * Get details of a volume with the given ID + * @returns unknown SingleVolumeResponse + * @throws ApiError + */ + public getVolume( + data: $OpenApiTs["/volumes/{volume_id}"]["get"]["req"], + ): CancelablePromise<$OpenApiTs["/volumes/{volume_id}"]["get"]["res"][200]> { + const { volumeId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/volumes/{volume_id}", + path: { + volume_id: volumeId, + }, + }); + } + + /** + * Update volume + * Update the details of a volume with the given ID + * @returns unknown SingleVolumeResponse + * @throws ApiError + */ + public updateVolume( + data: $OpenApiTs["/volumes/{volume_id}"]["patch"]["req"], + ): CancelablePromise< + $OpenApiTs["/volumes/{volume_id}"]["patch"]["res"][200] + > { + const { requestBody, volumeId } = data; + return this.httpRequest.request({ + method: "PATCH", + url: "/volumes/{volume_id}", + path: { + volume_id: volumeId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete volume + * Delete a volume with the given ID + * @returns void success + * @throws ApiError + */ + public deleteVolume( + data: $OpenApiTs["/volumes/{volume_id}"]["delete"]["req"], + ): CancelablePromise< + $OpenApiTs["/volumes/{volume_id}"]["delete"]["res"][204] + > { + const { volumeId } = data; + return this.httpRequest.request({ + method: "DELETE", + url: "/volumes/{volume_id}", + path: { + volume_id: volumeId, + }, + }); + } +} + +export class FilesystemsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Create filesystem + * @returns unknown SingleFilesystemResponse + * @throws ApiError + */ + public createFilesystem( + data: $OpenApiTs["/filesystems"]["post"]["req"], + ): CancelablePromise<$OpenApiTs["/filesystems"]["post"]["res"][201]> { + const { requestBody } = data; + return this.httpRequest.request({ + method: "POST", + url: "/filesystems", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List filesystems + * @returns unknown PaginatedFilesystemsResponse + * @throws ApiError + */ + public listFilesystems( + data: $OpenApiTs["/filesystems"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/filesystems"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/filesystems", + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Get filesystem + * Get details of a filesystem with the given ID + * @returns unknown SingleFilesystemResponse + * @throws ApiError + */ + public getFilesystem( + data: $OpenApiTs["/filesystems/{filesystem_id}"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/filesystems/{filesystem_id}"]["get"]["res"][200] + > { + const { filesystemId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/filesystems/{filesystem_id}", + path: { + filesystem_id: filesystemId, + }, + }); + } + + /** + * Update filesystem + * Update the details of a filesystem with the given ID + * @returns unknown SingleFilesystemResponse + * @throws ApiError + */ + public updateFilesystem( + data: $OpenApiTs["/filesystems/{filesystem_id}"]["patch"]["req"], + ): CancelablePromise< + $OpenApiTs["/filesystems/{filesystem_id}"]["patch"]["res"][200] + > { + const { requestBody, filesystemId } = data; + return this.httpRequest.request({ + method: "PATCH", + url: "/filesystems/{filesystem_id}", + path: { + filesystem_id: filesystemId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete filesystem + * Delete a filesystem with the given ID + * @returns void success + * @throws ApiError + */ + public deleteFilesystem( + data: $OpenApiTs["/filesystems/{filesystem_id}"]["delete"]["req"], + ): CancelablePromise< + $OpenApiTs["/filesystems/{filesystem_id}"]["delete"]["res"][204] + > { + const { filesystemId } = data; + return this.httpRequest.request({ + method: "DELETE", + url: "/filesystems/{filesystem_id}", + path: { + filesystem_id: filesystemId, + }, + }); + } +} + +export class SecurityGroupsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List security groups + * @returns unknown PaginatedSecurityGroupsResponse + * @throws ApiError + */ + public listSecurityGroups( + data: $OpenApiTs["/security-groups"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/security-groups"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/security-groups", + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Create security group + * @returns unknown SingleSecurityGroupResponse + * @throws ApiError + */ + public createSecurityGroup( + data: $OpenApiTs["/security-groups"]["post"]["req"], + ): CancelablePromise<$OpenApiTs["/security-groups"]["post"]["res"][201]> { + const { requestBody } = data; + return this.httpRequest.request({ + method: "POST", + url: "/security-groups", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get security group + * Get details of a security group with the given ID + * @returns unknown SingleSecurityGroupResponse + * @throws ApiError + */ + public getSecurityGroup( + data: $OpenApiTs["/security-groups/{security_group_id}"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/security-groups/{security_group_id}"]["get"]["res"][200] + > { + const { securityGroupId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/security-groups/{security_group_id}", + path: { + security_group_id: securityGroupId, + }, + }); + } + + /** + * Update security group + * Update the details of a security group with the given ID + * @returns unknown SingleSecurityGroupResponse + * @throws ApiError + */ + public updateSecurityGroup( + data: $OpenApiTs["/security-groups/{security_group_id}"]["patch"]["req"], + ): CancelablePromise< + $OpenApiTs["/security-groups/{security_group_id}"]["patch"]["res"][200] + > { + const { requestBody, securityGroupId } = data; + return this.httpRequest.request({ + method: "PATCH", + url: "/security-groups/{security_group_id}", + path: { + security_group_id: securityGroupId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete security group + * Delete a security group with the given ID + * @returns void success + * @throws ApiError + */ + public deleteSecurityGroup( + data: $OpenApiTs["/security-groups/{security_group_id}"]["delete"]["req"], + ): CancelablePromise< + $OpenApiTs["/security-groups/{security_group_id}"]["delete"]["res"][204] + > { + const { securityGroupId } = data; + return this.httpRequest.request({ + method: "DELETE", + url: "/security-groups/{security_group_id}", + path: { + security_group_id: securityGroupId, + }, + }); + } +} + +export class InstancesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List instances + * @returns unknown PaginatedInstancesResponse + * @throws ApiError + */ + public listInstances( + data: $OpenApiTs["/instances"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/instances"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/instances", + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Create instance + * @returns unknown SingleInstanceResponse + * @throws ApiError + */ + public createInstance( + data: $OpenApiTs["/instances"]["post"]["req"], + ): CancelablePromise<$OpenApiTs["/instances"]["post"]["res"][201]> { + const { requestBody } = data; + return this.httpRequest.request({ + method: "POST", + url: "/instances", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get instance + * Get details of an instance with the given ID. + * @returns unknown SingleInstanceResponse + * @throws ApiError + */ + public getInstance( + data: $OpenApiTs["/instances/{instance_id}"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/instances/{instance_id}"]["get"]["res"][200] + > { + const { instanceId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/instances/{instance_id}", + path: { + instance_id: instanceId, + }, + }); + } + + /** + * Delete instance + * Delete an instance with the given ID. + * @returns void success + * @throws ApiError + */ + public deleteInstance( + data: $OpenApiTs["/instances/{instance_id}"]["delete"]["req"], + ): CancelablePromise< + $OpenApiTs["/instances/{instance_id}"]["delete"]["res"][204] + > { + const { instanceId } = data; + return this.httpRequest.request({ + method: "DELETE", + url: "/instances/{instance_id}", + path: { + instance_id: instanceId, + }, + }); + } + + /** + * Update instance (attach/detach volumes, security groups, instance name) + * Update instance with the given ID (attach/detach volumes, security groups, name). + * @returns unknown SingleInstanceResponse + * @throws ApiError + */ + public updateInstance( + data: $OpenApiTs["/instances/{instance_id}"]["patch"]["req"], + ): CancelablePromise< + $OpenApiTs["/instances/{instance_id}"]["patch"]["res"][200] + > { + const { requestBody, instanceId } = data; + return this.httpRequest.request({ + method: "PATCH", + url: "/instances/{instance_id}", + path: { + instance_id: instanceId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List Instance actions + * Liste all actions that can currently be performed on a instance. + * @returns unknown Instance.ListActionsResponse + * @throws ApiError + */ + public listInstanceActions( + data: $OpenApiTs["/instances/{instance_id}/actions"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/instances/{instance_id}/actions"]["get"]["res"][200] + > { + const { instanceId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/instances/{instance_id}/actions", + path: { + instance_id: instanceId, + }, + }); + } + + /** + * Perform action + * The action to perform on the instance. + * @returns void success + * @throws ApiError + */ + public performInstanceAction( + data: $OpenApiTs["/instances/{instance_id}/actions"]["post"]["req"], + ): CancelablePromise< + $OpenApiTs["/instances/{instance_id}/actions"]["post"]["res"][204] + > { + const { requestBody, instanceId } = data; + return this.httpRequest.request({ + method: "POST", + url: "/instances/{instance_id}/actions", + path: { + instance_id: instanceId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List instance snapshots + * @returns unknown PaginatedSnapshotsResponse + * @throws ApiError + */ + public listInstanceSnapshots( + data: $OpenApiTs["/instances/{instance_id}/snapshots"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/instances/{instance_id}/snapshots"]["get"]["res"][200] + > { + const { instanceId, page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/instances/{instance_id}/snapshots", + path: { + instance_id: instanceId, + }, + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Create instance snapshot + * Takes a snapshot of the instance. + * @returns unknown SingleSnapshotResponse + * @throws ApiError + */ + public createInstanceSnapshot( + data: $OpenApiTs["/instances/{instance_id}/snapshots"]["post"]["req"], + ): CancelablePromise< + $OpenApiTs["/instances/{instance_id}/snapshots"]["post"]["res"][201] + > { + const { requestBody, instanceId } = data; + return this.httpRequest.request({ + method: "POST", + url: "/instances/{instance_id}/snapshots", + path: { + instance_id: instanceId, + }, + body: requestBody, + mediaType: "application/json", + }); + } +} + +export class SshKeysService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List SSH keys + * @returns unknown PaginatedSSHKeysResponse + * @throws ApiError + */ + public listSshKeys( + data: $OpenApiTs["/ssh-keys"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/ssh-keys"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/ssh-keys", + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Create SSH key + * @returns SSHKey SingleSSHKeyResponse + * @throws ApiError + */ + public createSshKey( + data: $OpenApiTs["/ssh-keys"]["post"]["req"], + ): CancelablePromise<$OpenApiTs["/ssh-keys"]["post"]["res"][201]> { + const { requestBody } = data; + return this.httpRequest.request({ + method: "POST", + url: "/ssh-keys", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get SSH key + * Get details of a ssh key with the given ID. + * @returns SSHKey SingleSSHKeyResponse + * @throws ApiError + */ + public getSshKey( + data: $OpenApiTs["/ssh-keys/{ssh_key_id}"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/ssh-keys/{ssh_key_id}"]["get"]["res"][200] + > { + const { sshKeyId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/ssh-keys/{ssh_key_id}", + path: { + ssh_key_id: sshKeyId, + }, + }); + } + + /** + * Update SSH key + * Edit the name of an existing SSH key. + * @returns SSHKey SingleSSHKeyResponse + * @throws ApiError + */ + public updateSshKey( + data: $OpenApiTs["/ssh-keys/{ssh_key_id}"]["patch"]["req"], + ): CancelablePromise< + $OpenApiTs["/ssh-keys/{ssh_key_id}"]["patch"]["res"][200] + > { + const { requestBody, sshKeyId } = data; + return this.httpRequest.request({ + method: "PATCH", + url: "/ssh-keys/{ssh_key_id}", + path: { + ssh_key_id: sshKeyId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete SSH key + * Delete a ssh key with the given ID. + * @returns void success + * @throws ApiError + */ + public deleteSshKey( + data: $OpenApiTs["/ssh-keys/{ssh_key_id}"]["delete"]["req"], + ): CancelablePromise< + $OpenApiTs["/ssh-keys/{ssh_key_id}"]["delete"]["res"][204] + > { + const { sshKeyId } = data; + return this.httpRequest.request({ + method: "DELETE", + url: "/ssh-keys/{ssh_key_id}", + path: { + ssh_key_id: sshKeyId, + }, + }); + } +} + +export class FloatingIpsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List floating IPs + * @returns unknown PaginatedFloatingIPsResponse + * @throws ApiError + */ + public listFloatingIps( + data: $OpenApiTs["/floating-ips"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/floating-ips"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/floating-ips", + query: { + page, + per_page: perPage, + }, + }); + } + + /** + * Create floating IP + * Create a new floating IP. + * @returns unknown SingleFloatingIPResponse + * @throws ApiError + */ + public createFloatingIp( + data: $OpenApiTs["/floating-ips"]["post"]["req"], + ): CancelablePromise<$OpenApiTs["/floating-ips"]["post"]["res"][201]> { + const { requestBody } = data; + return this.httpRequest.request({ + method: "POST", + url: "/floating-ips", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get floating IP + * Get floating IP. + * @returns unknown SingleFloatingIPResponse + * @throws ApiError + */ + public getFloatingIp( + data: $OpenApiTs["/floating-ips/{floating_ip_id}"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/floating-ips/{floating_ip_id}"]["get"]["res"][200] + > { + const { floatingIpId } = data; + return this.httpRequest.request({ + method: "GET", + url: "/floating-ips/{floating_ip_id}", + path: { + floating_ip_id: floatingIpId, + }, + }); + } + + /** + * Update floating IP + * Update an existing floating IP. + * @returns unknown SingleFloatingIPResponse + * @throws ApiError + */ + public updateFloatingIp( + data: $OpenApiTs["/floating-ips/{floating_ip_id}"]["patch"]["req"], + ): CancelablePromise< + $OpenApiTs["/floating-ips/{floating_ip_id}"]["patch"]["res"][200] + > { + const { requestBody, floatingIpId } = data; + return this.httpRequest.request({ + method: "PATCH", + url: "/floating-ips/{floating_ip_id}", + path: { + floating_ip_id: floatingIpId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete floating IP + * Delete floating IP. + * @returns void success + * @throws ApiError + */ + public deleteFloatingIp( + data: $OpenApiTs["/floating-ips/{floating_ip_id}"]["delete"]["req"], + ): CancelablePromise< + $OpenApiTs["/floating-ips/{floating_ip_id}"]["delete"]["res"][204] + > { + const { floatingIpId } = data; + return this.httpRequest.request({ + method: "DELETE", + url: "/floating-ips/{floating_ip_id}", + path: { + floating_ip_id: floatingIpId, + }, + }); + } +} + +export class AvailabilityService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Get cluster availability for region + * @returns InstancesAvailability InstancesAvailabilityResponse + * @throws ApiError + */ + public getInstancesAvailability( + data: $OpenApiTs["/availability/{region}/instances"]["get"]["req"], + ): CancelablePromise< + $OpenApiTs["/availability/{region}/instances"]["get"]["res"][200] + > { + const { region, placement } = data; + return this.httpRequest.request({ + method: "GET", + url: "/availability/{region}/instances", + path: { + region, + }, + query: { + placement, + }, + }); + } +} + +export class CatalogService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List catalog + * @returns unknown PaginatedCatalogResponse + * @throws ApiError + */ + public listCatalog( + data: $OpenApiTs["/catalog"]["get"]["req"] = {}, + ): CancelablePromise<$OpenApiTs["/catalog"]["get"]["res"][200]> { + const { page, perPage } = data; + return this.httpRequest.request({ + method: "GET", + url: "/catalog", + query: { + page, + per_page: perPage, + }, + }); + } +} diff --git a/src/services/AvailabilityService.ts b/src/services/AvailabilityService.ts new file mode 100644 index 0000000..417b2ee --- /dev/null +++ b/src/services/AvailabilityService.ts @@ -0,0 +1,37 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { InstancesAvailability } from "../models/InstancesAvailability"; +import type { Region } from "../models/Region"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class AvailabilityService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Get cluster availability for region + * @returns InstancesAvailability InstancesAvailabilityResponse + * @throws ApiError + */ + public getInstancesAvailability({ + region, + placement, + }: { + region: Region; + placement?: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "GET", + url: "/availability/{region}/instances", + path: { + region: region, + }, + query: { + placement: placement, + }, + }); + } +} diff --git a/src/services/CatalogService.ts b/src/services/CatalogService.ts new file mode 100644 index 0000000..01f6952 --- /dev/null +++ b/src/services/CatalogService.ts @@ -0,0 +1,39 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { Catalog } from "../models/Catalog"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class CatalogService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List catalog + * @returns any PaginatedCatalogResponse + * @throws ApiError + */ + public listCatalog({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + catalog: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/catalog", + query: { + page: page, + per_page: perPage, + }, + }); + } +} diff --git a/src/services/FilesystemsService.ts b/src/services/FilesystemsService.ts new file mode 100644 index 0000000..a9e5451 --- /dev/null +++ b/src/services/FilesystemsService.ts @@ -0,0 +1,160 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { Filesystem } from "../models/Filesystem"; +import type { FilesystemType } from "../models/FilesystemType"; +import type { Region } from "../models/Region"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class FilesystemsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Create filesystem + * @returns any SingleFilesystemResponse + * @throws ApiError + */ + public createFilesystem({ + requestBody, + }: { + requestBody: { + /** + * The human-readable name set for the filesystem. + * + */ + name: string; + /** + * The human-readable description set for the filesystem. + * + */ + description?: string; + type?: FilesystemType; + /** + * The storage size of this filesystem given in GiB (Min: 1GiB). + * + */ + size: number; + region: Region; + }; + }): CancelablePromise<{ + filesystem: Filesystem; + }> { + return this.httpRequest.request({ + method: "POST", + url: "/filesystems", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List filesystems + * @returns any PaginatedFilesystemsResponse + * @throws ApiError + */ + public listFilesystems({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + filesystems: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/filesystems", + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Get filesystem + * Get details of a filesystem with the given ID + * @returns any SingleFilesystemResponse + * @throws ApiError + */ + public getFilesystem({ + filesystemId, + }: { + filesystemId: string; + }): CancelablePromise<{ + filesystem: Filesystem; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/filesystems/{filesystem_id}", + path: { + filesystem_id: filesystemId, + }, + }); + } + + /** + * Update filesystem + * Update the details of a filesystem with the given ID + * @returns any SingleFilesystemResponse + * @throws ApiError + */ + public updateFilesystem({ + filesystemId, + requestBody, + }: { + filesystemId: string; + requestBody: { + /** + * The human-readable name set for the filesystem. + */ + name?: string; + /** + * The human-readable description set for the filesystem. + */ + description?: string; + /** + * The storage size of this filesystem given in GiB. + */ + size?: number; + }; + }): CancelablePromise<{ + filesystem: Filesystem; + }> { + return this.httpRequest.request({ + method: "PATCH", + url: "/filesystems/{filesystem_id}", + path: { + filesystem_id: filesystemId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete filesystem + * Delete a filesystem with the given ID + * @returns void + * @throws ApiError + */ + public deleteFilesystem({ + filesystemId, + }: { + filesystemId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/filesystems/{filesystem_id}", + path: { + filesystem_id: filesystemId, + }, + }); + } +} diff --git a/src/services/FloatingIPsService.ts b/src/services/FloatingIPsService.ts new file mode 100644 index 0000000..a229d9c --- /dev/null +++ b/src/services/FloatingIPsService.ts @@ -0,0 +1,155 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { FloatingIP } from "../models/FloatingIP"; +import type { Region } from "../models/Region"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class FloatingIPsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List floating IPs + * @returns any PaginatedFloatingIPsResponse + * @throws ApiError + */ + public listFloatingIPs({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + floating_ips: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/floating-ips", + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Create floating IP + * Create a new floating IP. + * @returns any SingleFloatingIPResponse + * @throws ApiError + */ + public createFloatingIp({ + requestBody, + }: { + requestBody: { + /** + * The human-readable name set for the floating IP. + * + */ + name: string; + /** + * The human-readable description set for the floating IP. + * + */ + description?: string; + region: Region; + /** + * The IP version of the floating IP. + * + */ + version?: "ipv4"; + }; + }): CancelablePromise<{ + floating_ip: FloatingIP; + }> { + return this.httpRequest.request({ + method: "POST", + url: "/floating-ips", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get floating IP + * Get floating IP. + * @returns any SingleFloatingIPResponse + * @throws ApiError + */ + public getFloatingIp({ + floatingIpId, + }: { + floatingIpId: string; + }): CancelablePromise<{ + floating_ip: FloatingIP; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/floating-ips/{floating_ip_id}", + path: { + floating_ip_id: floatingIpId, + }, + }); + } + + /** + * Update floating IP + * Update an existing floating IP. + * @returns any SingleFloatingIPResponse + * @throws ApiError + */ + public updateFloatingIp({ + floatingIpId, + requestBody, + }: { + floatingIpId: string; + requestBody: { + /** + * The human-readable name set for the floating IP. + */ + name?: string; + /** + * The human-readable description set for the floating IP. + */ + description?: string; + }; + }): CancelablePromise<{ + floating_ip: FloatingIP; + }> { + return this.httpRequest.request({ + method: "PATCH", + url: "/floating-ips/{floating_ip_id}", + path: { + floating_ip_id: floatingIpId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete floating IP + * Delete floating IP. + * @returns void + * @throws ApiError + */ + public deleteFloatingIp({ + floatingIpId, + }: { + floatingIpId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/floating-ips/{floating_ip_id}", + path: { + floating_ip_id: floatingIpId, + }, + }); + } +} diff --git a/src/services/ImagesService.ts b/src/services/ImagesService.ts new file mode 100644 index 0000000..5acaece --- /dev/null +++ b/src/services/ImagesService.ts @@ -0,0 +1,43 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { Image } from "../models/Image"; +import type { Image_Type } from "../models/Image_Type"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class ImagesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List images + * @returns any PaginatedImagesResponse + * @throws ApiError + */ + public listImages({ + page = 1, + perPage = 50, + type, + }: { + page?: number | null; + perPage?: number | null; + type?: Image_Type; + }): CancelablePromise<{ + images: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/images", + query: { + page: page, + per_page: perPage, + type: type, + }, + }); + } +} diff --git a/src/services/InstancesService.ts b/src/services/InstancesService.ts new file mode 100644 index 0000000..8aab4da --- /dev/null +++ b/src/services/InstancesService.ts @@ -0,0 +1,318 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ImageId } from "../models/ImageId"; +import type { Instance } from "../models/Instance"; +import type { Instance_Action } from "../models/Instance_Action"; +import type { Instance_BillingType } from "../models/Instance_BillingType"; +import type { Instance_DestroyOnShutdown } from "../models/Instance_DestroyOnShutdown"; +import type { Instance_FloatingIp } from "../models/Instance_FloatingIp"; +import type { Instance_Hostname } from "../models/Instance_Hostname"; +import type { Instance_IsProtected } from "../models/Instance_IsProtected"; +import type { Instance_Name } from "../models/Instance_Name"; +import type { Instance_PublicIpv6 } from "../models/Instance_PublicIpv6"; +import type { Instance_ReuseLongTermSubscription } from "../models/Instance_ReuseLongTermSubscription"; +import type { Instance_SecurityGroupIds } from "../models/Instance_SecurityGroupIds"; +import type { Instance_SSHKeyId } from "../models/Instance_SSHKeyId"; +import type { Instance_Type } from "../models/Instance_Type"; +import type { Instance_UserData } from "../models/Instance_UserData"; +import type { Region } from "../models/Region"; +import type { Snapshot } from "../models/Snapshot"; +import type { VolumeId } from "../models/VolumeId"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class InstancesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List instances + * @returns any PaginatedInstancesResponse + * @throws ApiError + */ + public listInstances({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + instances: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/instances", + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Create instance + * @returns any SingleInstanceResponse + * @throws ApiError + */ + public createInstance({ + requestBody, + }: { + requestBody: { + name: Instance_Name; + hostname: Instance_Hostname; + type: Instance_Type; + image: ImageId; + /** + * An array of ssh key ids. + * This should not be provided if `password` authentication method is desired. + * + */ + ssh_keys?: Array; + /** + * An array of volume ids. + * + */ + volumes?: Array; + /** + * The password to access the instance. + * Your password must have upper and lower chars, digits and length between 8-72. + * **Please Note**: Only one of `ssh_keys` or `password` can be provided. + * Password is less secure - we recommend you use an SSH key-pair. + * + */ + password?: string; + /** + * The placement option identifier in which instances are physically located relative to each other within a zone. + * + */ + placement_option?: string; + security_groups?: Instance_SecurityGroupIds; + is_protected?: Instance_IsProtected; + destroy_on_shutdown?: Instance_DestroyOnShutdown; + public_ipv6?: Instance_PublicIpv6; + floating_ip?: Instance_FloatingIp; + region: Region; + billing_type?: Instance_BillingType; + reuse_long_term_subscription?: Instance_ReuseLongTermSubscription; + /** + * The storage size of the instance's boot volume given in GiB (Min: 80GiB). + * + */ + disk_size?: number; + /** + * Option to provide metadata. + */ + metadata?: { + user_data?: Instance_UserData; + /** + * A plain text bash script or "cloud-config" file that will be executed after the first instance boot. + * It is limited to 64 KiB in size. You can use it to configure your instance, e.g. installing the **NVIDIA GPU driver**. + * Learn more about [startup scripts and installing the GPU driver](https://support.com/support/solutions/articles/47001122478). + * + */ + startup_script?: string; + }; + }; + }): CancelablePromise<{ + instance: Instance; + }> { + return this.httpRequest.request({ + method: "POST", + url: "/instances", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get instance + * Get details of an instance with the given ID. + * @returns any SingleInstanceResponse + * @throws ApiError + */ + public getInstance({ + instanceId, + }: { + instanceId: string; + }): CancelablePromise<{ + instance: Instance; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/instances/{instance_id}", + path: { + instance_id: instanceId, + }, + }); + } + + /** + * Delete instance + * Delete an instance with the given ID. + * @returns void + * @throws ApiError + */ + public deleteInstance({ + instanceId, + }: { + instanceId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/instances/{instance_id}", + path: { + instance_id: instanceId, + }, + }); + } + + /** + * Update instance (attach/detach volumes, security groups, instance name) + * Update instance with the given ID (attach/detach volumes, security groups, name). + * @returns any SingleInstanceResponse + * @throws ApiError + */ + public updateInstance({ + instanceId, + requestBody, + }: { + instanceId: string; + requestBody: { + name?: Instance_Name; + is_protected?: Instance_IsProtected; + security_groups?: Instance_SecurityGroupIds; + /** + * The instance's volumes IDs. + */ + volumes?: Array; + }; + }): CancelablePromise<{ + instance: Instance; + }> { + return this.httpRequest.request({ + method: "PATCH", + url: "/instances/{instance_id}", + path: { + instance_id: instanceId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List Instance actions + * Liste all actions that can currently be performed on a instance. + * @returns any Instance.ListActionsResponse + * @throws ApiError + */ + public listInstanceActions({ + instanceId, + }: { + instanceId: string; + }): CancelablePromise<{ + actions: Array; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/instances/{instance_id}/actions", + path: { + instance_id: instanceId, + }, + }); + } + + /** + * Perform action + * The action to perform on the instance. + * @returns void + * @throws ApiError + */ + public performInstanceAction({ + instanceId, + requestBody, + }: { + instanceId: string; + requestBody: { + action: Instance_Action; + }; + }): CancelablePromise { + return this.httpRequest.request({ + method: "POST", + url: "/instances/{instance_id}/actions", + path: { + instance_id: instanceId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List instance snapshots + * @returns any PaginatedSnapshotsResponse + * @throws ApiError + */ + public listInstanceSnapshots({ + instanceId, + page = 1, + perPage = 50, + }: { + instanceId: string; + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + snapshots: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/instances/{instance_id}/snapshots", + path: { + instance_id: instanceId, + }, + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Create instance snapshot + * Takes a snapshot of the instance. + * @returns any SingleSnapshotResponse + * @throws ApiError + */ + public createInstanceSnapshot({ + instanceId, + requestBody, + }: { + instanceId: string; + requestBody: { + /** + * Name of the snapshot. + */ + name: string; + }; + }): CancelablePromise<{ + snapshot: Snapshot; + }> { + return this.httpRequest.request({ + method: "POST", + url: "/instances/{instance_id}/snapshots", + path: { + instance_id: instanceId, + }, + body: requestBody, + mediaType: "application/json", + }); + } +} diff --git a/src/services/SecurityGroupsService.ts b/src/services/SecurityGroupsService.ts new file mode 100644 index 0000000..2a68517 --- /dev/null +++ b/src/services/SecurityGroupsService.ts @@ -0,0 +1,157 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { Region } from "../models/Region"; +import type { SecurityGroup } from "../models/SecurityGroup"; +import type { SecurityGroup_Rule } from "../models/SecurityGroup_Rule"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class SecurityGroupsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List security groups + * @returns any PaginatedSecurityGroupsResponse + * @throws ApiError + */ + public listSecurityGroups({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + security_groups: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/security-groups", + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Create security group + * @returns any SingleSecurityGroupResponse + * @throws ApiError + */ + public createSecurityGroup({ + requestBody, + }: { + requestBody: { + /** + * The human-readable name set for the security group. **Please Note**: `default` and `standard` are not allowed names (reserved words). + * + */ + name: string; + /** + * he human-readable description set for the security group. + */ + description?: string; + region: Region; + /** + * The list of rules of the security group. + */ + rules: Array; + }; + }): CancelablePromise<{ + security_group: SecurityGroup; + }> { + return this.httpRequest.request({ + method: "POST", + url: "/security-groups", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get security group + * Get details of a security group with the given ID + * @returns any SingleSecurityGroupResponse + * @throws ApiError + */ + public getSecurityGroup({ + securityGroupId, + }: { + securityGroupId: string; + }): CancelablePromise<{ + security_group: SecurityGroup; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/security-groups/{security_group_id}", + path: { + security_group_id: securityGroupId, + }, + }); + } + + /** + * Update security group + * Update the details of a security group with the given ID + * @returns any SingleSecurityGroupResponse + * @throws ApiError + */ + public updateSecurityGroup({ + securityGroupId, + requestBody, + }: { + securityGroupId: string; + requestBody: { + /** + * The human-readable name set for the security group. + */ + name?: string; + /** + * he human-readable description set for the security group. + */ + description?: string; + /** + * The list of rules of the security group. + */ + rules?: Array; + }; + }): CancelablePromise<{ + security_group: SecurityGroup; + }> { + return this.httpRequest.request({ + method: "PATCH", + url: "/security-groups/{security_group_id}", + path: { + security_group_id: securityGroupId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete security group + * Delete a security group with the given ID + * @returns void + * @throws ApiError + */ + public deleteSecurityGroup({ + securityGroupId, + }: { + securityGroupId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/security-groups/{security_group_id}", + path: { + security_group_id: securityGroupId, + }, + }); + } +} diff --git a/src/services/SnapshotsService.ts b/src/services/SnapshotsService.ts new file mode 100644 index 0000000..5b29aab --- /dev/null +++ b/src/services/SnapshotsService.ts @@ -0,0 +1,153 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { OSType } from "../models/OSType"; +import type { Region } from "../models/Region"; +import type { Snapshot } from "../models/Snapshot"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class SnapshotsService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Create snapshot + * @returns any SingleSnapshotResponse + * @throws ApiError + */ + public createSnapshot({ + requestBody, + }: { + requestBody: { + /** + * The human-readable name set for the snapshot. + * + */ + name: string; + /** + * The storage size of this snapshot given in GiB (Min: 1GiB). + * + */ + size: number; + /** + * The url pointing to a raw or raw with zstd compressed image. + * + */ + url: string; + os_type?: OSType; + region: Region; + }; + }): CancelablePromise<{ + snapshot: Snapshot; + }> { + return this.httpRequest.request({ + method: "POST", + url: "/snapshots", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List Snapshots + * @returns any PaginatedSnapshotsResponse + * @throws ApiError + */ + public listSnapshots({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + snapshots: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/snapshots", + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Get snapshot + * Get details of a snapshot with the given ID + * @returns any SingleSnapshotResponse + * @throws ApiError + */ + public getSnapshot({ + snapshotId, + }: { + snapshotId: string; + }): CancelablePromise<{ + snapshot: Snapshot; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/snapshots/{snapshot_id}", + path: { + snapshot_id: snapshotId, + }, + }); + } + + /** + * Update snapshot + * Update the details of a snapshot with the given ID + * @returns any SingleSnapshotResponse + * @throws ApiError + */ + public updateSnapshot({ + snapshotId, + requestBody, + }: { + snapshotId: string; + requestBody: { + /** + * The new human-readable name for your snapshot. + * + */ + name?: string; + }; + }): CancelablePromise<{ + snapshot: Snapshot; + }> { + return this.httpRequest.request({ + method: "PATCH", + url: "/snapshots/{snapshot_id}", + path: { + snapshot_id: snapshotId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete snapshot + * Delete a snapshot with the given ID + * @returns void + * @throws ApiError + */ + public deleteSnapshot({ + snapshotId, + }: { + snapshotId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/snapshots/{snapshot_id}", + path: { + snapshot_id: snapshotId, + }, + }); + } +} diff --git a/src/services/SshKeysService.ts b/src/services/SshKeysService.ts new file mode 100644 index 0000000..cb945e9 --- /dev/null +++ b/src/services/SshKeysService.ts @@ -0,0 +1,137 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { SSHKey } from "../models/SSHKey"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class SshKeysService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * List SSH keys + * @returns any PaginatedSSHKeysResponse + * @throws ApiError + */ + public listSshKeys({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + ssh_keys: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/ssh-keys", + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Create SSH key + * @returns SSHKey SingleSSHKeyResponse + * @throws ApiError + */ + public createSshKey({ + requestBody, + }: { + requestBody: { + /** + * The human-readable name for your ssh key. + * + */ + name: string; + /** + * SSH public key. + */ + value: string; + }; + }): CancelablePromise { + return this.httpRequest.request({ + method: "POST", + url: "/ssh-keys", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Get SSH key + * Get details of a ssh key with the given ID. + * @returns SSHKey SingleSSHKeyResponse + * @throws ApiError + */ + public getSshKey({ + sshKeyId, + }: { + sshKeyId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "GET", + url: "/ssh-keys/{ssh_key_id}", + path: { + ssh_key_id: sshKeyId, + }, + }); + } + + /** + * Update SSH key + * Edit the name of an existing SSH key. + * @returns SSHKey SingleSSHKeyResponse + * @throws ApiError + */ + public updateSshKey({ + sshKeyId, + requestBody, + }: { + sshKeyId: string; + requestBody: { + /** + * The new human-readable name for your ssh key. + * + */ + name?: string; + }; + }): CancelablePromise { + return this.httpRequest.request({ + method: "PATCH", + url: "/ssh-keys/{ssh_key_id}", + path: { + ssh_key_id: sshKeyId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete SSH key + * Delete a ssh key with the given ID. + * @returns void + * @throws ApiError + */ + public deleteSshKey({ + sshKeyId, + }: { + sshKeyId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/ssh-keys/{ssh_key_id}", + path: { + ssh_key_id: sshKeyId, + }, + }); + } +} diff --git a/src/services/VolumesService.ts b/src/services/VolumesService.ts new file mode 100644 index 0000000..7fb1444 --- /dev/null +++ b/src/services/VolumesService.ts @@ -0,0 +1,152 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { Region } from "../models/Region"; +import type { Volume } from "../models/Volume"; +import type { VolumeType } from "../models/VolumeType"; + +import type { CancelablePromise } from "../core/CancelablePromise"; +import type { BaseHttpRequest } from "../core/BaseHttpRequest"; + +export class VolumesService { + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Create volume + * @returns any SingleVolumeResponse + * @throws ApiError + */ + public createVolume({ + requestBody, + }: { + requestBody: { + /** + * The human-readable name set for the volume. + * + */ + name: string; + /** + * The human-readable description set for the volume. + * + */ + description?: string; + type?: VolumeType; + /** + * The storage size of this volume given in GiB (Min: 1GiB). + * + */ + size: number; + region: Region; + }; + }): CancelablePromise<{ + volume: Volume; + }> { + return this.httpRequest.request({ + method: "POST", + url: "/volumes", + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * List volumes + * @returns any PaginatedVolumesResponse + * @throws ApiError + */ + public listVolumes({ + page = 1, + perPage = 50, + }: { + page?: number | null; + perPage?: number | null; + }): CancelablePromise<{ + volumes: Array; + total_count: number; + page: number; + per_page: number; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/volumes", + query: { + page: page, + per_page: perPage, + }, + }); + } + + /** + * Get volume + * Get details of a volume with the given ID + * @returns any SingleVolumeResponse + * @throws ApiError + */ + public getVolume({ volumeId }: { volumeId: string }): CancelablePromise<{ + volume: Volume; + }> { + return this.httpRequest.request({ + method: "GET", + url: "/volumes/{volume_id}", + path: { + volume_id: volumeId, + }, + }); + } + + /** + * Update volume + * Update the details of a volume with the given ID + * @returns any SingleVolumeResponse + * @throws ApiError + */ + public updateVolume({ + volumeId, + requestBody, + }: { + volumeId: string; + requestBody: { + /** + * The human-readable name set for the volume. + */ + name?: string; + /** + * The human-readable description set for the volume. + */ + description?: string; + }; + }): CancelablePromise<{ + volume: Volume; + }> { + return this.httpRequest.request({ + method: "PATCH", + url: "/volumes/{volume_id}", + path: { + volume_id: volumeId, + }, + body: requestBody, + mediaType: "application/json", + }); + } + + /** + * Delete volume + * Delete a volume with the given ID + * @returns void + * @throws ApiError + */ + public deleteVolume({ + volumeId, + }: { + volumeId: string; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/volumes/{volume_id}", + path: { + volume_id: volumeId, + }, + }); + } +} diff --git a/src/types.gen.ts b/src/types.gen.ts new file mode 100644 index 0000000..510cd72 --- /dev/null +++ b/src/types.gen.ts @@ -0,0 +1,1430 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Timestamp = string; + +export type Error = { + /** + * The Genesis Cloud error code. + * Check the [developer documentation](https://developers.com/#error-codes) for more information on error codes. + * + */ + code: string; + /** + * An explanation of what went wrong. + */ + message: string; +}; + +export type Image = { + id: ImageId; + type: Image_Type; + family: string | null; + /** + * The display name that has been given to an image. This is what is shown in the control panel and is generally a descriptive title for the image in question. + */ + name: string; + os_type: OSType; + slug: string | null; + /** + * The list of versions if this is a cloud-image otherwise empty. + */ + versions: Array | null; + /** + * The list of regions in which this image can be used in. + */ + regions: Array; + created_at: Timestamp; + updated_at: Timestamp; +}; + +/** + * Describes the kind of image. + */ +export type Image_Type = + | "base-os" + | "cloud-image" + | "preconfigured" + | "snapshot"; + +export type Snapshot = { + /** + * A unique identifier for each snapshot. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the snapshot. + * + */ + name: string; + /** + * The storage size of this snapshot given in GiB. + * + */ + size: number; + /** + * The id of the resource (e.g. instance) that was snapshotted. + * + */ + resource_id: string; + region: Region; + status: Snapshot_Status; + os_type: OSType; + created_at: Timestamp; + updated_at: Timestamp; +}; + +/** + * The snapshot status. + */ +export type Snapshot_Status = + | "creating" + | "created" + | "pending_delete" + | "deleting" + | "active" + | "error"; + +/** + * A unique identifier for each volume. This is automatically generated. + * + */ +export type VolumeId = string; + +export type Volume = { + id: VolumeId; + /** + * The human-readable name for the volume. + */ + name: string; + /** + * The human-readable description for the volume. + */ + description: string; + type: VolumeType; + /** + * The storage size of this volume given in GiB. + */ + size: number; + region: Region; + /** + * The attached instances. + */ + instances: Array<{ + /** + * The id of the attached instance. + */ + id?: string; + /** + * The name of the attached instance. + */ + name?: string; + }>; + status: Volume_Status; + created_at: Timestamp; + updated_at: Timestamp; +}; + +export type Volume_Status = + | "creating" + | "created" + | "pending_delete" + | "deleting" + | "available" + | "in-use" + | "error"; + +/** + * A unique identifier for each filesystem. This is automatically generated. + * + */ +export type FilesystemId = string; + +export type Filesystem = { + id: FilesystemId; + /** + * The human-readable name for the filesystem. + */ + name: string; + /** + * The human-readable description for the filesystem. + */ + description: string; + type: FilesystemType; + /** + * The storage size of this filesystem given in GiB. + */ + size: number; + region: Region; + status: Filesystem_Status; + /** + * The mount endpoint range of the filesystem. + */ + mount_endpoint_range: [string, string, null]; + /** + * The mount base path of the filesystem. + */ + mount_base_path: string | null; + created_at: Timestamp; + updated_at: Timestamp; +}; + +export type Filesystem_Status = "creating" | "created" | "deleting"; + +export type SecurityGroup = { + /** + * A unique identifier for each security group. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the security group. + * + */ + name: string; + /** + * The human-readable description for the security group. + * + */ + description: string; + is_internal: boolean; + region: Region; + status: SecurityGroup_Status; + rules: Array; + created_at: Timestamp; + updated_at: Timestamp; +}; + +/** + * The security group status. + */ +export type SecurityGroup_Status = + | "creating" + | "created" + | "deleting" + | "updating" + | "error"; + +export type SecurityGroup_Rule = { + protocol: SecurityGroup_Rule_Protocol; + direction: SecurityGroup_Rule_Direction; + /** + * The minimum port number of the rule. + */ + port_range_min?: number | null; + /** + * The maximum port number of the rule. + */ + port_range_max?: number | null; +}; + +/** + * The direction of the rule. + */ +export type SecurityGroup_Rule_Direction = "ingress" | "egress"; + +/** + * The protocol of the rule. + */ +export type SecurityGroup_Rule_Protocol = "tcp" | "udp" | "icmp" | "all"; + +export type Instance = { + /** + * The unique ID of the instance. + */ + id: string; + name: Instance_Name; + hostname: Instance_Hostname; + type: Instance_Type; + os_type: OSType; + /** + * The public IPv4 IP-Address (IPv4 address). + */ + public_ip: string | null; + /** + * The private IPv4 IP-Address (IPv4 address). + */ + private_ip: string | null; + status: Instance_Status; + /** + * The ssh keys of the instance. + */ + ssh_keys: Array<{ + id: Instance_SSHKeyId; + /** + * The name of the ssh key. + */ + name: string; + }>; + /** + * The image of the instance. + */ + image: { + id: ImageId; + /** + * The image name. + */ + name: string; + }; + /** + * The floating IP attached to the instance. + */ + floating_ip?: { + /** + * The ID of the floating IP. + */ + id: string; + /** + * The name of the floating IP. + */ + name: string; + } | null; + /** + * The security groups of the instance. + */ + security_groups: Array<{ + id: Instance_SecurityGroupId; + /** + * The name of the security group. + */ + name: string; + }>; + /** + * The volumes of the instance + */ + volumes: Array<{ + id: VolumeId; + /** + * The volume name. + */ + name: string; + }>; + region: Region; + disk_size?: Instance_DiskSize; + /** + * The placement option identifier in which instances are physically located relative to each other within a zone. + * + */ + placement_option: string; + created_at: Timestamp; + updated_at: Timestamp; +}; + +/** + * The human-readable name set for the instance. + */ +export type Instance_Name = string; + +/** + * The hostname of your instance. + */ +export type Instance_Hostname = string; + +/** + * A unique number that can be used to identify and reference a specific image. + */ +export type ImageId = string; + +/** + * The ssh key ID. + */ +export type Instance_SSHKeyId = string; + +/** + * An array of security group ids. + * **Please Note**: By default the **standard security group** is set if you don"t specify any Security Groups. + * You can override this behavior by providing a different Security Group. + * + */ +export type Instance_SecurityGroupIds = Array; + +/** + * The security group ID. + */ +export type Instance_SecurityGroupId = string; + +/** + * The storage size of the instance's boot volume given in GiB (Min: 80GiB). + * + */ +export type Instance_DiskSize = number; + +/** + * Specifies if the instance is termination protected. + * When set to `true`, it"s not possible to destroy the instance until it"s switched to `false`. + * Set to `true` automatically for long-term billed instances. + * + */ +export type Instance_IsProtected = boolean; + +/** + * Option that you can set at instance creation that will allow the instance to destroy on shutdown command + * + */ +export type Instance_DestroyOnShutdown = boolean; + +export type Instance_Action = "start" | "stop" | "reset"; + +/** + * The instance status + */ +export type Instance_Status = + | "creating" + | "pending_payment" + | "active" + | "stopping" + | "stopped" + | "starting" + | "resetting" + | "error" + | "deleting" + | "enqueued" + | "copying" + | "build" + | "restarting" + | "shutoff" + | "updating" + | "unknown"; + +/** + * The id of the floating IP to attach to the instance. + */ +export type Instance_FloatingIp = string; + +/** + * A boolean value indicating whether the instance should have an ipv6 address or not. + * + */ +export type Instance_PublicIpv6 = boolean; + +/** + * The instance type identifier. + */ +export type Instance_Type = string; + +export type Instance_UserData = Array<{ + type: string; + filename?: string; + content: string; +}>; + +/** + * The billing type of the instance. + * + */ +export type Instance_BillingType = + | "on-demand" + | "prepaid-monthly" + | "prepaid-3-month" + | "prepaid-6-month" + | "prepaid-12-month"; + +/** + * The long term subscription id to be used for this instance. + * If not provided, the billing_type will default to on-demand. + * + */ +export type Instance_ReuseLongTermSubscription = string; + +export type SSHKey = { + /** + * A unique identifier for each SSH key. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the SSH key. + * + */ + name: string; + /** + * SSH public key. + * + */ + value: string; + /** + * The fingerprint of the SSH key. + * + */ + fingerprint: string; + /** + * The encryption algorithm type of the SSH key. + * + */ + type: string; + /** + * The length of the SSH key. + * + */ + size: number; + created_at: Timestamp; + updated_at: Timestamp; +}; + +export type FloatingIP = { + /** + * A unique identifier for each floating IP. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the floating IP. + * + */ + name: string; + /** + * The human-readable description for the floating IP. + * + */ + description: string; + /** + * The IP address of the floating IP. + * + */ + ip_address: string | null; + /** + * A boolean value indicating whether the floating IP is public or private. + * + */ + is_public: boolean; + /** + * The IP version of the floating IP. + * + */ + version: "ipv4" | "ipv6"; + region: Region; + status: FloatingIp_Status; + created_at: Timestamp; + updated_at: Timestamp; + instance: { + /** + * A unique identifier for the attached instance. + * + */ + id: string; + /** + * The name of the attached instance. + * + */ + name: string; + } | null; +}; + +/** + * The floating ip status. + */ +export type FloatingIp_Status = "creating" | "created" | "deleting" | "error"; + +export type Catalog = { + /** + * A unique identifier for each catalog. This is automatically generated. + * + */ + id: string; + /** + * The human-readable name for the catalog. + * + */ + name: string; + /** + * The human-readable description for the catalog. + * + */ + description: string; + /** + * The url of the catalog + * + */ + logo_url: string; + /** + * The image catalog requires driver + * + */ + requires_driver: boolean; + base_image_ids: Array; + images: Array<{ + id: string; + name: string; + }>; + fields: Catalog_Fields; + created_at: Timestamp; + updated_at: Timestamp; +}; + +export type Catalog_Fields = Array<{ + key: string; + label: string; + type: string; + env: string; +}>; + +export type InstancesAvailability = { + availability: { + type: string; + region: Region; + placement?: string; + instance_types: Array<{ + type: Instance_Type; + available: boolean; + count?: number; + }>; + }; +}; + +/** + * The region identifier. + */ +export type Region = "ARC-IS-HAF-1" | "EUC-DE-MUC-1" | "NORD-NO-KRS-1"; + +/** + * The volume type. + */ +export type VolumeType = "ssd" | "hdd"; + +/** + * The filesystem type. + */ +export type FilesystemType = "vast"; + +/** + * The OS type. + */ +export type OSType = "linux" | "windows"; + +export type PerPageQueryParameter = number | null; + +export type PageQueryParameter = number | null; + +export type $OpenApiTs = { + "/images": { + get: { + req: { + page?: number | null; + perPage?: number | null; + type?: Image_Type; + }; + res: { + /** + * PaginatedImagesResponse + */ + 200: { + images: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + }; + "/snapshots": { + post: { + req: { + requestBody: { + /** + * The human-readable name set for the snapshot. + * + */ + name: string; + /** + * The storage size of this snapshot given in GiB (Min: 1GiB). + * + */ + size: number; + /** + * The url pointing to a raw or raw with zstd compressed image. + * + */ + url: string; + os_type?: OSType; + region: Region; + }; + }; + res: { + /** + * SingleSnapshotResponse + */ + 201: { + snapshot: Snapshot; + }; + }; + }; + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedSnapshotsResponse + */ + 200: { + snapshots: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + }; + "/snapshots/{snapshot_id}": { + get: { + req: { + snapshotId: string; + }; + res: { + /** + * SingleSnapshotResponse + */ + 200: { + snapshot: Snapshot; + }; + }; + }; + patch: { + req: { + requestBody: { + /** + * The new human-readable name for your snapshot. + * + */ + name?: string; + }; + snapshotId: string; + }; + res: { + /** + * SingleSnapshotResponse + */ + 200: { + snapshot: Snapshot; + }; + }; + }; + delete: { + req: { + snapshotId: string; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + }; + "/volumes": { + post: { + req: { + requestBody: { + /** + * The human-readable name set for the volume. + * + */ + name: string; + /** + * The human-readable description set for the volume. + * + */ + description?: string; + type?: VolumeType; + /** + * The storage size of this volume given in GiB (Min: 1GiB). + * + */ + size: number; + region: Region; + }; + }; + res: { + /** + * SingleVolumeResponse + */ + 201: { + volume: Volume; + }; + }; + }; + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedVolumesResponse + */ + 200: { + volumes: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + }; + "/volumes/{volume_id}": { + get: { + req: { + volumeId: string; + }; + res: { + /** + * SingleVolumeResponse + */ + 200: { + volume: Volume; + }; + }; + }; + patch: { + req: { + requestBody: { + /** + * The human-readable name set for the volume. + */ + name?: string; + /** + * The human-readable description set for the volume. + */ + description?: string; + }; + volumeId: string; + }; + res: { + /** + * SingleVolumeResponse + */ + 200: { + volume: Volume; + }; + }; + }; + delete: { + req: { + volumeId: string; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + }; + "/filesystems": { + post: { + req: { + requestBody: { + /** + * The human-readable name set for the filesystem. + * + */ + name: string; + /** + * The human-readable description set for the filesystem. + * + */ + description?: string; + type?: FilesystemType; + /** + * The storage size of this filesystem given in GiB (Min: 1GiB). + * + */ + size: number; + region: Region; + }; + }; + res: { + /** + * SingleFilesystemResponse + */ + 201: { + filesystem: Filesystem; + }; + }; + }; + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedFilesystemsResponse + */ + 200: { + filesystems: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + }; + "/filesystems/{filesystem_id}": { + get: { + req: { + filesystemId: string; + }; + res: { + /** + * SingleFilesystemResponse + */ + 200: { + filesystem: Filesystem; + }; + }; + }; + patch: { + req: { + filesystemId: string; + requestBody: { + /** + * The human-readable name set for the filesystem. + */ + name?: string; + /** + * The human-readable description set for the filesystem. + */ + description?: string; + /** + * The storage size of this filesystem given in GiB. + */ + size?: number; + }; + }; + res: { + /** + * SingleFilesystemResponse + */ + 200: { + filesystem: Filesystem; + }; + }; + }; + delete: { + req: { + filesystemId: string; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + }; + "/security-groups": { + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedSecurityGroupsResponse + */ + 200: { + security_groups: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + post: { + req: { + requestBody: { + /** + * The human-readable name set for the security group. **Please Note**: `default` and `standard` are not allowed names (reserved words). + * + */ + name: string; + /** + * he human-readable description set for the security group. + */ + description?: string; + region: Region; + /** + * The list of rules of the security group. + */ + rules: Array; + }; + }; + res: { + /** + * SingleSecurityGroupResponse + */ + 201: { + security_group: SecurityGroup; + }; + }; + }; + }; + "/security-groups/{security_group_id}": { + get: { + req: { + securityGroupId: string; + }; + res: { + /** + * SingleSecurityGroupResponse + */ + 200: { + security_group: SecurityGroup; + }; + }; + }; + patch: { + req: { + requestBody: { + /** + * The human-readable name set for the security group. + */ + name?: string; + /** + * he human-readable description set for the security group. + */ + description?: string; + /** + * The list of rules of the security group. + */ + rules?: Array; + }; + securityGroupId: string; + }; + res: { + /** + * SingleSecurityGroupResponse + */ + 200: { + security_group: SecurityGroup; + }; + }; + }; + delete: { + req: { + securityGroupId: string; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + }; + "/instances": { + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedInstancesResponse + */ + 200: { + instances: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + post: { + req: { + requestBody: { + name: Instance_Name; + hostname: Instance_Hostname; + type: Instance_Type; + image: ImageId; + /** + * An array of ssh key ids. + * This should not be provided if `password` authentication method is desired. + * + */ + ssh_keys?: Array; + /** + * An array of volume ids. + * + */ + volumes?: Array; + /** + * The password to access the instance. + * Your password must have upper and lower chars, digits and length between 8-72. + * **Please Note**: Only one of `ssh_keys` or `password` can be provided. + * Password is less secure - we recommend you use an SSH key-pair. + * + */ + password?: string; + /** + * The placement option identifier in which instances are physically located relative to each other within a zone. + * + */ + placement_option?: string; + security_groups?: Instance_SecurityGroupIds; + is_protected?: Instance_IsProtected; + destroy_on_shutdown?: Instance_DestroyOnShutdown; + public_ipv6?: Instance_PublicIpv6; + floating_ip?: Instance_FloatingIp; + region: Region; + billing_type?: Instance_BillingType; + reuse_long_term_subscription?: Instance_ReuseLongTermSubscription; + disk_size?: Instance_DiskSize; + /** + * Option to provide metadata. + */ + metadata?: { + user_data?: Instance_UserData; + /** + * A plain text bash script or "cloud-config" file that will be executed after the first instance boot. + * It is limited to 64 KiB in size. You can use it to configure your instance, e.g. installing the **NVIDIA GPU driver**. + * Learn more about [startup scripts and installing the GPU driver](https://support.com/support/solutions/articles/47001122478). + * + */ + startup_script?: string; + }; + }; + }; + res: { + /** + * SingleInstanceResponse + */ + 201: { + instance: Instance; + }; + }; + }; + }; + "/instances/{instance_id}": { + get: { + req: { + instanceId: string; + }; + res: { + /** + * SingleInstanceResponse + */ + 200: { + instance: Instance; + }; + }; + }; + delete: { + req: { + instanceId: string; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + patch: { + req: { + instanceId: string; + requestBody: { + name?: Instance_Name; + is_protected?: Instance_IsProtected; + security_groups?: Instance_SecurityGroupIds; + /** + * The instance's volumes IDs. + */ + volumes?: Array; + disk_size?: Instance_DiskSize; + }; + }; + res: { + /** + * SingleInstanceResponse + */ + 200: { + instance: Instance; + }; + }; + }; + }; + "/instances/{instance_id}/actions": { + get: { + req: { + instanceId: string; + }; + res: { + /** + * Instance.ListActionsResponse + */ + 200: { + actions: Array; + }; + }; + }; + post: { + req: { + instanceId: string; + requestBody: { + action: Instance_Action; + }; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + }; + "/instances/{instance_id}/snapshots": { + get: { + req: { + instanceId: string; + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedSnapshotsResponse + */ + 200: { + snapshots: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + post: { + req: { + instanceId: string; + requestBody: { + /** + * Name of the snapshot. + */ + name: string; + }; + }; + res: { + /** + * SingleSnapshotResponse + */ + 201: { + snapshot: Snapshot; + }; + }; + }; + }; + "/ssh-keys": { + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedSSHKeysResponse + */ + 200: { + ssh_keys: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + post: { + req: { + requestBody: { + /** + * The human-readable name for your ssh key. + * + */ + name: string; + /** + * SSH public key. + */ + value: string; + }; + }; + res: { + /** + * SingleSSHKeyResponse + */ + 201: SSHKey; + }; + }; + }; + "/ssh-keys/{ssh_key_id}": { + get: { + req: { + sshKeyId: string; + }; + res: { + /** + * SingleSSHKeyResponse + */ + 200: SSHKey; + }; + }; + patch: { + req: { + requestBody: { + /** + * The new human-readable name for your ssh key. + * + */ + name?: string; + }; + sshKeyId: string; + }; + res: { + /** + * SingleSSHKeyResponse + */ + 200: SSHKey; + }; + }; + delete: { + req: { + sshKeyId: string; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + }; + "/floating-ips": { + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedFloatingIPsResponse + */ + 200: { + floating_ips: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + post: { + req: { + requestBody: { + /** + * The human-readable name set for the floating IP. + * + */ + name: string; + /** + * The human-readable description set for the floating IP. + * + */ + description?: string; + region: Region; + /** + * The IP version of the floating IP. + * + */ + version?: "ipv4"; + }; + }; + res: { + /** + * SingleFloatingIPResponse + */ + 201: { + floating_ip: FloatingIP; + }; + }; + }; + }; + "/floating-ips/{floating_ip_id}": { + get: { + req: { + floatingIpId: string; + }; + res: { + /** + * SingleFloatingIPResponse + */ + 200: { + floating_ip: FloatingIP; + }; + }; + }; + patch: { + req: { + floatingIpId: string; + requestBody: { + /** + * The human-readable name set for the floating IP. + */ + name?: string; + /** + * The human-readable description set for the floating IP. + */ + description?: string; + }; + }; + res: { + /** + * SingleFloatingIPResponse + */ + 200: { + floating_ip: FloatingIP; + }; + }; + }; + delete: { + req: { + floatingIpId: string; + }; + res: { + /** + * success + */ + 204: void; + }; + }; + }; + "/availability/{region}/instances": { + get: { + req: { + placement?: string; + region: Region; + }; + res: { + /** + * InstancesAvailabilityResponse + */ + 200: InstancesAvailability; + }; + }; + }; + "/catalog": { + get: { + req: { + page?: number | null; + perPage?: number | null; + }; + res: { + /** + * PaginatedCatalogResponse + */ + 200: { + catalog: Array; + total_count: number; + page: number; + per_page: number; + }; + }; + }; + }; +}; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c5faf58 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "lib": ["es2023", "DOM"], + "module": "node16", + "target": "es2022", + + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node16", + + "baseUrl": "src", + "outDir": "dist", + "sourceMap": true, + "declaration": true, + "declarationMap": true + }, + "include": ["src/**/*.ts"], + "exclude": ["node_modules"] +}