"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PXFDatasourceServiceClient = exports.PXFDatasourceServiceService = exports.DeletePXFDatasourceRequest = exports.UpdatePXFDatasourceRequest = exports.CreatePXFDatasourceRequest = exports.ListPXFDatasourcesResponse = exports.ListPXFDatasourcesRequest = exports.DeletePXFDatasourceMetadata = exports.UpdatePXFDatasourceMetadata = exports.CreatePXFDatasourceMetadata = 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 pxf_1 = require("../../../../../yandex/cloud/mdb/greenplum/v1/pxf");
const field_mask_1 = require("../../../../../google/protobuf/field_mask");
const operation_1 = require("../../../../../yandex/cloud/operation/operation");
exports.protobufPackage = 'yandex.cloud.mdb.greenplum.v1';
const baseCreatePXFDatasourceMetadata = { clusterId: '', datasourceName: '' };
exports.CreatePXFDatasourceMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        if (message.datasourceName !== '') {
            writer.uint32(18).string(message.datasourceName);
        }
        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({}, baseCreatePXFDatasourceMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                case 2:
                    message.datasourceName = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreatePXFDatasourceMetadata);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        message.datasourceName =
            object.datasourceName !== undefined && object.datasourceName !== null
                ? String(object.datasourceName)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        message.datasourceName !== undefined && (obj.datasourceName = message.datasourceName);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseCreatePXFDatasourceMetadata);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        message.datasourceName = (_b = object.datasourceName) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseUpdatePXFDatasourceMetadata = { clusterId: '', datasourceName: '' };
exports.UpdatePXFDatasourceMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        if (message.datasourceName !== '') {
            writer.uint32(18).string(message.datasourceName);
        }
        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({}, baseUpdatePXFDatasourceMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                case 2:
                    message.datasourceName = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdatePXFDatasourceMetadata);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        message.datasourceName =
            object.datasourceName !== undefined && object.datasourceName !== null
                ? String(object.datasourceName)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        message.datasourceName !== undefined && (obj.datasourceName = message.datasourceName);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseUpdatePXFDatasourceMetadata);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        message.datasourceName = (_b = object.datasourceName) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseDeletePXFDatasourceMetadata = { clusterId: '', datasourceName: '' };
exports.DeletePXFDatasourceMetadata = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        if (message.datasourceName !== '') {
            writer.uint32(18).string(message.datasourceName);
        }
        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({}, baseDeletePXFDatasourceMetadata);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                case 2:
                    message.datasourceName = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeletePXFDatasourceMetadata);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        message.datasourceName =
            object.datasourceName !== undefined && object.datasourceName !== null
                ? String(object.datasourceName)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        message.datasourceName !== undefined && (obj.datasourceName = message.datasourceName);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseDeletePXFDatasourceMetadata);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        message.datasourceName = (_b = object.datasourceName) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseListPXFDatasourcesRequest = { clusterId: '' };
