@bandprotocol/bandchain.js
Version:
Library for interacting with BandChain in browser and Node.js environments
531 lines (530 loc) • 20.3 kB
text/typescript
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.20.3
* source: google/api/http.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
export namespace google.api {
export class Http extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
rules?: HttpRule[];
fully_decode_reserved_expansion?: boolean;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("rules" in data && data.rules != undefined) {
this.rules = data.rules;
}
if ("fully_decode_reserved_expansion" in data && data.fully_decode_reserved_expansion != undefined) {
this.fully_decode_reserved_expansion = data.fully_decode_reserved_expansion;
}
}
}
get rules() {
return pb_1.Message.getRepeatedWrapperField(this, HttpRule, 1) as HttpRule[];
}
set rules(value: HttpRule[]) {
pb_1.Message.setRepeatedWrapperField(this, 1, value);
}
get fully_decode_reserved_expansion() {
return pb_1.Message.getFieldWithDefault(this, 2, false) as boolean;
}
set fully_decode_reserved_expansion(value: boolean) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
rules?: ReturnType<typeof HttpRule.prototype.toObject>[];
fully_decode_reserved_expansion?: boolean;
}): Http {
const message = new Http({});
if (data.rules != null) {
message.rules = data.rules.map(item => HttpRule.fromObject(item));
}
if (data.fully_decode_reserved_expansion != null) {
message.fully_decode_reserved_expansion = data.fully_decode_reserved_expansion;
}
return message;
}
toObject() {
const data: {
rules?: ReturnType<typeof HttpRule.prototype.toObject>[];
fully_decode_reserved_expansion?: boolean;
} = {};
if (this.rules != null) {
data.rules = this.rules.map((item: HttpRule) => item.toObject());
}
if (this.fully_decode_reserved_expansion != null) {
data.fully_decode_reserved_expansion = this.fully_decode_reserved_expansion;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.rules.length)
writer.writeRepeatedMessage(1, this.rules, (item: HttpRule) => item.serialize(writer));
if (this.fully_decode_reserved_expansion != false)
writer.writeBool(2, this.fully_decode_reserved_expansion);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Http {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Http();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.rules, () => pb_1.Message.addToRepeatedWrapperField(message, 1, HttpRule.deserialize(reader), HttpRule));
break;
case 2:
message.fully_decode_reserved_expansion = reader.readBool();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Http {
return Http.deserialize(bytes);
}
}
export class HttpRule extends pb_1.Message {
#one_of_decls: number[][] = [[2, 3, 4, 5, 6, 8]];
constructor(data?: any[] | ({
selector?: string;
body?: string;
response_body?: string;
additional_bindings?: HttpRule[];
} & (({
get?: string;
put?: never;
post?: never;
delete?: never;
patch?: never;
custom?: never;
} | {
get?: never;
put?: string;
post?: never;
delete?: never;
patch?: never;
custom?: never;
} | {
get?: never;
put?: never;
post?: string;
delete?: never;
patch?: never;
custom?: never;
} | {
get?: never;
put?: never;
post?: never;
delete?: string;
patch?: never;
custom?: never;
} | {
get?: never;
put?: never;
post?: never;
delete?: never;
patch?: string;
custom?: never;
} | {
get?: never;
put?: never;
post?: never;
delete?: never;
patch?: never;
custom?: CustomHttpPattern;
})))) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [11], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("selector" in data && data.selector != undefined) {
this.selector = data.selector;
}
if ("get" in data && data.get != undefined) {
this.get = data.get;
}
if ("put" in data && data.put != undefined) {
this.put = data.put;
}
if ("post" in data && data.post != undefined) {
this.post = data.post;
}
if ("delete" in data && data.delete != undefined) {
this.delete = data.delete;
}
if ("patch" in data && data.patch != undefined) {
this.patch = data.patch;
}
if ("custom" in data && data.custom != undefined) {
this.custom = data.custom;
}
if ("body" in data && data.body != undefined) {
this.body = data.body;
}
if ("response_body" in data && data.response_body != undefined) {
this.response_body = data.response_body;
}
if ("additional_bindings" in data && data.additional_bindings != undefined) {
this.additional_bindings = data.additional_bindings;
}
}
}
get selector() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set selector(value: string) {
pb_1.Message.setField(this, 1, value);
}
get get() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set get(value: string) {
pb_1.Message.setOneofField(this, 2, this.#one_of_decls[0], value);
}
get has_get() {
return pb_1.Message.getField(this, 2) != null;
}
get put() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set put(value: string) {
pb_1.Message.setOneofField(this, 3, this.#one_of_decls[0], value);
}
get has_put() {
return pb_1.Message.getField(this, 3) != null;
}
get post() {
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
}
set post(value: string) {
pb_1.Message.setOneofField(this, 4, this.#one_of_decls[0], value);
}
get has_post() {
return pb_1.Message.getField(this, 4) != null;
}
get delete() {
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
}
set delete(value: string) {
pb_1.Message.setOneofField(this, 5, this.#one_of_decls[0], value);
}
get has_delete() {
return pb_1.Message.getField(this, 5) != null;
}
get patch() {
return pb_1.Message.getFieldWithDefault(this, 6, "") as string;
}
set patch(value: string) {
pb_1.Message.setOneofField(this, 6, this.#one_of_decls[0], value);
}
get has_patch() {
return pb_1.Message.getField(this, 6) != null;
}
get custom() {
return pb_1.Message.getWrapperField(this, CustomHttpPattern, 8) as CustomHttpPattern;
}
set custom(value: CustomHttpPattern) {
pb_1.Message.setOneofWrapperField(this, 8, this.#one_of_decls[0], value);
}
get has_custom() {
return pb_1.Message.getField(this, 8) != null;
}
get body() {
return pb_1.Message.getFieldWithDefault(this, 7, "") as string;
}
set body(value: string) {
pb_1.Message.setField(this, 7, value);
}
get response_body() {
return pb_1.Message.getFieldWithDefault(this, 12, "") as string;
}
set response_body(value: string) {
pb_1.Message.setField(this, 12, value);
}
get additional_bindings() {
return pb_1.Message.getRepeatedWrapperField(this, HttpRule, 11) as HttpRule[];
}
set additional_bindings(value: HttpRule[]) {
pb_1.Message.setRepeatedWrapperField(this, 11, value);
}
get pattern() {
const cases: {
[index: number]: "none" | "get" | "put" | "post" | "delete" | "patch" | "custom";
} = {
0: "none",
2: "get",
3: "put",
4: "post",
5: "delete",
6: "patch",
8: "custom"
};
return cases[pb_1.Message.computeOneofCase(this, [2, 3, 4, 5, 6, 8])];
}
static fromObject(data: {
selector?: string;
get?: string;
put?: string;
post?: string;
delete?: string;
patch?: string;
custom?: ReturnType<typeof CustomHttpPattern.prototype.toObject>;
body?: string;
response_body?: string;
additional_bindings?: ReturnType<typeof HttpRule.prototype.toObject>[];
}): HttpRule {
const message = new HttpRule({});
if (data.selector != null) {
message.selector = data.selector;
}
if (data.get != null) {
message.get = data.get;
}
if (data.put != null) {
message.put = data.put;
}
if (data.post != null) {
message.post = data.post;
}
if (data.delete != null) {
message.delete = data.delete;
}
if (data.patch != null) {
message.patch = data.patch;
}
if (data.custom != null) {
message.custom = CustomHttpPattern.fromObject(data.custom);
}
if (data.body != null) {
message.body = data.body;
}
if (data.response_body != null) {
message.response_body = data.response_body;
}
if (data.additional_bindings != null) {
message.additional_bindings = data.additional_bindings.map(item => HttpRule.fromObject(item));
}
return message;
}
toObject() {
const data: {
selector?: string;
get?: string;
put?: string;
post?: string;
delete?: string;
patch?: string;
custom?: ReturnType<typeof CustomHttpPattern.prototype.toObject>;
body?: string;
response_body?: string;
additional_bindings?: ReturnType<typeof HttpRule.prototype.toObject>[];
} = {};
if (this.selector != null) {
data.selector = this.selector;
}
if (this.get != null) {
data.get = this.get;
}
if (this.put != null) {
data.put = this.put;
}
if (this.post != null) {
data.post = this.post;
}
if (this.delete != null) {
data.delete = this.delete;
}
if (this.patch != null) {
data.patch = this.patch;
}
if (this.custom != null) {
data.custom = this.custom.toObject();
}
if (this.body != null) {
data.body = this.body;
}
if (this.response_body != null) {
data.response_body = this.response_body;
}
if (this.additional_bindings != null) {
data.additional_bindings = this.additional_bindings.map((item: HttpRule) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.selector.length)
writer.writeString(1, this.selector);
if (this.has_get)
writer.writeString(2, this.get);
if (this.has_put)
writer.writeString(3, this.put);
if (this.has_post)
writer.writeString(4, this.post);
if (this.has_delete)
writer.writeString(5, this.delete);
if (this.has_patch)
writer.writeString(6, this.patch);
if (this.has_custom)
writer.writeMessage(8, this.custom, () => this.custom.serialize(writer));
if (this.body.length)
writer.writeString(7, this.body);
if (this.response_body.length)
writer.writeString(12, this.response_body);
if (this.additional_bindings.length)
writer.writeRepeatedMessage(11, this.additional_bindings, (item: HttpRule) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): HttpRule {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new HttpRule();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.selector = reader.readString();
break;
case 2:
message.get = reader.readString();
break;
case 3:
message.put = reader.readString();
break;
case 4:
message.post = reader.readString();
break;
case 5:
message.delete = reader.readString();
break;
case 6:
message.patch = reader.readString();
break;
case 8:
reader.readMessage(message.custom, () => message.custom = CustomHttpPattern.deserialize(reader));
break;
case 7:
message.body = reader.readString();
break;
case 12:
message.response_body = reader.readString();
break;
case 11:
reader.readMessage(message.additional_bindings, () => pb_1.Message.addToRepeatedWrapperField(message, 11, HttpRule.deserialize(reader), HttpRule));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): HttpRule {
return HttpRule.deserialize(bytes);
}
}
export class CustomHttpPattern extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
kind?: string;
path?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("kind" in data && data.kind != undefined) {
this.kind = data.kind;
}
if ("path" in data && data.path != undefined) {
this.path = data.path;
}
}
}
get kind() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set kind(value: string) {
pb_1.Message.setField(this, 1, value);
}
get path() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set path(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
kind?: string;
path?: string;
}): CustomHttpPattern {
const message = new CustomHttpPattern({});
if (data.kind != null) {
message.kind = data.kind;
}
if (data.path != null) {
message.path = data.path;
}
return message;
}
toObject() {
const data: {
kind?: string;
path?: string;
} = {};
if (this.kind != null) {
data.kind = this.kind;
}
if (this.path != null) {
data.path = this.path;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.kind.length)
writer.writeString(1, this.kind);
if (this.path.length)
writer.writeString(2, this.path);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CustomHttpPattern {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CustomHttpPattern();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.kind = reader.readString();
break;
case 2:
message.path = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CustomHttpPattern {
return CustomHttpPattern.deserialize(bytes);
}
}
}