UNPKG

ravendb

Version:
84 lines 3.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PutClientCertificateOperation = void 0; const index_js_1 = require("../../../Exceptions/index.js"); const HttpUtil_js_1 = require("../../../Utility/HttpUtil.js"); const RavenCommand_js_1 = require("../../../Http/RavenCommand.js"); const RaftIdGenerator_js_1 = require("../../../Utility/RaftIdGenerator.js"); class PutClientCertificateOperation { _certificate; _permissions; _name; _clearance; _twoFactorAuthenticationKey; constructor(name, certificate, permissions, clearance, twoFactorAuthenticationKey) { if (!certificate) { (0, index_js_1.throwError)("InvalidArgumentException", "Certificate cannot be null"); } if (!permissions) { (0, index_js_1.throwError)("InvalidArgumentException", "Permissions cannot be null."); } if (!name) { (0, index_js_1.throwError)("InvalidArgumentException", "Name cannot be null"); } this._certificate = certificate; this._permissions = permissions; this._name = name; this._clearance = clearance; this._twoFactorAuthenticationKey = twoFactorAuthenticationKey; } get resultType() { return "CommandResult"; } getCommand(conventions) { return new PutClientCertificateCommand(this._name, this._certificate, this._permissions, this._clearance, this._twoFactorAuthenticationKey); } } exports.PutClientCertificateOperation = PutClientCertificateOperation; class PutClientCertificateCommand extends RavenCommand_js_1.RavenCommand { _certificate; _permissions; _name; _clearance; _twoFactorAuthenticationKey; constructor(name, certificate, permissions, clearance, twoFactorAuthenticationKey) { super(); if (!certificate) { (0, index_js_1.throwError)("InvalidArgumentException", "Certificate cannot be null"); } if (!permissions) { (0, index_js_1.throwError)("InvalidArgumentException", "Permissions cannot be null."); } this._certificate = certificate; this._permissions = permissions; this._name = name; this._clearance = clearance; this._twoFactorAuthenticationKey = twoFactorAuthenticationKey; } get isReadRequest() { return false; } createRequest(node) { const uri = node.url + "/admin/certificates"; const body = this._serializer .serialize({ Name: this._name, Certificate: this._certificate, SecurityClearance: this._clearance, Permissions: this._permissions, TwoFactorAuthenticationKey: this._twoFactorAuthenticationKey ?? undefined }); return { uri, method: "PUT", headers: (0, HttpUtil_js_1.getHeaders)() .typeAppJson() .build(), body }; } getRaftUniqueRequestId() { return RaftIdGenerator_js_1.RaftIdGenerator.newId(); } } //# sourceMappingURL=PutClientCertificateOperation.js.map