cloudflare
Version:
The official TypeScript library for the Cloudflare API
120 lines (102 loc) • 3.11 kB
text/typescript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import { PagePromise, SinglePage } from '../../../core/pagination';
import { RequestOptions } from '../../../internal/request-options';
import { path } from '../../../internal/utils/path';
export class BaseCategories extends APIResource {
static override readonly _key: readonly ['zeroTrust', 'gateway', 'categories'] = Object.freeze([
'zeroTrust',
'gateway',
'categories',
] as const);
/**
* List all categories.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const category of client.zeroTrust.gateway.categories.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params: CategoryListParams, options?: RequestOptions): PagePromise<CategoriesSinglePage, Category> {
const { account_id } = params;
return this._client.getAPIList(
path`/accounts/${account_id}/gateway/categories`,
SinglePage<Category>,
options,
);
}
}
export class Categories extends BaseCategories {}
export type CategoriesSinglePage = SinglePage<Category>;
export interface Category {
/**
* Identify this category. Only one category per ID.
*/
id?: number;
/**
* Indicate whether the category is in beta and subject to change.
*/
beta?: boolean;
/**
* Specify which account types can create policies for this category. `blocked`
* Blocks unconditionally for all accounts. `removalPending` Allows removal from
* policies but disables addition. `noBlock` Prevents blocking.
*/
class?: 'free' | 'premium' | 'blocked' | 'removalPending' | 'noBlock';
/**
* Provide a short summary of domains in the category.
*/
description?: string;
/**
* Specify the category name.
*/
name?: string;
/**
* Provide all subcategories for this category.
*/
subcategories?: Array<Category.Subcategory>;
}
export namespace Category {
export interface Subcategory {
/**
* Identify this category. Only one category per ID.
*/
id?: number;
/**
* Indicate whether the category is in beta and subject to change.
*/
beta?: boolean;
/**
* Specify which account types can create policies for this category. `blocked`
* Blocks unconditionally for all accounts. `removalPending` Allows removal from
* policies but disables addition. `noBlock` Prevents blocking.
*/
class?: 'free' | 'premium' | 'blocked' | 'removalPending' | 'noBlock';
/**
* Provide a short summary of domains in the category.
*/
description?: string;
/**
* Specify the category name.
*/
name?: string;
}
}
export interface CategoryListParams {
/**
* Provide the identifier string.
*/
account_id: string;
}
export declare namespace Categories {
export {
type Category as Category,
type CategoriesSinglePage as CategoriesSinglePage,
type CategoryListParams as CategoryListParams,
};
}