import * as plugins from './plugins.js'; import type { CloudlyApiClient } from './classes.cloudlyapiclient.js'; export class ExternalRegistry implements plugins.servezoneInterfaces.data.IExternalRegistry { // STATIC public static async getExternalRegistryById(cloudlyClientRef: CloudlyApiClient, registryNameArg: string) { const getRegistryByIdTR = cloudlyClientRef.typedsocketClient.createTypedRequest( 'getExternalRegistryById' ); const response = await getRegistryByIdTR.fire({ identity: cloudlyClientRef.identity, id: registryNameArg, }); const newRegistry = new ExternalRegistry(cloudlyClientRef); Object.assign(newRegistry, response.registry); return newRegistry; } public static async getExternalRegistries(cloudlyClientRef: CloudlyApiClient) { const getRegistriesTR = cloudlyClientRef.typedsocketClient.createTypedRequest( 'getExternalRegistries' ); const response = await getRegistriesTR.fire({ identity: cloudlyClientRef.identity, }); const registryConfigs: ExternalRegistry[] = []; for (const registryConfig of response.registries) { const newRegistry = new ExternalRegistry(cloudlyClientRef); Object.assign(newRegistry, registryConfig); registryConfigs.push(newRegistry); } return registryConfigs; } public static async createExternalRegistry(cloudlyClientRef: CloudlyApiClient, registryDataArg: Partial) { const createRegistryTR = cloudlyClientRef.typedsocketClient.createTypedRequest( 'createExternalRegistry' ); const response = await createRegistryTR.fire({ identity: cloudlyClientRef.identity, registryData: registryDataArg as plugins.servezoneInterfaces.data.IExternalRegistry['data'], }); const newRegistry = new ExternalRegistry(cloudlyClientRef); Object.assign(newRegistry, response.registry); return newRegistry; } // INSTANCE public id: string; public data: plugins.servezoneInterfaces.data.IExternalRegistry['data']; public cloudlyClientRef: CloudlyApiClient; constructor(cloudlyClientRef: CloudlyApiClient) { this.cloudlyClientRef = cloudlyClientRef; } public async update() { const updateRegistryTR = this.cloudlyClientRef.typedsocketClient.createTypedRequest( 'updateExternalRegistry' ); const response = await updateRegistryTR.fire({ identity: this.cloudlyClientRef.identity, registryData: this.data, }); const resultRegistryData = response.resultRegistry.data; plugins.smartexpect.expect(resultRegistryData).toEqual(this.data); return this; } public async delete(cloudlyClientRef: CloudlyApiClient, registryIdArg: string) { const deleteRegistryTR = cloudlyClientRef.typedsocketClient.createTypedRequest( 'deleteExternalRegistryById' ); const response = await deleteRegistryTR.fire({ identity: cloudlyClientRef.identity, registryId: this.id, }); plugins.smartexpect.expect(response.ok).toBeTrue(); return null; } }