UNPKG

ravendb

Version:
65 lines 2.41 kB
import { StringUtil } from "../../../Utility/StringUtil.js"; import { throwError } from "../../../Exceptions/index.js"; import { RavenCommand } from "../../../Http/RavenCommand.js"; import { RaftIdGenerator } from "../../../Utility/RaftIdGenerator.js"; import { StatusCodes } from "../../../Http/StatusCode.js"; export class RegisterReplicationHubAccessOperation { _hubName; _access; constructor(hubName, access) { if (StringUtil.isNullOrWhitespace(hubName)) { throwError("InvalidArgumentException", "HubName cannot be null or whitespace."); } if (!access) { throwError("InvalidArgumentException", "Access cannot be null"); } this._hubName = hubName; this._access = access; } get resultType() { return "CommandResult"; } getCommand(conventions) { return new RegisterReplicationHubAccessCommand(this._hubName, this._access); } } class RegisterReplicationHubAccessCommand extends RavenCommand { _hubName; _access; constructor(hubName, access) { super(); if (StringUtil.isNullOrWhitespace(hubName)) { throwError("InvalidArgumentException", "HubName cannot be null or whitespace."); } if (!access) { throwError("InvalidArgumentException", "Access cannot be null"); } this._hubName = hubName; this._access = access; this._responseType = "Empty"; } get isReadRequest() { return false; } createRequest(node) { const uri = node.url + "/databases/" + node.database + "/admin/tasks/pull-replication/hub/access?name=" + this._urlEncode(this._hubName); const headers = this._headers().typeAppJson().build(); const body = this._serializer.serialize(this._access); return { uri, method: "PUT", headers, body }; } async processResponse(cache, response, bodyStream, url) { if (response.status === StatusCodes.NotFound) { throwError("ReplicationHubNotFoundException", "The replication hub " + this._hubName + " was not found on the database. Did you forget to define it first?"); } return "Automatic"; } getRaftUniqueRequestId() { return RaftIdGenerator.newId(); } } //# sourceMappingURL=RegisterReplicationHubAccessOperation.js.map