ravendb
Version:
RavenDB client for Node.js
86 lines • 2.71 kB
JavaScript
import { throwError } from "../../../Exceptions/index.js";
import { getHeaders } from "../../../Utility/HttpUtil.js";
import { readToBuffer } from "../../../Utility/StreamUtil.js";
import { RavenCommand } from "../../../Http/RavenCommand.js";
import { RaftIdGenerator } from "../../../Utility/RaftIdGenerator.js";
export class CreateClientCertificateOperation {
_name;
_permissions;
_clearance;
_password;
constructor(name, permissions, clearance, password) {
if (!name) {
throwError("InvalidArgumentException", "Name cannot be null.");
}
if (!permissions) {
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);
}
}
class CreateClientCertificateCommand extends RavenCommand {
_name;
_permissions;
_clearance;
_password;
constructor(name, permissions, clearance, password) {
super();
if (!name) {
throwError("InvalidArgumentException", "Name cannot be null.");
}
if (!permissions) {
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: getHeaders()
.typeAppJson()
.build(),
body
};
}
setResponseRaw(response, body) {
super.setResponseRaw(response, body);
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
this._throwInvalidResponse();
}
this.result = {
rawData: await readToBuffer(bodyStream)
};
return null;
}
getRaftUniqueRequestId() {
return RaftIdGenerator.newId();
}
}
//# sourceMappingURL=CreateClientCertificateOperation.js.map