"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LockServiceClient = exports.LockServiceService = exports.GetLockRequest = exports.EnsureLockMetadata = exports.EnsureLockRequest = 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 operation_1 = require("../../../../../../yandex/cloud/operation/operation");
const lock_1 = require("../../../../../../yandex/cloud/marketplace/licensemanager/v1/lock");
exports.protobufPackage = 'yandex.cloud.marketplace.licensemanager.saas.v1';
const baseEnsureLockRequest = { instanceToken: '', resourceId: '' };
exports.EnsureLockRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.instanceToken !== '') {
            writer.uint32(10).string(message.instanceToken);
        }
        if (message.resourceId !== '') {
            writer.uint32(18).string(message.resourceId);
        }
        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({}, baseEnsureLockRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.instanceToken = reader.string();
                    break;
                case 2:
                    message.resourceId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseEnsureLockRequest);
        message.instanceToken =
            object.instanceToken !== undefined && object.instanceToken !== null
                ? String(object.instanceToken)
                : '';
        message.resourceId =
            object.resourceId !== undefined && object.resourceId !== null
                ? String(object.resourceId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.instanceToken !== undefined && (obj.instanceToken = message.instanceToken);
        message.resourceId !== undefined && (obj.resourceId = message.resourceId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseEnsureLockRequest);
        message.instanceToken = (_a = object.instanceToken) !== null && _a !== void 0 ? _a : '';
        message.resourceId = (_b = object.resourceId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseEnsureLockMetadata = { lockId: '' };
exports.EnsureLockMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.lockId !== '') {
            writer.uint32(10).string(message.lockId);
        }
        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({}, baseEnsureLockMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.lockId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseEnsureLockMetadata);
        message.lockId =
            object.lockId !== undefined && object.lockId !== null ? String(object.lockId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.lockId !== undefined && (obj.lockId = message.lockId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseEnsureLockMetadata);
        message.lockId = (_a = object.lockId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseGetLockRequest = { lockId: '' };
exports.GetLockRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.lockId !== '') {
            writer.uint32(10).string(message.lockId);
        }
        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({}, baseGetLockRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.lockId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetLockRequest);
        message.lockId =
            object.lockId !== undefined && object.lockId !== null ? String(object.lockId) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.lockId !== undefined && (obj.lockId = message.lockId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetLockRequest);
        message.lockId = (_a = object.lockId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
/** A set of methods for managing subscription locks. */
exports.LockServiceService = {
    /**
     * Checks if the she specified subscription is already locked to the specified resource.
     * If it is not locked, locks the subscription to the resource.
     */
    ensure: {
        path: '/yandex.cloud.marketplace.licensemanager.saas.v1.LockService/Ensure',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.EnsureLockRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.EnsureLockRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Returns the specified subscription lock. */
    get: {
        path: '/yandex.cloud.marketplace.licensemanager.saas.v1.LockService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetLockRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetLockRequest.decode(value),
        responseSerialize: (value) => Buffer.from(lock_1.Lock.encode(value).finish()),
        responseDeserialize: (value) => lock_1.Lock.decode(value),
    },
};
exports.LockServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.LockServiceService, 'yandex.cloud.marketplace.licensemanager.saas.v1.LockService');
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
