"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudApplicationServiceClient = exports.CloudApplicationServiceService = exports.ResolveByWorkloadResponse = exports.ResolveByWorkloadRequest = exports.resolveByWorkloadRequest_WorkloadTypeToJSON = exports.resolveByWorkloadRequest_WorkloadTypeFromJSON = exports.ResolveByWorkloadRequest_WorkloadType = 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 cloud_application_1 = require("../../../../../yandex/cloud/cloudapps/workload/v1/cloud_application");
const empty_1 = require("../../../../../google/protobuf/empty");
exports.protobufPackage = 'yandex.cloud.cloudapps.workload.v1';
var ResolveByWorkloadRequest_WorkloadType;
(function (ResolveByWorkloadRequest_WorkloadType) {
    ResolveByWorkloadRequest_WorkloadType[ResolveByWorkloadRequest_WorkloadType["WORKLOAD_TYPE_UNSPECIFIED"] = 0] = "WORKLOAD_TYPE_UNSPECIFIED";
    /** COMPUTE_INSTANCE - Compute Instance */
    ResolveByWorkloadRequest_WorkloadType[ResolveByWorkloadRequest_WorkloadType["COMPUTE_INSTANCE"] = 1] = "COMPUTE_INSTANCE";
    ResolveByWorkloadRequest_WorkloadType[ResolveByWorkloadRequest_WorkloadType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(ResolveByWorkloadRequest_WorkloadType = exports.ResolveByWorkloadRequest_WorkloadType || (exports.ResolveByWorkloadRequest_WorkloadType = {}));
function resolveByWorkloadRequest_WorkloadTypeFromJSON(object) {
    switch (object) {
        case 0:
        case 'WORKLOAD_TYPE_UNSPECIFIED':
            return ResolveByWorkloadRequest_WorkloadType.WORKLOAD_TYPE_UNSPECIFIED;
        case 1:
        case 'COMPUTE_INSTANCE':
            return ResolveByWorkloadRequest_WorkloadType.COMPUTE_INSTANCE;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return ResolveByWorkloadRequest_WorkloadType.UNRECOGNIZED;
    }
}
exports.resolveByWorkloadRequest_WorkloadTypeFromJSON = resolveByWorkloadRequest_WorkloadTypeFromJSON;
function resolveByWorkloadRequest_WorkloadTypeToJSON(object) {
    switch (object) {
        case ResolveByWorkloadRequest_WorkloadType.WORKLOAD_TYPE_UNSPECIFIED:
            return 'WORKLOAD_TYPE_UNSPECIFIED';
        case ResolveByWorkloadRequest_WorkloadType.COMPUTE_INSTANCE:
            return 'COMPUTE_INSTANCE';
        default:
            return 'UNKNOWN';
    }
}
exports.resolveByWorkloadRequest_WorkloadTypeToJSON = resolveByWorkloadRequest_WorkloadTypeToJSON;
const baseResolveByWorkloadRequest = { workloadType: 0, workloadId: '' };
exports.ResolveByWorkloadRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.workloadType !== 0) {
            writer.uint32(8).int32(message.workloadType);
        }
        if (message.workloadId !== '') {
            writer.uint32(18).string(message.workloadId);
        }
        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({}, baseResolveByWorkloadRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.workloadType = reader.int32();
                    break;
                case 2:
                    message.workloadId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseResolveByWorkloadRequest);
        message.workloadType =
            object.workloadType !== undefined && object.workloadType !== null
                ? resolveByWorkloadRequest_WorkloadTypeFromJSON(object.workloadType)
                : 0;
        message.workloadId =
            object.workloadId !== undefined && object.workloadId !== null
                ? String(object.workloadId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.workloadType !== undefined &&
            (obj.workloadType = resolveByWorkloadRequest_WorkloadTypeToJSON(message.workloadType));
        message.workloadId !== undefined && (obj.workloadId = message.workloadId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseResolveByWorkloadRequest);
        message.workloadType = (_a = object.workloadType) !== null && _a !== void 0 ? _a : 0;
        message.workloadId = (_b = object.workloadId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseResolveByWorkloadResponse = {};
exports.ResolveByWorkloadResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.cloudApplication !== undefined) {
            cloud_application_1.CloudApplication.encode(message.cloudApplication, 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({}, baseResolveByWorkloadResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.cloudApplication = cloud_application_1.CloudApplication.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseResolveByWorkloadResponse);
        message.cloudApplication =
            object.cloudApplication !== undefined && object.cloudApplication !== null
                ? cloud_application_1.CloudApplication.fromJSON(object.cloudApplication)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.cloudApplication !== undefined &&
            (obj.cloudApplication = message.cloudApplication
                ? cloud_application_1.CloudApplication.toJSON(message.cloudApplication)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseResolveByWorkloadResponse);
        message.cloudApplication =
            object.cloudApplication !== undefined && object.cloudApplication !== null
                ? cloud_application_1.CloudApplication.fromPartial(object.cloudApplication)
                : undefined;
        return message;
    },
};
/** Cloud Application Service to be used by Workload software inside Cloud Application installations */
exports.CloudApplicationServiceService = {
    /** Get Current Application */
    get: {
        path: '/yandex.cloud.cloudapps.workload.v1.CloudApplicationService/Get',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(empty_1.Empty.encode(value).finish()),
        requestDeserialize: (value) => empty_1.Empty.decode(value),
        responseSerialize: (value) => Buffer.from(cloud_application_1.CloudApplication.encode(value).finish()),
        responseDeserialize: (value) => cloud_application_1.CloudApplication.decode(value),
    },
    /** Resolve Cloud Application by workload */
    resolveByWorkload: {
        path: '/yandex.cloud.cloudapps.workload.v1.CloudApplicationService/ResolveByWorkload',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ResolveByWorkloadRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ResolveByWorkloadRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ResolveByWorkloadResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ResolveByWorkloadResponse.decode(value),
    },
};
exports.CloudApplicationServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.CloudApplicationServiceService, 'yandex.cloud.cloudapps.workload.v1.CloudApplicationService');
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
