def get_compare_original_vs_processed(self, uuid): """Does a GET request to /ws/occurrence/compare/{UUID}. Compare the original record to the processed (interpreted) version of the record. Args: uuid (string): The identifier for the record. Returns: mixed: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # The base uri for api requests query_builder = Configuration.BASE_URI # Prepare query string for API call query_builder += "/ws/occurrence/compare/{UUID}" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters(query_builder, { "UUID": uuid }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "user-agent": "APIMATIC 2.0", "accept": "application/json" } # Prepare and invoke the API call request to fetch the response response = unirest.get(query_url, headers=headers) # Error handling using HTTP status codes if response.code < 200 or response.code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.code, response.body) return response.body
def retrieve_list_of_species_and_counts_for_group(self, options=dict()): """Does a GET request to /ws/explore/group/{group}. Supports the additional parameters pageSize, start, sort, dir - to allow paging through the results Args: options (dict, optional): Key-value pairs for any of the parameters to this API Endpoint. All parameters to the endpoint are supplied through the dictionary with their names being the key and their desired values being the value. A list of parameters that can be used are:: group -- string -- group dir -- string -- dir fq -- list of string -- The filter query lat -- double -- The latitude to limit the query by (must be used with lon and radius) lon -- double -- The longitude to limit the query by (must be used with lat and radius) page_size -- int -- Number of records to return q -- string -- The query which defaults to : when not supplied radius -- int -- The radius in km to limit the search to. Must be used with lat and lon. sort -- string -- sort start -- int -- Record offset, to enable paging Returns: mixed: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # The base uri for api requests query_builder = Configuration.BASE_URI # Prepare query string for API call query_builder += "/ws/explore/group/{group}" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters(query_builder, { "group": options.get('group', None) }) # Process optional query parameters query_builder = APIHelper.append_url_with_query_parameters(query_builder, { "dir": options.get('dir', None), "fq": options.get('fq', None), "lat": options.get('lat', None) if options.get('lat', None) is not None else -41.290817, "lon": options.get('lon', None) if options.get('lon', None) is not None else 174.753377, "pageSize": options.get('page_size', None), "q": options.get('q', None), "radius": options.get('radius', None) if options.get('radius', None) is not None else 20, "sort": options.get('sort', None), "start": options.get('start', None) }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "user-agent": "APIMATIC 2.0", "accept": "application/json" } # Prepare and invoke the API call request to fetch the response response = unirest.get(query_url, headers=headers) # Error handling using HTTP status codes if response.code < 200 or response.code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.code, response.body) return response.body
def get_download_list_of_species_in_group(self, options=dict()): """Does a GET request to /ws/explore/group/{group}/download. Retrieve all species groups and counts. The first count is total number of occurrence, the second is the number of distinct species Args: options (dict, optional): Key-value pairs for any of the parameters to this API Endpoint. All parameters to the endpoint are supplied through the dictionary with their names being the key and their desired values being the value. A list of parameters that can be used are:: group -- string -- group fq -- list of string -- The filter query lat -- double -- The latitude to limit the query by (must be used with lon and radius) lon -- double -- The longitude to limit the query by (must be used with lat and radius) q -- string -- The query which defaults to : when not supplied radius -- int -- The radius in km of the circle to limit to (must be used with lat and lon) Returns: binary: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # The base uri for api requests query_builder = Configuration.BASE_URI # Prepare query string for API call query_builder += "/ws/explore/group/{group}/download" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters(query_builder, { "group": options.get('group', None) }) # Process optional query parameters query_builder = APIHelper.append_url_with_query_parameters(query_builder, { "fq": options.get('fq', None), "lat": options.get('lat', None) if options.get('lat', None) is not None else -41.290817, "lon": options.get('lon', None) if options.get('lon', None) is not None else 174.753377, "q": options.get('q', None), "radius": options.get('radius', None) if options.get('radius', None) is not None else 20 }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "user-agent": "APIMATIC 2.0" } # Prepare and invoke the API call request to fetch the response response = unirest.get(query_url, headers=headers) # Error handling using HTTP status codes if response.code < 200 or response.code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.code, response.body) return response.body