"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PublicConnectionServiceClient = exports.PublicConnectionServiceService = exports.ListPublicConnectionsResponse = exports.ListPublicConnectionsRequest = exports.GetPublicConnectionRequest = 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 public_connection_1 = require("../../../../yandex/cloud/cic/v1/public_connection");
exports.protobufPackage = 'yandex.cloud.cic.v1';
const baseGetPublicConnectionRequest = { publicConnectionId: '' };
exports.GetPublicConnectionRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.publicConnectionId !== '') {
            writer.uint32(10).string(message.publicConnectionId);
        }
        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({}, baseGetPublicConnectionRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.publicConnectionId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetPublicConnectionRequest);
        message.publicConnectionId =
            object.publicConnectionId !== undefined && object.publicConnectionId !== null
                ? String(object.publicConnectionId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.publicConnectionId !== undefined &&
            (obj.publicConnectionId = message.publicConnectionId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetPublicConnectionRequest);
        message.publicConnectionId = (_a = object.publicConnectionId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListPublicConnectionsRequest = {
    folderId: '',
    pageSize: 0,
    pageToken: '',
    filter: '',
};
exports.ListPublicConnectionsRequest = {
    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({}, baseListPublicConnectionsRequest);
        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({}, baseListPublicConnectionsRequest);
        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({}, baseListPublicConnectionsRequest);
        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 baseListPublicConnectionsResponse = { nextPageToken: '' };
exports.ListPublicConnectionsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.publicConnections) {
            public_connection_1.PublicConnection.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({}, baseListPublicConnectionsResponse);
        message.publicConnections = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.publicConnections.push(public_connection_1.PublicConnection.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({}, baseListPublicConnectionsResponse);
        message.publicConnections = ((_a = object.publicConnections) !== null && _a !== void 0 ? _a : []).map((e) => public_connection_1.PublicConnection.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.publicConnections) {
            obj.publicConnections = message.publicConnections.map((e) => e ? public_connection_1.PublicConnection.toJSON(e) : undefined);
        }
        else {
            obj.publicConnections = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListPublicConnectionsResponse);
        message.publicConnections =
            ((_a = object.publicConnections) === null || _a === void 0 ? void 0 : _a.map((e) => public_connection_1.PublicConnection.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
/** A set of methods for managing PublicConnection resources. */
exports.PublicConnectionServiceService = {
    /**
     * Returns the specified PublicConnection resource.
     *
     * To get the list of available PublicConnection resources, make a [List] request.
     */
    get: {
        path: '/yandex.cloud.cic.v1.PublicConnectionService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetPublicConnectionRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetPublicConnectionRequest.decode(value),
        responseSerialize: (value) => Buffer.from(public_connection_1.PublicConnection.encode(value).finish()),
        responseDeserialize: (value) => public_connection_1.PublicConnection.decode(value),
    },
    /** Retrieves the list of PublicConnection resources in the specified folder. */
    list: {
        path: '/yandex.cloud.cic.v1.PublicConnectionService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListPublicConnectionsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListPublicConnectionsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListPublicConnectionsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListPublicConnectionsResponse.decode(value),
    },
};
exports.PublicConnectionServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.PublicConnectionServiceService, 'yandex.cloud.cic.v1.PublicConnectionService');
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();
}
