/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: b4ab75565bc0 */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { smartUnion } from "../../types/smartUnion.js"; import { AuthDirection, AuthDirection$outboundSchema, } from "./authdirection.js"; import { ConnectorAuthenticationHeader, ConnectorAuthenticationHeader$Outbound, ConnectorAuthenticationHeader$outboundSchema, } from "./connectorauthenticationheader.js"; import { ExtendedOAuthServerMetadata, ExtendedOAuthServerMetadata$Outbound, ExtendedOAuthServerMetadata$outboundSchema, } from "./extendedoauthservermetadata.js"; import { GlobalHeaderValue, GlobalHeaderValue$Outbound, GlobalHeaderValue$outboundSchema, } from "./globalheadervalue.js"; import { InboundAuthenticationType, InboundAuthenticationType$outboundSchema, } from "./inboundauthenticationtype.js"; import { Oauth2MetadataSecrets, Oauth2MetadataSecrets$Outbound, Oauth2MetadataSecrets$outboundSchema, } from "./oauth2metadatasecrets.js"; import { OutboundAuthenticationType, OutboundAuthenticationType$outboundSchema, } from "./outboundauthenticationtype.js"; /** * The type of authentication method (e.g. oauth2, bearer, none). */ export type MethodType = OutboundAuthenticationType | InboundAuthenticationType; export type AuthenticationMethodCreateOrUpdateRequest = { /** * The type of authentication method (e.g. oauth2, bearer, none). */ methodType: OutboundAuthenticationType | InboundAuthenticationType; authDirection?: AuthDirection | undefined; /** * Set of headers to connect to the connector */ headers?: Array | null | undefined; /** * Connector-wide headers keyed by header name, applied to every credential. Secret values are encrypted at rest and never returned in clear. */ globalHeaders?: { [k: string]: GlobalHeaderValue } | undefined; /** * New OAuth2 client credentials (client_id and client_secret). */ oauth2MetadataSecrets?: Oauth2MetadataSecrets | null | undefined; /** * New OAuth2 authorization server metadata. */ oauth2ServerMetadata?: ExtendedOAuthServerMetadata | null | undefined; }; /** @internal */ export type MethodType$Outbound = string | string; /** @internal */ export const MethodType$outboundSchema: z.ZodType< MethodType$Outbound, MethodType > = smartUnion([ OutboundAuthenticationType$outboundSchema, InboundAuthenticationType$outboundSchema, ]); export function methodTypeToJSON(methodType: MethodType): string { return JSON.stringify(MethodType$outboundSchema.parse(methodType)); } /** @internal */ export type AuthenticationMethodCreateOrUpdateRequest$Outbound = { method_type: string | string; auth_direction?: string | undefined; headers?: Array | null | undefined; global_headers?: { [k: string]: GlobalHeaderValue$Outbound } | undefined; oauth2_metadata_secrets?: Oauth2MetadataSecrets$Outbound | null | undefined; oauth2_server_metadata?: | ExtendedOAuthServerMetadata$Outbound | null | undefined; }; /** @internal */ export const AuthenticationMethodCreateOrUpdateRequest$outboundSchema: z.ZodType< AuthenticationMethodCreateOrUpdateRequest$Outbound, AuthenticationMethodCreateOrUpdateRequest > = z.object({ methodType: smartUnion([ OutboundAuthenticationType$outboundSchema, InboundAuthenticationType$outboundSchema, ]), authDirection: AuthDirection$outboundSchema.optional(), headers: z.nullable(z.array(ConnectorAuthenticationHeader$outboundSchema)) .optional(), globalHeaders: z.record(z.string(), GlobalHeaderValue$outboundSchema) .optional(), oauth2MetadataSecrets: z.nullable(Oauth2MetadataSecrets$outboundSchema) .optional(), oauth2ServerMetadata: z.nullable(ExtendedOAuthServerMetadata$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { methodType: "method_type", authDirection: "auth_direction", globalHeaders: "global_headers", oauth2MetadataSecrets: "oauth2_metadata_secrets", oauth2ServerMetadata: "oauth2_server_metadata", }); }); export function authenticationMethodCreateOrUpdateRequestToJSON( authenticationMethodCreateOrUpdateRequest: AuthenticationMethodCreateOrUpdateRequest, ): string { return JSON.stringify( AuthenticationMethodCreateOrUpdateRequest$outboundSchema.parse( authenticationMethodCreateOrUpdateRequest, ), ); }