cloudflare
Version:
The official TypeScript library for the Cloudflare API
165 lines • 6.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Configs = exports.BaseConfigs = 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 path_1 = require("../../internal/utils/path.js");
var BaseConfigs = /* @__PURE__ */ (() => {
class BaseConfigs extends resource_1.APIResource {
/**
* Creates and returns a new Hyperdrive configuration. For a PlanetScale
* integration, the Cloudflare account must already be linked to PlanetScale in the
* Hyperdrive dashboard.
*
* @example
* ```ts
* const config = await client.hyperdrive.configs.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'example-hyperdrive',
* origin: {
* database: 'postgres',
* host: 'database.example.com',
* password: 'password',
* port: 5432,
* scheme: 'postgres',
* user: 'postgres',
* },
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/hyperdrive/configs`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Replaces and returns the specified Hyperdrive configuration. The request must
* include the name and complete origin connection details. Omitted caching
* settings are reset to their defaults, while omitted mTLS settings and origin
* connection limits are preserved. Use the update operation to modify only
* selected fields.
*
* @example
* ```ts
* const config = await client.hyperdrive.configs.update(
* '023e105f4ecef8ad9ca31a8372d0c353',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'example-hyperdrive',
* origin: {
* database: 'postgres',
* host: 'database.example.com',
* password: 'password',
* port: 5432,
* scheme: 'postgres',
* user: 'postgres',
* },
* },
* );
* ```
*/
update(hyperdriveID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/hyperdrive/configs/${hyperdriveID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a list of Hyperdrives.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const configListResponse of client.hyperdrive.configs.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/hyperdrive/configs`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Deletes the specified Hyperdrive.
*
* @example
* ```ts
* const config = await client.hyperdrive.configs.delete(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(hyperdriveID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/hyperdrive/configs/${hyperdriveID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Updates and returns the specified fields of the Hyperdrive configuration. Custom
* caching settings are not kept if caching is disabled.
*
* @example
* ```ts
* const response = await client.hyperdrive.configs.edit(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(hyperdriveID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/hyperdrive/configs/${hyperdriveID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns the specified Hyperdrive configuration.
*
* @example
* ```ts
* const config = await client.hyperdrive.configs.get(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(hyperdriveID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/hyperdrive/configs/${hyperdriveID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Restarts the connection pool for the specified Hyperdrive configuration without
* changing its configuration. Existing connections are drained and a new pool is
* established at the edge.
*
* @example
* ```ts
* const response = await client.hyperdrive.configs.restart(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
restart(hyperdriveID, params, options) {
const { account_id } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/hyperdrive/configs/${hyperdriveID}/restart`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseConfigs._key = Object.freeze([
'hyperdrive',
'configs',
]);
return BaseConfigs;
})();
exports.BaseConfigs = BaseConfigs;
class Configs extends BaseConfigs {
}
exports.Configs = Configs;
//# sourceMappingURL=configs.js.map