cloudflare
Version:
The official TypeScript library for the Cloudflare API
174 lines • 6.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Targets = exports.BaseTargets = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const pagination_1 = require("../../../../core/pagination.js");
const headers_1 = require("../../../../internal/headers.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseTargets = /* @__PURE__ */ (() => {
class BaseTargets extends resource_1.APIResource {
/**
* Creates a new infrastructure access target in the account.
*
* @example
* ```ts
* const target =
* await client.zeroTrust.access.infrastructure.targets.create(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* hostname: 'infra-access-target',
* ip: {},
* },
* );
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/infrastructure/targets`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing infrastructure access target by its ID.
*
* @example
* ```ts
* const target =
* await client.zeroTrust.access.infrastructure.targets.update(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* hostname: 'infra-access-target',
* ip: {},
* },
* );
* ```
*/
update(targetID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/infrastructure/targets/${targetID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists and sorts an account's targets. Filters are optional and are ANDed
* together.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const targetListResponse of client.zeroTrust.access.infrastructure.targets.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/infrastructure/targets`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Removes a single infrastructure access target by its ID.
*
* @example
* ```ts
* await client.zeroTrust.access.infrastructure.targets.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(targetID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/infrastructure/targets/${targetID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Removes one or more targets.
*
* @deprecated
*/
bulkDelete(params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/infrastructure/targets/batch`, {
...options,
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Removes one or more targets.
*
* @example
* ```ts
* await client.zeroTrust.access.infrastructure.targets.bulkDeleteV2(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* target_ids: ['182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'],
* },
* );
* ```
*/
bulkDeleteV2(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/infrastructure/targets/batch_delete`, {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Adds one or more targets.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const targetBulkUpdateResponse of client.zeroTrust.access.infrastructure.targets.bulkUpdate(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* body: [
* {
* hostname: 'infra-access-target',
* ip: {},
* },
* ],
* },
* )) {
* // ...
* }
* ```
*/
bulkUpdate(params, options) {
const { account_id, body } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/infrastructure/targets/batch`, (pagination_1.SinglePage), { body: body, method: 'put', ...options });
}
/**
* Fetches a single infrastructure access target by its ID.
*
* @example
* ```ts
* const target =
* await client.zeroTrust.access.infrastructure.targets.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(targetID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/infrastructure/targets/${targetID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseTargets._key = Object.freeze(['zeroTrust', 'access', 'infrastructure', 'targets']);
return BaseTargets;
})();
exports.BaseTargets = BaseTargets;
class Targets extends BaseTargets {
}
exports.Targets = Targets;
//# sourceMappingURL=targets.js.map