UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

46 lines 2.44 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.Values = void 0; const resource_1 = require("cloudflare/resource"); const core_1 = require("cloudflare/core"); class Values extends resource_1.APIResource { /** * Write a value identified by a key. Use URL-encoding to use special characters * (for example, `:`, `!`, `%`) in the key name. Body should be the value to be * stored along with JSON metadata to be associated with the key/value pair. * Existing values, expirations, and metadata will be overwritten. If neither * `expiration` nor `expiration_ttl` is specified, the key-value pair will never * expire. If both are set, `expiration_ttl` is used and `expiration` is ignored. */ update(namespaceId, keyName, params, options) { const { account_id, ...body } = params; return this._client.put(`/accounts/${account_id}/storage/kv/namespaces/${namespaceId}/values/${keyName}`, (0, core_1.multipartFormRequestOptions)({ body, ...options }))._thenUnwrap((obj) => obj.result); } /** * Remove a KV pair from the namespace. Use URL-encoding to use special characters * (for example, `:`, `!`, `%`) in the key name. */ delete(namespaceId, keyName, params, options) { const { account_id, body } = params; return this._client.delete(`/accounts/${account_id}/storage/kv/namespaces/${namespaceId}/values/${keyName}`, { body: body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Returns the value associated with the given key in the given namespace. Use * URL-encoding to use special characters (for example, `:`, `!`, `%`) in the key * name. If the KV-pair is set to expire at some point, the expiration time as * measured in seconds since the UNIX epoch will be returned in the `expiration` * response header. */ get(namespaceId, keyName, params, options) { const { account_id } = params; return this._client.get(`/accounts/${account_id}/storage/kv/namespaces/${namespaceId}/values/${keyName}`, { ...options, headers: { Accept: 'application/json', ...options?.headers } }); } } exports.Values = Values; (function (Values) { })(Values = exports.Values || (exports.Values = {})); //# sourceMappingURL=values.js.map