UNPKG

@unkey/api

Version:

Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.

206 lines (196 loc) 6.19 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { permissionsCreatePermission } from "../funcs/permissionsCreatePermission.js"; import { permissionsCreateRole } from "../funcs/permissionsCreateRole.js"; import { permissionsDeletePermission } from "../funcs/permissionsDeletePermission.js"; import { permissionsDeleteRole } from "../funcs/permissionsDeleteRole.js"; import { permissionsGetPermission } from "../funcs/permissionsGetPermission.js"; import { permissionsGetRole } from "../funcs/permissionsGetRole.js"; import { permissionsListPermissions } from "../funcs/permissionsListPermissions.js"; import { permissionsListRoles } from "../funcs/permissionsListRoles.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; import { unwrapAsync } from "../types/fp.js"; export class Permissions extends ClientSDK { /** * Create permission * * @remarks * Create a new permission to define specific actions or capabilities in your RBAC system. Permissions can be assigned directly to API keys or included in roles. * * Use hierarchical naming patterns like `documents.read`, `admin.users.delete`, or `billing.invoices.create` for clear organization. * * **Important:** Permission names must be unique within the workspace. Once created, permissions are immediately available for assignment. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.create_permission` */ async createPermission( request: components.V2PermissionsCreatePermissionRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsCreatePermissionResponseBody> { return unwrapAsync(permissionsCreatePermission( this, request, options, )); } /** * Create role * * @remarks * Create a new role to group related permissions for easier management. Roles enable consistent permission assignment across multiple API keys. * * **Important:** Role names must be unique within the workspace. Once created, roles are immediately available for assignment. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.create_role` */ async createRole( request: components.V2PermissionsCreateRoleRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsCreateRoleResponseBody> { return unwrapAsync(permissionsCreateRole( this, request, options, )); } /** * Delete permission * * @remarks * Remove a permission from your workspace. This also removes the permission from all API keys and roles. * * **Important:** This operation cannot be undone and immediately affects all API keys and roles that had this permission assigned. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.delete_permission` */ async deletePermission( request: components.V2PermissionsDeletePermissionRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsDeletePermissionResponseBody> { return unwrapAsync(permissionsDeletePermission( this, request, options, )); } /** * Delete role * * @remarks * Remove a role from your workspace. This also removes the role from all assigned API keys. * * **Important:** This operation cannot be undone and immediately affects all API keys that had this role assigned. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.delete_role` */ async deleteRole( request: components.V2PermissionsDeleteRoleRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsDeleteRoleResponseBody> { return unwrapAsync(permissionsDeleteRole( this, request, options, )); } /** * Get permission * * @remarks * Retrieve details about a specific permission including its name, description, and metadata. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.read_permission` */ async getPermission( request: components.V2PermissionsGetPermissionRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsGetPermissionResponseBody> { return unwrapAsync(permissionsGetPermission( this, request, options, )); } /** * Get role * * @remarks * Retrieve details about a specific role including its assigned permissions. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.read_role` */ async getRole( request: components.V2PermissionsGetRoleRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsGetRoleResponseBody> { return unwrapAsync(permissionsGetRole( this, request, options, )); } /** * List permissions * * @remarks * Retrieve all permissions in your workspace. * Results are paginated and sorted by their id. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.read_permission` */ async listPermissions( request: components.V2PermissionsListPermissionsRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsListPermissionsResponseBody> { return unwrapAsync(permissionsListPermissions( this, request, options, )); } /** * List roles * * @remarks * Retrieve all roles in your workspace including their assigned permissions. * Results are paginated and sorted by their id. * * **Required Permissions** * * Your root key must have the following permission: * - `rbac.*.read_role` */ async listRoles( request: components.V2PermissionsListRolesRequestBody, options?: RequestOptions, ): Promise<components.V2PermissionsListRolesResponseBody> { return unwrapAsync(permissionsListRoles( this, request, options, )); } }