UNPKG

@configurator/ravendb

Version:
55 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigureTimeSeriesPolicyOperation = void 0; const Exceptions_1 = require("../../../Exceptions"); const RaftIdGenerator_1 = require("../../../Utility/RaftIdGenerator"); const RavenCommand_1 = require("../../../Http/RavenCommand"); class ConfigureTimeSeriesPolicyOperation { constructor(collection, config) { this._collection = collection; this._config = config; } getCommand(conventions) { return new ConfigureTimeSeriesPolicyCommand(this._collection, this._config); } get resultType() { return "CommandResult"; } } exports.ConfigureTimeSeriesPolicyOperation = ConfigureTimeSeriesPolicyOperation; class ConfigureTimeSeriesPolicyCommand extends RavenCommand_1.RavenCommand { constructor(collection, configuration) { super(); if (!configuration) { (0, Exceptions_1.throwError)("InvalidArgumentException", "Configuration cannot be null"); } if (!collection) { (0, Exceptions_1.throwError)("InvalidArgumentException", "Collection cannot be null"); } this._configuration = configuration; this._collection = collection; } get isReadRequest() { return false; } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/admin/timeseries/policy?collection=" + this._urlEncode(this._collection); const body = this._serializer.serialize(this._configuration.serialize()); return { method: "PUT", uri, body, headers: this._headers().typeAppJson().build() }; } async setResponseAsync(bodyStream, fromCache) { if (!bodyStream) { this._throwInvalidResponse(); } return this._parseResponseDefaultAsync(bodyStream); } getRaftUniqueRequestId() { return RaftIdGenerator_1.RaftIdGenerator.newId(); } } //# sourceMappingURL=ConfigureTimeSeriesPolicyOperation.js.map