"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Agent_LabelsEntry = exports.Agent = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const status_1 = require("../../../../../../yandex/cloud/loadtesting/api/v1/agent/status");
const log_settings_1 = require("../../../../../../yandex/cloud/loadtesting/api/v1/agent/log_settings");
exports.protobufPackage = 'yandex.cloud.loadtesting.api.v1.agent';
const baseAgent = {
    id: '',
    folderId: '',
    name: '',
    description: '',
    computeInstanceId: '',
    status: 0,
    errors: '',
    currentJobId: '',
    agentVersionId: '',
};
exports.Agent = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        if (message.name !== '') {
            writer.uint32(26).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        if (message.computeInstanceId !== '') {
            writer.uint32(42).string(message.computeInstanceId);
        }
        if (message.status !== 0) {
            writer.uint32(56).int32(message.status);
        }
        for (const v of message.errors) {
            writer.uint32(66).string(v);
        }
        if (message.currentJobId !== '') {
            writer.uint32(74).string(message.currentJobId);
        }
        if (message.agentVersionId !== '') {
            writer.uint32(82).string(message.agentVersionId);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.Agent_LabelsEntry.encode({ key: key, value }, writer.uint32(98).fork()).ldelim();
        });
        if (message.logSettings !== undefined) {
            log_settings_1.LogSettings.encode(message.logSettings, writer.uint32(106).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({}, baseAgent);
        message.errors = [];
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 3:
                    message.name = reader.string();
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                case 5:
                    message.computeInstanceId = reader.string();
                    break;
                case 7:
                    message.status = reader.int32();
                    break;
                case 8:
                    message.errors.push(reader.string());
                    break;
                case 9:
                    message.currentJobId = reader.string();
                    break;
                case 10:
                    message.agentVersionId = reader.string();
                    break;
                case 12:
                    const entry12 = exports.Agent_LabelsEntry.decode(reader, reader.uint32());
                    if (entry12.value !== undefined) {
                        message.labels[entry12.key] = entry12.value;
                    }
                    break;
                case 13:
                    message.logSettings = log_settings_1.LogSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b;
        const message = Object.assign({}, baseAgent);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        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.computeInstanceId =
            object.computeInstanceId !== undefined && object.computeInstanceId !== null
                ? String(object.computeInstanceId)
                : '';
        message.status =
            object.status !== undefined && object.status !== null
                ? (0, status_1.statusFromJSON)(object.status)
                : 0;
        message.errors = ((_a = object.errors) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        message.currentJobId =
            object.currentJobId !== undefined && object.currentJobId !== null
                ? String(object.currentJobId)
                : '';
        message.agentVersionId =
            object.agentVersionId !== undefined && object.agentVersionId !== null
                ? String(object.agentVersionId)
                : '';
        message.labels = Object.entries((_b = object.labels) !== null && _b !== void 0 ? _b : {}).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.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.computeInstanceId !== undefined &&
            (obj.computeInstanceId = message.computeInstanceId);
        message.status !== undefined && (obj.status = (0, status_1.statusToJSON)(message.status));
        if (message.errors) {
            obj.errors = message.errors.map((e) => e);
        }
        else {
            obj.errors = [];
        }
        message.currentJobId !== undefined && (obj.currentJobId = message.currentJobId);
        message.agentVersionId !== undefined && (obj.agentVersionId = message.agentVersionId);
        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, _f, _g, _h, _j, _k;
        const message = Object.assign({}, baseAgent);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.name = (_c = object.name) !== null && _c !== void 0 ? _c : '';
        message.description = (_d = object.description) !== null && _d !== void 0 ? _d : '';
        message.computeInstanceId = (_e = object.computeInstanceId) !== null && _e !== void 0 ? _e : '';
        message.status = (_f = object.status) !== null && _f !== void 0 ? _f : 0;
        message.errors = ((_g = object.errors) === null || _g === void 0 ? void 0 : _g.map((e) => e)) || [];
        message.currentJobId = (_h = object.currentJobId) !== null && _h !== void 0 ? _h : '';
        message.agentVersionId = (_j = object.agentVersionId) !== null && _j !== void 0 ? _j : '';
        message.labels = Object.entries((_k = object.labels) !== null && _k !== void 0 ? _k : {}).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 baseAgent_LabelsEntry = { key: '', value: '' };
exports.Agent_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({}, baseAgent_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({}, baseAgent_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({}, baseAgent_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
