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.1 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 { InferenceHardware } from "../../domain/inference-hardware";
import { ListInferenceHardwaresError } from "./errors/list-inference-hardwares-error";
export class ListInferenceHardwares
implements UseCase<void, InferenceHardware[], ListInferenceHardwaresError>
{
constructor(private readonly apiClient: ApiClientProvider) {}
async execute(): Promise<
Either<ListInferenceHardwaresError, InferenceHardware[]>
> {
try {
const hardwares = await this.apiClient.get<InferenceHardware[]>(
"/ai-inference/hardwares"
);
if (!hardwares) {
return left(
new ListInferenceHardwaresError("Failed to list inference hardwares")
);
}
return right(hardwares);
} catch (error) {
return left(
new ListInferenceHardwaresError(
error instanceof Error ? error.message : "Unexpected error occurred."
)
);
}
}
}