/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: c57ee38b90b2 */ import * as z from "zod/v4"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; export type SubjectScopeManager = { /** * Manager-scoped access */ type: "manager"; /** * ID of the specific manager this scope applies to */ managerId: string; }; export type SubjectScopeDeploymentGroup = { /** * Deployment group-scoped access */ type: "deployment-group"; /** * ID of the specific deployment group this scope applies to */ deploymentGroupId: string; /** * ID of the project this deployment group belongs to */ projectId: string; }; export type SubjectScopeDeployment = { /** * Deployment-scoped access */ type: "deployment"; /** * ID of the specific deployment this scope applies to */ deploymentId: string; /** * ID of the project this deployment belongs to */ projectId: string; }; export type SubjectScopeProject = { /** * Project-scoped access */ type: "project"; /** * ID of the specific project this scope applies to */ projectId: string; }; export type SubjectScopeWorkspace = { /** * Workspace-scoped access */ type: "workspace"; }; /** * Authorization scope defining what resources this service account can access */ export type SubjectScope = | SubjectScopeWorkspace | SubjectScopeProject | SubjectScopeDeployment | SubjectScopeDeploymentGroup | SubjectScopeManager; /** @internal */ export const SubjectScopeManager$inboundSchema: z.ZodType< SubjectScopeManager, unknown > = z.object({ type: z.literal("manager"), managerId: z.string(), }); export function subjectScopeManagerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubjectScopeManager$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubjectScopeManager' from JSON`, ); } /** @internal */ export const SubjectScopeDeploymentGroup$inboundSchema: z.ZodType< SubjectScopeDeploymentGroup, unknown > = z.object({ type: z.literal("deployment-group"), deploymentGroupId: z.string(), projectId: z.string(), }); export function subjectScopeDeploymentGroupFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubjectScopeDeploymentGroup$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubjectScopeDeploymentGroup' from JSON`, ); } /** @internal */ export const SubjectScopeDeployment$inboundSchema: z.ZodType< SubjectScopeDeployment, unknown > = z.object({ type: z.literal("deployment"), deploymentId: z.string(), projectId: z.string(), }); export function subjectScopeDeploymentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubjectScopeDeployment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubjectScopeDeployment' from JSON`, ); } /** @internal */ export const SubjectScopeProject$inboundSchema: z.ZodType< SubjectScopeProject, unknown > = z.object({ type: z.literal("project"), projectId: z.string(), }); export function subjectScopeProjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubjectScopeProject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubjectScopeProject' from JSON`, ); } /** @internal */ export const SubjectScopeWorkspace$inboundSchema: z.ZodType< SubjectScopeWorkspace, unknown > = z.object({ type: z.literal("workspace"), }); export function subjectScopeWorkspaceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubjectScopeWorkspace$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubjectScopeWorkspace' from JSON`, ); } /** @internal */ export const SubjectScope$inboundSchema: z.ZodType = z .union([ z.lazy(() => SubjectScopeWorkspace$inboundSchema), z.lazy(() => SubjectScopeProject$inboundSchema), z.lazy(() => SubjectScopeDeployment$inboundSchema), z.lazy(() => SubjectScopeDeploymentGroup$inboundSchema), z.lazy(() => SubjectScopeManager$inboundSchema), ]); export function subjectScopeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubjectScope$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubjectScope' from JSON`, ); }