/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type UpdateScopedApiKeyRequestBody = { keyId: string; scopes: Array; name?: string | undefined; rateLimitEnabled?: boolean | undefined; rateLimitTimeWindow?: number | undefined; rateLimitMax?: number | undefined; }; export type UpdateScopedApiKeyRequest = { /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; requestBody?: UpdateScopedApiKeyRequestBody | undefined; }; export const UpdateScopedApiKeyUserType = { User: "user", ServiceAccount: "service-account", } as const; export type UpdateScopedApiKeyUserType = ClosedEnum< typeof UpdateScopedApiKeyUserType >; /** * Updated */ export type UpdateScopedApiKeyResponseBody = { id: string; name?: string | null | undefined; key?: string | undefined; prefix?: string | null | undefined; start?: string | null | undefined; userId: string; userType: UpdateScopedApiKeyUserType; orgId: string | null; teamId: string | null; scopes: Array; expiresAt?: string | null | undefined; }; /** @internal */ export const UpdateScopedApiKeyRequestBody$inboundSchema: z.ZodType< UpdateScopedApiKeyRequestBody, z.ZodTypeDef, unknown > = z.object({ keyId: z.string(), scopes: z.array(z.string()), name: z.string().optional(), rateLimitEnabled: z.boolean().optional(), rateLimitTimeWindow: z.number().optional(), rateLimitMax: z.number().optional(), }); /** @internal */ export type UpdateScopedApiKeyRequestBody$Outbound = { keyId: string; scopes: Array; name?: string | undefined; rateLimitEnabled?: boolean | undefined; rateLimitTimeWindow?: number | undefined; rateLimitMax?: number | undefined; }; /** @internal */ export const UpdateScopedApiKeyRequestBody$outboundSchema: z.ZodType< UpdateScopedApiKeyRequestBody$Outbound, z.ZodTypeDef, UpdateScopedApiKeyRequestBody > = z.object({ keyId: z.string(), scopes: z.array(z.string()), name: z.string().optional(), rateLimitEnabled: z.boolean().optional(), rateLimitTimeWindow: z.number().optional(), rateLimitMax: z.number().optional(), }); export function updateScopedApiKeyRequestBodyToJSON( updateScopedApiKeyRequestBody: UpdateScopedApiKeyRequestBody, ): string { return JSON.stringify( UpdateScopedApiKeyRequestBody$outboundSchema.parse( updateScopedApiKeyRequestBody, ), ); } export function updateScopedApiKeyRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateScopedApiKeyRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateScopedApiKeyRequestBody' from JSON`, ); } /** @internal */ export const UpdateScopedApiKeyRequest$inboundSchema: z.ZodType< UpdateScopedApiKeyRequest, z.ZodTypeDef, unknown > = z.object({ "X-On-Behalf-Of": z.string().optional(), RequestBody: z.lazy(() => UpdateScopedApiKeyRequestBody$inboundSchema) .optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", "RequestBody": "requestBody", }); }); /** @internal */ export type UpdateScopedApiKeyRequest$Outbound = { "X-On-Behalf-Of"?: string | undefined; RequestBody?: UpdateScopedApiKeyRequestBody$Outbound | undefined; }; /** @internal */ export const UpdateScopedApiKeyRequest$outboundSchema: z.ZodType< UpdateScopedApiKeyRequest$Outbound, z.ZodTypeDef, UpdateScopedApiKeyRequest > = z.object({ xOnBehalfOf: z.string().optional(), requestBody: z.lazy(() => UpdateScopedApiKeyRequestBody$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", requestBody: "RequestBody", }); }); export function updateScopedApiKeyRequestToJSON( updateScopedApiKeyRequest: UpdateScopedApiKeyRequest, ): string { return JSON.stringify( UpdateScopedApiKeyRequest$outboundSchema.parse(updateScopedApiKeyRequest), ); } export function updateScopedApiKeyRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateScopedApiKeyRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateScopedApiKeyRequest' from JSON`, ); } /** @internal */ export const UpdateScopedApiKeyUserType$inboundSchema: z.ZodNativeEnum< typeof UpdateScopedApiKeyUserType > = z.nativeEnum(UpdateScopedApiKeyUserType); /** @internal */ export const UpdateScopedApiKeyUserType$outboundSchema: z.ZodNativeEnum< typeof UpdateScopedApiKeyUserType > = UpdateScopedApiKeyUserType$inboundSchema; /** @internal */ export const UpdateScopedApiKeyResponseBody$inboundSchema: z.ZodType< UpdateScopedApiKeyResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), name: z.nullable(z.string()).optional(), key: z.string().optional(), prefix: z.nullable(z.string()).optional(), start: z.nullable(z.string()).optional(), userId: z.string(), userType: UpdateScopedApiKeyUserType$inboundSchema, orgId: z.nullable(z.string()), teamId: z.nullable(z.string()), scopes: z.array(z.string()), expiresAt: z.nullable(z.string()).optional(), }); /** @internal */ export type UpdateScopedApiKeyResponseBody$Outbound = { id: string; name?: string | null | undefined; key?: string | undefined; prefix?: string | null | undefined; start?: string | null | undefined; userId: string; userType: string; orgId: string | null; teamId: string | null; scopes: Array; expiresAt?: string | null | undefined; }; /** @internal */ export const UpdateScopedApiKeyResponseBody$outboundSchema: z.ZodType< UpdateScopedApiKeyResponseBody$Outbound, z.ZodTypeDef, UpdateScopedApiKeyResponseBody > = z.object({ id: z.string(), name: z.nullable(z.string()).optional(), key: z.string().optional(), prefix: z.nullable(z.string()).optional(), start: z.nullable(z.string()).optional(), userId: z.string(), userType: UpdateScopedApiKeyUserType$outboundSchema, orgId: z.nullable(z.string()), teamId: z.nullable(z.string()), scopes: z.array(z.string()), expiresAt: z.nullable(z.string()).optional(), }); export function updateScopedApiKeyResponseBodyToJSON( updateScopedApiKeyResponseBody: UpdateScopedApiKeyResponseBody, ): string { return JSON.stringify( UpdateScopedApiKeyResponseBody$outboundSchema.parse( updateScopedApiKeyResponseBody, ), ); } export function updateScopedApiKeyResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateScopedApiKeyResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateScopedApiKeyResponseBody' from JSON`, ); }