ravendb
Version:
RavenDB client for Node.js
90 lines • 3.08 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateClientCertificateOperation = void 0;
const index_js_1 = require("../../../Exceptions/index.js");
const HttpUtil_js_1 = require("../../../Utility/HttpUtil.js");
const StreamUtil_js_1 = require("../../../Utility/StreamUtil.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
const RaftIdGenerator_js_1 = require("../../../Utility/RaftIdGenerator.js");
class CreateClientCertificateOperation {
_name;
_permissions;
_clearance;
_password;
constructor(name, permissions, clearance, password) {
if (!name) {
(0, index_js_1.throwError)("InvalidArgumentException", "Name cannot be null.");
}
if (!permissions) {
(0, index_js_1.throwError)("InvalidArgumentException", "Permissions cannot be null.");
}
this._name = name;
this._permissions = permissions;
this._clearance = clearance;
this._password = password;
}
get resultType() {
return "CommandResult";
}
getCommand(conventions) {
return new CreateClientCertificateCommand(this._name, this._permissions, this._clearance, this._password);
}
}
exports.CreateClientCertificateOperation = CreateClientCertificateOperation;
class CreateClientCertificateCommand extends RavenCommand_js_1.RavenCommand {
_name;
_permissions;
_clearance;
_password;
constructor(name, permissions, clearance, password) {
super();
if (!name) {
(0, index_js_1.throwError)("InvalidArgumentException", "Name cannot be null.");
}
if (!permissions) {
(0, index_js_1.throwError)("InvalidArgumentException", "Permissions cannot be null.");
}
this._name = name;
this._permissions = permissions;
this._clearance = clearance;
this._password = password;
this._responseType = "Raw";
}
get isReadRequest() {
return false;
}
createRequest(node) {
const uri = node.url + "/admin/certificates";
const body = this._serializer
.serialize({
Name: this._name,
SecurityClearance: this._clearance,
Password: this._password || undefined,
Permissions: this._permissions,
});
return {
method: "POST",
uri,
headers: (0, HttpUtil_js_1.getHeaders)()
.typeAppJson()
.build(),
body
};
}
setResponseRaw(response, body) {
super.setResponseRaw(response, body);
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
this._throwInvalidResponse();
}
this.result = {
rawData: await (0, StreamUtil_js_1.readToBuffer)(bodyStream)
};
return null;
}
getRaftUniqueRequestId() {
return RaftIdGenerator_js_1.RaftIdGenerator.newId();
}
}
//# sourceMappingURL=CreateClientCertificateOperation.js.map