feat(apiclient): Add external registry management capabilities to Cloudly API client.
This commit is contained in:
parent
e567ebbf21
commit
89bd767bea
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-12-29 - 4.9.0 - feat(apiclient)
|
||||||
|
Add external registry management capabilities to Cloudly API client.
|
||||||
|
|
||||||
|
- Introduce ExternalRegistry class with methods for getting, creating, and updating external registries.
|
||||||
|
- Expand requests module to handle external registry management, including creation and deletion.
|
||||||
|
|
||||||
## 2024-12-28 - 4.8.1 - fix(interfaces)
|
## 2024-12-28 - 4.8.1 - fix(interfaces)
|
||||||
Fix image location schema in IImage interface
|
Fix image location schema in IImage interface
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/cloudly',
|
name: '@serve.zone/cloudly',
|
||||||
version: '4.8.1',
|
version: '4.9.0',
|
||||||
description: 'A comprehensive tool for managing containerized applications across multiple cloud providers using Docker Swarmkit, featuring web, CLI, and API interfaces.'
|
description: 'A comprehensive tool for managing containerized applications across multiple cloud providers using Docker Swarmkit, featuring web, CLI, and API interfaces.'
|
||||||
}
|
}
|
||||||
|
84
ts_apiclient/classes.externalregistry.ts
Normal file
84
ts_apiclient/classes.externalregistry.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
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 getRegistryById(cloudlyClientRef: CloudlyApiClient, registryNameArg: string) {
|
||||||
|
const getRegistryByIdTR = cloudlyClientRef.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.externalRegistry.IReq_GetRegistryById>(
|
||||||
|
'getExternalRegistryById'
|
||||||
|
);
|
||||||
|
const response = await getRegistryByIdTR.fire({
|
||||||
|
identity: cloudlyClientRef.identity,
|
||||||
|
registryName: registryNameArg,
|
||||||
|
});
|
||||||
|
const newRegistry = new ExternalRegistry(cloudlyClientRef);
|
||||||
|
Object.assign(newRegistry, response.registry);
|
||||||
|
return newRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getRegistries(cloudlyClientRef: CloudlyApiClient) {
|
||||||
|
const getRegistriesTR = cloudlyClientRef.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.externalRegistry.IReq_GetRegistries>(
|
||||||
|
'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 createRegistry(cloudlyClientRef: CloudlyApiClient, registryNameArg: string, 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);
|
||||||
|
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<plugins.servezoneInterfaces.requests.externalRegistry.IReq_UpdateRegistry>(
|
||||||
|
'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<plugins.servezoneInterfaces.requests.externalRegistry.IReq_DeleteRegistryById>(
|
||||||
|
'deleteExternalRegistryById'
|
||||||
|
);
|
||||||
|
const response = await deleteRegistryTR.fire({
|
||||||
|
identity: cloudlyClientRef.identity,
|
||||||
|
registryId: this.id,
|
||||||
|
});
|
||||||
|
plugins.smartexpect.expect(response.ok).toBeTrue();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
73
ts_interfaces/requests/externalregistry.ts
Normal file
73
ts_interfaces/requests/externalregistry.ts
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import * as plugins from '../plugins.js';
|
||||||
|
import * as data from '../data/index.js';
|
||||||
|
import * as userInterfaces from '../data/user.js';
|
||||||
|
|
||||||
|
export interface IReq_GetRegistryById extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
|
IReq_GetRegistryById
|
||||||
|
> {
|
||||||
|
method: 'getExternalRegistryById';
|
||||||
|
request: {
|
||||||
|
identity: userInterfaces.IIdentity;
|
||||||
|
registryName: string;
|
||||||
|
};
|
||||||
|
response: {
|
||||||
|
registry: data.IExternalRegistry;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IReq_GetRegistries extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
|
IReq_GetRegistries
|
||||||
|
> {
|
||||||
|
method: 'getExternalRegistries';
|
||||||
|
request: {
|
||||||
|
identity: userInterfaces.IIdentity;
|
||||||
|
};
|
||||||
|
response: {
|
||||||
|
registries: data.IExternalRegistry[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IReq_CreateRegistry extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
|
IReq_CreateRegistry
|
||||||
|
> {
|
||||||
|
method: 'createExternalRegistry';
|
||||||
|
request: {
|
||||||
|
identity: userInterfaces.IIdentity;
|
||||||
|
registryName: string;
|
||||||
|
registryData: data.IExternalRegistry['data'];
|
||||||
|
};
|
||||||
|
response: {
|
||||||
|
registry: data.IExternalRegistry;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IReq_UpdateRegistry extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
|
IReq_UpdateRegistry
|
||||||
|
> {
|
||||||
|
method: 'updateExternalRegistry';
|
||||||
|
request: {
|
||||||
|
identity: userInterfaces.IIdentity;
|
||||||
|
registryData: data.IExternalRegistry['data'];
|
||||||
|
};
|
||||||
|
response: {
|
||||||
|
resultRegistry: data.IExternalRegistry;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IReq_DeleteRegistryById extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
|
IReq_DeleteRegistryById
|
||||||
|
> {
|
||||||
|
method: 'deleteExternalRegistryById';
|
||||||
|
request: {
|
||||||
|
identity: userInterfaces.IIdentity;
|
||||||
|
registryId: string;
|
||||||
|
};
|
||||||
|
response: {
|
||||||
|
ok: boolean;
|
||||||
|
};
|
||||||
|
}
|
@ -4,6 +4,7 @@ import * as adminRequests from './admin.js';
|
|||||||
import * as certificateRequests from './certificate.js';
|
import * as certificateRequests from './certificate.js';
|
||||||
import * as clusterRequests from './cluster.js';
|
import * as clusterRequests from './cluster.js';
|
||||||
import * as configRequests from './config.js';
|
import * as configRequests from './config.js';
|
||||||
|
import * as externalRegistryRequests from './externalregistry.js';
|
||||||
import * as identityRequests from './identity.js';
|
import * as identityRequests from './identity.js';
|
||||||
import * as imageRequests from './image.js';
|
import * as imageRequests from './image.js';
|
||||||
import * as informRequests from './inform.js';
|
import * as informRequests from './inform.js';
|
||||||
@ -22,6 +23,7 @@ export {
|
|||||||
certificateRequests as certificate,
|
certificateRequests as certificate,
|
||||||
clusterRequests as cluster,
|
clusterRequests as cluster,
|
||||||
configRequests as config,
|
configRequests as config,
|
||||||
|
externalRegistryRequests as externalRegistry,
|
||||||
identityRequests as identity,
|
identityRequests as identity,
|
||||||
imageRequests as image,
|
imageRequests as image,
|
||||||
informRequests as inform,
|
informRequests as inform,
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/cloudly',
|
name: '@serve.zone/cloudly',
|
||||||
version: '4.8.1',
|
version: '4.9.0',
|
||||||
description: 'A comprehensive tool for managing containerized applications across multiple cloud providers using Docker Swarmkit, featuring web, CLI, and API interfaces.'
|
description: 'A comprehensive tool for managing containerized applications across multiple cloud providers using Docker Swarmkit, featuring web, CLI, and API interfaces.'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user