cloudflare
Version:
The official TypeScript library for the Cloudflare API
132 lines • 4.88 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as PreviewsAPI from "./previews.mjs";
import { BasePreviews, Previews } from "./previews.mjs";
import * as ReferencesAPI from "./references.mjs";
import { BaseReferences, References, } from "./references.mjs";
import { SinglePage } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseMonitors = /* @__PURE__ */ (() => {
class BaseMonitors extends APIResource {
/**
* Create a configured monitor.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/load_balancers/monitors`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Modify a configured monitor.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.update(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(monitorID, params, options) {
const { account_id, ...body } = params;
return this._client.put(path `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List configured monitors for an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const monitor of client.loadBalancers.monitors.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.getAPIList(path `/accounts/${account_id}/load_balancers/monitors`, (SinglePage), options);
}
/**
* Delete a configured monitor.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.delete(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(monitorID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Apply changes to an existing monitor, overwriting the supplied properties.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.edit(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(monitorID, params, options) {
const { account_id, ...body } = params;
return this._client.patch(path `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List a single configured monitor for an account.
*
* @example
* ```ts
* const monitor = await client.loadBalancers.monitors.get(
* 'f1aba936b94213e5b8dca0c0dbf1f9cc',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(monitorID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/load_balancers/monitors/${monitorID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseMonitors._key = Object.freeze([
'loadBalancers',
'monitors',
]);
return BaseMonitors;
})();
export var Monitors = /* @__PURE__ */ (() => {
class Monitors extends BaseMonitors {
constructor() {
super(...arguments);
this.previews = new PreviewsAPI.Previews(this._client);
this.references = new ReferencesAPI.References(this._client);
}
}
Monitors.Previews = Previews;
Monitors.BasePreviews = BasePreviews;
Monitors.References = References;
Monitors.BaseReferences = BaseReferences;
return Monitors;
})();
//# sourceMappingURL=monitors.mjs.map