"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgentServiceClient = exports.AgentServiceService = exports.UpdateAgentMetadata = exports.UpdateAgentRequest_LabelsEntry = exports.UpdateAgentRequest = exports.ListAgentsResponse = exports.ListAgentsRequest = exports.DeleteAgentMetadata = exports.DeleteAgentRequest = exports.GetAgentRequest = exports.CreateAgentMetadata = exports.CreateAgentRequest_LabelsEntry = exports.CreateAgentRequest = 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 create_compute_instance_1 = require("../../../../../yandex/cloud/loadtesting/api/v1/agent/create_compute_instance");
const log_settings_1 = require("../../../../../yandex/cloud/loadtesting/api/v1/agent/log_settings");
const field_mask_1 = require("../../../../../google/protobuf/field_mask");
const agent_1 = require("../../../../../yandex/cloud/loadtesting/api/v1/agent/agent");
const operation_1 = require("../../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.loadtesting.api.v1';
const baseCreateAgentRequest = {
    folderId: '',
    name: '',
    description: '',
    agentVersion: '',
};
exports.CreateAgentRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.folderId !== '') {
            writer.uint32(10).string(message.folderId);
        }
        if (message.name !== '') {
            writer.uint32(18).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(26).string(message.description);
        }
        if (message.computeInstanceParams !== undefined) {
            create_compute_instance_1.CreateComputeInstance.encode(message.computeInstanceParams, writer.uint32(34).fork()).ldelim();
        }
        if (message.agentVersion !== '') {
            writer.uint32(42).string(message.agentVersion);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.CreateAgentRequest_LabelsEntry.encode({ key: key, value }, writer.uint32(50).fork()).ldelim();
        });
        if (message.logSettings !== undefined) {
            log_settings_1.LogSettings.encode(message.logSettings, writer.uint32(58).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({}, baseCreateAgentRequest);
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.folderId = reader.string();
                    break;
                case 2:
                    message.name = reader.string();
                    break;
                case 3:
                    message.description = reader.string();
                    break;
                case 4:
                    message.computeInstanceParams = create_compute_instance_1.CreateComputeInstance.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.agentVersion = reader.string();
                    break;
                case 6:
                    const entry6 = exports.CreateAgentRequest_LabelsEntry.decode(reader, reader.uint32());
                    if (entry6.value !== undefined) {
                        message.labels[entry6.key] = entry6.value;
                    }
                    break;
                case 7:
                    message.logSettings = log_settings_1.LogSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCreateAgentRequest);
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.computeInstanceParams =
            object.computeInstanceParams !== undefined && object.computeInstanceParams !== null
                ? create_compute_instance_1.CreateComputeInstance.fromJSON(object.computeInstanceParams)
                : undefined;
        message.agentVersion =
            object.agentVersion !== undefined && object.agentVersion !== null
                ? String(object.agentVersion)
                : '';
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.logSettings =
            object.logSettings !== undefined && object.logSettings !== null
                ? log_settings_1.LogSettings.fromJSON(object.logSettings)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.computeInstanceParams !== undefined &&
            (obj.computeInstanceParams = message.computeInstanceParams
                ? create_compute_instance_1.CreateComputeInstance.toJSON(message.computeInstanceParams)
                : undefined);
        message.agentVersion !== undefined && (obj.agentVersion = message.agentVersion);
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.logSettings !== undefined &&
            (obj.logSettings = message.logSettings
                ? log_settings_1.LogSettings.toJSON(message.logSettings)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e;
        const message = Object.assign({}, baseCreateAgentRequest);
        message.folderId = (_a = object.folderId) !== null && _a !== void 0 ? _a : '';
        message.name = (_b = object.name) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.computeInstanceParams =
            object.computeInstanceParams !== undefined && object.computeInstanceParams !== null
                ? create_compute_instance_1.CreateComputeInstance.fromPartial(object.computeInstanceParams)
                : undefined;
        message.agentVersion = (_d = object.agentVersion) !== null && _d !== void 0 ? _d : '';
        message.labels = Object.entries((_e = object.labels) !== null && _e !== void 0 ? _e : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.logSettings =
            object.logSettings !== undefined && object.logSettings !== null
                ? log_settings_1.LogSettings.fromPartial(object.logSettings)
                : undefined;
        return message;
    },
};
const baseCreateAgentRequest_LabelsEntry = { key: '', value: '' };
exports.CreateAgentRequest_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({}, baseCreateAgentRequest_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({}, baseCreateAgentRequest_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({}, baseCreateAgentRequest_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseCreateAgentMetadata = { agentId: '' };
exports.CreateAgentMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.agentId !== '') {
            writer.uint32(10).string(message.agentId);
        }
        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({}, baseCreateAgentMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.agentId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateAgentMetadata);
        message.agentId =
            object.agentId !== undefined && object.agentId !== null ? String(object.agentId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.agentId !== undefined && (obj.agentId = message.agentId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateAgentMetadata);
        message.agentId = (_a = object.agentId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetAgentRequest = { agentId: '' };
exports.GetAgentRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.agentId !== '') {
            writer.uint32(18).string(message.agentId);
        }
        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({}, baseGetAgentRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    message.agentId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetAgentRequest);
        message.agentId =
            object.agentId !== undefined && object.agentId !== null ? String(object.agentId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.agentId !== undefined && (obj.agentId = message.agentId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetAgentRequest);
        message.agentId = (_a = object.agentId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteAgentRequest = { agentId: '' };
exports.DeleteAgentRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.agentId !== '') {
            writer.uint32(10).string(message.agentId);
        }
        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({}, baseDeleteAgentRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.agentId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteAgentRequest);
        message.agentId =
            object.agentId !== undefined && object.agentId !== null ? String(object.agentId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.agentId !== undefined && (obj.agentId = message.agentId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteAgentRequest);
        message.agentId = (_a = object.agentId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseDeleteAgentMetadata = { agentId: '' };
exports.DeleteAgentMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.agentId !== '') {
            writer.uint32(10).string(message.agentId);
        }
        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({}, baseDeleteAgentMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.agentId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeleteAgentMetadata);
        message.agentId =
            object.agentId !== undefined && object.agentId !== null ? String(object.agentId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.agentId !== undefined && (obj.agentId = message.agentId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDeleteAgentMetadata);
        message.agentId = (_a = object.agentId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListAgentsRequest = { folderId: '', pageSize: 0, pageToken: '', filter: '' };
exports.ListAgentsRequest = {
    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({}, baseListAgentsRequest);
        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({}, baseListAgentsRequest);
        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({}, baseListAgentsRequest);
        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 baseListAgentsResponse = { nextPageToken: '' };
exports.ListAgentsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.agents) {
            agent_1.Agent.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({}, baseListAgentsResponse);
        message.agents = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.agents.push(agent_1.Agent.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({}, baseListAgentsResponse);
        message.agents = ((_a = object.agents) !== null && _a !== void 0 ? _a : []).map((e) => agent_1.Agent.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.agents) {
            obj.agents = message.agents.map((e) => (e ? agent_1.Agent.toJSON(e) : undefined));
        }
        else {
            obj.agents = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListAgentsResponse);
        message.agents = ((_a = object.agents) === null || _a === void 0 ? void 0 : _a.map((e) => agent_1.Agent.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseUpdateAgentRequest = { agentId: '', name: '', description: '' };
exports.UpdateAgentRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.agentId !== '') {
            writer.uint32(10).string(message.agentId);
        }
        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.computeInstanceParams !== undefined) {
            create_compute_instance_1.CreateComputeInstance.encode(message.computeInstanceParams, writer.uint32(42).fork()).ldelim();
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.UpdateAgentRequest_LabelsEntry.encode({ key: key, value }, writer.uint32(50).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({}, baseUpdateAgentRequest);
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.agentId = 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 5:
                    message.computeInstanceParams = create_compute_instance_1.CreateComputeInstance.decode(reader, reader.uint32());
                    break;
                case 6:
                    const entry6 = exports.UpdateAgentRequest_LabelsEntry.decode(reader, reader.uint32());
                    if (entry6.value !== undefined) {
                        message.labels[entry6.key] = entry6.value;
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseUpdateAgentRequest);
        message.agentId =
            object.agentId !== undefined && object.agentId !== null ? String(object.agentId) : '';
        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.computeInstanceParams =
            object.computeInstanceParams !== undefined && object.computeInstanceParams !== null
                ? create_compute_instance_1.CreateComputeInstance.fromJSON(object.computeInstanceParams)
                : undefined;
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.agentId !== undefined && (obj.agentId = message.agentId);
        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.computeInstanceParams !== undefined &&
            (obj.computeInstanceParams = message.computeInstanceParams
                ? create_compute_instance_1.CreateComputeInstance.toJSON(message.computeInstanceParams)
                : undefined);
        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;
        const message = Object.assign({}, baseUpdateAgentRequest);
        message.agentId = (_a = object.agentId) !== 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.computeInstanceParams =
            object.computeInstanceParams !== undefined && object.computeInstanceParams !== null
                ? create_compute_instance_1.CreateComputeInstance.fromPartial(object.computeInstanceParams)
                : undefined;
        message.labels = Object.entries((_d = object.labels) !== null && _d !== void 0 ? _d : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        return message;
    },
};
const baseUpdateAgentRequest_LabelsEntry = { key: '', value: '' };
exports.UpdateAgentRequest_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({}, baseUpdateAgentRequest_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({}, baseUpdateAgentRequest_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({}, baseUpdateAgentRequest_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseUpdateAgentMetadata = { agentId: '' };
exports.UpdateAgentMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.agentId !== '') {
            writer.uint32(10).string(message.agentId);
        }
        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({}, baseUpdateAgentMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.agentId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdateAgentMetadata);
        message.agentId =
            object.agentId !== undefined && object.agentId !== null ? String(object.agentId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.agentId !== undefined && (obj.agentId = message.agentId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseUpdateAgentMetadata);
        message.agentId = (_a = object.agentId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
/** A set of methods for managing Load Testing agents. */
exports.AgentServiceService = {
    /**
     * Creates an agent in the specified folder.
     *
     * Also creates a corresponding compute instance.
     */
    create: {
        path: '/yandex.cloud.loadtesting.api.v1.AgentService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreateAgentRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreateAgentRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /**
     * Returns the specified agent.
     *
     * To get the list of all available agents, make a [List] request.
     */
    get: {
        path: '/yandex.cloud.loadtesting.api.v1.AgentService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetAgentRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetAgentRequest.decode(value),
        responseSerialize: (value) => Buffer.from(agent_1.Agent.encode(value).finish()),
        responseDeserialize: (value) => agent_1.Agent.decode(value),
    },
    /** Retrieves the list of agents in the specified folder. */
    list: {
        path: '/yandex.cloud.loadtesting.api.v1.AgentService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListAgentsRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListAgentsRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListAgentsResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListAgentsResponse.decode(value),
    },
    /**
     * Deletes the specified agent.
     *
     * Also deletes a corresponding compute instance.
     */
    delete: {
        path: '/yandex.cloud.loadtesting.api.v1.AgentService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeleteAgentRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeleteAgentRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Updates the specified agent. */
    update: {
        path: '/yandex.cloud.loadtesting.api.v1.AgentService/Update',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.UpdateAgentRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.UpdateAgentRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
};
exports.AgentServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.AgentServiceService, 'yandex.cloud.loadtesting.api.v1.AgentService');
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();
}
