"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceAgent = exports.Service = exports.service_StatusToJSON = exports.service_StatusFromJSON = exports.Service_Status = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const resource_1 = require("../../../../yandex/cloud/iam/v1/resource");
const timestamp_1 = require("../../../../google/protobuf/timestamp");
exports.protobufPackage = 'yandex.cloud.iam.v1';
var Service_Status;
(function (Service_Status) {
    Service_Status[Service_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    /** ENABLED - The service is enabled. */
    Service_Status[Service_Status["ENABLED"] = 1] = "ENABLED";
    /** PAUSED - The service is paused. */
    Service_Status[Service_Status["PAUSED"] = 2] = "PAUSED";
    /** DISABLED - The service is disabled. */
    Service_Status[Service_Status["DISABLED"] = 3] = "DISABLED";
    /** ENABLING - The service is being enabled. */
    Service_Status[Service_Status["ENABLING"] = 4] = "ENABLING";
    /** RESUMING - The service is being resumed. */
    Service_Status[Service_Status["RESUMING"] = 5] = "RESUMING";
    /** PAUSING - The service is being paused. */
    Service_Status[Service_Status["PAUSING"] = 6] = "PAUSING";
    /** DISABLING - The service is being disabled. */
    Service_Status[Service_Status["DISABLING"] = 7] = "DISABLING";
    /** ERROR - The service is in error state. */
    Service_Status[Service_Status["ERROR"] = 8] = "ERROR";
    /** DEFAULT - The service could be auto enabled. */
    Service_Status[Service_Status["DEFAULT"] = 9] = "DEFAULT";
    Service_Status[Service_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Service_Status = exports.Service_Status || (exports.Service_Status = {}));
function service_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return Service_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'ENABLED':
            return Service_Status.ENABLED;
        case 2:
        case 'PAUSED':
            return Service_Status.PAUSED;
        case 3:
        case 'DISABLED':
            return Service_Status.DISABLED;
        case 4:
        case 'ENABLING':
            return Service_Status.ENABLING;
        case 5:
        case 'RESUMING':
            return Service_Status.RESUMING;
        case 6:
        case 'PAUSING':
            return Service_Status.PAUSING;
        case 7:
        case 'DISABLING':
            return Service_Status.DISABLING;
        case 8:
        case 'ERROR':
            return Service_Status.ERROR;
        case 9:
        case 'DEFAULT':
            return Service_Status.DEFAULT;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return Service_Status.UNRECOGNIZED;
    }
}
exports.service_StatusFromJSON = service_StatusFromJSON;
function service_StatusToJSON(object) {
    switch (object) {
        case Service_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case Service_Status.ENABLED:
            return 'ENABLED';
        case Service_Status.PAUSED:
            return 'PAUSED';
        case Service_Status.DISABLED:
            return 'DISABLED';
        case Service_Status.ENABLING:
            return 'ENABLING';
        case Service_Status.RESUMING:
            return 'RESUMING';
        case Service_Status.PAUSING:
            return 'PAUSING';
        case Service_Status.DISABLING:
            return 'DISABLING';
        case Service_Status.ERROR:
            return 'ERROR';
        case Service_Status.DEFAULT:
            return 'DEFAULT';
        default:
            return 'UNKNOWN';
    }
}
exports.service_StatusToJSON = service_StatusToJSON;
const baseService = { serviceId: '', status: 0 };
exports.Service = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.serviceId !== '') {
            writer.uint32(10).string(message.serviceId);
        }
        if (message.resource !== undefined) {
            resource_1.Resource.encode(message.resource, writer.uint32(18).fork()).ldelim();
        }
        if (message.updatedAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(26).fork()).ldelim();
        }
        if (message.status !== 0) {
            writer.uint32(32).int32(message.status);
        }
        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({}, baseService);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.serviceId = reader.string();
                    break;
                case 2:
                    message.resource = resource_1.Resource.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.updatedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.status = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseService);
        message.serviceId =
            object.serviceId !== undefined && object.serviceId !== null
                ? String(object.serviceId)
                : '';
        message.resource =
            object.resource !== undefined && object.resource !== null
                ? resource_1.Resource.fromJSON(object.resource)
                : undefined;
        message.updatedAt =
            object.updatedAt !== undefined && object.updatedAt !== null
                ? fromJsonTimestamp(object.updatedAt)
                : undefined;
        message.status =
            object.status !== undefined && object.status !== null
                ? service_StatusFromJSON(object.status)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.serviceId !== undefined && (obj.serviceId = message.serviceId);
        message.resource !== undefined &&
            (obj.resource = message.resource ? resource_1.Resource.toJSON(message.resource) : undefined);
        message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString());
        message.status !== undefined && (obj.status = service_StatusToJSON(message.status));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseService);
        message.serviceId = (_a = object.serviceId) !== null && _a !== void 0 ? _a : '';
        message.resource =
            object.resource !== undefined && object.resource !== null
                ? resource_1.Resource.fromPartial(object.resource)
                : undefined;
        message.updatedAt = (_b = object.updatedAt) !== null && _b !== void 0 ? _b : undefined;
        message.status = (_c = object.status) !== null && _c !== void 0 ? _c : 0;
        return message;
    },
};
const baseServiceAgent = { serviceAccountId: '', serviceId: '', microserviceId: '' };
exports.ServiceAgent = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.serviceAccountId !== '') {
            writer.uint32(10).string(message.serviceAccountId);
        }
        if (message.serviceId !== '') {
            writer.uint32(18).string(message.serviceId);
        }
        if (message.microserviceId !== '') {
            writer.uint32(26).string(message.microserviceId);
        }
        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({}, baseServiceAgent);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.serviceAccountId = reader.string();
                    break;
                case 2:
                    message.serviceId = reader.string();
                    break;
                case 3:
                    message.microserviceId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseServiceAgent);
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.serviceId =
            object.serviceId !== undefined && object.serviceId !== null
                ? String(object.serviceId)
                : '';
        message.microserviceId =
            object.microserviceId !== undefined && object.microserviceId !== null
                ? String(object.microserviceId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        message.serviceId !== undefined && (obj.serviceId = message.serviceId);
        message.microserviceId !== undefined && (obj.microserviceId = message.microserviceId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseServiceAgent);
        message.serviceAccountId = (_a = object.serviceAccountId) !== null && _a !== void 0 ? _a : '';
        message.serviceId = (_b = object.serviceId) !== null && _b !== void 0 ? _b : '';
        message.microserviceId = (_c = object.microserviceId) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
function toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = t.seconds * 1000;
    millis += t.nanos / 1000000;
    return new Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof Date) {
        return o;
    }
    else if (typeof o === 'string') {
        return new Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
