cloudflare
Version:
The official TypeScript library for the Cloudflare API
75 lines • 3.35 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import * as ChangelogAPI from "./changelog.mjs";
import { BaseChangelog, Changelog, } from "./changelog.mjs";
import { CursorPaginationAfter, } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseFlags = /* @__PURE__ */ (() => {
class BaseFlags extends 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(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(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(path `/accounts/${account_id}/flagship/apps/${appID}/flags`, (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(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(path `/accounts/${account_id}/flagship/apps/${app_id}/flags/${flagKey}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseFlags._key = Object.freeze([
'flagship',
'apps',
'flags',
]);
return BaseFlags;
})();
export var Flags = /* @__PURE__ */ (() => {
class Flags extends BaseFlags {
constructor() {
super(...arguments);
this.changelog = new ChangelogAPI.Changelog(this._client);
}
}
Flags.Changelog = Changelog;
Flags.BaseChangelog = BaseChangelog;
return Flags;
})();
//# sourceMappingURL=flags.mjs.map