cloudflare
Version:
The official TypeScript library for the Cloudflare API
81 lines • 3.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Flags = exports.BaseFlags = void 0;
const tslib_1 = require("../../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const ChangelogAPI = tslib_1.__importStar(require("./changelog.js"));
const changelog_1 = require("./changelog.js");
const pagination_1 = require("../../../../core/pagination.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseFlags = /* @__PURE__ */ (() => {
class BaseFlags extends resource_1.APIResource {
/**
* Creates a flag. Returns 409 if the key already exists. `type` is always inferred
* from variation values; legacy request-side values are ignored.
*/
create(appID, params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/flagship/apps/${appID}/flags`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Replaces the entire flag definition. Omitted fields are dropped, not preserved —
* read before writing. The path key identifies the flag and cannot be renamed by
* changing the body `key`. Each update appends a changelog entry.
*/
update(flagKey, params, options) {
const { account_id, app_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/flagship/apps/${app_id}/flags/${flagKey}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists an app's flags ordered by key. Pass `cursor` from `result_info` to page
* forward; a null cursor indicates the last page.
*/
list(appID, params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/flagship/apps/${appID}/flags`, (pagination_1.CursorPaginationAfter), { query, ...options });
}
/**
* Deletes a flag permanently. After deletion propagates, direct evaluations return
* not found; typed binding accessors may return the caller-supplied default.
* Cannot be undone.
*/
delete(flagKey, params, options) {
const { account_id, app_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/flagship/apps/${app_id}/flags/${flagKey}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Returns the full flag definition including rules, variations, and audit fields.
*/
get(flagKey, params, options) {
const { account_id, app_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/flagship/apps/${app_id}/flags/${flagKey}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseFlags._key = Object.freeze([
'flagship',
'apps',
'flags',
]);
return BaseFlags;
})();
exports.BaseFlags = BaseFlags;
var Flags = /* @__PURE__ */ (() => {
class Flags extends BaseFlags {
constructor() {
super(...arguments);
this.changelog = new ChangelogAPI.Changelog(this._client);
}
}
Flags.Changelog = changelog_1.Changelog;
Flags.BaseChangelog = changelog_1.BaseChangelog;
return Flags;
})();
exports.Flags = Flags;
//# sourceMappingURL=flags.js.map