cloudflare
Version:
The official TypeScript library for the Cloudflare API
156 lines • 6.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Operations = exports.BaseOperations = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const LabelsAPI = tslib_1.__importStar(require("./labels.js"));
const labels_1 = require("./labels.js");
const SchemaValidationAPI = tslib_1.__importStar(require("./schema-validation.js"));
const schema_validation_1 = require("./schema-validation.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseOperations = /* @__PURE__ */ (() => {
class BaseOperations extends resource_1.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((0, path_1.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((0, path_1.path) `/zones/${zone_id}/api_gateway/operations`, (pagination_1.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((0, path_1.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((0, path_1.path) `/zones/${zone_id}/api_gateway/operations`, (pagination_1.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((0, path_1.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((0, path_1.path) `/zones/${zone_id}/api_gateway/operations/${operationID}`, {
query,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseOperations._key = Object.freeze([
'apiGateway',
'operations',
]);
return BaseOperations;
})();
exports.BaseOperations = BaseOperations;
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_1.Labels;
Operations.BaseLabels = labels_1.BaseLabels;
Operations.SchemaValidation = schema_validation_1.SchemaValidation;
Operations.BaseSchemaValidation = schema_validation_1.BaseSchemaValidation;
return Operations;
})();
exports.Operations = Operations;
//# sourceMappingURL=operations.js.map