aiconfigsaccessdeniedreason.ts•5.08 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
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";
/**
* Whether this statement should allow or deny actions on the resources.
*/
export const AiConfigsAccessDeniedReasonEffect = {
Allow: "allow",
Deny: "deny",
} as const;
/**
* Whether this statement should allow or deny actions on the resources.
*/
export type AiConfigsAccessDeniedReasonEffect = ClosedEnum<
typeof AiConfigsAccessDeniedReasonEffect
>;
export type AiConfigsAccessDeniedReason = {
/**
* Resource specifier strings
*/
resources?: Array<string> | undefined;
/**
* Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
*/
notResources?: Array<string> | undefined;
/**
* Actions to perform on a resource
*/
actions?: Array<string> | undefined;
/**
* Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
*/
notActions?: Array<string> | undefined;
/**
* Whether this statement should allow or deny actions on the resources.
*/
effect: AiConfigsAccessDeniedReasonEffect;
roleName?: string | undefined;
};
/** @internal */
export const AiConfigsAccessDeniedReasonEffect$inboundSchema: z.ZodNativeEnum<
typeof AiConfigsAccessDeniedReasonEffect
> = z.nativeEnum(AiConfigsAccessDeniedReasonEffect);
/** @internal */
export const AiConfigsAccessDeniedReasonEffect$outboundSchema: z.ZodNativeEnum<
typeof AiConfigsAccessDeniedReasonEffect
> = AiConfigsAccessDeniedReasonEffect$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AiConfigsAccessDeniedReasonEffect$ {
/** @deprecated use `AiConfigsAccessDeniedReasonEffect$inboundSchema` instead. */
export const inboundSchema = AiConfigsAccessDeniedReasonEffect$inboundSchema;
/** @deprecated use `AiConfigsAccessDeniedReasonEffect$outboundSchema` instead. */
export const outboundSchema =
AiConfigsAccessDeniedReasonEffect$outboundSchema;
}
/** @internal */
export const AiConfigsAccessDeniedReason$inboundSchema: z.ZodType<
AiConfigsAccessDeniedReason,
z.ZodTypeDef,
unknown
> = z.object({
resources: z.array(z.string()).optional(),
notResources: z.array(z.string()).optional(),
actions: z.array(z.string()).optional(),
notActions: z.array(z.string()).optional(),
effect: AiConfigsAccessDeniedReasonEffect$inboundSchema,
role_name: z.string().optional(),
}).transform((v) => {
return remap$(v, {
"role_name": "roleName",
});
});
/** @internal */
export type AiConfigsAccessDeniedReason$Outbound = {
resources?: Array<string> | undefined;
notResources?: Array<string> | undefined;
actions?: Array<string> | undefined;
notActions?: Array<string> | undefined;
effect: string;
role_name?: string | undefined;
};
/** @internal */
export const AiConfigsAccessDeniedReason$outboundSchema: z.ZodType<
AiConfigsAccessDeniedReason$Outbound,
z.ZodTypeDef,
AiConfigsAccessDeniedReason
> = z.object({
resources: z.array(z.string()).optional(),
notResources: z.array(z.string()).optional(),
actions: z.array(z.string()).optional(),
notActions: z.array(z.string()).optional(),
effect: AiConfigsAccessDeniedReasonEffect$outboundSchema,
roleName: z.string().optional(),
}).transform((v) => {
return remap$(v, {
roleName: "role_name",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AiConfigsAccessDeniedReason$ {
/** @deprecated use `AiConfigsAccessDeniedReason$inboundSchema` instead. */
export const inboundSchema = AiConfigsAccessDeniedReason$inboundSchema;
/** @deprecated use `AiConfigsAccessDeniedReason$outboundSchema` instead. */
export const outboundSchema = AiConfigsAccessDeniedReason$outboundSchema;
/** @deprecated use `AiConfigsAccessDeniedReason$Outbound` instead. */
export type Outbound = AiConfigsAccessDeniedReason$Outbound;
}
export function aiConfigsAccessDeniedReasonToJSON(
aiConfigsAccessDeniedReason: AiConfigsAccessDeniedReason,
): string {
return JSON.stringify(
AiConfigsAccessDeniedReason$outboundSchema.parse(
aiConfigsAccessDeniedReason,
),
);
}
export function aiConfigsAccessDeniedReasonFromJSON(
jsonString: string,
): SafeParseResult<AiConfigsAccessDeniedReason, SDKValidationError> {
return safeParse(
jsonString,
(x) => AiConfigsAccessDeniedReason$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AiConfigsAccessDeniedReason' from JSON`,
);
}