@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
68 lines (63 loc) • 2.56 kB
text/typescript
/*
* 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 { Permission, Permission$inboundSchema } from "./permission.js";
export type Role = {
/**
* The unique identifier for this role within Unkey's system.
*
* @remarks
* Generated automatically when the role is created and used to reference this role in API operations.
* Always begins with 'role_' followed by alphanumeric characters and underscores.
*/
id: string;
/**
* The human-readable name for this role that describes its function.
*
* @remarks
* Should be descriptive enough for administrators to understand what access this role provides.
* Use clear, semantic names that reflect the job function or responsibility level.
* Names must be unique within your workspace to avoid confusion during role assignment.
*/
name: string;
/**
* Optional detailed explanation of what this role encompasses and what access it provides.
*
* @remarks
* Helps team members understand the role's scope, intended use cases, and security implications.
* Include information about what types of users should receive this role and what they can accomplish.
* Not visible to end users - this is for internal documentation and access control audits.
*/
description?: string | undefined;
/**
* Complete list of permissions currently assigned to this role.
*
* @remarks
* Each permission grants specific access rights that will be inherited by any keys or users assigned this role.
* Use this list to understand the full scope of access provided by this role.
* Permissions can be added or removed from roles without affecting the role's identity or other properties.
* Empty array indicates a role with no permissions currently assigned.
*/
permissions?: Array<Permission> | undefined;
};
/** @internal */
export const Role$inboundSchema: z.ZodType<Role, z.ZodTypeDef, unknown> = z
.object({
id: z.string(),
name: z.string(),
description: z.string().optional(),
permissions: z.array(Permission$inboundSchema).optional(),
});
export function roleFromJSON(
jsonString: string,
): SafeParseResult<Role, SDKValidationError> {
return safeParse(
jsonString,
(x) => Role$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Role' from JSON`,
);
}