cloudflare
Version:
The official TypeScript library for the Cloudflare API
74 lines (65 loc) • 2.43 kB
text/typescript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as Shared from '../shared';
import { RolesV4PagePaginationArray } from '../shared';
import { APIPromise } from '../../core/api-promise';
import { PagePromise, V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../core/pagination';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
/**
* @deprecated Please use the [Account Permission Groups](https://developers.cloudflare.com/api/resources/iam/subresources/permission_groups/) API instead
*/
export class BaseRoles extends APIResource {
static override readonly _key: readonly ['accounts', 'roles'] = Object.freeze([
'accounts',
'roles',
] as const);
/**
* Get all available roles for an account.
*
* @deprecated Use /accounts/{account_id}/iam/permission_groups instead.
*/
list(
params: RoleListParams,
options?: RequestOptions,
): PagePromise<RolesV4PagePaginationArray, Shared.Role> {
const { account_id, ...query } = params;
return this._client.getAPIList(path`/accounts/${account_id}/roles`, V4PagePaginationArray<Shared.Role>, {
query,
...options,
});
}
/**
* Get information about a specific role for an account.
*
* @deprecated Use /accounts/{account_id}/iam/permission_groups/{permission_group_id} instead.
*/
get(roleID: string, params: RoleGetParams, options?: RequestOptions): APIPromise<Shared.Role> {
const { account_id } = params;
return (
this._client.get(path`/accounts/${account_id}/roles/${roleID}`, options) as APIPromise<{
result: Shared.Role;
}>
)._thenUnwrap((obj) => obj.result);
}
}
/**
* @deprecated Please use the [Account Permission Groups](https://developers.cloudflare.com/api/resources/iam/subresources/permission_groups/) API instead
*/
export class Roles extends BaseRoles {}
export interface RoleListParams extends V4PagePaginationArrayParams {
/**
* Path param: Account identifier tag.
*/
account_id: string;
}
export interface RoleGetParams {
/**
* Account identifier tag.
*/
account_id: string;
}
export declare namespace Roles {
export { type RoleListParams as RoleListParams, type RoleGetParams as RoleGetParams };
}
export { type RolesV4PagePaginationArray };