/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { LlmResourceType, LlmResourceType$inboundSchema, LlmResourceType$outboundSchema, } from "./llmresourcetype.js"; import { ResourceRole, ResourceRole$inboundSchema, ResourceRole$outboundSchema, } from "./resourcerole.js"; export type GrantPermissionRequest = { /** * Type of LLM resource */ resourceType: LlmResourceType; /** * Unique identifier for the resource */ resourceId: string; /** * Unique identifier for the user, or "*" to grant/revoke public access */ userId: string; /** * Permission role for the resource (owner > writer > reader) */ role: ResourceRole; }; /** @internal */ export const GrantPermissionRequest$inboundSchema: z.ZodType< GrantPermissionRequest, z.ZodTypeDef, unknown > = z.object({ resourceType: LlmResourceType$inboundSchema, resourceId: z.string(), userId: z.string(), role: ResourceRole$inboundSchema, }); /** @internal */ export type GrantPermissionRequest$Outbound = { resourceType: string; resourceId: string; userId: string; role: string; }; /** @internal */ export const GrantPermissionRequest$outboundSchema: z.ZodType< GrantPermissionRequest$Outbound, z.ZodTypeDef, GrantPermissionRequest > = z.object({ resourceType: LlmResourceType$outboundSchema, resourceId: z.string(), userId: z.string(), role: ResourceRole$outboundSchema, }); export function grantPermissionRequestToJSON( grantPermissionRequest: GrantPermissionRequest, ): string { return JSON.stringify( GrantPermissionRequest$outboundSchema.parse(grantPermissionRequest), ); } export function grantPermissionRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GrantPermissionRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GrantPermissionRequest' from JSON`, ); }