UNPKG

sesterce-cli

Version:

A powerful command-line interface tool for managing Sesterce Cloud services. Sesterce CLI provides easy access to GPU cloud instances, AI inference services, container registries, and SSH key management directly from your terminal.

48 lines (43 loc) 1.33 kB
import { UseCase } from "@/core/domain/use-case"; import { Either, left, right } from "@/core/logic/either"; import { ApiClientProvider } from "@/providers/api-client-provider"; import { InferenceInstance } from "../../domain/inference-instance"; import { UpdateInferenceInstanceError } from "./errors/update-instance-error"; import { UpdateInferenceInstanceDto } from "./update-instance-dto"; export class UpdateInferenceInstance implements UseCase< UpdateInferenceInstanceDto, InferenceInstance, UpdateInferenceInstanceError > { constructor(private readonly apiClient: ApiClientProvider) {} async execute({ instanceId, ...dto }: UpdateInferenceInstanceDto): Promise< Either<UpdateInferenceInstanceError, InferenceInstance> > { try { const instance = await this.apiClient.patch<InferenceInstance>( `/ai-inference/instances/${instanceId}`, { body: JSON.stringify(dto), } ); if (!instance) { return left( new UpdateInferenceInstanceError("Failed to update instance") ); } return right(instance); } catch (error) { return left( new UpdateInferenceInstanceError( error instanceof Error ? error.message : "Unexpected error occurred." ) ); } } }