"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProjectServiceClient = exports.ProjectServiceService = exports.CreateProjectMetadata = exports.CreateProjectRequest = 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 project_1 = require("../../../../yandex/cloud/speechsense/v1/project");
const operation_1 = require("../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.speechsense.v1';
const baseCreateProjectRequest = { name: '', connectionId: '', description: '' };
exports.CreateProjectRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.name !== '') {
            writer.uint32(10).string(message.name);
        }
        if (message.connectionId !== '') {
            writer.uint32(18).string(message.connectionId);
        }
        if (message.description !== '') {
            writer.uint32(26).string(message.description);
        }
        for (const v of message.filters) {
            project_1.FieldFilter.encode(v, writer.uint32(34).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({}, baseCreateProjectRequest);
        message.filters = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.connectionId = reader.string();
                    break;
                case 3:
                    message.description = reader.string();
                    break;
                case 4:
                    message.filters.push(project_1.FieldFilter.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCreateProjectRequest);
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.connectionId =
            object.connectionId !== undefined && object.connectionId !== null
                ? String(object.connectionId)
                : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.filters = ((_a = object.filters) !== null && _a !== void 0 ? _a : []).map((e) => project_1.FieldFilter.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.connectionId !== undefined && (obj.connectionId = message.connectionId);
        message.description !== undefined && (obj.description = message.description);
        if (message.filters) {
            obj.filters = message.filters.map((e) => (e ? project_1.FieldFilter.toJSON(e) : undefined));
        }
        else {
            obj.filters = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseCreateProjectRequest);
        message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
        message.connectionId = (_b = object.connectionId) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.filters = ((_d = object.filters) === null || _d === void 0 ? void 0 : _d.map((e) => project_1.FieldFilter.fromPartial(e))) || [];
        return message;
    },
};
const baseCreateProjectMetadata = { id: '' };
exports.CreateProjectMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        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({}, baseCreateProjectMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreateProjectMetadata);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreateProjectMetadata);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
exports.ProjectServiceService = {
    /** rpc for creating speechsense project */
    create: {
        path: '/yandex.cloud.speechsense.v1.ProjectService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreateProjectRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreateProjectRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
};
exports.ProjectServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.ProjectServiceService, 'yandex.cloud.speechsense.v1.ProjectService');
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
