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.
36 lines (31 loc) • 1.09 kB
text/typescript
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 { ListInferenceInstancesError } from "./errors/list-instances-error";
export class ListInferenceInstances
implements UseCase<void, InferenceInstance[], ListInferenceInstancesError>
{
constructor(private readonly apiClient: ApiClientProvider) {}
async execute(): Promise<
Either<ListInferenceInstancesError, InferenceInstance[]>
> {
try {
const instances = await this.apiClient.get<InferenceInstance[]>(
"/ai-inference/instances"
);
if (!instances) {
return left(
new ListInferenceInstancesError("Failed to list inference instances")
);
}
return right(instances);
} catch (error) {
return left(
new ListInferenceInstancesError(
error instanceof Error ? error.message : "Unexpected error occurred."
)
);
}
}
}