"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoutingInstanceServiceClient = exports.RoutingInstanceServiceService = exports.ListRoutingInstanceOperationsResponse = exports.ListRoutingInstanceOperationsRequest = exports.DeleteRoutingInstanceMetadata = exports.DeleteRoutingInstanceRequest = exports.RemovePrivateConnectionRequest = exports.AddPrivateConnectionRequest = exports.VpcAzInfoPrefixes = exports.RemovePrefixesRequest = exports.UpsertPrefixesRequest = exports.UpdateRoutingInstanceMetadata = exports.UpdateRoutingInstanceRequest_LabelsEntry = exports.UpdateRoutingInstanceRequest = exports.CreateRoutingInstanceMetadata = exports.CreateRoutingInstanceRequest_LabelsEntry = exports.CreateRoutingInstanceRequest = exports.ListRoutingInstancesResponse = exports.ListRoutingInstancesRequest = exports.GetRoutingInstanceByVpcNetworkIdRequest = exports.GetRoutingInstanceByCicPrivateConnectionIdRequest = exports.GetRoutingInstanceRequest = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const grpc_js_1 = require("@grpc/grpc-js");
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const field_mask_1 = require("../../../../google/protobuf/field_mask");
const routing_instance_1 = require("../../../../yandex/cloud/cloudrouter/v1/routing_instance");
const operation_1 = require("../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.cloudrouter.v1';
const baseGetRoutingInstanceRequest = { routingInstanceId: '' };
exports.GetRoutingInstanceRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetRoutingInstanceRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetRoutingInstanceRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetRoutingInstanceRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetRoutingInstanceByCicPrivateConnectionIdRequest = {
    cicPrivateConnectionId: '',
};
exports.GetRoutingInstanceByCicPrivateConnectionIdRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.cicPrivateConnectionId !== '') {
            writer.uint32(10).string(message.cicPrivateConnectionId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetRoutingInstanceByCicPrivateConnectionIdRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.cicPrivateConnectionId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetRoutingInstanceByCicPrivateConnectionIdRequest);
        message.cicPrivateConnectionId =
            object.cicPrivateConnectionId !== undefined && object.cicPrivateConnectionId !== null
                ? String(object.cicPrivateConnectionId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.cicPrivateConnectionId !== undefined &&
            (obj.cicPrivateConnectionId = message.cicPrivateConnectionId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetRoutingInstanceByCicPrivateConnectionIdRequest);
        message.cicPrivateConnectionId = (_a = object.cicPrivateConnectionId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetRoutingInstanceByVpcNetworkIdRequest = { vpcNetworkId: '' };
exports.GetRoutingInstanceByVpcNetworkIdRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.vpcNetworkId !== '') {
            writer.uint32(10).string(message.vpcNetworkId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetRoutingInstanceByVpcNetworkIdRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.vpcNetworkId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetRoutingInstanceByVpcNetworkIdRequest);
        message.vpcNetworkId =
            object.vpcNetworkId !== undefined && object.vpcNetworkId !== null
                ? String(object.vpcNetworkId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.vpcNetworkId !== undefined && (obj.vpcNetworkId = message.vpcNetworkId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetRoutingInstanceByVpcNetworkIdRequest);
        message.vpcNetworkId = (_a = object.vpcNetworkId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListRoutingInstancesRequest = {
    folderId: '',
    pageSize: 0,
    pageToken: '',
    filter: '',
};
exports.ListRoutingInstancesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.folderId !== '') {
            writer.uint32(10).string(message.folderId);
        }
        if (message.pageSize !== 0) {
            writer.uint32(16).int64(message.pageSize);
        }
        if (message.pageToken !== '') {
            writer.uint32(26).string(message.pageToken);
        }
        if (message.filter !== '') {
            writer.uint32(34).string(message.filter);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseListRoutingInstancesRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.folderId = reader.string();
                    break;
                case 2:
                    message.pageSize = longToNumber(reader.int64());
                    break;
                case 3:
                    message.pageToken = reader.string();
                    break;
                case 4:
                    message.filter = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListRoutingInstancesRequest);
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.pageSize =
            object.pageSize !== undefined && object.pageSize !== null ? Number(object.pageSize) : 0;
        message.pageToken =
            object.pageToken !== undefined && object.pageToken !== null
                ? String(object.pageToken)
                : '';
        message.filter =
            object.filter !== undefined && object.filter !== null ? String(object.filter) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));
        message.pageToken !== undefined && (obj.pageToken = message.pageToken);
        message.filter !== undefined && (obj.filter = message.filter);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseListRoutingInstancesRequest);
        message.folderId = (_a = object.folderId) !== null && _a !== void 0 ? _a : '';
        message.pageSize = (_b = object.pageSize) !== null && _b !== void 0 ? _b : 0;
        message.pageToken = (_c = object.pageToken) !== null && _c !== void 0 ? _c : '';
        message.filter = (_d = object.filter) !== null && _d !== void 0 ? _d : '';
        return message;
    },
};
const baseListRoutingInstancesResponse = { nextPageToken: '' };
exports.ListRoutingInstancesResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.routingInstances) {
            routing_instance_1.RoutingInstance.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.nextPageToken !== '') {
            writer.uint32(18).string(message.nextPageToken);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseListRoutingInstancesResponse);
        message.routingInstances = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstances.push(routing_instance_1.RoutingInstance.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.nextPageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseListRoutingInstancesResponse);
        message.routingInstances = ((_a = object.routingInstances) !== null && _a !== void 0 ? _a : []).map((e) => routing_instance_1.RoutingInstance.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.routingInstances) {
            obj.routingInstances = message.routingInstances.map((e) => e ? routing_instance_1.RoutingInstance.toJSON(e) : undefined);
        }
        else {
            obj.routingInstances = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListRoutingInstancesResponse);
        message.routingInstances =
            ((_a = object.routingInstances) === null || _a === void 0 ? void 0 : _a.map((e) => routing_instance_1.RoutingInstance.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseCreateRoutingInstanceRequest = {
    name: '',
    description: '',
    folderId: '',
    regionId: '',
};
exports.CreateRoutingInstanceRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.name !== '') {
            writer.uint32(10).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(18).string(message.description);
        }
        if (message.folderId !== '') {
            writer.uint32(34).string(message.folderId);
        }
        if (message.regionId !== '') {
            writer.uint32(42).string(message.regionId);
        }
        for (const v of message.vpcInfo) {
            routing_instance_1.RoutingInstance_VpcInfo.encode(v, writer.uint32(50).fork()).ldelim();
        }
        for (const v of message.cicPrivateConnectionInfo) {
            routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.encode(v, writer.uint32(58).fork()).ldelim();
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.CreateRoutingInstanceRequest_LabelsEntry.encode({ key: key, value }, writer.uint32(98).fork()).ldelim();
        });
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseCreateRoutingInstanceRequest);
        message.vpcInfo = [];
        message.cicPrivateConnectionInfo = [];
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.description = reader.string();
                    break;
                case 4:
                    message.folderId = reader.string();
                    break;
                case 5:
                    message.regionId = reader.string();
                    break;
                case 6:
                    message.vpcInfo.push(routing_instance_1.RoutingInstance_VpcInfo.decode(reader, reader.uint32()));
                    break;
                case 7:
                    message.cicPrivateConnectionInfo.push(routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.decode(reader, reader.uint32()));
                    break;
                case 12:
                    const entry12 = exports.CreateRoutingInstanceRequest_LabelsEntry.decode(reader, reader.uint32());
                    if (entry12.value !== undefined) {
                        message.labels[entry12.key] = entry12.value;
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseCreateRoutingInstanceRequest);
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.regionId =
            object.regionId !== undefined && object.regionId !== null
                ? String(object.regionId)
                : '';
        message.vpcInfo = ((_a = object.vpcInfo) !== null && _a !== void 0 ? _a : []).map((e) => routing_instance_1.RoutingInstance_VpcInfo.fromJSON(e));
        message.cicPrivateConnectionInfo = ((_b = object.cicPrivateConnectionInfo) !== null && _b !== void 0 ? _b : []).map((e) => routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.fromJSON(e));
        message.labels = Object.entries((_c = object.labels) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.regionId !== undefined && (obj.regionId = message.regionId);
        if (message.vpcInfo) {
            obj.vpcInfo = message.vpcInfo.map((e) => e ? routing_instance_1.RoutingInstance_VpcInfo.toJSON(e) : undefined);
        }
        else {
            obj.vpcInfo = [];
        }
        if (message.cicPrivateConnectionInfo) {
            obj.cicPrivateConnectionInfo = message.cicPrivateConnectionInfo.map((e) => e ? routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.toJSON(e) : undefined);
        }
        else {
            obj.cicPrivateConnectionInfo = [];
        }
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g;
        const message = Object.assign({}, baseCreateRoutingInstanceRequest);
        message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
        message.description = (_b = object.description) !== null && _b !== void 0 ? _b : '';
        message.folderId = (_c = object.folderId) !== null && _c !== void 0 ? _c : '';
        message.regionId = (_d = object.regionId) !== null && _d !== void 0 ? _d : '';
        message.vpcInfo = ((_e = object.vpcInfo) === null || _e === void 0 ? void 0 : _e.map((e) => routing_instance_1.RoutingInstance_VpcInfo.fromPartial(e))) || [];
        message.cicPrivateConnectionInfo =
            ((_f = object.cicPrivateConnectionInfo) === null || _f === void 0 ? void 0 : _f.map((e) => routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.fromPartial(e))) || [];
        message.labels = Object.entries((_g = object.labels) !== null && _g !== void 0 ? _g : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        return message;
    },
};
const baseCreateRoutingInstanceRequest_LabelsEntry = { key: '', value: '' };
exports.CreateRoutingInstanceRequest_LabelsEntry = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.key !== '') {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== '') {
            writer.uint32(18).string(message.value);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseCreateRoutingInstanceRequest_LabelsEntry);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateRoutingInstanceRequest_LabelsEntry);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.value =
            object.value !== undefined && object.value !== null ? String(object.value) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.value !== undefined && (obj.value = message.value);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseCreateRoutingInstanceRequest_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseCreateRoutingInstanceMetadata = { routingInstanceId: '' };
