cloudflare
Version:
The official TypeScript library for the Cloudflare API
130 lines • 4.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Services = exports.BaseServices = 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 BaseServices = /* @__PURE__ */ (() => {
class BaseServices extends resource_1.APIResource {
/**
* Creates a new Workers VPC connectivity service in the account.
*
* @example
* ```ts
* const service =
* await client.connectivity.directory.services.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* host: {
* hostname: 'api.example.com',
* resolver_network: {
* tunnel_id: '0191dce4-9ab4-7fce-b660-8e5dec5172da',
* },
* },
* name: 'web-server',
* type: 'http',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/connectivity/directory/services`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing Workers VPC connectivity service by its ID.
*
* @example
* ```ts
* const service =
* await client.connectivity.directory.services.update(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* {
* account_id: 'account_id',
* host: {
* ipv4: '10.0.0.1',
* network: {
* tunnel_id: '0191dce4-9ab4-7fce-b660-8e5dec5172da',
* },
* },
* name: 'postgres-db',
* type: 'tcp',
* },
* );
* ```
*/
update(serviceID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/connectivity/directory/services/${serviceID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists the Workers VPC connectivity services in the account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const serviceListResponse of client.connectivity.directory.services.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/connectivity/directory/services`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Removes a single Workers VPC connectivity service by its ID. Any Worker bindings
* referencing this service will stop working.
*
* @example
* ```ts
* await client.connectivity.directory.services.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
delete(serviceID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/connectivity/directory/services/${serviceID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Fetches a single Workers VPC connectivity service by its ID.
*
* @example
* ```ts
* const service =
* await client.connectivity.directory.services.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
get(serviceID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/connectivity/directory/services/${serviceID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseServices._key = Object.freeze([
'connectivity',
'directory',
'services',
]);
return BaseServices;
})();
exports.BaseServices = BaseServices;
class Services extends BaseServices {
}
exports.Services = Services;
//# sourceMappingURL=services.js.map