UNPKG

ravendb

Version:
63 lines 2.36 kB
import { throwError } from "../../Exceptions/index.js"; import { RavenCommand } from "../../Http/RavenCommand.js"; import { RaftIdGenerator } from "../../Utility/RaftIdGenerator.js"; import { TypeUtil } from "../../Utility/TypeUtil.js"; import { ClientShardHelper } from "../../Utility/ClientShardHelper.js"; export class ModifyDatabaseTopologyOperation { _databaseName; _databaseTopology; constructor(databaseName, databaseTopologyOrShardNumber, databaseTopology) { if (TypeUtil.isNullOrUndefined(databaseTopologyOrShardNumber)) { throwError("InvalidArgumentException", "DatabaseTopology cannot be null"); } if (TypeUtil.isNumber(databaseTopologyOrShardNumber)) { this._databaseTopology = databaseTopology; this._databaseName = ClientShardHelper.toShardName(databaseName, databaseTopologyOrShardNumber); } else { this._databaseName = databaseName; this._databaseTopology = databaseTopology; } } get resultType() { return "CommandResult"; } getCommand(conventions) { return new ModifyDatabaseTopologyCommand(this._databaseName, this._databaseTopology); } } class ModifyDatabaseTopologyCommand extends RavenCommand { _databaseName; _databaseTopology; constructor(databaseName, databaseTopology) { super(); if (!databaseTopology) { throwError("InvalidArgumentException", "DatabaseTopology cannot be null"); } this._databaseTopology = databaseTopology; this._databaseName = databaseName; } createRequest(node) { const uri = node.url + "/admin/databases/topology/modify?name=" + this._databaseName; const body = this._serializer.serialize(this._databaseTopology); return { uri, method: "POST", body, headers: this._headers().typeAppJson().build(), }; } get isReadRequest() { return false; } getRaftUniqueRequestId() { return RaftIdGenerator.newId(); } async setResponseAsync(bodyStream, fromCache) { let body = null; this.result = await this._defaultPipeline(_ => body = _) .process(bodyStream); return body; } } //# sourceMappingURL=ModifyDatabaseTopologyOperation.js.map