@cerbos/grpc
Version:
Client library for interacting with the Cerbos policy decision point service over gRPC from server-side Node.js applications
186 lines • 6.33 kB
JavaScript
"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// source: google/api/http.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomHttpPattern = exports.HttpRule = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
exports.protobufPackage = "google.api";
function createBaseHttpRule() {
return {
selector: "",
pattern: undefined,
body: "",
responseBody: "",
additionalBindings: [],
};
}
exports.HttpRule = {
encode(message, writer = new wire_1.BinaryWriter()) {
if (message.selector !== "") {
writer.uint32(10).string(message.selector);
}
switch (message.pattern?.$case) {
case "get":
writer.uint32(18).string(message.pattern.get);
break;
case "put":
writer.uint32(26).string(message.pattern.put);
break;
case "post":
writer.uint32(34).string(message.pattern.post);
break;
case "delete":
writer.uint32(42).string(message.pattern.delete);
break;
case "patch":
writer.uint32(50).string(message.pattern.patch);
break;
case "custom":
exports.CustomHttpPattern.encode(message.pattern.custom, writer.uint32(66).fork()).join();
break;
}
if (message.body !== "") {
writer.uint32(58).string(message.body);
}
if (message.responseBody !== "") {
writer.uint32(98).string(message.responseBody);
}
for (const v of message.additionalBindings) {
exports.HttpRule.encode(v, writer.uint32(90).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseHttpRule();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.selector = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.pattern = { $case: "get", get: reader.string() };
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.pattern = { $case: "put", put: reader.string() };
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.pattern = { $case: "post", post: reader.string() };
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.pattern = { $case: "delete", delete: reader.string() };
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.pattern = { $case: "patch", patch: reader.string() };
continue;
}
case 8: {
if (tag !== 66) {
break;
}
message.pattern = {
$case: "custom",
custom: exports.CustomHttpPattern.decode(reader, reader.uint32()),
};
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.body = reader.string();
continue;
}
case 12: {
if (tag !== 98) {
break;
}
message.responseBody = reader.string();
continue;
}
case 11: {
if (tag !== 90) {
break;
}
message.additionalBindings.push(exports.HttpRule.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
};
function createBaseCustomHttpPattern() {
return { kind: "", path: "" };
}
exports.CustomHttpPattern = {
encode(message, writer = new wire_1.BinaryWriter()) {
if (message.kind !== "") {
writer.uint32(10).string(message.kind);
}
if (message.path !== "") {
writer.uint32(18).string(message.path);
}
return writer;
},
decode(input, length) {
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseCustomHttpPattern();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.kind = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.path = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
};
//# sourceMappingURL=http.js.map