UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

1,153 lines (1,042 loc) 36.5 kB
/* * 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 { smartUnion } from "../types/smartUnion.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; import { Session, Session$inboundSchema } from "./session.js"; /** * Match on the request path. Comparison is case-sensitive. */ export type UpdateSessionNetworkPolicyAllowPath = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; /** * Matcher for the entry key (header name or query key). */ export type UpdateSessionNetworkPolicyAllowKey = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; /** * Matcher for the entry value. */ export type UpdateSessionNetworkPolicyAllowValue = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; export type UpdateSessionNetworkPolicyAllowQueryString = { /** * Matcher for the entry key (header name or query key). */ key?: UpdateSessionNetworkPolicyAllowKey | undefined; /** * Matcher for the entry value. */ value?: UpdateSessionNetworkPolicyAllowValue | undefined; }; /** * Matcher for the entry key (header name or query key). */ export type UpdateSessionNetworkPolicyAllowSandboxesKey = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; /** * Matcher for the entry value. */ export type UpdateSessionNetworkPolicyAllowSandboxesValue = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; export type UpdateSessionNetworkPolicyAllowHeaders = { /** * Matcher for the entry key (header name or query key). */ key?: UpdateSessionNetworkPolicyAllowSandboxesKey | undefined; /** * Matcher for the entry value. */ value?: UpdateSessionNetworkPolicyAllowSandboxesValue | undefined; }; /** * Optional L7 match. When provided, the injection rule only applies to requests that satisfy every specified dimension. When multiple injection rules target the same domain they are evaluated in order and the first match wins; a rule without `match` matches any request and shadows later rules for the same domain. */ export type UpdateSessionNetworkPolicyAllowMatch = { /** * Match on the request path. Comparison is case-sensitive. */ path?: UpdateSessionNetworkPolicyAllowPath | undefined; /** * HTTP methods to match. Any single match succeeds (OR semantics). */ method?: Array<string> | undefined; /** * Query-string entry matchers. Multiple entries are ANDed. Query parameter names and values are both compared case-sensitively (RFC 3986). When a request has multiple values for the same key, any matching value satisfies the matcher. */ queryString?: Array<UpdateSessionNetworkPolicyAllowQueryString> | undefined; /** * Header matchers. Multiple entries are ANDed. Header names are compared case-insensitively (RFC 9110); header values are compared case-sensitively. When a request has multiple values for the same header, any matching value satisfies the matcher. */ headers?: Array<UpdateSessionNetworkPolicyAllowHeaders> | undefined; }; export type UpdateSessionNetworkPolicyAllowTransform = { headers?: { [k: string]: string } | undefined; }; /** * Answer matching requests from the proxy with this response instead of forwarding them to the origin. Combine with a `match` on an earlier rule to allow one sub-path and reject the rest of a domain. */ export type UpdateSessionNetworkPolicyAllowResponse = { /** * HTTP status code returned to the sandbox. */ statusCode: number; /** * HTTP response headers. Framing and hop-by-hop headers are managed by the proxy and cannot be set. */ headers?: { [k: string]: string } | undefined; /** * UTF-8 response body. Requires `contentType`. */ body?: string | undefined; /** * Value of the `Content-Type` response header. Required when `body` is set. */ contentType?: string | undefined; }; export type UpdateSessionNetworkPolicyAllow2 = { /** * Optional L7 match. When provided, the injection rule only applies to requests that satisfy every specified dimension. When multiple injection rules target the same domain they are evaluated in order and the first match wins; a rule without `match` matches any request and shadows later rules for the same domain. */ match?: UpdateSessionNetworkPolicyAllowMatch | undefined; transform?: Array<UpdateSessionNetworkPolicyAllowTransform> | undefined; /** * HTTP/1.1 proxy URL to forward traffic to. Must not include username, password, query string, or fragment. */ forwardURL?: string | undefined; /** * Answer matching requests from the proxy with this response instead of forwarding them to the origin. Combine with a `match` on an earlier rule to allow one sub-path and reject the rest of a domain. */ response?: UpdateSessionNetworkPolicyAllowResponse | undefined; }; export type RequestBodyAllow = Array<string> | { [k: string]: Array<UpdateSessionNetworkPolicyAllow2>; }; export type RequestBodySubnets = { allow?: Array<string> | undefined; deny?: Array<string> | undefined; }; export type UpdateSessionNetworkPolicyRequestBody2 = { allow?: Array<string> | { [k: string]: Array<UpdateSessionNetworkPolicyAllow2>; } | undefined; subnets?: RequestBodySubnets | undefined; }; /** * The network access policy mode. Use \"allow-all\" to permit all outbound traffic. Use \"deny-all\" to block all outbound traffic. Use \"custom\" to specify explicit allow/deny rules. */ export const RequestBodyMode = { AllowAll: "allow-all", DenyAll: "deny-all", Custom: "custom", DefaultAllow: "default-allow", DefaultDeny: "default-deny", } as const; /** * The network access policy mode. Use \"allow-all\" to permit all outbound traffic. Use \"deny-all\" to block all outbound traffic. Use \"custom\" to specify explicit allow/deny rules. */ export type RequestBodyMode = ClosedEnum<typeof RequestBodyMode>; /** * Match on the request path. Comparison is case-sensitive. */ export type RequestBodyPath = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; /** * Matcher for the entry key (header name or query key). */ export type RequestBodyKey = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; /** * Matcher for the entry value. */ export type UpdateSessionNetworkPolicyRequestBodySandboxesValue = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; export type RequestBodyQueryString = { /** * Matcher for the entry key (header name or query key). */ key?: RequestBodyKey | undefined; /** * Matcher for the entry value. */ value?: UpdateSessionNetworkPolicyRequestBodySandboxesValue | undefined; }; /** * Matcher for the entry key (header name or query key). */ export type UpdateSessionNetworkPolicyRequestBodyKey = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; /** * Matcher for the entry value. */ export type UpdateSessionNetworkPolicyRequestBodyValue = { /** * Match the value exactly. Case-sensitive for paths, header values, and methods; case-insensitive for domains and header keys. */ exact?: string | undefined; /** * Match values that start with the given prefix. */ startsWith?: string | undefined; }; export type RequestBodyHeaders = { /** * Matcher for the entry key (header name or query key). */ key?: UpdateSessionNetworkPolicyRequestBodyKey | undefined; /** * Matcher for the entry value. */ value?: UpdateSessionNetworkPolicyRequestBodyValue | undefined; }; /** * Optional L7 match. When provided, the injection rule only applies to requests that satisfy every specified dimension. When multiple injection rules target the same domain they are evaluated in order and the first match wins; a rule without `match` matches any request and shadows later rules for the same domain. */ export type RequestBodyMatch = { /** * Match on the request path. Comparison is case-sensitive. */ path?: RequestBodyPath | undefined; /** * HTTP methods to match. Any single match succeeds (OR semantics). */ method?: Array<string> | undefined; /** * Query-string entry matchers. Multiple entries are ANDed. Query parameter names and values are both compared case-sensitively (RFC 3986). When a request has multiple values for the same key, any matching value satisfies the matcher. */ queryString?: Array<RequestBodyQueryString> | undefined; /** * Header matchers. Multiple entries are ANDed. Header names are compared case-insensitively (RFC 9110); header values are compared case-sensitively. When a request has multiple values for the same header, any matching value satisfies the matcher. */ headers?: Array<RequestBodyHeaders> | undefined; }; export type RequestBodyInjectionRules = { /** * The domain (or pattern) of requests to add headers for. Supports wildcards like *.example.com. */ domain: string; /** * HTTP headers to inject into requests for this domain. Existing headers with the same name will be overridden. */ headers: { [k: string]: string }; /** * Optional L7 match. When provided, the injection rule only applies to requests that satisfy every specified dimension. When multiple injection rules target the same domain they are evaluated in order and the first match wins; a rule without `match` matches any request and shadows later rules for the same domain. */ match?: RequestBodyMatch | undefined; }; /** * Network access policy for the sandbox.\n Controls which external hosts the sandbox can communicate with.\n Use \"allow-all\" mode to allow all traffic, \"deny-all\" to block all traffic or \"custom\" to provide specific rules. */ export type UpdateSessionNetworkPolicyRequestBody1 = { /** * The network access policy mode. Use \"allow-all\" to permit all outbound traffic. Use \"deny-all\" to block all outbound traffic. Use \"custom\" to specify explicit allow/deny rules. */ mode: RequestBodyMode; /** * List of domain names the sandbox is allowed to connect to. Only applies when mode is \"custom\". Supports wildcard patterns (e.g., \"*.example.com\" matches all subdomains). */ allowedDomains?: Array<string> | undefined; /** * List of IP address ranges (in CIDR notation) the sandbox is allowed to connect to. Traffic to these addresses bypasses domain-based restrictions. */ allowedCIDRs?: Array<string> | undefined; /** * List of IP address ranges (in CIDR notation) the sandbox is blocked from connecting to. These rules take precedence over all allowed rules. */ deniedCIDRs?: Array<string> | undefined; /** * HTTP header injection rules for outgoing requests matching specific domains. Traffic to matching domains will be intercepted instead of proxied through encrypted connections. */ injectionRules?: Array<RequestBodyInjectionRules> | undefined; }; export type UpdateSessionNetworkPolicyRequestBody = | UpdateSessionNetworkPolicyRequestBody1 | UpdateSessionNetworkPolicyRequestBody2; export type UpdateSessionNetworkPolicyRequest = { /** * The unique identifier of the session to update the network policy for. */ sessionId: string; /** * The Team identifier to perform the request on behalf of. */ teamId?: string | undefined; /** * The Team slug to perform the request on behalf of. */ slug?: string | undefined; requestBody?: | UpdateSessionNetworkPolicyRequestBody1 | UpdateSessionNetworkPolicyRequestBody2 | undefined; }; /** * The session network policy was updated successfully. */ export type UpdateSessionNetworkPolicyResponseBody = { /** * This object contains information related to a Vercel Sandbox Session. v2 endpoints return "session" instead of "sandbox" as the response wrapper key. */ session: Session; }; /** @internal */ export type UpdateSessionNetworkPolicyAllowPath$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowPath$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowPath$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowPath > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyAllowPathToJSON( updateSessionNetworkPolicyAllowPath: UpdateSessionNetworkPolicyAllowPath, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowPath$outboundSchema.parse( updateSessionNetworkPolicyAllowPath, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowKey$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowKey$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowKey$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowKey > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyAllowKeyToJSON( updateSessionNetworkPolicyAllowKey: UpdateSessionNetworkPolicyAllowKey, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowKey$outboundSchema.parse( updateSessionNetworkPolicyAllowKey, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowValue$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowValue$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowValue$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowValue > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyAllowValueToJSON( updateSessionNetworkPolicyAllowValue: UpdateSessionNetworkPolicyAllowValue, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowValue$outboundSchema.parse( updateSessionNetworkPolicyAllowValue, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowQueryString$Outbound = { key?: UpdateSessionNetworkPolicyAllowKey$Outbound | undefined; value?: UpdateSessionNetworkPolicyAllowValue$Outbound | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowQueryString$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowQueryString$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowQueryString > = z.object({ key: z.lazy(() => UpdateSessionNetworkPolicyAllowKey$outboundSchema) .optional(), value: z.lazy(() => UpdateSessionNetworkPolicyAllowValue$outboundSchema) .optional(), }); export function updateSessionNetworkPolicyAllowQueryStringToJSON( updateSessionNetworkPolicyAllowQueryString: UpdateSessionNetworkPolicyAllowQueryString, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowQueryString$outboundSchema.parse( updateSessionNetworkPolicyAllowQueryString, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowSandboxesKey$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowSandboxesKey$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowSandboxesKey$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowSandboxesKey > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyAllowSandboxesKeyToJSON( updateSessionNetworkPolicyAllowSandboxesKey: UpdateSessionNetworkPolicyAllowSandboxesKey, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowSandboxesKey$outboundSchema.parse( updateSessionNetworkPolicyAllowSandboxesKey, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowSandboxesValue$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowSandboxesValue$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowSandboxesValue$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowSandboxesValue > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyAllowSandboxesValueToJSON( updateSessionNetworkPolicyAllowSandboxesValue: UpdateSessionNetworkPolicyAllowSandboxesValue, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowSandboxesValue$outboundSchema.parse( updateSessionNetworkPolicyAllowSandboxesValue, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowHeaders$Outbound = { key?: UpdateSessionNetworkPolicyAllowSandboxesKey$Outbound | undefined; value?: UpdateSessionNetworkPolicyAllowSandboxesValue$Outbound | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowHeaders$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowHeaders$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowHeaders > = z.object({ key: z.lazy(() => UpdateSessionNetworkPolicyAllowSandboxesKey$outboundSchema) .optional(), value: z.lazy(() => UpdateSessionNetworkPolicyAllowSandboxesValue$outboundSchema ).optional(), }); export function updateSessionNetworkPolicyAllowHeadersToJSON( updateSessionNetworkPolicyAllowHeaders: UpdateSessionNetworkPolicyAllowHeaders, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowHeaders$outboundSchema.parse( updateSessionNetworkPolicyAllowHeaders, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowMatch$Outbound = { path?: UpdateSessionNetworkPolicyAllowPath$Outbound | undefined; method?: Array<string> | undefined; queryString?: | Array<UpdateSessionNetworkPolicyAllowQueryString$Outbound> | undefined; headers?: Array<UpdateSessionNetworkPolicyAllowHeaders$Outbound> | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowMatch$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowMatch$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowMatch > = z.object({ path: z.lazy(() => UpdateSessionNetworkPolicyAllowPath$outboundSchema) .optional(), method: z.array(z.string()).optional(), queryString: z.array( z.lazy(() => UpdateSessionNetworkPolicyAllowQueryString$outboundSchema), ).optional(), headers: z.array( z.lazy(() => UpdateSessionNetworkPolicyAllowHeaders$outboundSchema), ).optional(), }); export function updateSessionNetworkPolicyAllowMatchToJSON( updateSessionNetworkPolicyAllowMatch: UpdateSessionNetworkPolicyAllowMatch, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowMatch$outboundSchema.parse( updateSessionNetworkPolicyAllowMatch, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowTransform$Outbound = { headers?: { [k: string]: string } | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowTransform$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowTransform$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowTransform > = z.object({ headers: z.record(z.string()).optional(), }); export function updateSessionNetworkPolicyAllowTransformToJSON( updateSessionNetworkPolicyAllowTransform: UpdateSessionNetworkPolicyAllowTransform, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowTransform$outboundSchema.parse( updateSessionNetworkPolicyAllowTransform, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllowResponse$Outbound = { statusCode: number; headers?: { [k: string]: string } | undefined; body?: string | undefined; contentType?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllowResponse$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllowResponse$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllowResponse > = z.object({ statusCode: z.number().int(), headers: z.record(z.string()).optional(), body: z.string().optional(), contentType: z.string().optional(), }); export function updateSessionNetworkPolicyAllowResponseToJSON( updateSessionNetworkPolicyAllowResponse: UpdateSessionNetworkPolicyAllowResponse, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllowResponse$outboundSchema.parse( updateSessionNetworkPolicyAllowResponse, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyAllow2$Outbound = { match?: UpdateSessionNetworkPolicyAllowMatch$Outbound | undefined; transform?: | Array<UpdateSessionNetworkPolicyAllowTransform$Outbound> | undefined; forwardURL?: string | undefined; response?: UpdateSessionNetworkPolicyAllowResponse$Outbound | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyAllow2$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyAllow2$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyAllow2 > = z.object({ match: z.lazy(() => UpdateSessionNetworkPolicyAllowMatch$outboundSchema) .optional(), transform: z.array( z.lazy(() => UpdateSessionNetworkPolicyAllowTransform$outboundSchema), ).optional(), forwardURL: z.string().optional(), response: z.lazy(() => UpdateSessionNetworkPolicyAllowResponse$outboundSchema) .optional(), }); export function updateSessionNetworkPolicyAllow2ToJSON( updateSessionNetworkPolicyAllow2: UpdateSessionNetworkPolicyAllow2, ): string { return JSON.stringify( UpdateSessionNetworkPolicyAllow2$outboundSchema.parse( updateSessionNetworkPolicyAllow2, ), ); } /** @internal */ export type RequestBodyAllow$Outbound = Array<string> | { [k: string]: Array<UpdateSessionNetworkPolicyAllow2$Outbound>; }; /** @internal */ export const RequestBodyAllow$outboundSchema: z.ZodType< RequestBodyAllow$Outbound, z.ZodTypeDef, RequestBodyAllow > = smartUnion([ z.array(z.string()), z.record( z.array(z.lazy(() => UpdateSessionNetworkPolicyAllow2$outboundSchema)), ), ]); export function requestBodyAllowToJSON( requestBodyAllow: RequestBodyAllow, ): string { return JSON.stringify( RequestBodyAllow$outboundSchema.parse(requestBodyAllow), ); } /** @internal */ export type RequestBodySubnets$Outbound = { allow?: Array<string> | undefined; deny?: Array<string> | undefined; }; /** @internal */ export const RequestBodySubnets$outboundSchema: z.ZodType< RequestBodySubnets$Outbound, z.ZodTypeDef, RequestBodySubnets > = z.object({ allow: z.array(z.string()).optional(), deny: z.array(z.string()).optional(), }); export function requestBodySubnetsToJSON( requestBodySubnets: RequestBodySubnets, ): string { return JSON.stringify( RequestBodySubnets$outboundSchema.parse(requestBodySubnets), ); } /** @internal */ export type UpdateSessionNetworkPolicyRequestBody2$Outbound = { allow?: Array<string> | { [k: string]: Array<UpdateSessionNetworkPolicyAllow2$Outbound>; } | undefined; subnets?: RequestBodySubnets$Outbound | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyRequestBody2$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyRequestBody2$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyRequestBody2 > = z.object({ allow: smartUnion([ z.array(z.string()), z.record( z.array(z.lazy(() => UpdateSessionNetworkPolicyAllow2$outboundSchema)), ), ]).optional(), subnets: z.lazy(() => RequestBodySubnets$outboundSchema).optional(), }); export function updateSessionNetworkPolicyRequestBody2ToJSON( updateSessionNetworkPolicyRequestBody2: UpdateSessionNetworkPolicyRequestBody2, ): string { return JSON.stringify( UpdateSessionNetworkPolicyRequestBody2$outboundSchema.parse( updateSessionNetworkPolicyRequestBody2, ), ); } /** @internal */ export const RequestBodyMode$outboundSchema: z.ZodNativeEnum< typeof RequestBodyMode > = z.nativeEnum(RequestBodyMode); /** @internal */ export type RequestBodyPath$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const RequestBodyPath$outboundSchema: z.ZodType< RequestBodyPath$Outbound, z.ZodTypeDef, RequestBodyPath > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function requestBodyPathToJSON( requestBodyPath: RequestBodyPath, ): string { return JSON.stringify(RequestBodyPath$outboundSchema.parse(requestBodyPath)); } /** @internal */ export type RequestBodyKey$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const RequestBodyKey$outboundSchema: z.ZodType< RequestBodyKey$Outbound, z.ZodTypeDef, RequestBodyKey > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function requestBodyKeyToJSON(requestBodyKey: RequestBodyKey): string { return JSON.stringify(RequestBodyKey$outboundSchema.parse(requestBodyKey)); } /** @internal */ export type UpdateSessionNetworkPolicyRequestBodySandboxesValue$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyRequestBodySandboxesValue$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyRequestBodySandboxesValue$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyRequestBodySandboxesValue > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyRequestBodySandboxesValueToJSON( updateSessionNetworkPolicyRequestBodySandboxesValue: UpdateSessionNetworkPolicyRequestBodySandboxesValue, ): string { return JSON.stringify( UpdateSessionNetworkPolicyRequestBodySandboxesValue$outboundSchema.parse( updateSessionNetworkPolicyRequestBodySandboxesValue, ), ); } /** @internal */ export type RequestBodyQueryString$Outbound = { key?: RequestBodyKey$Outbound | undefined; value?: | UpdateSessionNetworkPolicyRequestBodySandboxesValue$Outbound | undefined; }; /** @internal */ export const RequestBodyQueryString$outboundSchema: z.ZodType< RequestBodyQueryString$Outbound, z.ZodTypeDef, RequestBodyQueryString > = z.object({ key: z.lazy(() => RequestBodyKey$outboundSchema).optional(), value: z.lazy(() => UpdateSessionNetworkPolicyRequestBodySandboxesValue$outboundSchema ).optional(), }); export function requestBodyQueryStringToJSON( requestBodyQueryString: RequestBodyQueryString, ): string { return JSON.stringify( RequestBodyQueryString$outboundSchema.parse(requestBodyQueryString), ); } /** @internal */ export type UpdateSessionNetworkPolicyRequestBodyKey$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyRequestBodyKey$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyRequestBodyKey$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyRequestBodyKey > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyRequestBodyKeyToJSON( updateSessionNetworkPolicyRequestBodyKey: UpdateSessionNetworkPolicyRequestBodyKey, ): string { return JSON.stringify( UpdateSessionNetworkPolicyRequestBodyKey$outboundSchema.parse( updateSessionNetworkPolicyRequestBodyKey, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyRequestBodyValue$Outbound = { exact?: string | undefined; startsWith?: string | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyRequestBodyValue$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyRequestBodyValue$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyRequestBodyValue > = z.object({ exact: z.string().optional(), startsWith: z.string().optional(), }); export function updateSessionNetworkPolicyRequestBodyValueToJSON( updateSessionNetworkPolicyRequestBodyValue: UpdateSessionNetworkPolicyRequestBodyValue, ): string { return JSON.stringify( UpdateSessionNetworkPolicyRequestBodyValue$outboundSchema.parse( updateSessionNetworkPolicyRequestBodyValue, ), ); } /** @internal */ export type RequestBodyHeaders$Outbound = { key?: UpdateSessionNetworkPolicyRequestBodyKey$Outbound | undefined; value?: UpdateSessionNetworkPolicyRequestBodyValue$Outbound | undefined; }; /** @internal */ export const RequestBodyHeaders$outboundSchema: z.ZodType< RequestBodyHeaders$Outbound, z.ZodTypeDef, RequestBodyHeaders > = z.object({ key: z.lazy(() => UpdateSessionNetworkPolicyRequestBodyKey$outboundSchema) .optional(), value: z.lazy(() => UpdateSessionNetworkPolicyRequestBodyValue$outboundSchema) .optional(), }); export function requestBodyHeadersToJSON( requestBodyHeaders: RequestBodyHeaders, ): string { return JSON.stringify( RequestBodyHeaders$outboundSchema.parse(requestBodyHeaders), ); } /** @internal */ export type RequestBodyMatch$Outbound = { path?: RequestBodyPath$Outbound | undefined; method?: Array<string> | undefined; queryString?: Array<RequestBodyQueryString$Outbound> | undefined; headers?: Array<RequestBodyHeaders$Outbound> | undefined; }; /** @internal */ export const RequestBodyMatch$outboundSchema: z.ZodType< RequestBodyMatch$Outbound, z.ZodTypeDef, RequestBodyMatch > = z.object({ path: z.lazy(() => RequestBodyPath$outboundSchema).optional(), method: z.array(z.string()).optional(), queryString: z.array(z.lazy(() => RequestBodyQueryString$outboundSchema)) .optional(), headers: z.array(z.lazy(() => RequestBodyHeaders$outboundSchema)).optional(), }); export function requestBodyMatchToJSON( requestBodyMatch: RequestBodyMatch, ): string { return JSON.stringify( RequestBodyMatch$outboundSchema.parse(requestBodyMatch), ); } /** @internal */ export type RequestBodyInjectionRules$Outbound = { domain: string; headers: { [k: string]: string }; match?: RequestBodyMatch$Outbound | undefined; }; /** @internal */ export const RequestBodyInjectionRules$outboundSchema: z.ZodType< RequestBodyInjectionRules$Outbound, z.ZodTypeDef, RequestBodyInjectionRules > = z.object({ domain: z.string(), headers: z.record(z.string()), match: z.lazy(() => RequestBodyMatch$outboundSchema).optional(), }); export function requestBodyInjectionRulesToJSON( requestBodyInjectionRules: RequestBodyInjectionRules, ): string { return JSON.stringify( RequestBodyInjectionRules$outboundSchema.parse(requestBodyInjectionRules), ); } /** @internal */ export type UpdateSessionNetworkPolicyRequestBody1$Outbound = { mode: string; allowedDomains?: Array<string> | undefined; allowedCIDRs?: Array<string> | undefined; deniedCIDRs?: Array<string> | undefined; injectionRules?: Array<RequestBodyInjectionRules$Outbound> | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyRequestBody1$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyRequestBody1$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyRequestBody1 > = z.object({ mode: RequestBodyMode$outboundSchema, allowedDomains: z.array(z.string()).optional(), allowedCIDRs: z.array(z.string()).optional(), deniedCIDRs: z.array(z.string()).optional(), injectionRules: z.array( z.lazy(() => RequestBodyInjectionRules$outboundSchema), ).optional(), }); export function updateSessionNetworkPolicyRequestBody1ToJSON( updateSessionNetworkPolicyRequestBody1: UpdateSessionNetworkPolicyRequestBody1, ): string { return JSON.stringify( UpdateSessionNetworkPolicyRequestBody1$outboundSchema.parse( updateSessionNetworkPolicyRequestBody1, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyRequestBody$Outbound = | UpdateSessionNetworkPolicyRequestBody1$Outbound | UpdateSessionNetworkPolicyRequestBody2$Outbound; /** @internal */ export const UpdateSessionNetworkPolicyRequestBody$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyRequestBody$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyRequestBody > = smartUnion([ z.lazy(() => UpdateSessionNetworkPolicyRequestBody1$outboundSchema), z.lazy(() => UpdateSessionNetworkPolicyRequestBody2$outboundSchema), ]); export function updateSessionNetworkPolicyRequestBodyToJSON( updateSessionNetworkPolicyRequestBody: UpdateSessionNetworkPolicyRequestBody, ): string { return JSON.stringify( UpdateSessionNetworkPolicyRequestBody$outboundSchema.parse( updateSessionNetworkPolicyRequestBody, ), ); } /** @internal */ export type UpdateSessionNetworkPolicyRequest$Outbound = { sessionId: string; teamId?: string | undefined; slug?: string | undefined; RequestBody?: | UpdateSessionNetworkPolicyRequestBody1$Outbound | UpdateSessionNetworkPolicyRequestBody2$Outbound | undefined; }; /** @internal */ export const UpdateSessionNetworkPolicyRequest$outboundSchema: z.ZodType< UpdateSessionNetworkPolicyRequest$Outbound, z.ZodTypeDef, UpdateSessionNetworkPolicyRequest > = z.object({ sessionId: z.string(), teamId: z.string().optional(), slug: z.string().optional(), requestBody: smartUnion([ z.lazy(() => UpdateSessionNetworkPolicyRequestBody1$outboundSchema), z.lazy(() => UpdateSessionNetworkPolicyRequestBody2$outboundSchema), ]).optional(), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function updateSessionNetworkPolicyRequestToJSON( updateSessionNetworkPolicyRequest: UpdateSessionNetworkPolicyRequest, ): string { return JSON.stringify( UpdateSessionNetworkPolicyRequest$outboundSchema.parse( updateSessionNetworkPolicyRequest, ), ); } /** @internal */ export const UpdateSessionNetworkPolicyResponseBody$inboundSchema: z.ZodType< UpdateSessionNetworkPolicyResponseBody, z.ZodTypeDef, unknown > = z.object({ session: Session$inboundSchema, }); export function updateSessionNetworkPolicyResponseBodyFromJSON( jsonString: string, ): SafeParseResult<UpdateSessionNetworkPolicyResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => UpdateSessionNetworkPolicyResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateSessionNetworkPolicyResponseBody' from JSON`, ); }