"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigServiceClient = exports.ConfigServiceService = exports.DeleteConfigMetadata = exports.DeleteConfigRequest = exports.ListConfigsResponse = exports.ListConfigsRequest = exports.GetConfigRequest = exports.CreateConfigMetadata = exports.CreateConfigRequest = 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 config_1 = require("../../../../../yandex/cloud/loadtesting/api/v1/config/config");
const operation_1 = require("../../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.loadtesting.api.v1';
const baseCreateConfigRequest = { folderId: '', name: '' };
exports.CreateConfigRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.folderId !== '') {
            writer.uint32(10).string(message.folderId);
        }
        if (message.yamlString !== undefined) {
            writer.uint32(18).string(message.yamlString);
        }
        if (message.name !== '') {
            writer.uint32(82).string(message.name);
        }
        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({}, baseCreateConfigRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.folderId = reader.string();
                    break;
                case 2:
                    message.yamlString = reader.string();
                    break;
                case 10:
                    message.name = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateConfigRequest);
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.yamlString =
            object.yamlString !== undefined && object.yamlString !== null
                ? String(object.yamlString)
                : undefined;
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.yamlString !== undefined && (obj.yamlString = message.yamlString);
        message.name !== undefined && (obj.name = message.name);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseCreateConfigRequest);
        message.folderId = (_a = object.folderId) !== null && _a !== void 0 ? _a : '';
        message.yamlString = (_b = object.yamlString) !== null && _b !== void 0 ? _b : undefined;
        message.name = (_c = object.name) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
const baseCreateConfigMetadata = { configId: '' };
exports.CreateConfigMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.configId !== '') {
            writer.uint32(10).string(message.configId);
        }
        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({}, baseCreateConfigMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.configId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateConfigMetadata);
        message.configId =
            object.configId !== undefined && object.configId !== null
                ? String(object.configId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.configId !== undefined && (obj.configId = message.configId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateConfigMetadata);
        message.configId = (_a = object.configId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetConfigRequest = { configId: '' };
exports.GetConfigRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.configId !== '') {
            writer.uint32(10).string(message.configId);
        }
        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({}, baseGetConfigRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.configId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetConfigRequest);
        message.configId =
            object.configId !== undefined && object.configId !== null
                ? String(object.configId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.configId !== undefined && (obj.configId = message.configId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetConfigRequest);
        message.configId = (_a = object.configId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListConfigsRequest = { folderId: '', pageSize: 0, pageToken: '', filter: '' };
exports.ListConfigsRequest = {
    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({}, baseListConfigsRequest);
        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({}, baseListConfigsRequest);
        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({}, baseListConfigsRequest);
        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 baseListConfigsResponse = { nextPageToken: '' };
exports.ListConfigsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.configs) {
            config_1.Config.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({}, baseListConfigsResponse);
        message.configs = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.configs.push(config_1.Config.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({}, baseListConfigsResponse);
        message.configs = ((_a = object.configs) !== null && _a !== void 0 ? _a : []).map((e) => config_1.Config.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.configs) {
            obj.configs = message.configs.map((e) => (e ? config_1.Config.toJSON(e) : undefined));
        }
        else {
            obj.configs = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListConfigsResponse);
        message.configs = ((_a = object.configs) === null || _a === void 0 ? void 0 : _a.map((e) => config_1.Config.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseDeleteConfigRequest = { configId: '' };
exports.DeleteConfigRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.configId !== '') {
            writer.uint32(10).string(message.configId);
        }
        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({}, baseDeleteConfigRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.configId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteConfigRequest);
        message.configId =
            object.configId !== undefined && object.configId !== null
                ? String(object.configId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.configId !== undefined && (obj.configId = message.configId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteConfigRequest);
        message.configId = (_a = object.configId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteConfigMetadata = { configId: '' };
exports.DeleteConfigMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.configId !== '') {
            writer.uint32(10).string(message.configId);
        }
        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({}, baseDeleteConfigMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.configId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteConfigMetadata);
        message.configId =
            object.configId !== undefined && object.configId !== null
                ? String(object.configId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.configId !== undefined && (obj.configId = message.configId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteConfigMetadata);
        message.configId = (_a = object.configId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
/** A set of methods for managing test configurations. */
exports.ConfigServiceService = {
    /** Creates a test config in the specified folder. */
    create: {
        path: '/yandex.cloud.loadtesting.api.v1.ConfigService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreateConfigRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreateConfigRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Returns the specified config.
     *
     * To get the list of all available configs, make a [List] request.
     */
    get: {
        path: '/yandex.cloud.loadtesting.api.v1.ConfigService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetConfigRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetConfigRequest.decode(value),
        responseSerialize: (value) => Buffer.from(config_1.Config.encode(value).finish()),
        responseDeserialize: (value) => config_1.Config.decode(value),
    },
    /** Retrieves the list of configs in the specified folder. */
    list: {
        path: '/yandex.cloud.loadtesting.api.v1.ConfigService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListConfigsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListConfigsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListConfigsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListConfigsResponse.decode(value),
    },
    /** Deletes the specified config. */
    delete: {
        path: '/yandex.cloud.loadtesting.api.v1.ConfigService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeleteConfigRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeleteConfigRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
};
exports.ConfigServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.ConfigServiceService, 'yandex.cloud.loadtesting.api.v1.ConfigService');
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();
}
