MG === -------- conex_PG -------- ------ update ------ Update has some tools to update databases. .. py:function:: MG/update/staticBase Service to update a static database through files downloading. :param user: User id. Used to load all user data. (Not implemented yet , TODO) :type user: str :param output_layer: Connection to ftp where image will be downloaded :type output_layer: FTP Connection :param base_type: StaticBase to be updated. Options: sentinel :type base_type: str :param aoi: Connection to ftp where AOI is hosted :type aoi: FTP Connection :param user_ms: User ID of sentinel platform :type user_ms: str :param password_ms: Password to sentinel platform :type password_ms: str :param cloud_coverage_max: Max cloud coverage, hundred per cent. :type cloud_coverage_max: float :param date: Date to get the images. Options: "month/year" or "now" :type date: str :param sort: :type sort: bool :returns: **response** -- List containing the path of all images downloaded. :rtype: list of str .. rubric:: Examples >>> import requests >>> import json >>> array_bytes = open('AOI_TEST.kml', 'rb').read() >>> int_array = list(array_bytes) >>> params = {"user": 'test', "base": 'sentinel', "params": {"AOI": int_array, "date": '02/2019'}} >>> response = requests.post(url=':/MG/update/staticBase', json=params) [sentinel_repo/29THQ/2019/2, sentinel_repo/29THP/2019/2, ......., sentinel_repo/30TVK/2019/2] -------------------- externalRestAPI_call -------------------- .. py:function:: MG/externalRestAPI_call/Catastro_api Get information from catastro :param user: User ID :type user: str :param service: service to load :type service: str :param Provincia: Nombre de provincia :type Provincia: str :param Municipio: Nombre de municipio :type Municipio: str :param Sigla: Siglas :type Sigla: str :param Calle: Nombre de Calle :type Calle: str :param Numero: Número :type Numero: str :param Bloque: Bloque :type Bloque: str :param Escalera: Escalera :type Escalera: str :param Planta: Planta :type Planta: str :param Puerta: Puerta :type Puerta: str :param RC: RC :type RC: str :param Poligono: Id de polígono :type Poligono: str :param Parcela: Id de Parcela :type Parcela: str :param TipoVia: Tipo de vía :type TipoVia: str :param NombreVia: Nombre de vía :type NombreVia: str :param SRS: SRS :type SRS: str :param Coordenada_X: Coordenada x :type Coordenada_X: float :param Coordenada_Y: Coordendada y :type Coordenada_Y: float :returns: **success** -- Resultado :rtype: dict .. rubric:: Notes http://www.catastro.meh.es/ws/Webservices_Libres.pdf hoja 18 .. py:function:: MG/externalRestAPI_call/camaras_madrid_m30 Get information from Portal de Datos Abiertos de Madrid. Datos en tiempo real de las Cámaras de Madrid :param user: User ID :type user: str :returns: :rtype: csv object .. py:function:: MG/externalRestAPI_call/geocoding_Inverse_geopy Service to get the latitude and longitude through "referencia catastral" using the geopy server :param user: User ID :type user: str :param input: Dirección :type input: str :param exactly_one: :param timeout: time :type timeout: int :param limit: limint :type limit: int :param addressdetails: address info :type addressdetails: str :param language: :type language: str :param geometry: coordinates :type geometry: float :param extratags: tags :type extratags: str :param country_codes: :type country_codes: str :param viewbox: coordinates the box :type viewbox: float :param bounded: bounded :type bounded: float :param featuretype: type feature :type featuretype: str :param namedetails: details :type namedetails: str .. py:function:: MG/externalRestAPI_call/geocoding_Inverse_CartoCiudad Service to get the latitude and longitude through "referencia catastral" :param user: User ID :type user: str :param input: Dirección :type input: str :returns: **success** -- Result :rtype: dict .. py:function:: MG/externalRestAPI_call/geocoding_Direct_CartoCiudad Getting "referencia cadastral" from longitude and latitude :param user: User ID :type user: str :param longitude: Longitude :type longitude: float :param latitude: Latitude :type latitude: float :returns: **success** -- Results :rtype: dict .. py:function:: MG/externalRestAPI_call/red_de_aviones_en_vuelo Información de los aviones que se encuentran en vuelo. :param task: :type task: str :param user: User ID :type user: str :param service: Tipo de servicio que puede ser:All State Vectors, Flights in Time Interval, Flights by Aircraft, Arrivals by Airport, Departures by Airport :type service: str :param time: Tiempo en segundos desde la época ( Marca de tiempo Unix para recuperar los estados. Si se omite, se usará la hora actual. :type time: integer :param icao24: Una o más direcciones de transpondedor ICAO24 representadas por una cadena hexadecimal (por ejemplo, abc9f3). Para filtrar varios ICAO24, agregue la propiedad una vez par cada dirección. Si se omite, se devuelven los vectores de estado de todas las aeronaves. :type icao24: str :param begin: Inicio del intervalo de tiempo para recuperar vuelos como tiempo Unix (segundos desde época) :type begin: integer :param end: Fin del intervalo de tiempo para recuperar vuelos como t iempo Unix (segundos desde época) :type end: integer :param lamin: límite inferior de la latitud en grados decimales :type lamin: float :param lomin: límite inferior de la longitud en grados decimales :type lomin: float :param lamax: límite superior de la latitud en grados decimales :type lamax: float :param lomax: límite superior de la longitud en grados decimales :type lomax: float :param airport: identificador ICAO del aeropuerto :type airport: str :returns: :rtype: dict .. py:function:: MG/externalRestAPI_call/geocoding_Direct_geopy Getting through geopy service the cadastral reference from longitude and latitude :param user: User ID :type user: str :param longitude: Longitude :type longitude: float :param latitude: Latitude :type latitude: float :param exactly_one: Get only one :type exactly_one: str or bool :param timeout: Seconds to timeout :type timeout: float :param language: Language ID :type language: str :param addressdetails: Get address details :type addressdetails: bool :param zoom: Zoom level :type zoom: int :returns: **success** -- Result :rtype: dict .. py:function:: MG/externalRestAPI_call/geocoding_Inverse_nominatim Service to get the latitude and logitud through "referencia catastral" :param task: :param user: User ID :type user: str :param input: Address :type input: str :param limit: limite :type limit: str :param dimension: dimension :type dimension: float .. py:function:: MG/externalRestAPI_call/geocoding_Direct_nominatim Getting through nominatim service the cadastral reference from longitude and latitude :param user: User Id :type user: str :param longitude: Longitude :type longitude: float :param latitude: Longitude :type latitude: float :param dimension: Dimension :type dimension: int :param zoom: Nivel de zoom :type zoom: int :returns: **success** -- Result :rtype: dict ------- sources ------- .. py:function:: MG/sources/info Send the info of schema and database foreign wrapper :param user: User ID :type user: str :returns: Dict with status and message :rtype: dict .. rubric:: Examples >>> import requests >>> parameters={'user':'TEST'} >>> response = requests.post(':/MG/sources/calls/info', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/sources/conn_exist Check whether the connection exist. This is the first step to know if the connection is available :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :returns: Dict with status and message :rtype: dict .. rubric:: Examples >>> import requests >>> input_layer = {'user': 'user', ... 'password': '12345', ... 'ip': '192.168.1.3', ... 'protocol': 'FTP', ... 'type': 'VECTOR', ... 'driver_type': 'SHAPE', ... 'port': '2222', ... "domain": '', ... "source": '/SHP/VECTORES.shp', ... 'layer_name': 'VECTORES'} >>> parameters={'user':'TEST', "input_layer":input_layer} >>> response = requests.post(':/MG/sources/calls/conn_exist', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/sources/create Create a foreign table through wrapper to obtain its information and then be able to create a view to preview the attributes selected by the user. :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :param params: Dict with attributes, name view or sql clauses :type params: dict :param overwrite: Bool to show whether the view could be overwrite if exist :type overwrite: bool :returns: Dict with status and message CSV :rtype: dict .. rubric:: Examples >>> import requests >>> input_layer = {'user': '', ... 'password': '', ... 'ip': '192.168.1.3', ... 'protocol': 'HTTP', ... 'type': 'VECTOR', ... 'driver_type': 'SHAPE', ... 'port': '8001', ... "domain": '', ... "source": 'a/SHP/AREAS_CANINAS.shp', ... 'layer_name': 'AREAS_CANINAS'} >>> params = {'view': 'areas_caninas', ... 'select': '*', ... 'where': '', ... 'groupBy': '', ... 'having': '', ... 'orderBy': '', ... 'limit': ''} >>> parameters={'user':'TEST', "input_layer":input_layer, "params":params, "overwrite":True} >>> response = requests.post(':/MG/sources/calls/create', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/sources/check Check whether the source exist :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :returns: Dict with status and message :rtype: dict .. rubric:: Examples >>> import requests >>> input_layer = {'user': 'user', ... 'password': '12345', ... 'ip': '192.168.1.3', ... 'protocol': 'FTP', ... 'type': 'VECTOR', ... 'driver_type': 'SHAPE', ... 'port': '2222', ... "domain": '', ... "source": '/SHP/VECTORES.shp', ... 'layer_name': 'VECTORES'} >>> parameters={'user':'TEST', "input_layer":input_layer} >>> response = requests.post(':/MG/sources/calls/check', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/sources/list Check if the dataSource exist and list attributes and name :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :returns: Dictionary with status and message that contain the attributes and name of the layers :rtype: dict .. rubric:: Examples >>> import requests >>> input_layer = {'user': '', ... 'password': '', ... 'ip': '192.168.1.3', ... 'protocol': 'HTTP', ... 'type': 'VECTOR', ... 'driver_type': 'GeoTIFF', ... 'port': '8001', ... "domain": '', ... "source": '/a/mdt/wind_direction.tif', ... 'layer_name': 'wind_direction'} >>> parameters={'user':'TEST', "input_layer":input_layer} >>> response = requests.post(':/MG/sources/calls/list', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/sources/preview Create a foreign table through wrapper of the vector and thematic layers to obtain its information and then be able to create a view to preview the attributes selected by the user. The foreign server created will be delimited in the preview service. Statistical information is supplied for raster layers and the contained files are supplied for generic layers. :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :param params: Dict with attributes, name view or sql clauses :type params: dict :param overwrite: Bool to show whether the view could be overwrited if exist :type overwrite: bool :returns: Dict with status and message CSV :rtype: dict .. rubric:: Examples >>> import requests >>> input_layer = {'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'ip': '192.168.1.43', ... "domain": '', ... 'port': '30030', ... 'user': 'srm_postgres_1', ... 'password': 'pg_produccion#1', ... 'database_name': 'imetadata', ... 'schema': 'TEST', ... 'table_view_name': 'edificios'} >>> params = {'view': 'edificios', ... 'select': '*', ... 'where': '', ... 'groupBy': '', ... 'having': '', ... 'orderBy': '', ... 'limit': ''} >>> parameters={'user':'TEST', "input_layer":input_layer, "params":params, "overwrite":True} >>> response = requests.post(':/MG/sources/calls/preview', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/sources/list_ftp_files List all the files and folders contained in the FTP main folder :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :returns: CSV file with the files of the FTP root directory :rtype: obj .. py:function:: MG/sources/delete Delete the foreing table :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :returns: Dict with status and message :rtype: dict .. rubric:: Examples >>> import requests >>> input_layer = {'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'ip': '192.168.1.43', ... "domain": '', ... 'port': '30030', ... 'user': 'srm_postgres_1', ... 'password': 'pg_produccion#1', ... 'database_name': 'imetadata', ... 'schema': 'TEST', ... 'table_view_name': 'edificios'} >>> parameters={'user':'TEST', "input_layer":input_layer} >>> response = requests.post(':/MG/sources/calls/delete', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/sources/prelist Preview the list of schemas or layer of a source. :param user: User ID :type user: str :param input_layer: Object Input Layer :type input_layer: Layer :returns: Dict with status and message CSV :rtype: dict .. rubric:: Examples >>> import requests >>> input_layer = {'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'ip': '192.168.1.3', ... "domain": '', ... 'port': '5432', ... 'user': 'postgres', ... 'password': 'pg', ... 'database_name': 'postgres', ... 'schema': 'TEST', ... 'table_view_name': 'raspberry_loop'} >>> parameters={'user':'TEST', "input_layer":input_layer} >>> response = requests.post(':/MG/sources/calls/prelist', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} -- pg -- .. py:function:: MG/pg/refresh_concurretly_pg Service to refresh PostgreSQL :param task: :param user: :type user: user :param ip_pg: ip PostgreSQL :type ip_pg: str :param port_pg: port PostgreSQL :type port_pg: int :param user_pg: user PostgreSQL :type user_pg: str :param passw_pg: password postgreSQL :type passw_pg: str :param database_pg: name database :type database_pg: str :param schema_pg: name schema :type schema_pg: str :param table_pg: Name table PostgreSQl :type table_pg: str :returns: :rtype: None .. py:function:: MG/pg/insert_data_pgTable Insertar datos en una tabla de Postgres. Con esta función se ingresarán los datos contenidos en el parametro data en una tabla que se encuetre en una base de datos. :param user: User ID :type user: str :param input_layer: Diccionario con los datos de entrada. :type input_layer: dict :param data: Diccionario con el contenido que se desea insertar en la tabla :type data: dict :param extra: Lista con un máximo de tres valores. El primero hace referencia al dominio en caso de que no se posea un postgres: SRM El segundo hace referencia a el esquema de la base de datos. El tercero hace referencia al nombre de la tabla empleada. :type extra: str :param email_verification: Lista que contiene los email para enviar mensaje de verificación :type email_verification: list .. rubric:: Notes Note: En esta función aquellas comillas que vayan precedidas de ___" sirven para poder insertar una setencia SQL y que sirvan para evitar conflictos. .. py:function:: MG/pg/update_data_pgTable Service to update the data of a PostgreSQL table :param task: :param user: :type user: user :param input_layer: Input PostgreSQL layer :type input_layer: Layer :param data: Dict with the data to update :type data: dict :param extra: :type extra: dict :param id: id to update the row :type id: int :param delete: to delete the row or update :type delete: bool :returns: :rtype: None .. py:function:: MG/pg/select_by_id Seleccionar por identificador. Con está función se puede realizar una consulta de los datos en función de los parámetros de busqueda :param user: User ID :type user: str :param input_layer: Diccionario con los datos de entrada. :type input_layer: dict :param extra: Lista con un máximo de tres valores. El primero hace referencia al dominio en caso de que no se posea un postgres: SRM El segundo hace referencia a el esquema de la base de datos. El tercero hace referencia al nombre de la tabla empleada. :type extra: str :param id: Diccionario abierto. Como mínimo este diccionario debe contener dos llaves atribName y value :type id: dict .. rubric:: Examples >>> id = { "atribName": 'id_srm', ... "value": 100, ... "password": 'srmConsulting010', ... "valuePassword": 'srm', ... "key": '2020-11-17-14:03:58Z' ... } .. py:function:: MG/pg/create_foreing_table_pg :param user: User ID :type user: str :param input_layer: Connection to vector source :type input_layer: Connection :returns: **success** :rtype: None .. rubric:: Examples >>> import requests >>> input_layer = {"ip": "192.168.1.214", ... "port": 8001, ... "protocol": 'FTP', ... "user": "test", ... "password": "test", ... "layer_name": "AOI_little", ... "driver_type": "KML", ... "source": "/AOI_little.kml"} >>> parameters={'user':'test', "input_layer":input_layer, "options": "WMS"} >>> response = requests.post(':/MG/layer_server/create_mse', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9"'} ------- plugins ------- .. py:function:: MG/plugins/SQL_sentence Esta función es una función generica para implementar una setencia SQL. :param user: User ID :type user: str :param input_layer: Tabla de postgres de entrada :type input_layer: dict :param output_layer: conexión para la vista o vista materializada de salida :type output_layer: dict :param content: Sentencia en leguaje SQL de la completa :type content: str :returns: **output_layer** -- nombre de a tabla de salida si ha sido creada :rtype: OutLayer .. py:function:: MG/plugins/SQL_sentence_byClauses Esta función es una función generica para implementar una setencia SQL. :param user: User ID :type user: str :param input_layer: Tabla de postgres de entrada :type input_layer: dict :param output_layer: conexión para la vista o vista materializada de salida :type output_layer: dict :param select: Sentencia en leguaje SQL de la clausula select :type select: str :param where: Sentencia en leguaje SQL de la clausula where :type where: str :param groupBy: Sentencia en leguaje SQL de la clausula group by :type groupBy: str :param having: Sentencia en leguaje SQL de la clausula having :type having: str :param orderBy: Sentencia en leguaje SQL de la clausula order by :type orderBy: str :param limit: Sentencia en leguaje SQL de la clausula limit :type limit: str :returns: **output_layer** -- nombre de a tabla de salida si ha sido creada :rtype: OutLayer .. py:function:: MG/plugins/exec_gdal Función que permite la ejecucción de comandos de GDAL sin pasar por los wrappers :param task: :param user: user :type user: str :param input_layer: input_layer kind FPT or POSTGRES :type input_layer: NonLocalLayer :param output_layer: output_layer without wrapper :type output_layer: NonLocalOutLayer :param exec_name: Available kind org2ogr and gdal_translate :type exec_name: str :param command: like %x %i %o :type command: str :param formats: List with all available GDAL formats :type formats: list .. py:function:: MG/plugins/generic_pg_function_2_inputs Esta función llama a una función de PG existente en el sistema que devuelva una tabla :param user: User ID :type user: str :param input_layer_1: Tabla de postgres de entrada :type input_layer_1: dict :param input_layer_2: Segunda tabla de entrada en caso de lanzar sentencias que requieran una segunda tabla de entrada :type input_layer_2: dict :param output_layer: conexión para la vista o vista materializada de salida :type output_layer: dict :param function_name: nombre de la función :type function_name: str :param function_params: parámetros separados por coma y cada uno de ellos entre comillas simples :returns: **output_layer** -- nombre de a tabla de salida si ha sido creada :rtype: OutLayer .. rubric:: Examples >>> import requests >>> input_layer_1 = {'user': '', ... 'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'schema': 'datos', ... "ip": '192.168.1.3', "domain": '', ... "port": '5432', ... "user": 'postgres', ... "database_name": 'postgres', ... "password": 'pg', ... "table_view_name": 'distritos'} >>> input_layer_2 = {'user': '', ... 'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'schema': 'datos', ... "ip": '192.168.1.3', "domain": '', ... "port": '5432', ... "user": 'postgres', ... "database_name": 'postgres', ... "password": 'pg', ... "table_view_name": 'barrios'} >>> output_layer = {'user': '', ... 'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'schema': 'Sonia_pruebas', ... "ip": '192.168.1.3', "domain": '', ... "port": '5432', ... "user": 'postgres', ... "database_name": 'postgres', ... "password": 'pg', ... "table_view_name": 'prueba_generic_diff_dump'} >>> function_name = "difference_dump_vw", >>> function_params = "'TEST',%i1, %i2, %o, 'gid,id_annex,annexdescr,id_tema,tema_descr,id_conjunt,conj_descr,id_subconj,sconj_desc,id_element,elem_descr,nivell,ndescr_ca,ndescr_es,ndescr_en,terme,districte,barri,aeb,sec_cens,granbarri,zua,area_i,literal,perimetre,area,ord_repres,codi_ua,tipus_ua,nom,web1,web2,web3,documenta,rangescala,tipus_pol,gruix_id,gruixdimen,estil_id,estil_qgis,valor1qgis,valor2qgis,col_farcit,fcol_descr,fhex_color,col_descr,hex_color7,', '4326', '4326'", >>> parameters={'user':'TEST', "input_layer_1":input_layer_1, "input_layer_2":input_layer_2, ... "output_layer":output_layer, "function_name": function_name, ... "function_params": function_params } >>> response = requests.post(':/MG/sources/calls/create', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/plugins/generic_pg_function Esta función llama a una función de PG existente en el sistema que devuelva una tabla :param user: User ID :type user: str :param input_layer: Tabla de postgres de entrada tabla de entrada :type input_layer: dict :param output_layer: conexión para la vista o vista materializada de salida :type output_layer: dict :param function_name: nombre de la función :type function_name: str :param function_params: parámetros separados por coma y cada uno de ellos entre comillas simples :returns: **output_layer** -- nombre de a tabla de salida si ha sido creada :rtype: OutLayer .. rubric:: Examples >>> import requests >>> input_layer = {'user': '', ... 'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'schema': 'datos', ... "ip": '192.168.1.3', "domain": '', ... "port": '5432', ... "user": 'postgres', ... "database_name": 'postgres', ... "password": 'pg', ... "table_view_name": 'distritos'} >>> output_layer = {'user': '', ... 'protocol': 'PostgreSQL', ... 'type': 'VECTOR', ... 'driver_type': 'PostgreSQL', ... 'schema': 'Sonia_pruebas', ... "ip": '192.168.1.3', "domain": '', ... "port": '5432', ... "user": 'postgres', ... "database_name": 'postgres', ... "password": 'pg', ... "table_view_name": 'prueba_generic_diff_dump'} >>> function_name = "difference_dump_vw", >>> function_params = "'TEST',%i1, %i2, %o, 'gid,id_annex,annexdescr,id_tema,tema_descr,id_conjunt,conj_descr,id_subconj,sconj_desc,id_element,elem_descr,nivell,ndescr_ca,ndescr_es,ndescr_en,terme,districte,barri,aeb,sec_cens,granbarri,zua,area_i,literal,perimetre,area,ord_repres,codi_ua,tipus_ua,nom,web1,web2,web3,documenta,rangescala,tipus_pol,gruix_id,gruixdimen,estil_id,estil_qgis,valor1qgis,valor2qgis,col_farcit,fcol_descr,fhex_color,col_descr,hex_color7,', '4326', '4326'", >>> parameters={'user':'TEST', "input_layer":input_layer, "output_layer":output_layer, ... "function_name": function_name, ... "function_params": function_params } >>> response = requests.post(':/MG/plugins/calls/generic_pg_function', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} ------------ layer_server ------------ .. py:function:: MG/layer_server/create_mse Service to create mse :param user: User ID. :type user: str :param input_layer: Connection to vector source. :type input_layer: Connection :param options: Layer server type: one of `[WMS, WMTS, GeoJSON]` :type options: str :param autorefresh: Layer server sincronized? :type autorefresh: bool :param autorefresh_latency: Layer server interval refresh :type autorefresh_latency: float :param out_layer: None :type out_layer: None :returns: **success** -- URL to layer server :rtype: str .. rubric:: Examples >>> import requests >>> input_layer = {"ip": "192.168.1.214", ... "port": 8001, ... "protocol": 'FTP', ... "user": "test", ... "password": "test", ... "layer_name": "AOI_little", ... "driver_type": "KML", ... "source": "/AOI_little.kml"} >>> parameters={'user':'test', "input_layer":input_layer, "options": "WMS"} >>> response = requests.post(':/MG/layer_server/create_mse', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9"'} .. py:function:: MG/layer_server/delete_layer_server Delete a layer_server of iMaps :param user: User ID :type user: str :param layer_gs: :type layer_gs: str :returns: Dict with status and message :rtype: dict .. rubric:: Examples >>> import requests >>> layer_gs = 'tiger:tiger_roads' >>> parameters={'user':'TEST', "layer_gs":layer_gs} >>> response = requests.post(':/MG/layer_server/calls/delete_layer_server', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/layer_server/publish_kml Service to publish a kml using Geoserver API :param task: :param user: :type user: user :param url_user_pass: url user :type url_user_pass: str :param connect_user: user to access Geoserver :type connect_user: str :param connect_pass: Password to access Geoserver :type connect_pass: str :param options: options :type options: str :param autorefresh: :type autorefresh: bool :param out_layer: :type out_layer: OutLayer .. py:function:: MG/layer_server/publish_pg Service to publish a pg table :param task: :param user: :type user: user :param ip_pg: ip of PostgreSQL :type ip_pg: str :param port_pg: port of PostgreSQL :type port_pg: int :param user_pg: user to access PostgreSQL :type user_pg: str :param passw_pg: Password to access PostgreSQL :type passw_pg: str :param database_pg: Name database :type database_pg: str :param schema_pg: Name schema :type schema_pg: str :param table_pg: Name PostgreSQL table :type table_pg: str :param options: options :type options: str :param autorefresh: :type autorefresh: bool :param out_layer: OutLayer :type out_layer: dict :returns: :rtype: None .. py:function:: MG/layer_server/publish_shp Service to publish a shapefile :param task: :param user: :param url_user_pass: :type url_user_pass: str :param connect_user: Username :type connect_user: str :param connect_pass: password :type connect_pass: str :param options: extra options :type options: str :param autorefresh: :type autorefresh: bool :param out_layer: :type out_layer: OutLayer :returns: :rtype: None .. py:function:: MG/layer_server/publish_gjson Service to publish a geojson using Geoserver API :param task: :param user: :type user: user :param url_user_pass: url user :type url_user_pass: str :param connect_user: user to access Geoserver :type connect_user: str :param connect_pass: Password to access Geoserver :type connect_pass: str :param options: options :type options: str :param autorefresh: :type autorefresh: bool :param out_layer: :type out_layer: OutLayer ------------ authenticate ------------ .. py:function:: MG/authenticate/dropbox Trigger the authentication flow. After do the post follow the url returned. :param user: User to register :type user: str :param request: Kind of request :type request: str :returns: Url to complete the authentication flow. :rtype: str .. rubric:: Examples >>> import requests >>> parameters={'user':'test'} >>> response = requests.post(':/MG/authenticate/dropbox', ... json=parameters) >>> response.json() "https://www.dropbox.com/oauth2/authorize?response_type=code&redirect_uri=http%3A%2F%2F 127.0.0.1%3A1114%2FMG%2Fauthenticate%2Fdropbox&state=90kB7zdLEs3A861wLD8ihw%3D%3D%7C%7B %22user%22%3A+%22test%22%7D&client_id=t6rpf1d5nr54enk&token_access_type=offline" ----- stats ----- .. py:function:: MG/stats/list_user_catalog_layerServers Función genérica que devuelve de una vez toooodo el contenido de un metadato solicitado :param task: id de la tarea :type task: str :param user: identificador del usuario :type user: str :param catalog: nombre del catálogo :type catalog: str :param id: identificador del elemento a consultar, si se quiere todos id = None :type id: int :param action: string de los valores permitidos. actualmente list, --> lista elementos del catálogo creation, --> crea un nuevo catálogo con el nombre indicado en catalog y user insert, --> añade un nuevo registro al catálogo seleccinado update, --> actualiza un registro con un id especificado remove_id, --> elimina elemento por id delete_all, --> elimina la tabla :type action: str :param values: Si se ha seleccionado la action = insert o update :type values: dict :returns: :rtype: objeto serializable con la información requerida .. py:function:: MG/stats/list_generic_all_external Sevice to return all conent of generic data requested :param task: id de la tarea :type task: str :param user: identificador del usuario :type user: str :param input: string de los valores permitidos. actualmente [ external_layer_servers, --> devuelve un diccionario con los layerServers, tipos y demás info ] :type input: str :param conexion_params: dict con los params de conexión :type conexion_params: dict :returns: :rtype: objeto serializable con la información requerida .. py:function:: MG/stats/extract_info_map Service to extract the info of the map :param task: :param user: :type user: user :param input: dict with a list keyword :type input: dict :returns: :rtype: dict .. py:function:: MG/stats/list_svg_types Service to get the types of the svg available :param task: :param user: :param input: name with the table of svg :type input: str .. py:function:: MG/stats/list_conections_and_sources Service to get the connections and sources :param task: id de la tarea :type task: str :param user: identificador del usuario :type user: str :param input: nombre de la tabla a consultar :type input: str :param id_conexion_type: id de la conexión a consultar, puede ser None/False/false :type id_conexion_type: str :param id_subtype: id del subtipo a consultar, puede ser None/False/false :type id_subtype: str :returns: :rtype: dict serializable con la información requerida .. py:function:: MG/stats/extract_metadata_video_to_csv Parse metadata from video file or url to GMV csv format. :param user: User ID :type user: str :param metadata_format: Metadata format name. "MISB" :KLV(Key-Length-Value) of MISB(Motion Imagery Standards Board) :type metadata_format: str :param video_path: Uniform Resource Locator(Only http) or path to local video with metadata stream. :type video_path: str :returns: comma-separated values of headers and metadata package separated by '/n' :rtype: str :raises NameError: Video not found, video format not supported or video does not contain data stream .. rubric:: Examples >>> import requests >>> parameters={"user": "test", ... "metadata_format": "MISB", ... "video_path": "http://83.48.27.22:30020/marketing/public/dev/metadata_videos/klv_MISB/Esri_multiplexer_0.mp4" ... } >>> response = requests.post('http://:/MG/stats/extract_metadata_video_to_csv', ... json=parameters) >>> response.content String formatted CSV .. py:function:: MG/stats/list_layerserver_and_types Service to get the layer server and types list :param task: id de la tarea :type task: str :param user: identificador del usuario :type user: str :param input: nombre de la tabla a consultar :type input: str :param id_layerserver_type: id del elemento a consultar, puede ser None/False/false :type id_layerserver_type: str :returns: :rtype: objeto serializable con la información requerida .. py:function:: MG/stats/list_svg Service to get a list of svg :param task: :param user: :param input: name of table with the sgv :type input: str :param id_svg_type: id of the svg type :type id_svg_type: str .. py:function:: MG/stats/geoserver_info Reload geoserver through the Geoserver API :param task: :param user: User ID :type user: str :param action: Define the action to exec :type action: str :param extra_param: Dict to define others parameters in case they are necessary :type extra_param: dict :returns: Dict with status and message :rtype: dict .. rubric:: Examples >>> import requests >>> extra_param = {} >>> action = 'reload' >>> parameters={'user':'TEST', 'action': action, "extra_param":extra_param} >>> response = requests.post(':/MG/stats/calls/geoserver_info', ... json=parameters) >>> response.json() {'task_id': 'XoiRl9'} .. py:function:: MG/stats/list_generic_all Función genérica que devuelve de una vez toooodo el contenido de un metadato solicitado :param task: id de la tarea :type task: str :param user: identificador del usuario :type user: str :param input: string de los valores permitidos. actualmente [ connections, --> devuelve un diccionario con los tipos de conexiones y datos permitidos para cada una layer_servers, --> devuelve un diccionario con los layerServers, tipos y demás info ] :type input: str :param id: identificador del elemento a consultar, si se quiere todos id = None :type id: int :returns: :rtype: objeto serializable con la información requerida .. py:function:: MG/stats/list_svg_and_types Service to get a list with the svg and types :param task: :param user: :param input: :type input: str :param id_svg_type: identifier of svg :type id_svg_type: int ------------ comunication ------------ .. py:function:: MG/comunication/gms_server Trigger the communication with gms server is available. :param user: User :type user: str :param url: url of gms server :type url: str :returns: Dict with status and message :rtype: dict .. rubric:: Examples >>> import requests >>> parameters={'url':'http://127.0.0.1:1114/MG/comunication'} >>> response = requests.post(':/MG/comunication/gms_server', ... json=parameters) >>> response.json() "{'status': 'ok', 'message': 'Connection gms server is available'}" .. py:function:: MG/comunication/sendEmail Service to send an email :param task: :param user: :param receiver_email: user who received the email :type receiver_email: str :param subject: subject of email to send :type subject: str :param text_type: text :type text_type: str :param contain: contain of email :type contain: str :returns: :rtype: None .. py:function:: MG/comunication/call_bot_twitter Service to call bot twitter :param task: :param user: :param function: :param keywords: keywords :type keywords: str :param tweet: tweet :type tweet: str :param message: message :type message: str :param message_rt: message retweet :type message_rt: str :param tweet_user: user of twitter :type tweet_user: str :param dm: :type dm: str :param consumer_key: consumer key API :type consumer_key: str :param consumer_secret: consumer sercret API :type consumer_secret: str :param access_token: access token :type access_token: str :param access_token_secret: secret access token :type access_token_secret: str .. py:function:: MG/comunication/send_email Send `email_type` email from `from_addr` with `from_addr_passw` to `to_addrs`. Each `email_type` has its own `email_parameters`. :param user: :param to_addrs: Space separated emails. "example_1@example.com example_2@example.com" :type to_addrs: str :param from_addr: Email account from email will be sent. If is None the default account will be used. :type from_addr: str, optional :param from_addr_passw: Password for `from_addr`. If `from_addr` is None will be ignored. :type from_addr_passw: str, optional :param input_layer: Connection to set as a download link in the email :type input_layer: Connection, optional :param email_type: Email type, Options ['success'] email_parameters with header_message :type email_type: str :param email_parameters: Json format parameters for `email_type` :type email_parameters: str :returns: :rtype: None .. rubric:: Examples >>> import requests >>> params={'user': 'test', ... 'input_layer': {'protocol': "FTP", ... "ip": "ftp", ... "port": 21, ... "user": "test", ... "password": "test", ... "driver_type": "KML", ... 'type': 'VECTOR', ... "source": '/AOI_little.kml', ... 'layer_name': "AOI_little" ... }, ... "to_addrs": 'robertpardillo93@gmail.com rpardillo@srmconsulting.es', ... "email_type": "success", ... "email_parameters": "header_message: Texto de cabecera", ... "from_addr": None, ... "from_addr_passw": None} >>> response = requests.post(':/MG/comunications/send_eamil', ... json=params) >>> response.json() -------- routines -------- Routines allows the user to execute periodically a service. .. py:function:: MG/routines/info Task information :param user: Task user :type user: str :param task_id: Task id :type task_id: str :returns: **result** -- If task does not exist return error. If task exists return a dict with some info. Dict keys 'is_enabled', 'user_taskid', 'command', 'description', 'last_run' :rtype: str or dict .. rubric:: Notes % in any of string make script falls. .. rubric:: Examples >>> import requests >>> import json >>> params = {"user": 'test', "task_id": '8485#&'} >>> requests.post(url='/MG/routines/info', json=params) {'is_enabled': True, 'user_taskid: 'test#8485#&', 'command': geomicroservice, 'description': description, 'last_run': last_run_date} .. py:function:: MG/routines/remove Remove task :param user: User id :type user: str :param task_id: Task id :type task_id: str :returns: **result** -- result[0]: message result[1]: bool if it is deleted or not :rtype: list of str and bool .. rubric:: Notes % in any of string make script falls. .. rubric:: Examples >>> import requests >>> import json >>> params = {"user": 'test', task_id:'88657y!'} >>> requests.post(url='/MG/routines/remove', json=params) ['Your task has successfully removed', True] .. py:function:: MG/routines/start Start a stopped task :param user: User id :type user: str :param task_id: Task id :type task_id: str :returns: **result** -- result[0]: message result[1]: bool if it is started or not :rtype: list of str and bool .. rubric:: Notes % in any of string make script falls. .. rubric:: Examples >>> import requests >>> import json >>> params = {"user": 'test', task_id:'88657y!'} >>> requests.post(url='/MG/update/start', json=params) ['Your task has successfully started', True] .. py:function:: MG/routines/create Create a geomicroservice routine :param user: User id :type user: str :param geom: Geomicroservice in URL format :type geom: str :param params: Dict containing the parameters to feed `geom` geomicroservice :type params: dict :param period: Cron formatted string scheduling the task :type period: str :returns: **result** -- Dict containing task_id field with id of created task :rtype: dict .. rubric:: Notes % in any of string make script falls. .. rubric:: Examples >>> import requests >>> import json >>> ints = list(open('AOI_TEST.kml', 'rb').read()) >>> date = '02/18' >>> params = {"user": 'test', "geom": 'MG/update/staticBase', "params": {"user": 'I6', "base": 'sentinel', "params": {"AOI": ints,"date": date}}, "period": 'minute.every(1)'} >>> requests.post(url='/MG/routines/create', json=params) {'task_id':'oij89&!0'} .. py:function:: MG/routines/stop Stop a task. :param user: User id :type user: str :param task_id: Task id :type task_id: str :returns: result[0]: message result[1]: bool if it is stopped or not :rtype: result .. rubric:: Notes % in any of string make script falls. >>> import requests >>> import json >>> params = {"user": 'test', task_id:'88657y!'} >>> requests.post(url='/MG/update/stop', json=params) ['Your task has successfully stopped', True] .. py:function:: MG/routines/change Change schedule of the given task :param task_id: Id of task to be change :type task_id: str :param period: Cron formatted schedule string :type period: str :param user: Task user :type user: str :returns: **result** -- result[0]: message result[1]: bool if it is deleted or not :rtype: str .. rubric:: Notes % in any of string make script falls. .. rubric:: Examples >>> # Change stopped task >>> import requests >>> import json >>> params = {"user": 'test', "task_id": '8485#&', "period": 'minute.every(1)'} >>> requests.post(url='/MG/routines/change', json=params) ['8485#& succesfully changed', True] >>> # Change started task >>> params = {"user": 'test', "task_id": '8485#&'} >>> requests.post(url='/MG/routines/change', json=params) ['8485#& succesfully stopped', True] >>> params = {"user": 'test', "task_id": '8485#&', "period": 'minute.every(1)'} >>> requests.post(url='/MG/routines/change', json=params) ['8485#& succesfully changed', True] >>> # Wrong task_id >>> params = {"user": 'test', "task_id": '0000000'} >>> requests.post(url='/MG/routines/change', json=params) ['Wrong task id. This task does not exists.', False] .. py:function:: MG/routines/list List all task scheduled by `user` :param user: User id :type user: str :returns: **result** -- List with info of each task. :rtype: list of dict .. rubric:: Notes % in any of string make script falls. .. rubric:: Examples >>> import requests >>> import json >>> params = {"user": 'test'} >>> requests.post(url='/MG/routines/list', json=params) [{'is_enabled': True, 'user_taskid: 'test#8485#&', 'command': geomicroservice, 'description': description, 'last_run': last_run_date}, ...., {'is_enabled': True, 'user_taskid: 'test#897548', 'command': geomicroservice, 'description': description, 'last_run': last_run_date}] ------- itasker ------- .. py:function:: MG/itasker/run_task :param user: User id :type user: str :param json_graph: Dict containing graph architecture :type json_graph: dict .. py:function:: MG/itasker/get_result Obtiene el resultado de una tarea :param user: Id de usuario :type user: str :param task_id: Id de tarea :type task_id: str :returns: **result** -- Diccionario con el resultado :rtype: dict .. py:function:: MG/itasker/get_task_list Servicio que devuelve un json con la lista de tareas :param user: Id del usuario. :type user: str :returns: **result** -- Devuelve un json con la lista de tareas :rtype: json .. py:function:: MG/itasker/get_task_monitor Obtener información sobre una tarea :param user: Id de usuario :type user: str :param task_id: Id de tarea :type task_id: str :returns: **result** -- Si la tarea existe devuelve su información. Si no existe devuelve una lista. :rtype: dict or list .. py:function:: MG/itasker/pause_task Pausa una tarea :param user: Id de usuario :type user: str :param task_id: Id de tarea :type task_id: str :returns: **result** -- Si la tarea existe devuelve su información. Si no existe devuelve una lista. :rtype: dict or list .. py:function:: MG/itasker/test :param user: User id :type user: str :param graph: Dict containing graph architecture :type graph: dict .. py:function:: MG/itasker/restart_task Pausa una tarea :param user: Id de usuario :type user: str :param task_id: Id de tarea :type task_id: str :returns: **result** -- Si la tarea existe devuelve su información. Si no existe devuelve una lista. :rtype: dict or list .. py:function:: MG/itasker/kill_task Cancela una tarea :param user: Id de usuario :type user: str :param task_id: Id de tarea :type task_id: str :returns: **result** -- Si la tarea existe devuelve su información. Si no existe devuelve una lista. :rtype: dict or list