exports.ListPXFDatasourcesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        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({}, baseListPXFDatasourcesRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListPXFDatasourcesRequest);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseListPXFDatasourcesRequest);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListPXFDatasourcesResponse = {};
exports.ListPXFDatasourcesResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.datasources) {
            pxf_1.PXFDatasource.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({}, baseListPXFDatasourcesResponse);
        message.datasources = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.datasources.push(pxf_1.PXFDatasource.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseListPXFDatasourcesResponse);
        message.datasources = ((_a = object.datasources) !== null && _a !== void 0 ? _a : []).map((e) => pxf_1.PXFDatasource.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.datasources) {
            obj.datasources = message.datasources.map((e) => e ? pxf_1.PXFDatasource.toJSON(e) : undefined);
        }
        else {
            obj.datasources = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseListPXFDatasourcesResponse);
        message.datasources = ((_a = object.datasources) === null || _a === void 0 ? void 0 : _a.map((e) => pxf_1.PXFDatasource.fromPartial(e))) || [];
        return message;
    },
};
const baseCreatePXFDatasourceRequest = { clusterId: '' };
exports.CreatePXFDatasourceRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        if (message.datasource !== undefined) {
            pxf_1.PXFDatasource.encode(message.datasource, 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({}, baseCreatePXFDatasourceRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                case 2:
                    message.datasource = pxf_1.PXFDatasource.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCreatePXFDatasourceRequest);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        message.datasource =
            object.datasource !== undefined && object.datasource !== null
                ? pxf_1.PXFDatasource.fromJSON(object.datasource)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        message.datasource !== undefined &&
            (obj.datasource = message.datasource
                ? pxf_1.PXFDatasource.toJSON(message.datasource)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCreatePXFDatasourceRequest);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        message.datasource =
            object.datasource !== undefined && object.datasource !== null
                ? pxf_1.PXFDatasource.fromPartial(object.datasource)
                : undefined;
        return message;
    },
};
const baseUpdatePXFDatasourceRequest = { clusterId: '' };
exports.UpdatePXFDatasourceRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        if (message.updateMask !== undefined) {
            field_mask_1.FieldMask.encode(message.updateMask, writer.uint32(18).fork()).ldelim();
        }
        if (message.datasource !== undefined) {
            pxf_1.PXFDatasource.encode(message.datasource, 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({}, baseUpdatePXFDatasourceRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                case 2:
                    message.updateMask = field_mask_1.FieldMask.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.datasource = pxf_1.PXFDatasource.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdatePXFDatasourceRequest);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        message.updateMask =
            object.updateMask !== undefined && object.updateMask !== null
                ? field_mask_1.FieldMask.fromJSON(object.updateMask)
                : undefined;
        message.datasource =
            object.datasource !== undefined && object.datasource !== null
                ? pxf_1.PXFDatasource.fromJSON(object.datasource)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        message.updateMask !== undefined &&
            (obj.updateMask = message.updateMask
                ? field_mask_1.FieldMask.toJSON(message.updateMask)
                : undefined);
        message.datasource !== undefined &&
            (obj.datasource = message.datasource
                ? pxf_1.PXFDatasource.toJSON(message.datasource)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseUpdatePXFDatasourceRequest);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        message.updateMask =
            object.updateMask !== undefined && object.updateMask !== null
                ? field_mask_1.FieldMask.fromPartial(object.updateMask)
                : undefined;
        message.datasource =
            object.datasource !== undefined && object.datasource !== null
                ? pxf_1.PXFDatasource.fromPartial(object.datasource)
                : undefined;
        return message;
    },
};
const baseDeletePXFDatasourceRequest = { clusterId: '', datasourceName: '' };
exports.DeletePXFDatasourceRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        if (message.datasourceName !== '') {
            writer.uint32(18).string(message.datasourceName);
        }
        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({}, baseDeletePXFDatasourceRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                case 2:
                    message.datasourceName = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseDeletePXFDatasourceRequest);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        message.datasourceName =
            object.datasourceName !== undefined && object.datasourceName !== null
                ? String(object.datasourceName)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        message.datasourceName !== undefined && (obj.datasourceName = message.datasourceName);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseDeletePXFDatasourceRequest);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        message.datasourceName = (_b = object.datasourceName) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
exports.PXFDatasourceServiceService = {
    /** List all PXF datasources */
    list: {
        path: '/yandex.cloud.mdb.greenplum.v1.PXFDatasourceService/List',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListPXFDatasourcesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListPXFDatasourcesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListPXFDatasourcesResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListPXFDatasourcesResponse.decode(value),
    },
    /** Creates PXF datasource */
    create: {
        path: '/yandex.cloud.mdb.greenplum.v1.PXFDatasourceService/Create',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.CreatePXFDatasourceRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.CreatePXFDatasourceRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Update PXF datasource */
    update: {
        path: '/yandex.cloud.mdb.greenplum.v1.PXFDatasourceService/Update',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.UpdatePXFDatasourceRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.UpdatePXFDatasourceRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
    /** Delete PXF datasource */
    delete: {
        path: '/yandex.cloud.mdb.greenplum.v1.PXFDatasourceService/Delete',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.DeletePXFDatasourceRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.DeletePXFDatasourceRequest.decode(value),
        responseSerialize: (value) => Buffer.from(operation_1.Operation.encode(value).finish()),
        responseDeserialize: (value) => operation_1.Operation.decode(value),
    },
};
exports.PXFDatasourceServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.PXFDatasourceServiceService, 'yandex.cloud.mdb.greenplum.v1.PXFDatasourceService');
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
