import { toURLSearchParams } from '@wix/metro-runtime';
import { serializer } from '@wix/metro-runtime/ambassador';
import { resolveUrl } from '@wix/metro-runtime';
var _createExternalDatabaseConnectionRequest = {};
var _createExternalDatabaseConnectionResponse = {};
var _deleteExternalDatabaseConnectionRequest = {};
var _deleteExternalDatabaseConnectionResponse = {};
var _getExternalDatabaseConnectionRequest = {};
var _getExternalDatabaseConnectionResponse = {};
var _listExternalDatabaseConnectionsRequest = {};
var _listExternalDatabaseConnectionsResponse = {};
var _updateExternalDatabaseConnectionRequest = {};
var _updateExternalDatabaseConnectionResponse = {};
function resolveComWixpressCloudDataApiExternaldatabaseExternalDatabaseConnectionServiceUrl(opts) {
    var domainToMappings = {
        'api._api_base_domain_': [
            {
                srcPath: '/cloud-data',
                destPath: '',
            },
        ],
        'code._base_domain_': [
            {
                srcPath: '/_api/cloud-data/v1/data-settings',
                destPath: '/v1/data-settings',
            },
            {
                srcPath: '/_api/cloud-data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/cloud-data/v1/connector',
                destPath: '/v1/connector',
            },
            {
                srcPath: '/_api/data/v1/data-settings',
                destPath: '/v1/data-settings',
            },
            {
                srcPath: '/_api/data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/data/v1/connector',
                destPath: '/v1/connector',
            },
            {
                srcPath: '/_api/cloud-data/v1/wix-data',
                destPath: '/v1/wix-data',
            },
        ],
        'cloud-data.wix-code.com': [
            {
                srcPath: '',
                destPath: '',
            },
        ],
        _: [
            {
                srcPath: '/_api/cloud-data',
                destPath: '',
            },
        ],
        'www._base_domain_': [
            {
                srcPath: '/_api/cloud-data',
                destPath: '',
            },
            {
                srcPath: '/_api/data',
                destPath: '',
            },
            {
                srcPath: '/_api/cloud-data',
                destPath: '',
            },
        ],
        'dev._base_domain_': [
            {
                srcPath: '/_api/cloud-data',
                destPath: '',
            },
        ],
        'bo._base_domain_': [
            {
                srcPath: '/_api/cloud-data/v1',
                destPath: '/v1',
            },
            {
                srcPath: '/_api/cloud-data/v2',
                destPath: '/v2',
            },
        ],
        'wixbo.ai': [
            {
                srcPath: '/_api/cloud-data/v1',
                destPath: '/v1',
            },
            {
                srcPath: '/_api/cloud-data/v2',
                destPath: '/v2',
            },
        ],
        'wix-bo.com': [
            {
                srcPath: '/_api/cloud-data/v1',
                destPath: '/v1',
            },
            {
                srcPath: '/_api/cloud-data/v2',
                destPath: '/v2',
            },
        ],
        'manage._base_domain_': [
            {
                srcPath: '/_api/cloud-data',
                destPath: '',
            },
            {
                srcPath: '/_api/data',
                destPath: '',
            },
            {
                srcPath: '/_api/cloud-data',
                destPath: '',
            },
        ],
        'editor._base_domain_': [
            {
                srcPath: '/_api/cloud-data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/cloud-data/dbs/tasks',
                destPath: '/dbs/tasks',
            },
            {
                srcPath: '/_api/data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/data/dbs/tasks',
                destPath: '/dbs/tasks',
            },
            {
                srcPath: '/_api/cloud-data/v1/wix-data',
                destPath: '/v1/wix-data',
            },
            {
                srcPath: '/_api/cloud-data/v1/data-settings',
                destPath: '/v1/data-settings',
            },
            {
                srcPath: '/_api/data/v2/indexes',
                destPath: '/v2/indexes',
            },
            {
                srcPath: '/_api/cloud-data/v1/external-database-connections',
                destPath: '/v1/external-database-connections',
            },
            {
                srcPath: '/_api/data/v1/data-collection-sharing',
                destPath: '/v1/data-collection-sharing',
            },
            {
                srcPath: '/_api/cloud-data/v2/collections',
                destPath: '/v2/collections',
            },
            {
                srcPath: '/_api/cloud-data/v2/bulk',
                destPath: '/v2/bulk',
            },
            {
                srcPath: '/_api/cloud-data/v2/items',
                destPath: '/v2/items',
            },
            {
                srcPath: '/_api/cloud-data/v2/dbs/tasks',
                destPath: '/v2/dbs/tasks',
            },
        ],
        'blocks._base_domain_': [
            {
                srcPath: '/_api/cloud-data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/cloud-data/dbs/tasks',
                destPath: '/dbs/tasks',
            },
            {
                srcPath: '/_api/data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/data/dbs/tasks',
                destPath: '/dbs/tasks',
            },
            {
                srcPath: '/_api/cloud-data/v1/wix-data',
                destPath: '/v1/wix-data',
            },
            {
                srcPath: '/_api/cloud-data/v1/data-settings',
                destPath: '/v1/data-settings',
            },
            {
                srcPath: '/_api/data/v2/indexes',
                destPath: '/v2/indexes',
            },
            {
                srcPath: '/_api/cloud-data/v1/external-database-connections',
                destPath: '/v1/external-database-connections',
            },
            {
                srcPath: '/_api/data/v1/data-collection-sharing',
                destPath: '/v1/data-collection-sharing',
            },
            {
                srcPath: '/_api/cloud-data/v2/collections',
                destPath: '/v2/collections',
            },
            {
                srcPath: '/_api/cloud-data/v2/bulk',
                destPath: '/v2/bulk',
            },
            {
                srcPath: '/_api/cloud-data/v2/items',
                destPath: '/v2/items',
            },
            {
                srcPath: '/_api/cloud-data/v2/dbs/tasks',
                destPath: '/v2/dbs/tasks',
            },
        ],
        'create.editorx': [
            {
                srcPath: '/_api/cloud-data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/cloud-data/dbs/tasks',
                destPath: '/dbs/tasks',
            },
            {
                srcPath: '/_api/data/v1/schemas',
                destPath: '/v1/schemas',
            },
            {
                srcPath: '/_api/data/dbs/tasks',
                destPath: '/dbs/tasks',
            },
            {
                srcPath: '/_api/cloud-data/v1/wix-data',
                destPath: '/v1/wix-data',
            },
            {
                srcPath: '/_api/cloud-data/v1/data-settings',
                destPath: '/v1/data-settings',
            },
            {
                srcPath: '/_api/data/v2/indexes',
                destPath: '/v2/indexes',
            },
            {
                srcPath: '/_api/cloud-data/v1/external-database-connections',
                destPath: '/v1/external-database-connections',
            },
            {
                srcPath: '/_api/data/v1/data-collection-sharing',
                destPath: '/v1/data-collection-sharing',
            },
            {
                srcPath: '/_api/cloud-data/v2/collections',
                destPath: '/v2/collections',
            },
            {
                srcPath: '/_api/cloud-data/v2/bulk',
                destPath: '/v2/bulk',
            },
            {
                srcPath: '/_api/cloud-data/v2/items',
                destPath: '/v2/items',
            },
            {
                srcPath: '/_api/cloud-data/v2/dbs/tasks',
                destPath: '/v2/dbs/tasks',
            },
        ],
        'www.wixapis.com': [
            {
                srcPath: '/wix-data/v1/collections',
                destPath: '/v1/wix-data/collections',
            },
            {
                srcPath: '/wix-data/v1/external-database-connections',
                destPath: '/v1/external-database-connections',
            },
            {
                srcPath: '/wix-data/v2/indexes',
                destPath: '/v2/indexes',
            },
            {
                srcPath: '/wix-data/v1/items',
                destPath: '/v1/items',
            },
            {
                srcPath: '/wix-data/v1/bulk',
                destPath: '/v1/bulk',
            },
            {
                srcPath: '/wix-data/v1/external-databases',
                destPath: '/v1/external-databases',
            },
            {
                srcPath: '/wix-data/v2',
                destPath: '/v2',
            },
            {
                srcPath: '/data/v2/collections',
                destPath: '/v2/collections',
            },
            {
                srcPath: '/data/v2/items',
                destPath: '/v2/items',
            },
            {
                srcPath: '/data/v2/bulk/items',
                destPath: '/v2/bulk/items',
            },
            {
                srcPath: '/data/v2/indexes',
                destPath: '/v2/indexes',
            },
            {
                srcPath: '/data/v1/external-database-connections',
                destPath: '/v1/external-database-connections',
            },
            {
                srcPath: '/data/v1/data-collection-sharing',
                destPath: '/v1/data-collection-sharing',
            },
        ],
        'www.wixgateway.com': [
            {
                srcPath: '/wix-data/v1/items',
                destPath: '/v1/items',
            },
            {
                srcPath: '/wix-data/v1/bulk',
                destPath: '/v1/bulk',
            },
        ],
        '*.dev.wix-code.com': [
            {
                srcPath: '/_api/cloud-data/v2',
                destPath: '/v2',
            },
            {
                srcPath: '/_api/cloud-data/v1/external-database-connections',
                destPath: '/v1/external-database-connections',
            },
            {
                srcPath: '/data/v1/data-collection-sharing',
                destPath: '/v1/data-collection-sharing',
            },
        ],
    };
    return resolveUrl(Object.assign(opts, { domainToMappings: domainToMappings }));
}
/** Retrieves the specified external database connection. */
export function getExternalDatabaseConnection(payload) {
    var _a = serializer(_getExternalDatabaseConnectionRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = serializer(_getExternalDatabaseConnectionResponse, {}).fromJSON;
    function __getExternalDatabaseConnection(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data.v1.external_database_connection',
            method: 'GET',
            methodFqn: 'com.wixpress.cloud.data.api.externaldatabase.ExternalDatabaseConnectionService.GetExternalDatabaseConnection',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveComWixpressCloudDataApiExternaldatabaseExternalDatabaseConnectionServiceUrl({
                protoPath: '/v1/external-database-connections/{name}',
                data: serializedData,
                host: host,
            }),
            params: toURLSearchParams(serializedData),
            transformResponse: fromRes,
        };
        return metadata;
    }
    __getExternalDatabaseConnection.fromReq = fromReq;
    __getExternalDatabaseConnection.__isAmbassador = true;
    return __getExternalDatabaseConnection;
}
/** Lists all of the site's external database connections of all adaptor types. */
export function listExternalDatabaseConnections(payload) {
    var _a = serializer(_listExternalDatabaseConnectionsRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = serializer(_listExternalDatabaseConnectionsResponse, {}).fromJSON;
    function __listExternalDatabaseConnections(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data.v1.external_database_connection',
            method: 'GET',
            methodFqn: 'com.wixpress.cloud.data.api.externaldatabase.ExternalDatabaseConnectionService.ListExternalDatabaseConnections',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveComWixpressCloudDataApiExternaldatabaseExternalDatabaseConnectionServiceUrl({
                protoPath: '/v1/external-database-connections',
                data: serializedData,
                host: host,
            }),
            params: toURLSearchParams(serializedData),
            transformResponse: fromRes,
        };
        return metadata;
    }
    __listExternalDatabaseConnections.fromReq = fromReq;
    __listExternalDatabaseConnections.__isAmbassador = true;
    return __listExternalDatabaseConnections;
}
/**
 * Creates a new external database connection.
 *
 * Before you can establish a connection between a site and an external database, you must prepare an external database adaptor.
 */
