Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
r, c, geo_query = handle_geo_query(georel, geometry, coords)
if r:
return r, c
if attrs is not None:
attrs = attrs.split(',')
fiware_s = request.headers.get('fiware-service', None)
fiware_sp = request.headers.get('fiware-servicepath', None)
entities = None
entity_ids = None
if id_:
entity_ids = [s.strip() for s in id_.split(',') if s]
try:
with translator_for(fiware_s) as trans:
entities = trans.query(attr_names=attrs,
entity_type=entity_type,
entity_ids=entity_ids,
aggr_method=aggr_method,
aggr_period=aggr_period,
aggr_scope=aggr_scope,
from_date=from_date,
to_date=to_date,
last_n=last_n,
limit=limit,
offset=offset,
fiware_service=fiware_s,
fiware_servicepath=fiware_sp,
geo_query=geo_query)
except NGSIUsageError as e:
return {
if c != 200:
return r, c
r, c, geo_query = handle_geo_query(georel, geometry, coords)
if r:
return r, c
fiware_s = request.headers.get('fiware-service', None)
fiware_sp = request.headers.get('fiware-servicepath', None)
entities = None
entity_ids = None
if id_:
entity_ids = [s.strip() for s in id_.split(',') if s]
try:
with translator_for(fiware_s) as trans:
entities = trans.query(attr_names=[attr_name],
entity_type=entity_type,
entity_ids=entity_ids,
aggr_method=aggr_method,
aggr_period=aggr_period,
aggr_scope=aggr_scope,
from_date=from_date,
to_date=to_date,
last_n=last_n,
limit=limit,
offset=offset,
fiware_service=fiware_s,
fiware_servicepath=fiware_sp,
geo_query=geo_query)
except NGSIUsageError as e:
return {
aggr_scope,
options)
if c != 200:
return r, c
r, c, geo_query = handle_geo_query(georel, geometry, coords)
if r:
return r, c
fiware_s = request.headers.get('fiware-service', None)
fiware_sp = request.headers.get('fiware-servicepath', None)
entities = None
entity_ids = None
if id_:
entity_ids = [s.strip() for s in id_.split(',') if s]
try:
with translator_for(fiware_s) as trans:
entities = trans.query(attr_names=[attr_name],
entity_type=type_,
entity_ids=entity_ids,
aggr_method=aggr_method,
aggr_period=aggr_period,
aggr_scope=aggr_scope,
from_date=from_date,
to_date=to_date,
last_n=last_n,
limit=limit,
offset=offset,
fiware_service=fiware_s,
fiware_servicepath=fiware_sp,
geo_query=geo_query)
except NGSIUsageError as e:
msg = "Bad Request Error: {}".format(e)
if c != 200:
return r, c
r, c, geo_query = handle_geo_query(georel, geometry, coords)
if r:
return r, c
if attrs is not None:
attrs = attrs.split(',')
fiware_s = request.headers.get('fiware-service', None)
fiware_sp = request.headers.get('fiware-servicepath', None)
entities = None
try:
with translator_for(fiware_s) as trans:
entities = trans.query(attr_names=attrs,
entity_type=type_,
entity_id=entity_id,
aggr_method=aggr_method,
aggr_period=aggr_period,
from_date=from_date,
to_date=to_date,
last_n=last_n,
limit=limit,
offset=offset,
fiware_service=fiware_s,
fiware_servicepath=fiware_sp,
geo_query=geo_query)
except NGSIUsageError as e:
return {
"error": "{}".format(type(e)),
if r:
return r, c
if attrs is not None:
attrs = attrs.split(',')
fiware_s = request.headers.get('fiware-service', None)
fiware_sp = request.headers.get('fiware-servicepath', None)
entities = None
entity_ids = None
if id_:
entity_ids = [s.strip() for s in id_.split(',') if s]
try:
with translator_for(fiware_s) as trans:
entities = trans.query(attr_names=attrs,
entity_type=type_,
entity_ids=entity_ids,
aggr_method=aggr_method,
aggr_period=aggr_period,
aggr_scope=aggr_scope,
from_date=from_date,
to_date=to_date,
last_n=last_n,
limit=limit,
offset=offset,
fiware_service=fiware_s,
fiware_servicepath=fiware_sp,
geo_query=geo_query)
except NGSIUsageError as e:
msg = "Bad Request Error: {}".format(e)
if fiware_s:
fiware_sp = request.headers.get('fiware-servicepath', None)
else:
fiware_sp = None
res_entity = []
e = None
for entity in payload:
# Validate entity update
e = _filter_empty_entities(entity)
if e is not None:
e_new = _filter_no_type_no_value_entities(e)
res_entity.append(e_new)
payload = res_entity
# Send valid entities to translator
with translator_for(fiware_s) as trans:
trans.insert(payload, fiware_s, fiware_sp)
msg = 'Notification successfully processed'
log().info(msg)
return msg