/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: dac0b1f1b711 */ import * as z from "zod/v4"; 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"; import * as models from "../index.js"; export type ApproveAccessRequestGlobals = { /** * Workspace name. Platform API keys already select a workspace; other authentication methods can configure it once on the SDK client. */ workspace?: string | undefined; }; export type ApproveAccessRequestRequestBody = { method: string; /** * Deprecated and ignored. Actor identity comes from the authenticated user. */ actorId?: string | undefined; source?: { [k: string]: any | null } | undefined; approvedForMinutes?: number | undefined; }; export type ApproveAccessRequestRequest = { id: string; requestBody?: ApproveAccessRequestRequestBody | undefined; }; export const ApproveAccessRequestRequesterKind = { User: "user", ServiceAccount: "serviceAccount", } as const; export type ApproveAccessRequestRequesterKind = ClosedEnum< typeof ApproveAccessRequestRequesterKind >; export type ApproveAccessRequestDeployment = { id: string; name: string; deploymentGroup?: models.DeploymentGroupInfo | undefined; }; /** * How risky an operation is (declared by the plugin metadata). */ export const ApproveAccessRequestTier = { ReadOnly: "read-only", Mutating: "mutating", Destructive: "destructive", } as const; /** * How risky an operation is (declared by the plugin metadata). */ export type ApproveAccessRequestTier = ClosedEnum< typeof ApproveAccessRequestTier >; export type ApproveAccessRequestCommand = { command: string; summary: string; params?: any | null | undefined; /** * How risky an operation is (declared by the plugin metadata). */ tier?: ApproveAccessRequestTier | undefined; }; /** * How risky an operation is (declared by the plugin metadata). */ export const ApproveAccessRequestMaxRisk = { ReadOnly: "read-only", Mutating: "mutating", Destructive: "destructive", } as const; /** * How risky an operation is (declared by the plugin metadata). */ export type ApproveAccessRequestMaxRisk = ClosedEnum< typeof ApproveAccessRequestMaxRisk >; /** * The approved access request. */ export type ApproveAccessRequestResponse = { id: string; requesterKind: ApproveAccessRequestRequesterKind | null; requesterId: string | null; requestedExpiresAt: string | null; deploymentId: string; deployment?: ApproveAccessRequestDeployment | undefined; remediationPlanId: string | null; title: string; reason: string | null; commands: Array; operationPattern: string | null; /** * How risky an operation is (declared by the plugin metadata). */ maxRisk: ApproveAccessRequestMaxRisk | null; status: models.AccessRequestStatus; approvedUntil: string | null; approvalMethod: string; }; /** @internal */ export type ApproveAccessRequestRequestBody$Outbound = { method: string; actorId?: string | undefined; source?: { [k: string]: any | null } | undefined; approvedForMinutes?: number | undefined; }; /** @internal */ export const ApproveAccessRequestRequestBody$outboundSchema: z.ZodType< ApproveAccessRequestRequestBody$Outbound, ApproveAccessRequestRequestBody > = z.object({ method: z.string(), actorId: z.string().optional(), source: z.record(z.string(), z.nullable(z.any())).optional(), approvedForMinutes: z.int().optional(), }); export function approveAccessRequestRequestBodyToJSON( approveAccessRequestRequestBody: ApproveAccessRequestRequestBody, ): string { return JSON.stringify( ApproveAccessRequestRequestBody$outboundSchema.parse( approveAccessRequestRequestBody, ), ); } /** @internal */ export type ApproveAccessRequestRequest$Outbound = { id: string; RequestBody?: ApproveAccessRequestRequestBody$Outbound | undefined; }; /** @internal */ export const ApproveAccessRequestRequest$outboundSchema: z.ZodType< ApproveAccessRequestRequest$Outbound, ApproveAccessRequestRequest > = z.object({ id: z.string(), requestBody: z.lazy(() => ApproveAccessRequestRequestBody$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function approveAccessRequestRequestToJSON( approveAccessRequestRequest: ApproveAccessRequestRequest, ): string { return JSON.stringify( ApproveAccessRequestRequest$outboundSchema.parse( approveAccessRequestRequest, ), ); } /** @internal */ export const ApproveAccessRequestRequesterKind$inboundSchema: z.ZodEnum< typeof ApproveAccessRequestRequesterKind > = z.enum(ApproveAccessRequestRequesterKind); /** @internal */ export const ApproveAccessRequestDeployment$inboundSchema: z.ZodType< ApproveAccessRequestDeployment, unknown > = z.object({ id: z.string(), name: z.string(), deploymentGroup: models.DeploymentGroupInfo$inboundSchema.optional(), }); export function approveAccessRequestDeploymentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApproveAccessRequestDeployment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApproveAccessRequestDeployment' from JSON`, ); } /** @internal */ export const ApproveAccessRequestTier$inboundSchema: z.ZodEnum< typeof ApproveAccessRequestTier > = z.enum(ApproveAccessRequestTier); /** @internal */ export const ApproveAccessRequestCommand$inboundSchema: z.ZodType< ApproveAccessRequestCommand, unknown > = z.object({ command: z.string(), summary: z.string(), params: z.nullable(z.any()).optional(), tier: ApproveAccessRequestTier$inboundSchema.optional(), }); export function approveAccessRequestCommandFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApproveAccessRequestCommand$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApproveAccessRequestCommand' from JSON`, ); } /** @internal */ export const ApproveAccessRequestMaxRisk$inboundSchema: z.ZodEnum< typeof ApproveAccessRequestMaxRisk > = z.enum(ApproveAccessRequestMaxRisk); /** @internal */ export const ApproveAccessRequestResponse$inboundSchema: z.ZodType< ApproveAccessRequestResponse, unknown > = z.object({ id: z.string(), requesterKind: z.nullable(ApproveAccessRequestRequesterKind$inboundSchema), requesterId: z.nullable(z.string()), requestedExpiresAt: z.nullable(z.string()), deploymentId: z.string(), deployment: z.lazy(() => ApproveAccessRequestDeployment$inboundSchema) .optional(), remediationPlanId: z.nullable(z.string()), title: z.string(), reason: z.nullable(z.string()), commands: z.array(z.lazy(() => ApproveAccessRequestCommand$inboundSchema)), operationPattern: z.nullable(z.string()), maxRisk: z.nullable(ApproveAccessRequestMaxRisk$inboundSchema), status: models.AccessRequestStatus$inboundSchema, approvedUntil: z.nullable(z.string()), approvalMethod: z.string(), }); export function approveAccessRequestResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApproveAccessRequestResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApproveAccessRequestResponse' from JSON`, ); }