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.
23 lines (20 loc) • 824 B
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 { SSHKey } from "../../domain/ssh-key";
import { SSHKeysFetchError } from "./errors/ssh-keys-fetch-error";
export class ListSSHKeys implements UseCase<void, SSHKey[], SSHKeysFetchError> {
constructor(private readonly apiClient: ApiClientProvider) {}
async execute(): Promise<Either<SSHKeysFetchError, SSHKey[]>> {
try {
const sshKeys = await this.apiClient.get<SSHKey[]>("/gpu-cloud/ssh-keys");
return right(sshKeys ?? []);
} catch (error) {
return left(
new SSHKeysFetchError(
error instanceof Error ? error.message : "Unexpected error occurred."
)
);
}
}
}