@phala/cloud
Version:
TypeScript SDK for Phala Cloud API
122 lines • 4.47 kB
TypeScript
import { z } from "zod";
import { type Client, type SafeResult } from "../client";
import { ActionParameters, ActionReturnType } from "../types/common";
import { LooseAppComposeSchema } from "../types/app_compose";
/**
* Get CVM compose file configuration
*
* Retrieves the current Docker Compose file configuration and metadata for a specified CVM.
*
* @example
* ```typescript
* import { createClient, getCvmComposeFile } from '@phala/cloud'
*
* const client = createClient({ apiKey: 'your-api-key' })
* const composeFile = await getCvmComposeFile(client, { id: 'cvm-123' })
* // Output: { compose_content: '...', version: '...', last_modified: '...' }
* ```
*
* ## Returns
*
* `GetCvmComposeFileResult | unknown`
*
* The CVM compose file configuration including compose_content and metadata. Return type depends on schema parameter.
*
* ## Parameters
*
* ### request (required)
* - **Type:** `GetCvmComposeFileRequest`
*
* Request parameters containing the CVM identifier. Can be one of:
* - id: The CVM ID
* - uuid: The CVM UUID
* - appId: The App ID (40 chars)
* - instanceId: The Instance ID (40 chars)
*
* ### parameters (optional)
* - **Type:** `GetCvmComposeFileParameters`
*
* Optional behavior parameters for schema validation.
*
* ```typescript
* // Use default schema
* const result = await getCvmComposeFile(client, { id: 'cvm-123' })
*
* // Return raw data without validation
* const raw = await getCvmComposeFile(client, { id: 'cvm-123' }, { schema: false })
*
* // Use custom schema
* const customSchema = z.object({ compose_content: z.string() })
* const custom = await getCvmComposeFile(client, { id: 'cvm-123' }, { schema: customSchema })
* ```
*
* ## Safe Version
*
* Use `safeGetCvmComposeFile` for error handling without exceptions:
*
* ```typescript
* import { safeGetCvmComposeFile } from '@phala/cloud'
*
* const result = await safeGetCvmComposeFile(client, { id: 'cvm-123' })
* if (result.success) {
* console.log(result.data.compose_content)
* } else {
* if ("isRequestError" in result.error) {
* console.error(`HTTP ${result.error.status}: ${result.error.message}`)
* } else {
* console.error(`Validation error: ${result.error.issues}`)
* }
* }
* ```
*/
export type GetCvmComposeFileResult = z.infer<typeof LooseAppComposeSchema>;
export declare const GetCvmComposeFileRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
id: z.ZodOptional<z.ZodString>;
uuid: z.ZodOptional<z.ZodString>;
app_id: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
instance_id: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
}, "strip", z.ZodTypeAny, {
id?: string | undefined;
app_id?: string | undefined;
instance_id?: string | undefined;
uuid?: string | undefined;
}, {
id?: string | undefined;
app_id?: string | undefined;
instance_id?: string | undefined;
uuid?: string | undefined;
}>, {
id?: string | undefined;
app_id?: string | undefined;
instance_id?: string | undefined;
uuid?: string | undefined;
}, {
id?: string | undefined;
app_id?: string | undefined;
instance_id?: string | undefined;
uuid?: string | undefined;
}>, {
cvmId: string | undefined;
_raw: {
id?: string | undefined;
app_id?: string | undefined;
instance_id?: string | undefined;
uuid?: string | undefined;
};
}, {
id?: string | undefined;
app_id?: string | undefined;
instance_id?: string | undefined;
uuid?: string | undefined;
}>;
export type GetCvmComposeFileRequest = {
id?: string;
uuid?: string;
app_id?: string;
instance_id?: string;
};
export type GetCvmComposeFileParameters<T = undefined> = ActionParameters<T>;
export type GetCvmComposeFileReturnType<T = undefined> = ActionReturnType<GetCvmComposeFileResult, T>;
export declare function getCvmComposeFile<T extends z.ZodSchema | false | undefined = undefined>(client: Client, request: GetCvmComposeFileRequest, parameters?: GetCvmComposeFileParameters<T>): Promise<GetCvmComposeFileReturnType<T>>;
export declare function safeGetCvmComposeFile<T extends z.ZodSchema | false | undefined = undefined>(client: Client, request: GetCvmComposeFileRequest, parameters?: GetCvmComposeFileParameters<T>): Promise<SafeResult<GetCvmComposeFileReturnType<T>>>;
//# sourceMappingURL=get_cvm_compose_file.d.ts.map