45 lines
2.0 KiB
PL/PgSQL
45 lines
2.0 KiB
PL/PgSQL
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.6.0'" to load this file. \quit
|
|
|
|
--
|
|
-- Public dataservices API function
|
|
--
|
|
-- These are the only ones with permissions to publicuser role
|
|
-- and should also be the only ones with SECURITY DEFINER
|
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_route_with_waypoints (waypoints geometry(Point, 4326)[], mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
|
DECLARE
|
|
ret cdb_dataservices_client.simple_route;
|
|
username text;
|
|
orgname text;
|
|
BEGIN
|
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
|
RAISE EXCEPTION 'The api_key must be provided';
|
|
END IF;
|
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
|
-- JSON value stored "" is taken as literal
|
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
|
END IF;
|
|
|
|
SELECT * FROM cdb_dataservices_client._cdb_route_with_waypoints(username, orgname, waypoints, mode, options, units) INTO ret;
|
|
RETURN ret;
|
|
|
|
END;
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_route_with_waypoints (username text, organization_name text, waypoints geometry(Point, 4326)[], mode text, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers')
|
|
RETURNS cdb_dataservices_client.simple_route AS $$
|
|
CONNECT cdb_dataservices_client._server_conn_str();
|
|
|
|
SELECT * FROM cdb_dataservices_server.cdb_route_with_waypoints (username, organization_name, waypoints, mode, options, units);
|
|
|
|
$$ LANGUAGE plproxy;
|
|
|
|
|
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_route_with_waypoints(waypoints geometry(Point, 4326)[], mode text, options text[], units text) TO publicuser;
|