feat(apiclient): Added support for managing external registries in the API client.

This commit is contained in:
2024-12-29 13:40:51 +01:00
parent 355e04fd1d
commit a617f51b19
6 changed files with 25 additions and 7 deletions

View File

@ -7,6 +7,7 @@ import { Service } from './classes.service.js';
import { Cluster } from './classes.cluster.js';
import { SecretBundle } from './classes.secretbundle.js';
import { SecretGroup } from './classes.secretgroup.js';
import { ExternalRegistry } from './classes.externalregistry.js';
export class CloudlyApiClient {
private cloudlyUrl: string;
@ -159,6 +160,19 @@ export class CloudlyApiClient {
return typedResponse.certificate;
}
public externalRegistry = {
// ExternalRegistry
getRegistryById: async (registryNameArg: string) => {
return ExternalRegistry.getExternalRegistryById(this, registryNameArg);
},
getRegistries: async () => {
return ExternalRegistry.getExternalRegistries(this);
},
createRegistry: async (optionsArg: Parameters<typeof ExternalRegistry.createExternalRegistry>[1]) => {
return ExternalRegistry.createExternalRegistry(this, optionsArg);
}
}
public image = {
// Images
getImageById: async (imageIdArg: string) => {

View File

@ -3,7 +3,7 @@ import type { CloudlyApiClient } from './classes.cloudlyapiclient.js';
export class ExternalRegistry implements plugins.servezoneInterfaces.data.IExternalRegistry {
// STATIC
public static async getRegistryById(cloudlyClientRef: CloudlyApiClient, registryNameArg: string) {
public static async getExternalRegistryById(cloudlyClientRef: CloudlyApiClient, registryNameArg: string) {
const getRegistryByIdTR = cloudlyClientRef.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.externalRegistry.IReq_GetRegistryById>(
'getExternalRegistryById'
);
@ -16,7 +16,7 @@ export class ExternalRegistry implements plugins.servezoneInterfaces.data.IExter
return newRegistry;
}
public static async getRegistries(cloudlyClientRef: CloudlyApiClient) {
public static async getExternalRegistries(cloudlyClientRef: CloudlyApiClient) {
const getRegistriesTR = cloudlyClientRef.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.externalRegistry.IReq_GetRegistries>(
'getExternalRegistries'
);
@ -32,13 +32,12 @@ export class ExternalRegistry implements plugins.servezoneInterfaces.data.IExter
return registryConfigs;
}
public static async createRegistry(cloudlyClientRef: CloudlyApiClient, registryNameArg: string, registryDataArg: Partial<plugins.servezoneInterfaces.data.IExternalRegistry['data']>) {
public static async createExternalRegistry(cloudlyClientRef: CloudlyApiClient, registryDataArg: Partial<plugins.servezoneInterfaces.data.IExternalRegistry['data']>) {
const createRegistryTR = cloudlyClientRef.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.externalRegistry.IReq_CreateRegistry>(
'createExternalRegistry'
);
const response = await createRegistryTR.fire({
identity: cloudlyClientRef.identity,
registryName: registryNameArg,
registryData: registryDataArg as plugins.servezoneInterfaces.data.IExternalRegistry['data'],
});
const newRegistry = new ExternalRegistry(cloudlyClientRef);