feat: Enhance API client integration across web and CLI
- Added typedRequestInterfaces import to plugins.ts for better type handling. - Updated CLI client to utilize environment variables for Cloudly API credentials and improved authentication flow. - Refactored appstate.ts to use a shared API client instance, reducing redundancy in API calls for various actions. - Simplified external registry actions in appstate.ts by leveraging the shared API client. - Updated CloudlyDashboard and CloudlyViewSettings components to utilize the shared API client for fetching settings and managing connections. - Removed redundant TypedRequest instances in favor of direct API client calls for improved performance and maintainability. - Exposed the API client in plugins.ts for easier access in UI components.
This commit is contained in:
		| @@ -54,6 +54,21 @@ export class CloudlyApiClient { | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   // Helper: resolve HTTP typedrequest endpoint | ||||
|   private get httpEndpoint() { | ||||
|     const base = (this.cloudlyUrl || '').replace(/\/$/, ''); | ||||
|     return `${base}/typedrequest`; | ||||
|   } | ||||
|  | ||||
|   // Helper: choose transport (WS if available, else HTTP) | ||||
|   private createWsRequest<T extends plugins.typedRequestInterfaces.ITypedRequest>(operation: string) { | ||||
|     return this.typedsocketClient?.createTypedRequest<T>(operation); | ||||
|   } | ||||
|  | ||||
|   private createHttpRequest<T extends plugins.typedRequestInterfaces.ITypedRequest>(operation: string) { | ||||
|     return new plugins.typedrequest.TypedRequest<T>(this.httpEndpoint, operation); | ||||
|   } | ||||
|  | ||||
|   public async start() { | ||||
|     this.typedsocketClient = await plugins.typedsocket.TypedSocket.createClient( | ||||
|       this.typedrouter, | ||||
| @@ -170,9 +185,35 @@ export class CloudlyApiClient { | ||||
|     }, | ||||
|     createRegistry: async (optionsArg: Parameters<typeof ExternalRegistry.createExternalRegistry>[1]) => { | ||||
|       return ExternalRegistry.createExternalRegistry(this, optionsArg); | ||||
|     }, | ||||
|     verifyRegistry: async (registryId: string): Promise<{ success: boolean; message: string; registry?: ExternalRegistry }> => { | ||||
|       const op = 'verifyExternalRegistry'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.externalRegistry.IReq_VerifyRegistry>(op); | ||||
|       const payload = { identity: this.identity, registryId } as any; | ||||
|       const resp = wsReq ? await wsReq.fire(payload) : await this.createHttpRequest<plugins.servezoneInterfaces.requests.externalRegistry.IReq_VerifyRegistry>(op).fire(payload); | ||||
|       let registryInstance: ExternalRegistry | undefined; | ||||
|       if (resp.registry) { | ||||
|         registryInstance = new ExternalRegistry(this); | ||||
|         Object.assign(registryInstance, resp.registry); | ||||
|       } | ||||
|       return { success: resp.success, message: resp.message, registry: registryInstance }; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Auth helpers | ||||
|   public async loginWithUsernameAndPassword(username: string, password: string): Promise<plugins.servezoneInterfaces.data.IIdentity> { | ||||
|     const op = 'adminLoginWithUsernameAndPassword'; | ||||
|     // Login endpoint is exposed via HTTP typedrequest | ||||
|     const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.admin.IReq_Admin_LoginWithUsernameAndPassword>(op); | ||||
|     const response = await httpReq.fire({ username, password }); | ||||
|     this.identity = response.identity; | ||||
|     // If WS connection is available, tag it with identity for server-side guards | ||||
|     if (this.typedsocketClient) { | ||||
|       try { this.typedsocketClient.addTag('identity', this.identity); } catch {} | ||||
|     } | ||||
|     return this.identity; | ||||
|   } | ||||
|  | ||||
|   public image = { | ||||
|     // Images | ||||
|     getImageById: async (imageIdArg: string) => { | ||||
| @@ -183,6 +224,13 @@ export class CloudlyApiClient { | ||||
|     }, | ||||
|     createImage: async (optionsArg: Parameters<typeof Image.createImage>[1]) => { | ||||
|       return Image.createImage(this, optionsArg); | ||||
|     }, | ||||
|     deleteImage: async (imageId: string): Promise<void> => { | ||||
|       const op = 'deleteImage'; | ||||
|       const payload = { identity: this.identity, imageId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.image.IRequest_DeleteImage>(op); | ||||
|       if (wsReq) { await wsReq.fire(payload); return; } | ||||
|       await this.createHttpRequest<plugins.servezoneInterfaces.requests.image.IRequest_DeleteImage>(op).fire(payload); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -196,6 +244,20 @@ export class CloudlyApiClient { | ||||
|     }, | ||||
|     createService: async (optionsArg: Parameters<typeof Service.createService>[1]) => { | ||||
|       return Service.createService(this, optionsArg); | ||||
|     }, | ||||
|     updateService: async (serviceId: string, serviceData: plugins.servezoneInterfaces.data.IService['data']): Promise<{ service: plugins.servezoneInterfaces.data.IService }> => { | ||||
|       const op = 'updateService'; | ||||
|       const payload = { identity: this.identity, serviceId, serviceData } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.service.IRequest_Any_Cloudly_UpdateService>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.service.IRequest_Any_Cloudly_UpdateService>(op).fire(payload); | ||||
|     }, | ||||
|     deleteService: async (serviceId: string): Promise<void> => { | ||||
|       const op = 'deleteServiceById'; | ||||
|       const payload = { identity: this.identity, serviceId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.service.IRequest_Any_Cloudly_DeleteServiceById>(op); | ||||
|       if (wsReq) { await wsReq.fire(payload); return; } | ||||
|       await this.createHttpRequest<plugins.servezoneInterfaces.requests.service.IRequest_Any_Cloudly_DeleteServiceById>(op).fire(payload); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -237,4 +299,251 @@ export class CloudlyApiClient { | ||||
|       return SecretGroup.createSecretGroup(this, optionsArg); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Settings API | ||||
|   public settings = { | ||||
|     getSettings: async (): Promise<{ | ||||
|       settings: plugins.servezoneInterfaces.data.ICloudlySettingsMasked | ||||
|     }> => { | ||||
|       const op = 'getSettings'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.settings.IRequest_GetSettings>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.settings.IRequest_GetSettings>(op); | ||||
|       return httpReq.fire({ identity: this.identity }); | ||||
|     }, | ||||
|     updateSettings: async (updates: Partial<plugins.servezoneInterfaces.data.ICloudlySettings>): Promise<{ | ||||
|       success: boolean; | ||||
|       message: string; | ||||
|     }> => { | ||||
|       const op = 'updateSettings'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.settings.IRequest_UpdateSettings>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity, updates }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.settings.IRequest_UpdateSettings>(op); | ||||
|       return httpReq.fire({ identity: this.identity, updates }); | ||||
|     }, | ||||
|     testProviderConnection: async (provider: string): Promise<{ | ||||
|       connectionValid: boolean; | ||||
|       message: string; | ||||
|     }> => { | ||||
|       const op = 'testProviderConnection'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.settings.IRequest_TestProviderConnection>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity, provider: provider as any }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.settings.IRequest_TestProviderConnection>(op); | ||||
|       return httpReq.fire({ identity: this.identity, provider: provider as any }); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Task API | ||||
|   public tasks = { | ||||
|     getTasks: async (): Promise<{ | ||||
|       tasks: Array<{ | ||||
|         name: string; | ||||
|         description: string; | ||||
|         category: 'maintenance' | 'deployment' | 'backup' | 'monitoring' | 'cleanup' | 'system' | 'security'; | ||||
|         schedule?: string; | ||||
|         lastRun?: number; | ||||
|         enabled: boolean; | ||||
|       }> | ||||
|     }> => { | ||||
|       const op = 'getTasks'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_GetTasks>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_GetTasks>(op); | ||||
|       return httpReq.fire({ identity: this.identity }); | ||||
|     }, | ||||
|     getTaskExecutions: async (filter?: any): Promise<{ | ||||
|       executions: plugins.servezoneInterfaces.data.ITaskExecution[]; | ||||
|     }> => { | ||||
|       const op = 'getTaskExecutions'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutions>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity, filter }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutions>(op); | ||||
|       return httpReq.fire({ identity: this.identity, filter }); | ||||
|     }, | ||||
|     getTaskExecutionById: async (executionId: string): Promise<{ | ||||
|       execution: plugins.servezoneInterfaces.data.ITaskExecution | ||||
|     }> => { | ||||
|       const op = 'getTaskExecutionById'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutionById>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity, executionId }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutionById>(op); | ||||
|       return httpReq.fire({ identity: this.identity, executionId }); | ||||
|     }, | ||||
|     triggerTask: async (taskName: string, userId?: string): Promise<{ | ||||
|       execution: plugins.servezoneInterfaces.data.ITaskExecution | ||||
|     }> => { | ||||
|       const op = 'triggerTask'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_TriggerTask>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity, taskName, userId }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_TriggerTask>(op); | ||||
|       return httpReq.fire({ identity: this.identity, taskName, userId }); | ||||
|     }, | ||||
|     cancelTask: async (executionId: string): Promise<{ success: boolean }> => { | ||||
|       const op = 'cancelTask'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_CancelTask>(op); | ||||
|       if (wsReq) { | ||||
|         return wsReq.fire({ identity: this.identity, executionId }); | ||||
|       } | ||||
|       const httpReq = this.createHttpRequest<plugins.servezoneInterfaces.requests.task.IRequest_Any_Cloudly_CancelTask>(op); | ||||
|       return httpReq.fire({ identity: this.identity, executionId }); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Domain API | ||||
|   public domains = { | ||||
|     getDomains: async (): Promise<{ domains: plugins.servezoneInterfaces.data.IDomain[] }> => { | ||||
|       const op = 'getDomains'; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_GetDomains>(op); | ||||
|       if (wsReq) return wsReq.fire({ identity: this.identity }); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_GetDomains>(op).fire({ identity: this.identity }); | ||||
|     }, | ||||
|     getDomainById: async (domainId: string): Promise<{ domain: plugins.servezoneInterfaces.data.IDomain }> => { | ||||
|       const op = 'getDomainById'; | ||||
|       const payload = { identity: this.identity, domainId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_GetDomainById>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_GetDomainById>(op).fire(payload); | ||||
|     }, | ||||
|     createDomain: async (domainData: plugins.servezoneInterfaces.data.IDomain['data']): Promise<{ domain: plugins.servezoneInterfaces.data.IDomain }> => { | ||||
|       const op = 'createDomain'; | ||||
|       const payload = { identity: this.identity, domainData } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_CreateDomain>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_CreateDomain>(op).fire(payload); | ||||
|     }, | ||||
|     updateDomain: async (domainId: string, domainData: Partial<plugins.servezoneInterfaces.data.IDomain['data']>): Promise<{ domain: plugins.servezoneInterfaces.data.IDomain }> => { | ||||
|       const op = 'updateDomain'; | ||||
|       const payload = { identity: this.identity, domainId, domainData } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_UpdateDomain>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_UpdateDomain>(op).fire(payload); | ||||
|     }, | ||||
|     deleteDomain: async (domainId: string): Promise<{ success: boolean }> => { | ||||
|       const op = 'deleteDomain'; | ||||
|       const payload = { identity: this.identity, domainId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_DeleteDomain>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_DeleteDomain>(op).fire(payload); | ||||
|     }, | ||||
|     verifyDomain: async (domainId: string, verificationMethod?: 'dns' | 'http' | 'email' | 'manual'): Promise<{ domain: plugins.servezoneInterfaces.data.IDomain; verificationResult: any }> => { | ||||
|       const op = 'verifyDomain'; | ||||
|       const payload = { identity: this.identity, domainId, verificationMethod } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_VerifyDomain>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.domain.IRequest_Any_Cloudly_VerifyDomain>(op).fire(payload); | ||||
|     }, | ||||
|   }; | ||||
|  | ||||
|   // DNS API | ||||
|   public dns = { | ||||
|     getDnsEntries: async (zone?: string): Promise<{ dnsEntries: plugins.servezoneInterfaces.data.IDnsEntry[] }> => { | ||||
|       const op = 'getDnsEntries'; | ||||
|       const payload = { identity: this.identity, zone } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_GetDnsEntries>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_GetDnsEntries>(op).fire(payload); | ||||
|     }, | ||||
|     getDnsEntryById: async (dnsEntryId: string): Promise<{ dnsEntry: plugins.servezoneInterfaces.data.IDnsEntry }> => { | ||||
|       const op = 'getDnsEntryById'; | ||||
|       const payload = { identity: this.identity, dnsEntryId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_GetDnsEntryById>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_GetDnsEntryById>(op).fire(payload); | ||||
|     }, | ||||
|     createDnsEntry: async (dnsEntryData: plugins.servezoneInterfaces.data.IDnsEntry['data']): Promise<{ dnsEntry: plugins.servezoneInterfaces.data.IDnsEntry }> => { | ||||
|       const op = 'createDnsEntry'; | ||||
|       const payload = { identity: this.identity, dnsEntryData } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_CreateDnsEntry>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_CreateDnsEntry>(op).fire(payload); | ||||
|     }, | ||||
|     updateDnsEntry: async (dnsEntryId: string, dnsEntryData: plugins.servezoneInterfaces.data.IDnsEntry['data']): Promise<{ dnsEntry: plugins.servezoneInterfaces.data.IDnsEntry }> => { | ||||
|       const op = 'updateDnsEntry'; | ||||
|       const payload = { identity: this.identity, dnsEntryId, dnsEntryData } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_UpdateDnsEntry>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_UpdateDnsEntry>(op).fire(payload); | ||||
|     }, | ||||
|     deleteDnsEntry: async (dnsEntryId: string): Promise<{ success: boolean }> => { | ||||
|       const op = 'deleteDnsEntry'; | ||||
|       const payload = { identity: this.identity, dnsEntryId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_DeleteDnsEntry>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_DeleteDnsEntry>(op).fire(payload); | ||||
|     }, | ||||
|     getDnsZones: async (): Promise<{ zones: string[] }> => { | ||||
|       const op = 'getDnsZones'; | ||||
|       const payload = { identity: this.identity } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_GetDnsZones>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.dns.IRequest_Any_Cloudly_GetDnsZones>(op).fire(payload); | ||||
|     }, | ||||
|   }; | ||||
|  | ||||
|   // Deployment API | ||||
|   public deployments = { | ||||
|     getDeployments: async (): Promise<{ deployments: plugins.servezoneInterfaces.data.IDeployment[] }> => { | ||||
|       const op = 'getDeployments'; | ||||
|       const payload = { identity: this.identity } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_GetDeployments>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_GetDeployments>(op).fire(payload); | ||||
|     }, | ||||
|     getDeploymentById: async (deploymentId: string): Promise<{ deployment: plugins.servezoneInterfaces.data.IDeployment }> => { | ||||
|       const op = 'getDeploymentById'; | ||||
|       const payload = { identity: this.identity, deploymentId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_GetDeploymentById>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_GetDeploymentById>(op).fire(payload); | ||||
|     }, | ||||
|     createDeployment: async (deploymentData: Partial<plugins.servezoneInterfaces.data.IDeployment>): Promise<{ deployment: plugins.servezoneInterfaces.data.IDeployment }> => { | ||||
|       const op = 'createDeployment'; | ||||
|       const payload = { identity: this.identity, deploymentData } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_CreateDeployment>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_CreateDeployment>(op).fire(payload); | ||||
|     }, | ||||
|     updateDeployment: async (deploymentId: string, deploymentData: Partial<plugins.servezoneInterfaces.data.IDeployment>): Promise<{ deployment: plugins.servezoneInterfaces.data.IDeployment }> => { | ||||
|       const op = 'updateDeployment'; | ||||
|       const payload = { identity: this.identity, deploymentId, deploymentData } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_UpdateDeployment>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_UpdateDeployment>(op).fire(payload); | ||||
|     }, | ||||
|     deleteDeployment: async (deploymentId: string): Promise<{ success: boolean }> => { | ||||
|       const op = 'deleteDeploymentById'; | ||||
|       const payload = { identity: this.identity, deploymentId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_DeleteDeploymentById>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_DeleteDeploymentById>(op).fire(payload); | ||||
|     }, | ||||
|     restartDeployment: async (deploymentId: string): Promise<{ success: boolean; deployment: plugins.servezoneInterfaces.data.IDeployment }> => { | ||||
|       const op = 'restartDeployment'; | ||||
|       const payload = { identity: this.identity, deploymentId } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_RestartDeployment>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_RestartDeployment>(op).fire(payload); | ||||
|     }, | ||||
|     scaleDeployment: async (deploymentId: string, replicas: number): Promise<{ success: boolean; deployment: plugins.servezoneInterfaces.data.IDeployment }> => { | ||||
|       const op = 'scaleDeployment'; | ||||
|       const payload = { identity: this.identity, deploymentId, replicas } as any; | ||||
|       const wsReq = this.createWsRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_ScaleDeployment>(op); | ||||
|       if (wsReq) return wsReq.fire(payload); | ||||
|       return this.createHttpRequest<plugins.servezoneInterfaces.requests.deployment.IReq_Any_Cloudly_ScaleDeployment>(op).fire(payload); | ||||
|     }, | ||||
|   }; | ||||
| } | ||||
|   | ||||
| @@ -21,10 +21,12 @@ export { | ||||
| // @api.global scope | ||||
| import * as typedrequest from '@api.global/typedrequest'; | ||||
| import * as typedsocket from '@api.global/typedsocket'; | ||||
| import * as typedRequestInterfaces from '@api.global/typedrequest-interfaces'; | ||||
|  | ||||
| export { | ||||
|   typedrequest, | ||||
|   typedsocket | ||||
|   typedsocket, | ||||
|   typedRequestInterfaces, | ||||
| } | ||||
|  | ||||
| // @tsclass scope | ||||
| @@ -32,4 +34,4 @@ import * as tsclass from '@tsclass/tsclass'; | ||||
|  | ||||
| export { | ||||
|   tsclass, | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user