import {z} from 'zod' export type HashicorpVaultConfig = {vault_addr?: (string | null) | undefined, vault_token?: (string | null) | undefined, approle_role_id?: (string | null) | undefined, approle_secret_id?: (string | null) | undefined, approle_mount_path?: (string | null) | undefined, client_cert?: (string | null) | undefined, client_key?: (string | null) | undefined, vault_cert_role?: (string | null) | undefined, vault_namespace?: (string | null) | undefined, vault_login_namespace?: (string | null) | undefined, vault_secret_namespace?: (string | null) | undefined, vault_mount_name?: (string | null) | undefined, vault_path_prefix?: (string | null) | undefined}; export type CreateApiConfigOverridesHashicorpVaultArgs = {'litellm-changed-by'?: (string | null) | undefined, body: HashicorpVaultConfig}; export type CreateApiConfigOverridesHashicorpVaultOptions = {baseUrl: string, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiConfigOverridesHashicorpVaultResponse = z.unknown(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update Hashicorp Vault Config * * POST /config_overrides/hashicorp_vault */ export const createApiConfigOverridesHashicorpVault = async (args: CreateApiConfigOverridesHashicorpVaultArgs, options: CreateApiConfigOverridesHashicorpVaultOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['litellm-changed-by'] != null) headers.set("litellm-changed-by", String(args['litellm-changed-by'])) if (APIKeyHeader !== undefined) headers.set("x-litellm-api-key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/config_overrides/hashicorp_vault${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiConfigOverridesHashicorpVaultResponse, await res.json()) };