"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScheduledMaintenance = exports.WeeklyMaintenanceWindow = exports.DaysOfWeekMaintenanceWindow = exports.DailyMaintenanceWindow = exports.AnytimeMaintenanceWindow = exports.MaintenanceWindow = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const timeofday_1 = require("../../../../google/type/timeofday");
const duration_1 = require("../../../../google/protobuf/duration");
const timestamp_1 = require("../../../../google/protobuf/timestamp");
const dayofweek_1 = require("../../../../google/type/dayofweek");
exports.protobufPackage = 'yandex.cloud.k8s.v1';
const baseMaintenanceWindow = {};
exports.MaintenanceWindow = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.anytime !== undefined) {
            exports.AnytimeMaintenanceWindow.encode(message.anytime, writer.uint32(10).fork()).ldelim();
        }
        if (message.dailyMaintenanceWindow !== undefined) {
            exports.DailyMaintenanceWindow.encode(message.dailyMaintenanceWindow, writer.uint32(18).fork()).ldelim();
        }
        if (message.weeklyMaintenanceWindow !== undefined) {
            exports.WeeklyMaintenanceWindow.encode(message.weeklyMaintenanceWindow, 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({}, baseMaintenanceWindow);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.anytime = exports.AnytimeMaintenanceWindow.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.dailyMaintenanceWindow = exports.DailyMaintenanceWindow.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.weeklyMaintenanceWindow = exports.WeeklyMaintenanceWindow.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseMaintenanceWindow);
        message.anytime =
            object.anytime !== undefined && object.anytime !== null
                ? exports.AnytimeMaintenanceWindow.fromJSON(object.anytime)
                : undefined;
        message.dailyMaintenanceWindow =
            object.dailyMaintenanceWindow !== undefined && object.dailyMaintenanceWindow !== null
                ? exports.DailyMaintenanceWindow.fromJSON(object.dailyMaintenanceWindow)
                : undefined;
        message.weeklyMaintenanceWindow =
            object.weeklyMaintenanceWindow !== undefined && object.weeklyMaintenanceWindow !== null
                ? exports.WeeklyMaintenanceWindow.fromJSON(object.weeklyMaintenanceWindow)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.anytime !== undefined &&
            (obj.anytime = message.anytime
                ? exports.AnytimeMaintenanceWindow.toJSON(message.anytime)
                : undefined);
        message.dailyMaintenanceWindow !== undefined &&
            (obj.dailyMaintenanceWindow = message.dailyMaintenanceWindow
                ? exports.DailyMaintenanceWindow.toJSON(message.dailyMaintenanceWindow)
                : undefined);
        message.weeklyMaintenanceWindow !== undefined &&
            (obj.weeklyMaintenanceWindow = message.weeklyMaintenanceWindow
                ? exports.WeeklyMaintenanceWindow.toJSON(message.weeklyMaintenanceWindow)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseMaintenanceWindow);
        message.anytime =
            object.anytime !== undefined && object.anytime !== null
                ? exports.AnytimeMaintenanceWindow.fromPartial(object.anytime)
                : undefined;
        message.dailyMaintenanceWindow =
            object.dailyMaintenanceWindow !== undefined && object.dailyMaintenanceWindow !== null
                ? exports.DailyMaintenanceWindow.fromPartial(object.dailyMaintenanceWindow)
                : undefined;
        message.weeklyMaintenanceWindow =
            object.weeklyMaintenanceWindow !== undefined && object.weeklyMaintenanceWindow !== null
                ? exports.WeeklyMaintenanceWindow.fromPartial(object.weeklyMaintenanceWindow)
                : undefined;
        return message;
    },
};
const baseAnytimeMaintenanceWindow = {};
exports.AnytimeMaintenanceWindow = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, baseAnytimeMaintenanceWindow);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseAnytimeMaintenanceWindow);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseAnytimeMaintenanceWindow);
        return message;
    },
};
const baseDailyMaintenanceWindow = {};
exports.DailyMaintenanceWindow = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.startTime !== undefined) {
            timeofday_1.TimeOfDay.encode(message.startTime, writer.uint32(10).fork()).ldelim();
        }
        if (message.duration !== undefined) {
            duration_1.Duration.encode(message.duration, writer.uint32(18).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({}, baseDailyMaintenanceWindow);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.startTime = timeofday_1.TimeOfDay.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.duration = duration_1.Duration.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDailyMaintenanceWindow);
        message.startTime =
            object.startTime !== undefined && object.startTime !== null
                ? timeofday_1.TimeOfDay.fromJSON(object.startTime)
                : undefined;
        message.duration =
            object.duration !== undefined && object.duration !== null
                ? duration_1.Duration.fromJSON(object.duration)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.startTime !== undefined &&
            (obj.startTime = message.startTime ? timeofday_1.TimeOfDay.toJSON(message.startTime) : undefined);
        message.duration !== undefined &&
            (obj.duration = message.duration ? duration_1.Duration.toJSON(message.duration) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseDailyMaintenanceWindow);
        message.startTime =
            object.startTime !== undefined && object.startTime !== null
                ? timeofday_1.TimeOfDay.fromPartial(object.startTime)
                : undefined;
        message.duration =
            object.duration !== undefined && object.duration !== null
                ? duration_1.Duration.fromPartial(object.duration)
                : undefined;
        return message;
    },
};
const baseDaysOfWeekMaintenanceWindow = { days: 0 };
exports.DaysOfWeekMaintenanceWindow = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        writer.uint32(10).fork();
        for (const v of message.days) {
            writer.int32(v);
        }
        writer.ldelim();
        if (message.startTime !== undefined) {
            timeofday_1.TimeOfDay.encode(message.startTime, writer.uint32(18).fork()).ldelim();
        }
        if (message.duration !== undefined) {
            duration_1.Duration.encode(message.duration, 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({}, baseDaysOfWeekMaintenanceWindow);
        message.days = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if ((tag & 7) === 2) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.days.push(reader.int32());
                        }
                    }
                    else {
                        message.days.push(reader.int32());
                    }
                    break;
                case 2:
                    message.startTime = timeofday_1.TimeOfDay.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.duration = duration_1.Duration.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseDaysOfWeekMaintenanceWindow);
        message.days = ((_a = object.days) !== null && _a !== void 0 ? _a : []).map((e) => (0, dayofweek_1.dayOfWeekFromJSON)(e));
        message.startTime =
            object.startTime !== undefined && object.startTime !== null
                ? timeofday_1.TimeOfDay.fromJSON(object.startTime)
                : undefined;
        message.duration =
            object.duration !== undefined && object.duration !== null
                ? duration_1.Duration.fromJSON(object.duration)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.days) {
            obj.days = message.days.map((e) => (0, dayofweek_1.dayOfWeekToJSON)(e));
        }
        else {
            obj.days = [];
        }
        message.startTime !== undefined &&
            (obj.startTime = message.startTime ? timeofday_1.TimeOfDay.toJSON(message.startTime) : undefined);
        message.duration !== undefined &&
            (obj.duration = message.duration ? duration_1.Duration.toJSON(message.duration) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseDaysOfWeekMaintenanceWindow);
        message.days = ((_a = object.days) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        message.startTime =
            object.startTime !== undefined && object.startTime !== null
                ? timeofday_1.TimeOfDay.fromPartial(object.startTime)
                : undefined;
        message.duration =
            object.duration !== undefined && object.duration !== null
                ? duration_1.Duration.fromPartial(object.duration)
                : undefined;
        return message;
    },
};
const baseWeeklyMaintenanceWindow = {};
exports.WeeklyMaintenanceWindow = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.daysOfWeek) {
            exports.DaysOfWeekMaintenanceWindow.encode(v, writer.uint32(10).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({}, baseWeeklyMaintenanceWindow);
        message.daysOfWeek = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.daysOfWeek.push(exports.DaysOfWeekMaintenanceWindow.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseWeeklyMaintenanceWindow);
        message.daysOfWeek = ((_a = object.daysOfWeek) !== null && _a !== void 0 ? _a : []).map((e) => exports.DaysOfWeekMaintenanceWindow.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.daysOfWeek) {
            obj.daysOfWeek = message.daysOfWeek.map((e) => e ? exports.DaysOfWeekMaintenanceWindow.toJSON(e) : undefined);
        }
        else {
            obj.daysOfWeek = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseWeeklyMaintenanceWindow);
        message.daysOfWeek =
            ((_a = object.daysOfWeek) === null || _a === void 0 ? void 0 : _a.map((e) => exports.DaysOfWeekMaintenanceWindow.fromPartial(e))) || [];
        return message;
    },
};
const baseScheduledMaintenance = { description: '' };
exports.ScheduledMaintenance = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.delayedUntil !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.delayedUntil), writer.uint32(10).fork()).ldelim();
        }
        if (message.availableFrom !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.availableFrom), writer.uint32(18).fork()).ldelim();
        }
        if (message.noLaterThan !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.noLaterThan), writer.uint32(26).fork()).ldelim();
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        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({}, baseScheduledMaintenance);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.delayedUntil = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.availableFrom = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.noLaterThan = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseScheduledMaintenance);
        message.delayedUntil =
            object.delayedUntil !== undefined && object.delayedUntil !== null
                ? fromJsonTimestamp(object.delayedUntil)
                : undefined;
        message.availableFrom =
            object.availableFrom !== undefined && object.availableFrom !== null
                ? fromJsonTimestamp(object.availableFrom)
                : undefined;
        message.noLaterThan =
            object.noLaterThan !== undefined && object.noLaterThan !== null
                ? fromJsonTimestamp(object.noLaterThan)
                : undefined;
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.delayedUntil !== undefined &&
            (obj.delayedUntil = message.delayedUntil.toISOString());
        message.availableFrom !== undefined &&
            (obj.availableFrom = message.availableFrom.toISOString());
        message.noLaterThan !== undefined && (obj.noLaterThan = message.noLaterThan.toISOString());
        message.description !== undefined && (obj.description = message.description);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseScheduledMaintenance);
        message.delayedUntil = (_a = object.delayedUntil) !== null && _a !== void 0 ? _a : undefined;
        message.availableFrom = (_b = object.availableFrom) !== null && _b !== void 0 ? _b : undefined;
        message.noLaterThan = (_c = object.noLaterThan) !== null && _c !== void 0 ? _c : undefined;
        message.description = (_d = object.description) !== null && _d !== void 0 ? _d : '';
        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();
}
