diff --git a/changelog.md b/changelog.md index 60971d6..2d49537 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-01-20 - 4.13.0 - feat(service) +Add support for service creation, update, and deletion. + +- Implemented TypedHandlers for creating a new service. +- Added features to update existing service details. +- Enabled deletion of services by their unique ID. + ## 2025-01-20 - 4.12.2 - fix(service) Fix secret bundle and service management bugs diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 132dd7a..5334eb0 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@serve.zone/cloudly', - version: '4.12.2', + version: '4.13.0', description: 'A comprehensive tool for managing containerized applications across multiple cloud providers using Docker Swarmkit, featuring web, CLI, and API interfaces.' } diff --git a/ts/manager.service/classes.servicemanager.ts b/ts/manager.service/classes.servicemanager.ts index 06f8d48..eef327e 100644 --- a/ts/manager.service/classes.servicemanager.ts +++ b/ts/manager.service/classes.servicemanager.ts @@ -62,5 +62,39 @@ export class ServiceManager { } ) ); + + this.typedrouter.addTypedHandler( + new plugins.typedrequest.TypedHandler( + 'updateService', + async (dataArg) => { + const service = await Service.getInstance({ + id: dataArg.serviceId, + }); + service.data = { + ...service.data, + ...dataArg.serviceData, + }; + await service.save(); + return { + service: await service.createSavableObject(), + }; + } + ) + ); + + this.typedrouter.addTypedHandler( + new plugins.typedrequest.TypedHandler( + 'deleteServiceById', + async (dataArg) => { + const service = await Service.getInstance({ + id: dataArg.serviceId, + }); + await service.delete(); + return { + success: true, + }; + } + ) + ); } } diff --git a/ts_apiclient/classes.service.ts b/ts_apiclient/classes.service.ts index b4b7af4..3dc79bc 100644 --- a/ts_apiclient/classes.service.ts +++ b/ts_apiclient/classes.service.ts @@ -40,19 +40,7 @@ export class Service implements plugins.servezoneInterfaces.data.IService { ); const response = await createServiceTR.fire({ identity: cloudlyClientRef.identity, - name: serviceDataArg.name, - description: serviceDataArg.description, - imageId: serviceDataArg.imageId, - imageVersion: serviceDataArg.imageVersion, - environment: {}, - secretBundleId: null, - scaleFactor: 1, - balancingStrategy: serviceDataArg.balancingStrategy, - ports: { - web: null, - }, - resources: serviceDataArg.resources, - domains: [], + serviceData: serviceDataArg as plugins.servezoneInterfaces.data.IService['data'], }); const newService = new Service(cloudlyClientRef); Object.assign(newService, response.service); diff --git a/ts_interfaces/requests/service.ts b/ts_interfaces/requests/service.ts index 5a9565f..80549f3 100644 --- a/ts_interfaces/requests/service.ts +++ b/ts_interfaces/requests/service.ts @@ -40,24 +40,7 @@ extends plugins.typedrequestInterfaces.implementsTR< method: 'createService'; request: { identity: IIdentity; - name: string; - description: string; - imageId: string; - imageVersion: string; - environment: { [key: string]: string }; - secretBundleId: string; - scaleFactor: number; - balancingStrategy: 'round-robin' | 'least-connections'; - ports: { - web: number; - custom?: { [domain: string]: string }; - }; - resources?: IServiceRessources; - domains: { - name: string; - port?: number; - protocol?: 'http' | 'https' | 'ssh'; - }[]; + serviceData: IService['data']; }; response: { service: IService; @@ -73,36 +56,19 @@ extends plugins.typedrequestInterfaces.implementsTR< request: { identity: IIdentity; serviceId: string; - name: string; - description: string; - imageId: string; - imageVersion: string; - environment: { [key: string]: string }; - secretBundleId: string; - scaleFactor: number; - balancingStrategy: 'round-robin' | 'least-connections'; - ports: { - web: number; - custom?: { [domain: string]: string }; - }; - resources?: IServiceRessources; - domains: { - name: string; - port?: number; - protocol?: 'http' | 'https' | 'ssh'; - }[]; + serviceData: IService['data']; }; response: { service: IService; }; } -export interface IRequest_Any_Cloudly_DeleteService +export interface IRequest_Any_Cloudly_DeleteServiceById extends plugins.typedrequestInterfaces.implementsTR< plugins.typedrequestInterfaces.ITypedRequest, - IRequest_Any_Cloudly_DeleteService + IRequest_Any_Cloudly_DeleteServiceById > { - method: 'deleteService'; + method: 'deleteServiceById'; request: { identity: IIdentity; serviceId: string; diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index 132dd7a..5334eb0 100644 --- a/ts_web/00_commitinfo_data.ts +++ b/ts_web/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@serve.zone/cloudly', - version: '4.12.2', + version: '4.13.0', description: 'A comprehensive tool for managing containerized applications across multiple cloud providers using Docker Swarmkit, featuring web, CLI, and API interfaces.' }