UNPKG

@phala/cloud

Version:
143 lines 5.63 kB
import { z } from "zod"; import { type Client, type SafeResult } from "../client"; import { ActionParameters, ActionReturnType } from "../types/common"; /** * Commit CVM compose file update * * Finalizes a CVM compose file update by committing the previously provisioned changes. * This should be called after `provisionCvmComposeFileUpdate` to complete the update process. * * @example * ```typescript * import { createClient, commitCvmComposeFileUpdate } from '@phala/cloud' * * const client = createClient({ apiKey: 'your-api-key' }) * await commitCvmComposeFileUpdate(client, { * cvmId: 'cvm-123', * request: { * compose_hash: 'abc123...' * } * }) * // Request accepted, update will be processed asynchronously * ``` * * ## Returns * * `void | unknown` * * No response body (HTTP 202 Accepted). The update is processed asynchronously. Return type depends on schema parameter. * * ## Parameters * * ### request (required) * - **Type:** `CommitCvmComposeFileUpdateRequestData` * * Request parameters containing the CVM ID and commit request data. * * ### parameters (optional) * - **Type:** `CommitCvmComposeFileUpdateParameters` * * Optional behavior parameters for schema validation. * * ```typescript * // Use default schema (void response) * await commitCvmComposeFileUpdate(client, { cvmId: 'cvm-123', request: commitRequest }) * * // Return raw data without validation * const raw = await commitCvmComposeFileUpdate(client, { cvmId: 'cvm-123', request: commitRequest }, { schema: false }) * * // Use custom schema * const customSchema = z.object({ status: z.string() }) * const custom = await commitCvmComposeFileUpdate(client, { cvmId: 'cvm-123', request: commitRequest }, { schema: customSchema }) * ``` * * ## Safe Version * * Use `safeCommitCvmComposeFileUpdate` for error handling without exceptions: * * ```typescript * import { safeCommitCvmComposeFileUpdate } from '@phala/cloud' * * const result = await safeCommitCvmComposeFileUpdate(client, { cvmId: 'cvm-123', request: commitRequest }) * if (result.success) { * console.log('Compose file update committed successfully') * } else { * if ("isRequestError" in result.error) { * console.error(`HTTP ${result.error.status}: ${result.error.message}`) * } else { * console.error(`Validation error: ${result.error.issues}`) * } * } * ``` */ export declare const CommitCvmComposeFileUpdateRequestSchema: 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>>; compose_hash: z.ZodString; encrypted_env: z.ZodOptional<z.ZodString>; env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { compose_hash: string; id?: string | undefined; app_id?: string | undefined; instance_id?: string | undefined; env_keys?: string[] | undefined; encrypted_env?: string | undefined; uuid?: string | undefined; }, { compose_hash: string; id?: string | undefined; app_id?: string | undefined; instance_id?: string | undefined; env_keys?: string[] | undefined; encrypted_env?: string | undefined; uuid?: string | undefined; }>, { compose_hash: string; id?: string | undefined; app_id?: string | undefined; instance_id?: string | undefined; env_keys?: string[] | undefined; encrypted_env?: string | undefined; uuid?: string | undefined; }, { compose_hash: string; id?: string | undefined; app_id?: string | undefined; instance_id?: string | undefined; env_keys?: string[] | undefined; encrypted_env?: string | undefined; uuid?: string | undefined; }>, { cvmId: string | undefined; compose_hash: string; encrypted_env: string | undefined; env_keys: string[] | undefined; _raw: { compose_hash: string; id?: string | undefined; app_id?: string | undefined; instance_id?: string | undefined; env_keys?: string[] | undefined; encrypted_env?: string | undefined; uuid?: string | undefined; }; }, { compose_hash: string; id?: string | undefined; app_id?: string | undefined; instance_id?: string | undefined; env_keys?: string[] | undefined; encrypted_env?: string | undefined; uuid?: string | undefined; }>; export declare const CommitCvmComposeFileUpdateSchema: z.ZodEffects<z.ZodAny, undefined, any>; export type CommitCvmComposeFileUpdateRequest = z.infer<typeof CommitCvmComposeFileUpdateRequestSchema>; export type CommitCvmComposeFileUpdate = undefined; export type CommitCvmComposeFileUpdateParameters<T = undefined> = ActionParameters<T>; export type CommitCvmComposeFileUpdateReturnType<T = undefined> = ActionReturnType<CommitCvmComposeFileUpdate, T>; export declare function commitCvmComposeFileUpdate<T extends z.ZodSchema | false | undefined = undefined>(client: Client, request: CommitCvmComposeFileUpdateRequest, parameters?: CommitCvmComposeFileUpdateParameters<T>): Promise<CommitCvmComposeFileUpdateReturnType<T>>; export declare function safeCommitCvmComposeFileUpdate<T extends z.ZodSchema | false | undefined = undefined>(client: Client, request: CommitCvmComposeFileUpdateRequest, parameters?: CommitCvmComposeFileUpdateParameters<T>): Promise<SafeResult<CommitCvmComposeFileUpdateReturnType<T>>>; //# sourceMappingURL=commit_cvm_compose_file_update.d.ts.map