import {z} from 'zod' export type DeleteApiMarketplaceProvidersDatabasesArgs = {id: string}; export type DeleteApiMarketplaceProvidersDatabasesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const databasePrice = z.object({architecture: z.string().optional(), availability_zone: z.string().optional(), billing_config: z.string().optional(), capacity_unit: z.string().optional(), cost_per_capacity_unit: z.number().optional(), cost_per_hour: z.number().optional(), cost_per_io_request: z.number().optional(), cost_per_iops_hour: z.number().optional(), cost_per_storage_gb_hour: z.number().optional(), cost_per_throughput_mbps_hour: z.number().optional(), cost_per_vcpu_license_hour: z.number().optional(), cpu_cores: z.number().optional(), cpu_cores_cost_per_hour: z.number().optional(), created_at: z.string().optional(), currency: z.string().optional(), deployment_option: z.string().optional(), edition: z.string().optional(), engine: z.string().optional(), id: z.string().optional(), instance_type: z.string().optional(), max_iops: z.number().optional(), max_storage_gb: z.number().optional(), max_throughput_mbps: z.number().optional(), min_iops: z.number().optional(), min_storage_gb: z.number().optional(), min_throughput_mbps: z.number().optional(), native_cost_per_hour: z.number().optional(), native_cost_per_storage_gb_hour: z.number().optional(), period_billing_hours: z.number().optional(), provider: z.string().optional(), ram_gb: z.number().optional(), ram_gb_cost_per_hour: z.number().optional(), raw_pricing_data: z.object({}).optional(), region: z.string().optional(), service: z.string().optional(), storage_type: z.string().optional(), tags: z.object({}).optional(), updated_at: z.string().optional(), usage_type: z.string().optional()}); export const registrationStatus = z.enum(["Registered", "Deleted"]); export const registeredDatabasePrices = z.object({entries: z.array(databasePrice).optional(), status: registrationStatus.optional()}); 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 }; /** * Delete a custom database pricing entry * * DELETE /marketplace/providers/databases * * Also accepts auth: BearerAuth */ export const deleteApiMarketplaceProvidersDatabases = async (args: DeleteApiMarketplaceProvidersDatabasesArgs, options?: DeleteApiMarketplaceProvidersDatabasesOptions) => { const {baseUrl = "https://pricing.baselinehq.cloud", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.id != null) query.append("id", String(args.id)) if (ApiKeyAuth !== undefined) headers.set("X-API-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/marketplace/providers/databases${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(registeredDatabasePrices, await res.json()) };