"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworkServiceClient = exports.NetworkServiceService = exports.TriggerUsedNetworkCleanupResponse = exports.TriggerUsedNetworkCleanupRequest = exports.ListConnectedResourcesResponse_ConnectedResource = exports.ListConnectedResourcesResponse = exports.ListConnectedResourcesRequest = exports.ListUsedNetworksResponse = exports.ListUsedNetworksRequest = exports.GetUsedNetworkRequest = exports.UsedNetwork = exports.usedNetwork_StatusToJSON = exports.usedNetwork_StatusFromJSON = exports.UsedNetwork_Status = 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 timestamp_1 = require("../../../../../google/protobuf/timestamp");
exports.protobufPackage = 'yandex.cloud.serverless.functions.v1';
var UsedNetwork_Status;
(function (UsedNetwork_Status) {
    UsedNetwork_Status[UsedNetwork_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    /** CREATING - Network is connecting to its first serverless resource. */
    UsedNetwork_Status[UsedNetwork_Status["CREATING"] = 1] = "CREATING";
    /** ACTIVE - Network is already being used by some serverless resources. */
    UsedNetwork_Status[UsedNetwork_Status["ACTIVE"] = 2] = "ACTIVE";
    /**
     * OBSOLETE - Network is no longer used by any serverless resources.
     * It will be cleaned-up after a while.
     */
    UsedNetwork_Status[UsedNetwork_Status["OBSOLETE"] = 3] = "OBSOLETE";
    UsedNetwork_Status[UsedNetwork_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(UsedNetwork_Status = exports.UsedNetwork_Status || (exports.UsedNetwork_Status = {}));
function usedNetwork_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return UsedNetwork_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'CREATING':
            return UsedNetwork_Status.CREATING;
        case 2:
        case 'ACTIVE':
            return UsedNetwork_Status.ACTIVE;
        case 3:
        case 'OBSOLETE':
            return UsedNetwork_Status.OBSOLETE;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return UsedNetwork_Status.UNRECOGNIZED;
    }
}
exports.usedNetwork_StatusFromJSON = usedNetwork_StatusFromJSON;
function usedNetwork_StatusToJSON(object) {
    switch (object) {
        case UsedNetwork_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case UsedNetwork_Status.CREATING:
            return 'CREATING';
        case UsedNetwork_Status.ACTIVE:
            return 'ACTIVE';
        case UsedNetwork_Status.OBSOLETE:
            return 'OBSOLETE';
        default:
            return 'UNKNOWN';
    }
}
exports.usedNetwork_StatusToJSON = usedNetwork_StatusToJSON;
const baseUsedNetwork = {
    networkId: '',
    cloudId: '',
    folderId: '',
    status: 0,
    connectionsCount: 0,
};
exports.UsedNetwork = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.networkId !== '') {
            writer.uint32(10).string(message.networkId);
        }
        if (message.cloudId !== '') {
            writer.uint32(18).string(message.cloudId);
        }
        if (message.folderId !== '') {
            writer.uint32(26).string(message.folderId);
        }
        if (message.status !== 0) {
            writer.uint32(32).int32(message.status);
        }
        if (message.willBeCleanedUpAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.willBeCleanedUpAt), writer.uint32(42).fork()).ldelim();
        }
        if (message.connectionsCount !== 0) {
            writer.uint32(48).int64(message.connectionsCount);
        }
        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({}, baseUsedNetwork);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.networkId = reader.string();
                    break;
                case 2:
                    message.cloudId = reader.string();
                    break;
                case 3:
                    message.folderId = reader.string();
                    break;
                case 4:
                    message.status = reader.int32();
                    break;
                case 5:
                    message.willBeCleanedUpAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 6:
                    message.connectionsCount = longToNumber(reader.int64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUsedNetwork);
        message.networkId =
            object.networkId !== undefined && object.networkId !== null
                ? String(object.networkId)
                : '';
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null ? String(object.cloudId) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.status =
            object.status !== undefined && object.status !== null
                ? usedNetwork_StatusFromJSON(object.status)
                : 0;
        message.willBeCleanedUpAt =
            object.willBeCleanedUpAt !== undefined && object.willBeCleanedUpAt !== null
                ? fromJsonTimestamp(object.willBeCleanedUpAt)
                : undefined;
        message.connectionsCount =
            object.connectionsCount !== undefined && object.connectionsCount !== null
                ? Number(object.connectionsCount)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.networkId !== undefined && (obj.networkId = message.networkId);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.status !== undefined && (obj.status = usedNetwork_StatusToJSON(message.status));
        message.willBeCleanedUpAt !== undefined &&
            (obj.willBeCleanedUpAt = message.willBeCleanedUpAt.toISOString());
        message.connectionsCount !== undefined &&
            (obj.connectionsCount = Math.round(message.connectionsCount));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f;
        const message = Object.assign({}, baseUsedNetwork);
        message.networkId = (_a = object.networkId) !== null && _a !== void 0 ? _a : '';
        message.cloudId = (_b = object.cloudId) !== null && _b !== void 0 ? _b : '';
        message.folderId = (_c = object.folderId) !== null && _c !== void 0 ? _c : '';
        message.status = (_d = object.status) !== null && _d !== void 0 ? _d : 0;
        message.willBeCleanedUpAt = (_e = object.willBeCleanedUpAt) !== null && _e !== void 0 ? _e : undefined;
        message.connectionsCount = (_f = object.connectionsCount) !== null && _f !== void 0 ? _f : 0;
        return message;
    },
};
const baseGetUsedNetworkRequest = { networkId: '' };
exports.GetUsedNetworkRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.networkId !== '') {
            writer.uint32(10).string(message.networkId);
        }
        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({}, baseGetUsedNetworkRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.networkId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetUsedNetworkRequest);
        message.networkId =
            object.networkId !== undefined && object.networkId !== null
                ? String(object.networkId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.networkId !== undefined && (obj.networkId = message.networkId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseGetUsedNetworkRequest);
        message.networkId = (_a = object.networkId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseListUsedNetworksRequest = { pageSize: 0, pageToken: '' };
exports.ListUsedNetworksRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.pageSize !== 0) {
            writer.uint32(8).int64(message.pageSize);
        }
        if (message.pageToken !== '') {
            writer.uint32(18).string(message.pageToken);
        }
        if (message.cloudId !== undefined) {
            writer.uint32(26).string(message.cloudId);
        }
        if (message.folderId !== undefined) {
            writer.uint32(34).string(message.folderId);
        }
        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({}, baseListUsedNetworksRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.pageSize = longToNumber(reader.int64());
                    break;
                case 2:
                    message.pageToken = reader.string();
                    break;
                case 3:
                    message.cloudId = reader.string();
                    break;
                case 4:
                    message.folderId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListUsedNetworksRequest);
        message.pageSize =
            object.pageSize !== undefined && object.pageSize !== null ? Number(object.pageSize) : 0;
        message.pageToken =
            object.pageToken !== undefined && object.pageToken !== null
                ? String(object.pageToken)
                : '';
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null
                ? String(object.cloudId)
                : undefined;
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));
        message.pageToken !== undefined && (obj.pageToken = message.pageToken);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseListUsedNetworksRequest);
        message.pageSize = (_a = object.pageSize) !== null && _a !== void 0 ? _a : 0;
        message.pageToken = (_b = object.pageToken) !== null && _b !== void 0 ? _b : '';
        message.cloudId = (_c = object.cloudId) !== null && _c !== void 0 ? _c : undefined;
        message.folderId = (_d = object.folderId) !== null && _d !== void 0 ? _d : undefined;
        return message;
    },
};
const baseListUsedNetworksResponse = { nextPageToken: '' };
exports.ListUsedNetworksResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.networks) {
            exports.UsedNetwork.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.nextPageToken !== '') {
            writer.uint32(18).string(message.nextPageToken);
        }
        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({}, baseListUsedNetworksResponse);
        message.networks = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.networks.push(exports.UsedNetwork.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.nextPageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseListUsedNetworksResponse);
        message.networks = ((_a = object.networks) !== null && _a !== void 0 ? _a : []).map((e) => exports.UsedNetwork.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.networks) {
            obj.networks = message.networks.map((e) => (e ? exports.UsedNetwork.toJSON(e) : undefined));
        }
        else {
            obj.networks = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListUsedNetworksResponse);
        message.networks = ((_a = object.networks) === null || _a === void 0 ? void 0 : _a.map((e) => exports.UsedNetwork.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseListConnectedResourcesRequest = { pageSize: 0, pageToken: '' };
exports.ListConnectedResourcesRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.pageSize !== 0) {
            writer.uint32(8).int64(message.pageSize);
        }
        if (message.pageToken !== '') {
            writer.uint32(18).string(message.pageToken);
        }
        if (message.networkId !== undefined) {
            writer.uint32(26).string(message.networkId);
        }
        if (message.cloudId !== undefined) {
            writer.uint32(34).string(message.cloudId);
        }
        if (message.folderId !== undefined) {
            writer.uint32(42).string(message.folderId);
        }
        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({}, baseListConnectedResourcesRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.pageSize = longToNumber(reader.int64());
                    break;
                case 2:
                    message.pageToken = reader.string();
                    break;
                case 3:
                    message.networkId = reader.string();
                    break;
                case 4:
                    message.cloudId = reader.string();
                    break;
                case 5:
                    message.folderId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListConnectedResourcesRequest);
        message.pageSize =
            object.pageSize !== undefined && object.pageSize !== null ? Number(object.pageSize) : 0;
        message.pageToken =
            object.pageToken !== undefined && object.pageToken !== null
                ? String(object.pageToken)
                : '';
        message.networkId =
            object.networkId !== undefined && object.networkId !== null
                ? String(object.networkId)
                : undefined;
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null
                ? String(object.cloudId)
                : undefined;
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));
        message.pageToken !== undefined && (obj.pageToken = message.pageToken);
        message.networkId !== undefined && (obj.networkId = message.networkId);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e;
        const message = Object.assign({}, baseListConnectedResourcesRequest);
        message.pageSize = (_a = object.pageSize) !== null && _a !== void 0 ? _a : 0;
        message.pageToken = (_b = object.pageToken) !== null && _b !== void 0 ? _b : '';
        message.networkId = (_c = object.networkId) !== null && _c !== void 0 ? _c : undefined;
        message.cloudId = (_d = object.cloudId) !== null && _d !== void 0 ? _d : undefined;
        message.folderId = (_e = object.folderId) !== null && _e !== void 0 ? _e : undefined;
        return message;
    },
};
const baseListConnectedResourcesResponse = { nextPageToken: '' };
exports.ListConnectedResourcesResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.resources) {
            exports.ListConnectedResourcesResponse_ConnectedResource.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.nextPageToken !== '') {
            writer.uint32(18).string(message.nextPageToken);
        }
        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({}, baseListConnectedResourcesResponse);
        message.resources = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.resources.push(exports.ListConnectedResourcesResponse_ConnectedResource.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.nextPageToken = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseListConnectedResourcesResponse);
        message.resources = ((_a = object.resources) !== null && _a !== void 0 ? _a : []).map((e) => exports.ListConnectedResourcesResponse_ConnectedResource.fromJSON(e));
        message.nextPageToken =
            object.nextPageToken !== undefined && object.nextPageToken !== null
                ? String(object.nextPageToken)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.resources) {
            obj.resources = message.resources.map((e) => e ? exports.ListConnectedResourcesResponse_ConnectedResource.toJSON(e) : undefined);
        }
        else {
            obj.resources = [];
        }
        message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseListConnectedResourcesResponse);
        message.resources =
            ((_a = object.resources) === null || _a === void 0 ? void 0 : _a.map((e) => exports.ListConnectedResourcesResponse_ConnectedResource.fromPartial(e))) || [];
        message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseListConnectedResourcesResponse_ConnectedResource = {
    networkId: '',
    resourceType: '',
    resourceId: '',
    subresourceType: '',
    subresourceId: '',
    resourceCloudId: '',
    resourceFolderId: '',
};
exports.ListConnectedResourcesResponse_ConnectedResource = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.networkId !== '') {
            writer.uint32(10).string(message.networkId);
        }
        if (message.resourceType !== '') {
            writer.uint32(18).string(message.resourceType);
        }
        if (message.resourceId !== '') {
            writer.uint32(26).string(message.resourceId);
        }
        if (message.subresourceType !== '') {
            writer.uint32(34).string(message.subresourceType);
        }
        if (message.subresourceId !== '') {
            writer.uint32(42).string(message.subresourceId);
        }
        if (message.resourceCloudId !== '') {
            writer.uint32(50).string(message.resourceCloudId);
        }
        if (message.resourceFolderId !== '') {
            writer.uint32(58).string(message.resourceFolderId);
        }
        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({}, baseListConnectedResourcesResponse_ConnectedResource);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.networkId = reader.string();
                    break;
                case 2:
                    message.resourceType = reader.string();
                    break;
                case 3:
                    message.resourceId = reader.string();
                    break;
                case 4:
                    message.subresourceType = reader.string();
                    break;
                case 5:
                    message.subresourceId = reader.string();
                    break;
                case 6:
                    message.resourceCloudId = reader.string();
                    break;
                case 7:
                    message.resourceFolderId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseListConnectedResourcesResponse_ConnectedResource);
        message.networkId =
            object.networkId !== undefined && object.networkId !== null
                ? String(object.networkId)
                : '';
        message.resourceType =
            object.resourceType !== undefined && object.resourceType !== null
                ? String(object.resourceType)
                : '';
        message.resourceId =
            object.resourceId !== undefined && object.resourceId !== null
                ? String(object.resourceId)
                : '';
        message.subresourceType =
            object.subresourceType !== undefined && object.subresourceType !== null
                ? String(object.subresourceType)
                : '';
        message.subresourceId =
            object.subresourceId !== undefined && object.subresourceId !== null
                ? String(object.subresourceId)
                : '';
        message.resourceCloudId =
            object.resourceCloudId !== undefined && object.resourceCloudId !== null
                ? String(object.resourceCloudId)
                : '';
        message.resourceFolderId =
            object.resourceFolderId !== undefined && object.resourceFolderId !== null
                ? String(object.resourceFolderId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.networkId !== undefined && (obj.networkId = message.networkId);
        message.resourceType !== undefined && (obj.resourceType = message.resourceType);
        message.resourceId !== undefined && (obj.resourceId = message.resourceId);
        message.subresourceType !== undefined && (obj.subresourceType = message.subresourceType);
        message.subresourceId !== undefined && (obj.subresourceId = message.subresourceId);
        message.resourceCloudId !== undefined && (obj.resourceCloudId = message.resourceCloudId);
        message.resourceFolderId !== undefined && (obj.resourceFolderId = message.resourceFolderId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g;
        const message = Object.assign({}, baseListConnectedResourcesResponse_ConnectedResource);
        message.networkId = (_a = object.networkId) !== null && _a !== void 0 ? _a : '';
        message.resourceType = (_b = object.resourceType) !== null && _b !== void 0 ? _b : '';
        message.resourceId = (_c = object.resourceId) !== null && _c !== void 0 ? _c : '';
        message.subresourceType = (_d = object.subresourceType) !== null && _d !== void 0 ? _d : '';
        message.subresourceId = (_e = object.subresourceId) !== null && _e !== void 0 ? _e : '';
        message.resourceCloudId = (_f = object.resourceCloudId) !== null && _f !== void 0 ? _f : '';
        message.resourceFolderId = (_g = object.resourceFolderId) !== null && _g !== void 0 ? _g : '';
        return message;
    },
};
const baseTriggerUsedNetworkCleanupRequest = { networkId: '' };
exports.TriggerUsedNetworkCleanupRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.networkId !== '') {
            writer.uint32(10).string(message.networkId);
        }
        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({}, baseTriggerUsedNetworkCleanupRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.networkId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTriggerUsedNetworkCleanupRequest);
        message.networkId =
            object.networkId !== undefined && object.networkId !== null
                ? String(object.networkId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.networkId !== undefined && (obj.networkId = message.networkId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTriggerUsedNetworkCleanupRequest);
        message.networkId = (_a = object.networkId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseTriggerUsedNetworkCleanupResponse = {};
exports.TriggerUsedNetworkCleanupResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.networkCleanupTime !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.networkCleanupTime), 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({}, baseTriggerUsedNetworkCleanupResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.networkCleanupTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTriggerUsedNetworkCleanupResponse);
        message.networkCleanupTime =
            object.networkCleanupTime !== undefined && object.networkCleanupTime !== null
                ? fromJsonTimestamp(object.networkCleanupTime)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.networkCleanupTime !== undefined &&
            (obj.networkCleanupTime = message.networkCleanupTime.toISOString());
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTriggerUsedNetworkCleanupResponse);
        message.networkCleanupTime = (_a = object.networkCleanupTime) !== null && _a !== void 0 ? _a : undefined;
        return message;
    },
};
/** A set of methods for managing VPC networks connected to serverless resources. */
exports.NetworkServiceService = {
    /** Returns the specified network used in serverless resources. */
    getUsed: {
        path: '/yandex.cloud.serverless.functions.v1.NetworkService/GetUsed',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.GetUsedNetworkRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.GetUsedNetworkRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.UsedNetwork.encode(value).finish()),
        responseDeserialize: (value) => exports.UsedNetwork.decode(value),
    },
    /** Retrieves the list of networks in the specified scope that are used in serverless resources. */
    listUsed: {
        path: '/yandex.cloud.serverless.functions.v1.NetworkService/ListUsed',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListUsedNetworksRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListUsedNetworksRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListUsedNetworksResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListUsedNetworksResponse.decode(value),
    },
    /** Retrieves the list of serverless resources connected to any network from the specified scope. */
    listConnectedResources: {
        path: '/yandex.cloud.serverless.functions.v1.NetworkService/ListConnectedResources',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.ListConnectedResourcesRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.ListConnectedResourcesRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.ListConnectedResourcesResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.ListConnectedResourcesResponse.decode(value),
    },
    /**
     * Forces obsolete used network to start cleanup process as soon as possible.
     * Invocation does not wait for start or end of the cleanup process.
     * Second invocation with the same network does nothing until network is completely cleaned-up.
     */
    triggerUsedCleanup: {
        path: '/yandex.cloud.serverless.functions.v1.NetworkService/TriggerUsedCleanup',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.TriggerUsedNetworkCleanupRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.TriggerUsedNetworkCleanupRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.TriggerUsedNetworkCleanupResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.TriggerUsedNetworkCleanupResponse.decode(value),
    },
};
exports.NetworkServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.NetworkServiceService, 'yandex.cloud.serverless.functions.v1.NetworkService');
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
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));
    }
}
function longToNumber(long) {
    if (long.gt(Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
    }
    return long.toNumber();
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
