cloudflare
Version:
The official TypeScript library for the Cloudflare API
150 lines • 5.77 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as LabelsAPI from "./labels.mjs";
import { BaseLabels, Labels, } from "./labels.mjs";
import * as SchemaValidationAPI from "./schema-validation.mjs";
import { BaseSchemaValidation, SchemaValidation, } from "./schema-validation.mjs";
import { SinglePage, V4PagePaginationArray, } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseOperations = /* @__PURE__ */ (() => {
class BaseOperations extends APIResource {
/**
* Creates one web or API operation. The host, method, and path are normalized; an
* existing matching operation is returned instead of duplicated.
*
* @example
* ```ts
* const operation = await client.apiGateway.operations.create(
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* endpoint: '/api/v1/users/{var1}',
* host: 'www.example.com',
* method: 'GET',
* },
* );
* ```
*/
create(params, options) {
const { zone_id, ...body } = params;
return this._client.post(path `/zones/${zone_id}/api_gateway/operations/item`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists web and API operations tracked for the zone, including each operation's
* method, path, and feature configuration.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const operationListResponse of client.apiGateway.operations.list(
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { zone_id, ...query } = params;
return this._client.getAPIList(path `/zones/${zone_id}/api_gateway/operations`, (V4PagePaginationArray), { query, ...options });
}
/**
* Deletes a web or API operation from endpoint management so its feature
* configuration is no longer tracked.
*
* @example
* ```ts
* const operation = await client.apiGateway.operations.delete(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(operationID, params, options) {
const { zone_id } = params;
return this._client.delete(path `/zones/${zone_id}/api_gateway/operations/${operationID}`, options);
}
/**
* Creates one or more web or API operations. Hosts, methods, and paths are
* normalized; an existing matching operation is returned instead of duplicated.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const operationBulkCreateResponse of client.apiGateway.operations.bulkCreate(
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* body: [
* {
* endpoint: '/api/v1/users/{var1}',
* host: 'www.example.com',
* method: 'GET',
* },
* ],
* },
* )) {
* // ...
* }
* ```
*/
bulkCreate(params, options) {
const { zone_id, body } = params;
return this._client.getAPIList(path `/zones/${zone_id}/api_gateway/operations`, (SinglePage), { body: body, method: 'post', ...options });
}
/**
* Deletes multiple web or API operations from endpoint management in one request.
*
* @example
* ```ts
* const response =
* await client.apiGateway.operations.bulkDelete({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
bulkDelete(params, options) {
const { zone_id } = params;
return this._client.delete(path `/zones/${zone_id}/api_gateway/operations`, options);
}
/**
* Returns a web or API operation, including its schema validation settings and
* requested feature data.
*
* @example
* ```ts
* const operation = await client.apiGateway.operations.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(operationID, params, options) {
const { zone_id, ...query } = params;
return this._client.get(path `/zones/${zone_id}/api_gateway/operations/${operationID}`, {
query,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseOperations._key = Object.freeze([
'apiGateway',
'operations',
]);
return BaseOperations;
})();
export var Operations = /* @__PURE__ */ (() => {
class Operations extends BaseOperations {
constructor() {
super(...arguments);
this.labels = new LabelsAPI.Labels(this._client);
this.schemaValidation = new SchemaValidationAPI.SchemaValidation(this._client);
}
}
Operations.Labels = Labels;
Operations.BaseLabels = BaseLabels;
Operations.SchemaValidation = SchemaValidation;
Operations.BaseSchemaValidation = BaseSchemaValidation;
return Operations;
})();
//# sourceMappingURL=operations.mjs.map