export function createExternalDatabaseConnection(payload) {
    var _a = serializer(_createExternalDatabaseConnectionRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = serializer(_createExternalDatabaseConnectionResponse, {}).fromJSON;
    function __createExternalDatabaseConnection(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data.v1.external_database_connection',
            method: 'POST',
            methodFqn: 'com.wixpress.cloud.data.api.externaldatabase.ExternalDatabaseConnectionService.CreateExternalDatabaseConnection',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveComWixpressCloudDataApiExternaldatabaseExternalDatabaseConnectionServiceUrl({
                protoPath: '/v1/external-database-connections',
                data: serializedData,
                host: host,
            }),
            data: serializedData,
            transformResponse: fromRes,
        };
        return metadata;
    }
    __createExternalDatabaseConnection.fromReq = fromReq;
    __createExternalDatabaseConnection.__isAmbassador = true;
    return __createExternalDatabaseConnection;
}
/**
 * Updates an external database connection.
 *
 * > **Note:** After an external database connection is updated, it only contains the values provided in the request. All previous values are lost.
 */
export function updateExternalDatabaseConnection(payload) {
    var _a = serializer(_updateExternalDatabaseConnectionRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = serializer(_updateExternalDatabaseConnectionResponse, {}).fromJSON;
    function __updateExternalDatabaseConnection(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data.v1.external_database_connection',
            method: 'PUT',
            methodFqn: 'com.wixpress.cloud.data.api.externaldatabase.ExternalDatabaseConnectionService.UpdateExternalDatabaseConnection',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveComWixpressCloudDataApiExternaldatabaseExternalDatabaseConnectionServiceUrl({
                protoPath: '/v1/external-database-connections/{externalDatabaseConnection.name}',
                data: serializedData,
                host: host,
            }),
            data: serializedData,
            transformResponse: fromRes,
        };
        return metadata;
    }
    __updateExternalDatabaseConnection.fromReq = fromReq;
    __updateExternalDatabaseConnection.__isAmbassador = true;
    return __updateExternalDatabaseConnection;
}
/**
 * Deletes an external database connection.
 *
 * > **Note:** Once an external database connection is deleted, it can't be restored. To reconnect the database, create a new external database connection.
 */
export function deleteExternalDatabaseConnection(payload) {
    var _a = serializer(_deleteExternalDatabaseConnectionRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = serializer(_deleteExternalDatabaseConnectionResponse, {}).fromJSON;
    function __deleteExternalDatabaseConnection(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data.v1.external_database_connection',
            method: 'DELETE',
            methodFqn: 'com.wixpress.cloud.data.api.externaldatabase.ExternalDatabaseConnectionService.DeleteExternalDatabaseConnection',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveComWixpressCloudDataApiExternaldatabaseExternalDatabaseConnectionServiceUrl({
                protoPath: '/v1/external-database-connections/{name}',
                data: serializedData,
                host: host,
            }),
            params: toURLSearchParams(serializedData),
            transformResponse: fromRes,
        };
        return metadata;
    }
    __deleteExternalDatabaseConnection.fromReq = fromReq;
    __deleteExternalDatabaseConnection.__isAmbassador = true;
    return __deleteExternalDatabaseConnection;
}
//# sourceMappingURL=http.impl.js.map