cloudflare
Version:
The official TypeScript library for the Cloudflare API
232 lines (195 loc) • 5.2 kB
text/typescript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../../core/resource';
import { APIPromise } from '../../../../core/api-promise';
import { RequestOptions } from '../../../../internal/request-options';
import { path } from '../../../../internal/utils/path';
export class BaseItems extends APIResource {
static override readonly _key: readonly ['DDoSProtection', 'advancedTCPProtection', 'prefixes', 'items'] =
Object.freeze(['DDoSProtection', 'advancedTCPProtection', 'prefixes', 'items'] as const);
/**
* Delete the prefix for an account given a UUID.
*
* @example
* ```ts
* const item =
* await client.DDoSProtection.advancedTCPProtection.prefixes.items.delete(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(
prefixID: string,
params: ItemDeleteParams,
options?: RequestOptions,
): APIPromise<ItemDeleteResponse> {
const { account_id } = params;
return this._client.delete(
path`/accounts/${account_id}/magic/advanced_tcp_protection/configs/prefixes/${prefixID}`,
options,
);
}
/**
* Update a prefix specified by the given UUID.
*
* @example
* ```ts
* const response =
* await client.DDoSProtection.advancedTCPProtection.prefixes.items.edit(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(prefixID: string, params: ItemEditParams, options?: RequestOptions): APIPromise<ItemEditResponse> {
const { account_id, ...body } = params;
return (
this._client.patch(
path`/accounts/${account_id}/magic/advanced_tcp_protection/configs/prefixes/${prefixID}`,
{ body, ...options },
) as APIPromise<{ result: ItemEditResponse }>
)._thenUnwrap((obj) => obj.result);
}
/**
* Get a prefix specified by the given UUID.
*
* @example
* ```ts
* const item =
* await client.DDoSProtection.advancedTCPProtection.prefixes.items.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(prefixID: string, params: ItemGetParams, options?: RequestOptions): APIPromise<ItemGetResponse> {
const { account_id } = params;
return (
this._client.get(
path`/accounts/${account_id}/magic/advanced_tcp_protection/configs/prefixes/${prefixID}`,
options,
) as APIPromise<{ result: ItemGetResponse }>
)._thenUnwrap((obj) => obj.result);
}
}
export class Items extends BaseItems {}
export interface ItemDeleteResponse {
errors: Array<ItemDeleteResponse.Error>;
messages: Array<ItemDeleteResponse.Message>;
/**
* Whether the API call was successful.
*/
success: true;
}
export namespace ItemDeleteResponse {
export interface Error {
code: number;
message: string;
documentation_url?: string;
source?: Error.Source;
}
export namespace Error {
export interface Source {
pointer?: string;
}
}
export interface Message {
code: number;
message: string;
documentation_url?: string;
source?: Message.Source;
}
export namespace Message {
export interface Source {
pointer?: string;
}
}
}
export interface ItemEditResponse {
/**
* The unique ID of the prefix.
*/
id: string;
/**
* A comment describing the prefix.
*/
comment: string;
/**
* The creation timestamp of the prefix.
*/
created_on: string;
/**
* Whether to exclude the prefix from protection.
*/
excluded: boolean;
/**
* The last modification timestamp of the prefix.
*/
modified_on: string;
/**
* The prefix in CIDR format.
*/
prefix: string;
}
export interface ItemGetResponse {
/**
* The unique ID of the prefix.
*/
id: string;
/**
* A comment describing the prefix.
*/
comment: string;
/**
* The creation timestamp of the prefix.
*/
created_on: string;
/**
* Whether to exclude the prefix from protection.
*/
excluded: boolean;
/**
* The last modification timestamp of the prefix.
*/
modified_on: string;
/**
* The prefix in CIDR format.
*/
prefix: string;
}
export interface ItemDeleteParams {
/**
* The ID of the account.
*/
account_id: string;
}
export interface ItemEditParams {
/**
* Path param: The ID of the account.
*/
account_id: string;
/**
* Body param: A new comment for the prefix. Optional.
*/
comment?: string;
/**
* Body param: Whether to exclude the prefix from protection. Optional.
*/
excluded?: boolean;
}
export interface ItemGetParams {
/**
* The ID of the account.
*/
account_id: string;
}
export declare namespace Items {
export {
type ItemDeleteResponse as ItemDeleteResponse,
type ItemEditResponse as ItemEditResponse,
type ItemGetResponse as ItemGetResponse,
type ItemDeleteParams as ItemDeleteParams,
type ItemEditParams as ItemEditParams,
type ItemGetParams as ItemGetParams,
};
}