cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.2.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/accounts/roles.ts

55lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import * as Core from '../../core';
5import * as Shared from '../shared';
6import { RolesV4PagePaginationArray } from '../shared';
7import { type V4PagePaginationArrayParams } from '../../pagination';
8
9export class Roles extends APIResource {
10 /**
11 * Get all available roles for an account.
12 */
13 list(
14 params: RoleListParams,
15 options?: Core.RequestOptions,
16 ): Core.PagePromise<RolesV4PagePaginationArray, Shared.Role> {
17 const { account_id, ...query } = params;
18 return this._client.getAPIList(`/accounts/${account_id}/roles`, RolesV4PagePaginationArray, {
19 query,
20 ...options,
21 });
22 }
23
24 /**
25 * Get information about a specific role for an account.
26 */
27 get(roleId: string, params: RoleGetParams, options?: Core.RequestOptions): Core.APIPromise<Shared.Role> {
28 const { account_id } = params;
29 return (
30 this._client.get(`/accounts/${account_id}/roles/${roleId}`, options) as Core.APIPromise<{
31 result: Shared.Role;
32 }>
33 )._thenUnwrap((obj) => obj.result);
34 }
35}
36
37export interface RoleListParams extends V4PagePaginationArrayParams {
38 /**
39 * Path param: Account identifier tag.
40 */
41 account_id: string;
42}
43
44export interface RoleGetParams {
45 /**
46 * Account identifier tag.
47 */
48 account_id: string;
49}
50
51export declare namespace Roles {
52 export { type RoleListParams as RoleListParams, type RoleGetParams as RoleGetParams };
53}
54
55export { RolesV4PagePaginationArray };
56