def get_metadata(server, dataset, display=True): url = meta_url.format(server, dataset) response = requests.get(url, headers=HEADERS) file_info = response.json() if display: print_json(file_info) return file_info
def get_dataset_info(server, dataset_name, display=True): url = dataset_meta_url.format(server, dataset_name) response = requests.get(url, headers=HEADERS) dataset_info = response.json() if display: print_json(dataset_info) return dataset_info
def get_multipoints(server, datasets, locations, out_file=None): url = multipoint_url.format(server) parameters = {"locations": json.dumps(locations), "name": datasets} response = requests.get(url, headers=HEADERS, params=parameters) # Or do a POST Request. POST is required for large numbers of points. # response = requests.post(url, headers=HEADERS, json=parameters, params={'name': datasets}) result = response.json() # Write it to a file, if required, or print it, if not if response.status_code == 404 or response.status_code == 400: print("Area request failed... Reason follows.") print(response.text) else: if out_file: with open(out_file, 'w') as outfile: json.dump(result, outfile) else: print_json(result)