exports.CreateRoutingInstanceMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseCreateRoutingInstanceMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateRoutingInstanceMetadata);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateRoutingInstanceMetadata);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseUpdateRoutingInstanceRequest = {
    routingInstanceId: '',
    name: '',
    description: '',
    regionId: '',
};
exports.UpdateRoutingInstanceRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        if (message.updateMask !== undefined) {
            field_mask_1.FieldMask.encode(message.updateMask, writer.uint32(18).fork()).ldelim();
        }
        if (message.name !== '') {
            writer.uint32(26).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        if (message.regionId !== '') {
            writer.uint32(58).string(message.regionId);
        }
        for (const v of message.vpcInfo) {
            routing_instance_1.RoutingInstance_VpcInfo.encode(v, writer.uint32(66).fork()).ldelim();
        }
        for (const v of message.cicPrivateConnectionInfo) {
            routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.encode(v, writer.uint32(74).fork()).ldelim();
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.UpdateRoutingInstanceRequest_LabelsEntry.encode({ key: key, value }, writer.uint32(114).fork()).ldelim();
        });
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseUpdateRoutingInstanceRequest);
        message.vpcInfo = [];
        message.cicPrivateConnectionInfo = [];
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                case 2:
                    message.updateMask = field_mask_1.FieldMask.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.name = reader.string();
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                case 7:
                    message.regionId = reader.string();
                    break;
                case 8:
                    message.vpcInfo.push(routing_instance_1.RoutingInstance_VpcInfo.decode(reader, reader.uint32()));
                    break;
                case 9:
                    message.cicPrivateConnectionInfo.push(routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.decode(reader, reader.uint32()));
                    break;
                case 14:
                    const entry14 = exports.UpdateRoutingInstanceRequest_LabelsEntry.decode(reader, reader.uint32());
                    if (entry14.value !== undefined) {
                        message.labels[entry14.key] = entry14.value;
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseUpdateRoutingInstanceRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        message.updateMask =
            object.updateMask !== undefined && object.updateMask !== null
                ? field_mask_1.FieldMask.fromJSON(object.updateMask)
                : undefined;
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.regionId =
            object.regionId !== undefined && object.regionId !== null
                ? String(object.regionId)
                : '';
        message.vpcInfo = ((_a = object.vpcInfo) !== null && _a !== void 0 ? _a : []).map((e) => routing_instance_1.RoutingInstance_VpcInfo.fromJSON(e));
        message.cicPrivateConnectionInfo = ((_b = object.cicPrivateConnectionInfo) !== null && _b !== void 0 ? _b : []).map((e) => routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.fromJSON(e));
        message.labels = Object.entries((_c = object.labels) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        message.updateMask !== undefined &&
            (obj.updateMask = message.updateMask
                ? field_mask_1.FieldMask.toJSON(message.updateMask)
                : undefined);
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.regionId !== undefined && (obj.regionId = message.regionId);
        if (message.vpcInfo) {
            obj.vpcInfo = message.vpcInfo.map((e) => e ? routing_instance_1.RoutingInstance_VpcInfo.toJSON(e) : undefined);
        }
        else {
            obj.vpcInfo = [];
        }
        if (message.cicPrivateConnectionInfo) {
            obj.cicPrivateConnectionInfo = message.cicPrivateConnectionInfo.map((e) => e ? routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.toJSON(e) : undefined);
        }
        else {
            obj.cicPrivateConnectionInfo = [];
        }
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g;
        const message = Object.assign({}, baseUpdateRoutingInstanceRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        message.updateMask =
            object.updateMask !== undefined && object.updateMask !== null
                ? field_mask_1.FieldMask.fromPartial(object.updateMask)
                : undefined;
        message.name = (_b = object.name) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.regionId = (_d = object.regionId) !== null && _d !== void 0 ? _d : '';
        message.vpcInfo = ((_e = object.vpcInfo) === null || _e === void 0 ? void 0 : _e.map((e) => routing_instance_1.RoutingInstance_VpcInfo.fromPartial(e))) || [];
        message.cicPrivateConnectionInfo =
            ((_f = object.cicPrivateConnectionInfo) === null || _f === void 0 ? void 0 : _f.map((e) => routing_instance_1.RoutingInstance_CicPrivateConnectionInfo.fromPartial(e))) || [];
        message.labels = Object.entries((_g = object.labels) !== null && _g !== void 0 ? _g : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        return message;
    },
};
const baseUpdateRoutingInstanceRequest_LabelsEntry = { key: '', value: '' };
exports.UpdateRoutingInstanceRequest_LabelsEntry = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.key !== '') {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== '') {
            writer.uint32(18).string(message.value);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseUpdateRoutingInstanceRequest_LabelsEntry);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdateRoutingInstanceRequest_LabelsEntry);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.value =
            object.value !== undefined && object.value !== null ? String(object.value) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.value !== undefined && (obj.value = message.value);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseUpdateRoutingInstanceRequest_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseUpdateRoutingInstanceMetadata = { routingInstanceId: '' };
exports.UpdateRoutingInstanceMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseUpdateRoutingInstanceMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdateRoutingInstanceMetadata);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseUpdateRoutingInstanceMetadata);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseUpsertPrefixesRequest = { routingInstanceId: '', vpcNetworkId: '' };
exports.UpsertPrefixesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        if (message.vpcNetworkId !== '') {
            writer.uint32(18).string(message.vpcNetworkId);
        }
        for (const v of message.vpcAzInfoPrefixes) {
            exports.VpcAzInfoPrefixes.encode(v, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseUpsertPrefixesRequest);
        message.vpcAzInfoPrefixes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                case 2:
                    message.vpcNetworkId = reader.string();
                    break;
                case 3:
                    message.vpcAzInfoPrefixes.push(exports.VpcAzInfoPrefixes.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseUpsertPrefixesRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        message.vpcNetworkId =
            object.vpcNetworkId !== undefined && object.vpcNetworkId !== null
                ? String(object.vpcNetworkId)
                : '';
        message.vpcAzInfoPrefixes = ((_a = object.vpcAzInfoPrefixes) !== null && _a !== void 0 ? _a : []).map((e) => exports.VpcAzInfoPrefixes.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        message.vpcNetworkId !== undefined && (obj.vpcNetworkId = message.vpcNetworkId);
        if (message.vpcAzInfoPrefixes) {
            obj.vpcAzInfoPrefixes = message.vpcAzInfoPrefixes.map((e) => e ? exports.VpcAzInfoPrefixes.toJSON(e) : undefined);
        }
        else {
            obj.vpcAzInfoPrefixes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseUpsertPrefixesRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        message.vpcNetworkId = (_b = object.vpcNetworkId) !== null && _b !== void 0 ? _b : '';
        message.vpcAzInfoPrefixes =
            ((_c = object.vpcAzInfoPrefixes) === null || _c === void 0 ? void 0 : _c.map((e) => exports.VpcAzInfoPrefixes.fromPartial(e))) || [];
        return message;
    },
};
const baseRemovePrefixesRequest = { routingInstanceId: '', vpcNetworkId: '' };
exports.RemovePrefixesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        if (message.vpcNetworkId !== '') {
            writer.uint32(18).string(message.vpcNetworkId);
        }
        for (const v of message.vpcAzInfoPrefixes) {
            exports.VpcAzInfoPrefixes.encode(v, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseRemovePrefixesRequest);
        message.vpcAzInfoPrefixes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                case 2:
                    message.vpcNetworkId = reader.string();
                    break;
                case 3:
                    message.vpcAzInfoPrefixes.push(exports.VpcAzInfoPrefixes.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseRemovePrefixesRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        message.vpcNetworkId =
            object.vpcNetworkId !== undefined && object.vpcNetworkId !== null
                ? String(object.vpcNetworkId)
                : '';
        message.vpcAzInfoPrefixes = ((_a = object.vpcAzInfoPrefixes) !== null && _a !== void 0 ? _a : []).map((e) => exports.VpcAzInfoPrefixes.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        message.vpcNetworkId !== undefined && (obj.vpcNetworkId = message.vpcNetworkId);
        if (message.vpcAzInfoPrefixes) {
            obj.vpcAzInfoPrefixes = message.vpcAzInfoPrefixes.map((e) => e ? exports.VpcAzInfoPrefixes.toJSON(e) : undefined);
        }
        else {
            obj.vpcAzInfoPrefixes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseRemovePrefixesRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        message.vpcNetworkId = (_b = object.vpcNetworkId) !== null && _b !== void 0 ? _b : '';
        message.vpcAzInfoPrefixes =
            ((_c = object.vpcAzInfoPrefixes) === null || _c === void 0 ? void 0 : _c.map((e) => exports.VpcAzInfoPrefixes.fromPartial(e))) || [];
        return message;
    },
};
const baseVpcAzInfoPrefixes = { azId: '', prefixes: '' };
exports.VpcAzInfoPrefixes = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.azId !== '') {
            writer.uint32(10).string(message.azId);
        }
        for (const v of message.prefixes) {
            writer.uint32(18).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseVpcAzInfoPrefixes);
        message.prefixes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.azId = reader.string();
                    break;
                case 2:
                    message.prefixes.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseVpcAzInfoPrefixes);
        message.azId = object.azId !== undefined && object.azId !== null ? String(object.azId) : '';
        message.prefixes = ((_a = object.prefixes) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.azId !== undefined && (obj.azId = message.azId);
        if (message.prefixes) {
            obj.prefixes = message.prefixes.map((e) => e);
        }
        else {
            obj.prefixes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseVpcAzInfoPrefixes);
        message.azId = (_a = object.azId) !== null && _a !== void 0 ? _a : '';
        message.prefixes = ((_b = object.prefixes) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        return message;
    },
};
const baseAddPrivateConnectionRequest = {
    routingInstanceId: '',
    cicPrivateConnectionId: '',
};
exports.AddPrivateConnectionRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        if (message.cicPrivateConnectionId !== '') {
            writer.uint32(18).string(message.cicPrivateConnectionId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseAddPrivateConnectionRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                case 2:
                    message.cicPrivateConnectionId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseAddPrivateConnectionRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        message.cicPrivateConnectionId =
            object.cicPrivateConnectionId !== undefined && object.cicPrivateConnectionId !== null
                ? String(object.cicPrivateConnectionId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        message.cicPrivateConnectionId !== undefined &&
            (obj.cicPrivateConnectionId = message.cicPrivateConnectionId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseAddPrivateConnectionRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        message.cicPrivateConnectionId = (_b = object.cicPrivateConnectionId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseRemovePrivateConnectionRequest = {
    routingInstanceId: '',
    cicPrivateConnectionId: '',
};
exports.RemovePrivateConnectionRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        if (message.cicPrivateConnectionId !== '') {
            writer.uint32(18).string(message.cicPrivateConnectionId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseRemovePrivateConnectionRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                case 2:
                    message.cicPrivateConnectionId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRemovePrivateConnectionRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        message.cicPrivateConnectionId =
            object.cicPrivateConnectionId !== undefined && object.cicPrivateConnectionId !== null
                ? String(object.cicPrivateConnectionId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        message.cicPrivateConnectionId !== undefined &&
            (obj.cicPrivateConnectionId = message.cicPrivateConnectionId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseRemovePrivateConnectionRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        message.cicPrivateConnectionId = (_b = object.cicPrivateConnectionId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseDeleteRoutingInstanceRequest = { routingInstanceId: '' };
exports.DeleteRoutingInstanceRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseDeleteRoutingInstanceRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteRoutingInstanceRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteRoutingInstanceRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteRoutingInstanceMetadata = { routingInstanceId: '' };
exports.DeleteRoutingInstanceMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseDeleteRoutingInstanceMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteRoutingInstanceMetadata);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteRoutingInstanceMetadata);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListRoutingInstanceOperationsRequest = {
    routingInstanceId: '',
    pageSize: 0,
    pageToken: '',
};
exports.ListRoutingInstanceOperationsRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.routingInstanceId !== '') {
            writer.uint32(10).string(message.routingInstanceId);
        }
        if (message.pageSize !== 0) {
            writer.uint32(16).int64(message.pageSize);
        }
        if (message.pageToken !== '') {
            writer.uint32(26).string(message.pageToken);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseListRoutingInstanceOperationsRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.routingInstanceId = reader.string();
                    break;
                case 2:
                    message.pageSize = longToNumber(reader.int64());
                    break;
                case 3:
                    message.pageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListRoutingInstanceOperationsRequest);
        message.routingInstanceId =
            object.routingInstanceId !== undefined && object.routingInstanceId !== null
                ? String(object.routingInstanceId)
                : '';
        message.pageSize =
            object.pageSize !== undefined && object.pageSize !== null ? Number(object.pageSize) : 0;
        message.pageToken =
            object.pageToken !== undefined && object.pageToken !== null
                ? String(object.pageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.routingInstanceId !== undefined &&
            (obj.routingInstanceId = message.routingInstanceId);
        message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));
        message.pageToken !== undefined && (obj.pageToken = message.pageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseListRoutingInstanceOperationsRequest);
        message.routingInstanceId = (_a = object.routingInstanceId) !== null && _a !== void 0 ? _a : '';
        message.pageSize = (_b = object.pageSize) !== null && _b !== void 0 ? _b : 0;
        message.pageToken = (_c = object.pageToken) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
const baseListRoutingInstanceOperationsResponse = { nextPageToken: '' };
exports.ListRoutingInstanceOperationsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.operations) {
            operation_1.Operation.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.nextPageToken !== '') {
            writer.uint32(18).string(message.nextPageToken);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseListRoutingInstanceOperationsResponse);
        message.operations = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.operations.push(operation_1.Operation.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.nextPageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseListRoutingInstanceOperationsResponse);
        message.operations = ((_a = object.operations) !== null && _a !== void 0 ? _a : []).map((e) => operation_1.Operation.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.operations) {
            obj.operations = message.operations.map((e) => (e ? operation_1.Operation.toJSON(e) : undefined));
        }
        else {
            obj.operations = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListRoutingInstanceOperationsResponse);
        message.operations = ((_a = object.operations) === null || _a === void 0 ? void 0 : _a.map((e) => operation_1.Operation.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
/** A set of methods for managing RoutingInstance resources. */
exports.RoutingInstanceServiceService = {
    /**
     * Returns the specified RoutingInstance resource.
     *
     * To get the list of available RoutingInstance resources, make a [List] request.
     */
    get: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetRoutingInstanceRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetRoutingInstanceRequest.decode(value),
        responseSerialize: (value) => Buffer.from(routing_instance_1.RoutingInstance.encode(value).finish()),
        responseDeserialize: (value) => routing_instance_1.RoutingInstance.decode(value),
    },
    /**
     * Returns the RoutingInstance resource by vpcNetworkId
     *
     * To get the list of available RoutingInstance resources, make a [List] request.
     */
    getByVpcNetworkId: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/GetByVpcNetworkId',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetRoutingInstanceByVpcNetworkIdRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetRoutingInstanceByVpcNetworkIdRequest.decode(value),
        responseSerialize: (value) => Buffer.from(routing_instance_1.RoutingInstance.encode(value).finish()),
        responseDeserialize: (value) => routing_instance_1.RoutingInstance.decode(value),
    },
    /**
     * Returns the RoutingInstance resource by cicPrivateConnectionId
     *
     * To get the list of available RoutingInstance resources, make a [List] request.
     */
    getByCicPrivateConnectionId: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/GetByCicPrivateConnectionId',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetRoutingInstanceByCicPrivateConnectionIdRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetRoutingInstanceByCicPrivateConnectionIdRequest.decode(value),
        responseSerialize: (value) => Buffer.from(routing_instance_1.RoutingInstance.encode(value).finish()),
        responseDeserialize: (value) => routing_instance_1.RoutingInstance.decode(value),
    },
    /** Retrieves the list of RoutingInstance resources in the specified folder. */
    list: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListRoutingInstancesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListRoutingInstancesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListRoutingInstancesResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListRoutingInstancesResponse.decode(value),
    },
    /**
     * Creates a RoutingInstance resource in the specified folder using the data specified in the request.
     * Method starts an asynchronous operation that can be cancelled while it is in progress.
     */
    create: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreateRoutingInstanceRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreateRoutingInstanceRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Updates a RoutingInstance resource using the data specified in the request.
     * Method starts an asynchronous operation that can be cancelled while it is in progress.
     */
    update: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/Update',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.UpdateRoutingInstanceRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.UpdateRoutingInstanceRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Upserts specified prefixes to a RoutingInstance resource.
     * Method starts an asynchronous operation that can be cancelled while it is in progress.
     */
    upsertPrefixes: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/UpsertPrefixes',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.UpsertPrefixesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.UpsertPrefixesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Removes specified prefixes from a RoutingInstance resource.
     * Method starts an asynchronous operation that can be cancelled while it is in progress.
     */
    removePrefixes: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/RemovePrefixes',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.RemovePrefixesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.RemovePrefixesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Adds specified PrivateConnection to a RoutingInstance resource.
     * Method starts an asynchronous operation that can be cancelled while it is in progress.
     */
    addPrivateConnection: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/AddPrivateConnection',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.AddPrivateConnectionRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.AddPrivateConnectionRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Removes specified PrivateConnection from a RoutingInstance resource.
     * Method starts an asynchronous operation that can be cancelled while it is in progress.
     */
    removePrivateConnection: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/RemovePrivateConnection',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.RemovePrivateConnectionRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.RemovePrivateConnectionRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Deletes a RoutingInstance resource.
     * Method starts an asynchronous operation that can be cancelled while it is in progress.
     */
    delete: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeleteRoutingInstanceRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeleteRoutingInstanceRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Lists operations for the specified RoutingInstance. */
    listOperations: {
        path: '/yandex.cloud.cloudrouter.v1.RoutingInstanceService/ListOperations',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListRoutingInstanceOperationsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListRoutingInstanceOperationsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListRoutingInstanceOperationsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListRoutingInstanceOperationsResponse.decode(value),
    },
};
exports.RoutingInstanceServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.RoutingInstanceServiceService, 'yandex.cloud.cloudrouter.v1.RoutingInstanceService');
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
function longToNumber(long) {
    if (long.gt(Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
    }
    return long.toNumber();
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
