import {z} from 'zod' export type GithubComBaselinehqGolangSharedTypesProvider = 'GCP' | 'AWS' | 'DigitalOcean' | 'Azure' | 'Hetzner' | 'OVHCloud' | 'PlanetScale' | 'STACKIT' | 'Linode' | 'Base' | 'Akash' | 'Alibaba' | 'Baseten' | 'Beam' | 'Cerebrium' | 'CIRunners' | 'Civo' | 'Clore' | 'CoreWeave' | 'Crusoe' | 'CUDO' | 'DataCrunch' | 'DeepInfra' | 'Denvr' | 'E2ENetworks' | 'Exoscale' | 'Fal' | 'HotAisle' | 'Hyperbolic' | 'Hyperstack' | 'IBM' | 'Lambda' | 'Latitude' | 'MassedCompute' | 'Modal' | 'Nebius' | 'Novita' | 'Oblivus' | 'OCI' | 'OpenTelekom' | 'PrimeIntellect' | 'Replicate' | 'RunPod' | 'Salad' | 'Scaleway' | 'Sesterce' | 'Shadeform' | 'ThunderCompute' | 'UpCloud' | 'Vast' | 'Vultr'; export type TypesService = 'ComputeEngine' | 'AmazonEC2' | 'Droplet' | 'AzureCompute' | 'AzureManagedDisks' | 'HetznerCompute' | 'OVHPublicCloud' | 'BaseCompute' | 'BaseDisks' | 'AmazonEBS' | 'AmazonRDS' | 'AuroraDSQL' | 'CloudSQL' | 'AlloyDB' | 'CloudSpanner' | 'AzureDatabaseForPostgreSQL' | 'AzureDatabaseForMySQL' | 'AzureSQLDatabase' | 'AzureSQLManagedInstance' | 'PlanetScale' | 'ComputeEnginePersistentDisk' | 'STACKITCompute' | 'STACKITBlockStorage' | 'STACKITDatabase' | 'AkamaiLinode' | 'AkamaiBlockStorage' | 'AkamaiDatabase' | 'AkashCompute' | 'AlibabaCompute' | 'AlibabaBlockStorage' | 'BasetenCompute' | 'BeamCompute' | 'CerebriumCompute' | 'CivoCompute' | 'CivoBlockStorage' | 'CloreCompute' | 'CoreWeaveCompute' | 'CrusoeCompute' | 'CUDOCompute' | 'DataCrunchCompute' | 'DeepInfraCompute' | 'DenvrCompute' | 'E2ENetworksCompute' | 'ExoscaleCompute' | 'ExoscaleBlockStorage' | 'FalCompute' | 'HotAisleCompute' | 'HyperbolicCompute' | 'HyperstackCompute' | 'IBMCompute' | 'IBMBlockStorage' | 'LambdaCompute' | 'LatitudeCompute' | 'MassedComputeCompute' | 'ModalCompute' | 'NebiusCompute' | 'NovitaCompute' | 'OblivusCompute' | 'OCICompute' | 'OCIBlockStorage' | 'OpenTelekomCompute' | 'PrimeIntellectCompute' | 'ReplicateCompute' | 'RunPodCompute' | 'SaladCompute' | 'ScalewayCompute' | 'ScalewayBlockStorage' | 'SesterceCompute' | 'ShadeformCompute' | 'ThunderComputeCompute' | 'UpCloudCompute' | 'UpCloudBlockStorage' | 'VastCompute' | 'VultrCompute' | 'VultrBlockStorage'; export type GithubComBaselinehqGolangSharedTypesUsageType = 'SPOT_PREEMPTIBLE' | 'ONDEMAND' | 'RESERVED' | 'ONDEMAND_CUSTOM' | 'SPOT_PREEMPTIBLE_CUSTOM' | 'RESERVED_CUSTOM' | 'SOLE_TENANCY' | 'CUSTOM' | 'EXTENDED'; export type Disk = {availability_zone?: string | undefined, capacity_gb?: number | undefined, fallback_to_base_pricing?: boolean | undefined, id?: string | undefined, iops?: number | undefined, provider?: GithubComBaselinehqGolangSharedTypesProvider | undefined, region?: string | undefined, service?: TypesService | undefined, throughput_mbps?: number | undefined, type?: string | undefined, usage_type?: GithubComBaselinehqGolangSharedTypesUsageType | undefined}; export type CreateApiPricingDisksArgs = {body: Disk}; export type CreateApiPricingDisksOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const diskPrice = z.object({availability_zone: z.string().optional(), cost_per_gb_hour: z.number().optional(), cost_per_iops_hour: z.number().optional(), cost_per_throughput_mbps_hour: z.number().optional(), created_at: z.string().optional(), currency: z.string().optional(), id: z.string().optional(), max_capacity_gb: z.number().optional(), max_iops: z.number().optional(), max_throughput_mbps: z.number().optional(), min_capacity_gb: z.number().optional(), min_iops: z.number().optional(), min_throughput_mbps: z.number().optional(), native_cost_per_gb_hour: z.number().optional(), native_cost_per_iops_hour: z.number().optional(), native_cost_per_throughput_mbps_hour: z.number().optional(), period_billing_hours: z.number().optional(), provider: z.string().optional(), raw_pricing_data: z.object({}).optional(), region: z.string().optional(), service: z.string().optional(), tags: z.object({}).optional(), type: z.string().optional(), updated_at: z.string().optional(), usage_type: z.string().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 }; /** * Get pricing for a disk * * POST /pricing/disks * * Also accepts auth: BearerAuth */ export const createApiPricingDisks = async (args: CreateApiPricingDisksArgs, options?: CreateApiPricingDisksOptions) => { const {baseUrl = "https://pricing.baselinehq.cloud", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("X-API-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/pricing/disks${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(diskPrice, await res.json()) };