cloudflare
Version:
The official TypeScript library for the Cloudflare API
251 lines (203 loc) • 5.3 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 BaseAccounts extends APIResource {
static override readonly _key: readonly ['addressing', 'addressMaps', 'accounts'] = Object.freeze([
'addressing',
'addressMaps',
'accounts',
] as const);
/**
* Add an account as a member of a particular address map.
*
* @example
* ```ts
* const account =
* await client.addressing.addressMaps.accounts.update(
* '258def64c72dae45f3e4c8516e2111f2',
* {
* account_id: '258def64c72dae45f3e4c8516e2111f2',
* address_map_id: '055817b111884e0227e1be16a0be6ee0',
* },
* );
* ```
*/
update(
memberAccountID: string,
params: AccountUpdateParams,
options?: RequestOptions,
): APIPromise<AccountUpdateResponse> {
const { account_id, address_map_id } = params;
return this._client.put(
path`/accounts/${account_id}/addressing/address_maps/${address_map_id}/accounts/${memberAccountID}`,
options,
);
}
/**
* Remove an account as a member of a particular address map.
*
* @example
* ```ts
* const account =
* await client.addressing.addressMaps.accounts.delete(
* '258def64c72dae45f3e4c8516e2111f2',
* {
* account_id: '258def64c72dae45f3e4c8516e2111f2',
* address_map_id: '055817b111884e0227e1be16a0be6ee0',
* },
* );
* ```
*/
delete(
memberAccountID: string,
params: AccountDeleteParams,
options?: RequestOptions,
): APIPromise<AccountDeleteResponse> {
const { account_id, address_map_id } = params;
return this._client.delete(
path`/accounts/${account_id}/addressing/address_maps/${address_map_id}/accounts/${memberAccountID}`,
options,
);
}
}
export class Accounts extends BaseAccounts {}
export interface AccountUpdateResponse {
errors: Array<AccountUpdateResponse.Error>;
messages: Array<AccountUpdateResponse.Message>;
/**
* Whether the API call was successful.
*/
success: true;
result_info?: AccountUpdateResponse.ResultInfo;
}
export namespace AccountUpdateResponse {
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 ResultInfo {
/**
* Total number of results for the requested service.
*/
count?: number;
/**
* Current page within paginated list of results.
*/
page?: number;
/**
* Number of results per page of results.
*/
per_page?: number;
/**
* Total results available without any search parameters.
*/
total_count?: number;
/**
* The number of total pages in the entire result set.
*/
total_pages?: number;
}
}
export interface AccountDeleteResponse {
errors: Array<AccountDeleteResponse.Error>;
messages: Array<AccountDeleteResponse.Message>;
/**
* Whether the API call was successful.
*/
success: true;
result_info?: AccountDeleteResponse.ResultInfo;
}
export namespace AccountDeleteResponse {
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 ResultInfo {
/**
* Total number of results for the requested service.
*/
count?: number;
/**
* Current page within paginated list of results.
*/
page?: number;
/**
* Number of results per page of results.
*/
per_page?: number;
/**
* Total results available without any search parameters.
*/
total_count?: number;
/**
* The number of total pages in the entire result set.
*/
total_pages?: number;
}
}
export interface AccountUpdateParams {
/**
* Identifier of a Cloudflare account.
*/
account_id: string;
/**
* Identifier of an Address Map.
*/
address_map_id: string;
}
export interface AccountDeleteParams {
/**
* Identifier of a Cloudflare account.
*/
account_id: string;
/**
* Identifier of an Address Map.
*/
address_map_id: string;
}
export declare namespace Accounts {
export {
type AccountUpdateResponse as AccountUpdateResponse,
type AccountDeleteResponse as AccountDeleteResponse,
type AccountUpdateParams as AccountUpdateParams,
type AccountDeleteParams as AccountDeleteParams,
};
}