From b22f3b6d6448064223e4857e1082965cd8286035 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Tue, 28 Apr 2026 12:11:54 +0000 Subject: [PATCH] feat: add platform api helpers --- package.json | 4 +- pnpm-lock.yaml | 10 +-- ts/classes.cloudlyapiclient.ts | 47 +++++++++++++ ts/classes.platform.ts | 125 +++++++++++++++++++++++++++++++++ 4 files changed, 179 insertions(+), 7 deletions(-) create mode 100644 ts/classes.platform.ts diff --git a/package.json b/package.json index 23efc9d..1fc9c25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@serve.zone/api", - "version": "5.3.1", + "version": "5.3.2", "private": false, "description": "Type-safe API client for Cloudly and the serve.zone control plane.", "exports": { @@ -22,7 +22,7 @@ "@push.rocks/smartpromise": "^4.2.3", "@push.rocks/smartrx": "^3.0.10", "@push.rocks/smartstream": "^3.2.5", - "@serve.zone/interfaces": "^5.4.3", + "@serve.zone/interfaces": "^5.4.5", "@tsclass/tsclass": "^9.2.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9fa00b1..9434b12 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,8 +30,8 @@ importers: specifier: ^3.2.5 version: 3.4.0 '@serve.zone/interfaces': - specifier: ^5.4.3 - version: 5.4.3 + specifier: ^5.4.5 + version: 5.4.5 '@tsclass/tsclass': specifier: ^9.2.0 version: 9.5.0 @@ -1384,8 +1384,8 @@ packages: '@sec-ant/readable-stream@0.4.1': resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} - '@serve.zone/interfaces@5.4.3': - resolution: {integrity: sha512-9ijFhHoC7GYyyAUJbBoDYmcoCmIXTFPiD6fI3x68SWiC0xA+2LG0nOe14D32c1QN9X/3i2Ac5/1sUibfjHsIGg==} + '@serve.zone/interfaces@5.4.5': + resolution: {integrity: sha512-asqUUjem3MGfIbseovHR8SxE+6FvjeQEYtV+PxcyY8YRXJ/vE3hNCDs7ePXgBbh4JXa+vNMaXHsFfz5Vrk6Ggg==} '@shikijs/engine-oniguruma@3.23.0': resolution: {integrity: sha512-1nWINwKXxKKLqPibT5f4pAFLej9oZzQTsby8942OTlsJzOBZ0MWKiwzMsd+jhzu8YPCHAswGnnN1YtQfirL35g==} @@ -6566,7 +6566,7 @@ snapshots: '@sec-ant/readable-stream@0.4.1': {} - '@serve.zone/interfaces@5.4.3': + '@serve.zone/interfaces@5.4.5': dependencies: '@api.global/typedrequest-interfaces': 3.0.19 '@push.rocks/smartlog-interfaces': 3.0.2 diff --git a/ts/classes.cloudlyapiclient.ts b/ts/classes.cloudlyapiclient.ts index 2bd9e7b..27e08de 100644 --- a/ts/classes.cloudlyapiclient.ts +++ b/ts/classes.cloudlyapiclient.ts @@ -8,6 +8,7 @@ import { Cluster } from './classes.cluster.js'; import { SecretBundle } from './classes.secretbundle.js'; import { SecretGroup } from './classes.secretgroup.js'; import { ExternalRegistry } from './classes.externalregistry.js'; +import { Platform } from './classes.platform.js'; export class CloudlyApiClient { private cloudlyUrl: string; @@ -336,6 +337,52 @@ export class CloudlyApiClient { } } + public platform = { + getPlatformDesiredState: async () => { + return Platform.getPlatformDesiredState(this); + }, + getPlatformCapabilities: async () => { + return Platform.getPlatformCapabilities(this); + }, + getPlatformProviderConfigs: async ( + capability?: plugins.servezoneInterfaces.platform.TPlatformCapability, + ) => { + return Platform.getPlatformProviderConfigs(this, capability); + }, + upsertPlatformProviderConfig: async ( + providerConfig: plugins.servezoneInterfaces.platform.IPlatformProviderConfig, + ) => { + return Platform.upsertPlatformProviderConfig(this, providerConfig); + }, + deletePlatformProviderConfigById: async (providerConfigId: string) => { + return Platform.deletePlatformProviderConfigById(this, providerConfigId); + }, + getPlatformBindings: async ( + optionsArg: { + serviceId?: string; + capability?: plugins.servezoneInterfaces.platform.TPlatformCapability; + } = {}, + ) => { + return Platform.getPlatformBindings(this, optionsArg); + }, + upsertPlatformBinding: async ( + binding: plugins.servezoneInterfaces.platform.IPlatformBinding, + ) => { + return Platform.upsertPlatformBinding(this, binding); + }, + updatePlatformBindingStatus: async ( + optionsArg: Omit< + plugins.servezoneInterfaces.requests.platform.IReq_Any_Cloudly_UpdatePlatformBindingStatus['request'], + 'identity' + >, + ) => { + return Platform.updatePlatformBindingStatus(this, optionsArg); + }, + deletePlatformBindingById: async (bindingId: string) => { + return Platform.deletePlatformBindingById(this, bindingId); + }, + } + // Settings API public settings = { getSettings: async (): Promise<{ diff --git a/ts/classes.platform.ts b/ts/classes.platform.ts new file mode 100644 index 0000000..70ec62d --- /dev/null +++ b/ts/classes.platform.ts @@ -0,0 +1,125 @@ +import * as plugins from './plugins.js'; +import type { CloudlyApiClient } from './classes.cloudlyapiclient.js'; + +export class Platform { + public static async getPlatformDesiredState(cloudlyClientRef: CloudlyApiClient) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'getPlatformDesiredState', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + }); + } + + public static async getPlatformCapabilities(cloudlyClientRef: CloudlyApiClient) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'getPlatformCapabilities', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + }); + } + + public static async getPlatformProviderConfigs( + cloudlyClientRef: CloudlyApiClient, + capability?: plugins.servezoneInterfaces.platform.TPlatformCapability, + ) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'getPlatformProviderConfigs', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + capability, + }); + } + + public static async upsertPlatformProviderConfig( + cloudlyClientRef: CloudlyApiClient, + providerConfig: plugins.servezoneInterfaces.platform.IPlatformProviderConfig, + ) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'upsertPlatformProviderConfig', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + providerConfig, + }); + } + + public static async deletePlatformProviderConfigById( + cloudlyClientRef: CloudlyApiClient, + providerConfigId: string, + ) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'deletePlatformProviderConfigById', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + providerConfigId, + }); + } + + public static async getPlatformBindings( + cloudlyClientRef: CloudlyApiClient, + optionsArg: { + serviceId?: string; + capability?: plugins.servezoneInterfaces.platform.TPlatformCapability; + } = {}, + ) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'getPlatformBindings', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + ...optionsArg, + }); + } + + public static async upsertPlatformBinding( + cloudlyClientRef: CloudlyApiClient, + binding: plugins.servezoneInterfaces.platform.IPlatformBinding, + ) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'upsertPlatformBinding', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + binding, + }); + } + + public static async updatePlatformBindingStatus( + cloudlyClientRef: CloudlyApiClient, + optionsArg: Omit< + plugins.servezoneInterfaces.requests.platform.IReq_Any_Cloudly_UpdatePlatformBindingStatus['request'], + 'identity' + >, + ) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'updatePlatformBindingStatus', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + ...optionsArg, + }); + } + + public static async deletePlatformBindingById(cloudlyClientRef: CloudlyApiClient, bindingId: string) { + const request = + cloudlyClientRef.typedsocketClient.createTypedRequest( + 'deletePlatformBindingById', + ); + return await request.fire({ + identity: cloudlyClientRef.identity, + bindingId, + }); + } +}