"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TestServiceClient = exports.TestServiceService = exports.ListTestsResponse = exports.ListTestsRequest = exports.DeleteTestMetadata = exports.DeleteTestRequest = exports.StopTestMetadata = exports.StopTestRequest = exports.GetTestRequest = exports.CreateTestMetadata = exports.CreateTestRequest = 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 details_1 = require("../../../../../yandex/cloud/loadtesting/api/v1/test/details");
const single_agent_configuration_1 = require("../../../../../yandex/cloud/loadtesting/api/v1/test/single_agent_configuration");
const test_1 = require("../../../../../yandex/cloud/loadtesting/api/v1/test/test");
const operation_1 = require("../../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.loadtesting.api.v1';
const baseCreateTestRequest = { folderId: '' };
exports.CreateTestRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.folderId !== '') {
            writer.uint32(10).string(message.folderId);
        }
        for (const v of message.configurations) {
            single_agent_configuration_1.SingleAgentConfiguration.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.testDetails !== undefined) {
            details_1.Details.encode(message.testDetails, 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({}, baseCreateTestRequest);
        message.configurations = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.folderId = reader.string();
                    break;
                case 2:
                    message.configurations.push(single_agent_configuration_1.SingleAgentConfiguration.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.testDetails = details_1.Details.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCreateTestRequest);
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.configurations = ((_a = object.configurations) !== null && _a !== void 0 ? _a : []).map((e) => single_agent_configuration_1.SingleAgentConfiguration.fromJSON(e));
        message.testDetails =
            object.testDetails !== undefined && object.testDetails !== null
                ? details_1.Details.fromJSON(object.testDetails)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.folderId !== undefined && (obj.folderId = message.folderId);
        if (message.configurations) {
            obj.configurations = message.configurations.map((e) => e ? single_agent_configuration_1.SingleAgentConfiguration.toJSON(e) : undefined);
        }
        else {
            obj.configurations = [];
        }
        message.testDetails !== undefined &&
            (obj.testDetails = message.testDetails
                ? details_1.Details.toJSON(message.testDetails)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseCreateTestRequest);
        message.folderId = (_a = object.folderId) !== null && _a !== void 0 ? _a : '';
        message.configurations =
            ((_b = object.configurations) === null || _b === void 0 ? void 0 : _b.map((e) => single_agent_configuration_1.SingleAgentConfiguration.fromPartial(e))) || [];
        message.testDetails =
            object.testDetails !== undefined && object.testDetails !== null
                ? details_1.Details.fromPartial(object.testDetails)
                : undefined;
        return message;
    },
};
const baseCreateTestMetadata = { testId: '' };
exports.CreateTestMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.testId !== '') {
            writer.uint32(10).string(message.testId);
        }
        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({}, baseCreateTestMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.testId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateTestMetadata);
        message.testId =
            object.testId !== undefined && object.testId !== null ? String(object.testId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.testId !== undefined && (obj.testId = message.testId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateTestMetadata);
        message.testId = (_a = object.testId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetTestRequest = { testId: '' };
exports.GetTestRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.testId !== '') {
            writer.uint32(10).string(message.testId);
        }
        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({}, baseGetTestRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.testId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetTestRequest);
        message.testId =
            object.testId !== undefined && object.testId !== null ? String(object.testId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.testId !== undefined && (obj.testId = message.testId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetTestRequest);
        message.testId = (_a = object.testId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseStopTestRequest = { testId: '' };
exports.StopTestRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.testId !== '') {
            writer.uint32(10).string(message.testId);
        }
        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({}, baseStopTestRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.testId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseStopTestRequest);
        message.testId =
            object.testId !== undefined && object.testId !== null ? String(object.testId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.testId !== undefined && (obj.testId = message.testId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseStopTestRequest);
        message.testId = (_a = object.testId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseStopTestMetadata = { testId: '' };
exports.StopTestMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.testId !== '') {
            writer.uint32(10).string(message.testId);
        }
        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({}, baseStopTestMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.testId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseStopTestMetadata);
        message.testId =
            object.testId !== undefined && object.testId !== null ? String(object.testId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.testId !== undefined && (obj.testId = message.testId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseStopTestMetadata);
        message.testId = (_a = object.testId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteTestRequest = { testId: '' };
exports.DeleteTestRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.testId !== '') {
            writer.uint32(10).string(message.testId);
        }
        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({}, baseDeleteTestRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.testId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteTestRequest);
        message.testId =
            object.testId !== undefined && object.testId !== null ? String(object.testId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.testId !== undefined && (obj.testId = message.testId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteTestRequest);
        message.testId = (_a = object.testId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteTestMetadata = { testId: '' };
exports.DeleteTestMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.testId !== '') {
            writer.uint32(10).string(message.testId);
        }
        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({}, baseDeleteTestMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.testId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteTestMetadata);
        message.testId =
            object.testId !== undefined && object.testId !== null ? String(object.testId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.testId !== undefined && (obj.testId = message.testId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteTestMetadata);
        message.testId = (_a = object.testId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListTestsRequest = { folderId: '', pageSize: 0, pageToken: '', filter: '' };
exports.ListTestsRequest = {
    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({}, baseListTestsRequest);
        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({}, baseListTestsRequest);
        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({}, baseListTestsRequest);
        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 baseListTestsResponse = { nextPageToken: '' };
exports.ListTestsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.tests) {
            test_1.Test.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({}, baseListTestsResponse);
        message.tests = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.tests.push(test_1.Test.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({}, baseListTestsResponse);
        message.tests = ((_a = object.tests) !== null && _a !== void 0 ? _a : []).map((e) => test_1.Test.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.tests) {
            obj.tests = message.tests.map((e) => (e ? test_1.Test.toJSON(e) : undefined));
        }
        else {
            obj.tests = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListTestsResponse);
        message.tests = ((_a = object.tests) === null || _a === void 0 ? void 0 : _a.map((e) => test_1.Test.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
/** A set of methods for managing tests. */
exports.TestServiceService = {
    /** Creates (runs) a test in the specified folder. */
    create: {
        path: '/yandex.cloud.loadtesting.api.v1.TestService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreateTestRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreateTestRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Returns the specified test.
     *
     * To get the list of all available tests, make a [List] request.
     */
    get: {
        path: '/yandex.cloud.loadtesting.api.v1.TestService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetTestRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetTestRequest.decode(value),
        responseSerialize: (value) => Buffer.from(test_1.Test.encode(value).finish()),
        responseDeserialize: (value) => test_1.Test.decode(value),
    },
    /** Stops the specified test. */
    stop: {
        path: '/yandex.cloud.loadtesting.api.v1.TestService/Stop',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.StopTestRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.StopTestRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Deletes specified tests. */
    delete: {
        path: '/yandex.cloud.loadtesting.api.v1.TestService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeleteTestRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeleteTestRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Retrieves the list of test in the specified folder. */
    list: {
        path: '/yandex.cloud.loadtesting.api.v1.TestService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListTestsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListTestsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListTestsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListTestsResponse.decode(value),
    },
};
exports.TestServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.TestServiceService, 'yandex.cloud.loadtesting.api.v1.TestService');
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();
}
