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