cloudflare
Version:
The official TypeScript library for the Cloudflare API
125 lines • 4.61 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { V4PagePaginationArray, } from "../../../core/pagination.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseServices = /* @__PURE__ */ (() => {
class BaseServices extends 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(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(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(path `/accounts/${account_id}/connectivity/directory/services`, (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(path `/accounts/${account_id}/connectivity/directory/services/${serviceID}`, {
...options,
headers: 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(path `/accounts/${account_id}/connectivity/directory/services/${serviceID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseServices._key = Object.freeze([
'connectivity',
'directory',
'services',
]);
return BaseServices;
})();
export class Services extends BaseServices {
}
//# sourceMappingURL=services.mjs.map