cloudflare
Version:
The official TypeScript library for the Cloudflare API
160 lines • 6.17 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 { path } from "../../internal/utils/path.mjs";
export var BaseConfigs = /* @__PURE__ */ (() => {
class BaseConfigs extends 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(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(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(path `/accounts/${account_id}/hyperdrive/configs`, (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(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(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(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(path `/accounts/${account_id}/hyperdrive/configs/${hyperdriveID}/restart`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseConfigs._key = Object.freeze([
'hyperdrive',
'configs',
]);
return BaseConfigs;
})();
export class Configs extends BaseConfigs {
}
//# sourceMappingURL=configs.mjs.map