def post(self, boom_post_json): """POST a new gridset creation request. Args: boom_post_json (dict): A JSON dictionary of gridset parameters. Returns: HTTP Response: A success indication as an HTTP response status. """ return RestService.post(self, self.end_point, body=json.dumps(boom_post_json), headers={'Content-Type': 'application/json'})
def post(self, taxon_ids): """Get points for the provided taxon identifiers. Args: taxon_ids (list): A list of taxonomic identifiers to get points for. Returns: dict: A dictionary (JSON) of metadata about the points request. """ return RestService.post(self, self.end_point, body=json.dumps(taxon_ids), headers={'Content-Type': 'application/json'})
def post(self, taxon_ids): """Submit a POST request to the Open Tree endpoint to get a tree from ids. Args: taxon_ids (list): A list of taxonomic identifiers established by GBIF. Returns: dict: A JSON dictionary of Open Tree response data. """ return RestService.post(self, self.end_point, body=json.dumps(taxon_ids), headers={'Content-Type': 'application/json'})
def post(self, scenario_json): """Post a new scenario to the server. Args: scenario_json (dict): A JSON dictionary of scenario metadata. Returns: dict: A JSON dictionary of scenario metadata. """ return RestService.post(self, self.end_point, body=scenario_json, headers={'Content-Type': 'application/json'})
def post(self, names_list): """Submit a request to get accepted names from a provided list of names. Args: names_list (list of str): A list of names to get the GBIF accepted names for, if they are available. Returns: dict: A dictionary (JSON) of name translation information. """ return RestService.post(self, self.end_point, body=json.dumps(names_list), headers={'Content-Type': 'application/json'})
def post(self, boom_post_json): """Post a new experiment. Args: boom_post_json (dict): A dictionary of BOOM parameters for submitting an experiment. Returns: HTTP Response: An indication of success of the experiment post. """ return RestService.post(self, self.end_point, body=boom_post_json, headers={'Content-Type': 'application/json'})
def post(self, collection, query_string): """Submit a POST request to the Raw Solr endpoint. Args: collection (str): The Lifemapper Solr connection to connect to. query_string (str): The Solr query string to pass along. Returns: dict: A dictionary of Solr related content. """ return RestService.post(self, self.end_point, body=json.dumps({ 'collection': collection, 'query_string': query_string }), headers={'Content-Type': 'application/json'})
def tree(self, filename, tree_name): """Upload a tree file. Args: filename (str): The file path to the tree to upload. tree_name (str): The name of the newly uploaded tree. Returns: HTTP Response: An indication of success. """ if os.path.exists(filename): return RestService.post( self, self.end_point, files={'file': (filename, open(filename, 'rb'))}, file_name=tree_name, upload_type='tree')
def post(self, name, epsg_code, cell_sides, cell_size, map_units, bbox, cutout=None): """Posts a new shapegrid to the server. Args: name (str): A name for this shapegrid. epsg_code (int): An EPSG code representing the map projection to use when defining this shapegrid. cell_sides (int): The number of sides each cell in the shapegrid should have. Use 4 for rectangular cells and 6 for hexagonal cells. cell_size (float): The size of each side of each cell in the shapegrid (in map_units). map_units (str): The units for the cell_sizes of the map. Examples are: dd - decimal degrees m - meters ft - feet bbox (tuple): Bounding box tuple for this shapegrid in the form (minimum x, maximum x, minimum y, maximum y). cutout (:obj:`str`, optional): An area of the shapegrid to "cut out", meaning to remove cells that fall within that area. This should be specified as Well-Known Text. Returns: dict - A JSON dictionary of metadata about the newly posted shapegrid. """ return RestService.post(self, self.end_point, headers={'Content-Type': 'application/json'}, name=name, epsg_code=epsg_code, cell_sides=cell_sides, cell_size=cell_size, map_units=map_units, bbox=bbox, cutout=cutout)
def biogeographic_hypotheses(self, filename, package_name): """Upload a zip file of biogeographic hypotheses. Args: filename (str): The file path to the hypothesis zip file to upload. package_name (str): A name for this newly uploaded hypotheses zip file. Returns: HTTP Response: An indication of success. """ if os.path.exists(filename): return RestService.post(self, self.end_point, files={ 'file': (filename, open(filename, 'rb'), 'application/zip') }, file_name=package_name, upload_type='biogeo')
def post(self, filename_or_flo, name, schema): """Attempt to POST a new tree to the service end-point. Args: filename_or_flo (str or file-like object): A filename or file-like object containing the tree data. name (str): A name for this new tree. schema (str): The tree schema (newick, nexus, nexml). Returns: dict: A dictionary of tree metadata. """ try: body = filename_or_flo.read() except Exception: # Try opening the file with open(filename_or_flo) as in_file: body = in_file.read() return RestService.post(self, self.end_point, body=body, name=name, schema=schema)
def occurrence(self, filename, metadata, data_name): """Upload a zip file of occurrence data. Args: filename (str): The file path to the occurrence zip file to upload. metadata (dict): Metadata about the structure of the occurrence data file. data_name (str): A name for the newly uploaded occurrence file. Returns: HTTP Response: An indication of success. """ # If metadata is a dictionary, encode for posting if isinstance(metadata, dict): metadata = json.dumps(metadata) if os.path.exists(filename): return RestService.post( self, self.end_point, files={'file': (filename, open(filename, 'rb'), 'text/csv')}, file_name=data_name, upload_type='occurrence', metadata=metadata)
def post_tree(self, gridset_id, tree_id=None, tree_content=None, tree_schema=None): """POST a tree to be added to the specified gridset. Args: gridset_id (int): The identifier of the gridset to add the tree to. tree_id (int): If the tree already exists on the server, just specify it's identifier. tree_content (str): The content of the tree if it does not already exist. tree_schema (str): The schema of the tree content to post. Returns: HTTP Response: An HTTP status response indicating if the request was successfully received. """ return RestService.post(self, '{}/{}/tree'.format(self.end_point, gridset_id), body=tree_content, tree_schema=tree_schema, tree_id=tree_id)
def post_analyses(self, gridset_id, do_calc=None, do_mcpa=None, num_permutations=None): """Request computational analyses to be run on a gridset. Args: gridset_id (int): The identifier of the gridset to use. do_calc (int): Zero or one indicating if RAD stats should be computed. do_mcpa (int): Zero or one indicating if MCPA should be computed. num_permutations (int): The number of permutations to create when creating an null model. Returns: HTTP Response: An HTTP status response indicating if the request was successfully received. """ return RestService.post(self, '{}/{}/analysis'.format( self.end_point, gridset_id), do_calc=do_calc, do_mcpa=do_mcpa, num_permutations=num_permutations)
def post_subset( self, archive_name, gridset_id, algorithm_code=None, bbox=None, display_name=None, model_scenario_code=None, point_max=None, point_min=None, prj_scen_code=None, squid=None, taxon_kingdom=None, taxon_phylum=None, taxon_class=None, taxon_order=None, taxon_family=None, taxon_genus=None, taxon_species=None ): """Create a new subset using the query parameters to select PAVs. Args: archive_name (str): The name of the new subset archive. algorithm_code (str): The code of the modeling algorithm the PAVs should have been built from. bbox (tuple of number): A (min x, min y, max x, max y) bounding box to subset to. display_name (str): Match on this display name. gridset_id (int): The identifier of the gridset containing the PAVs. model_scenario_code (str): The scenario code of the PAV's model. point_max (int): The maximum number of points the PAV should be built from. point_min (int): The minimum number of points the PAV should be built from. prj_scen_code (str): A projection scenario code to match on. squid (str): A Lifemapper species identifier to match on. taxon_kingdom (str): A taxonomic kingdom to match on. taxon_phylum (str): A taxonomic phylum to match on. taxon_class (str): A taxonomic class to match on. taxon_order (str): A taxonomic order to match on. taxon_family (str): A family to match on. taxon_genus (str): A genus name to match on. taxon_species (str): A species name to match on. Returns: list of dict: A JSON list of matching PAV objects. """ return RestService.post( self, self.end_point, headers={'Content-Type': 'application/json'}, archive_name=archive_name, gridset_id=gridset_id, algorithm_code=algorithm_code, bbox=bbox, display_name=display_name, model_scenario_code=model_scenario_code, point_max=point_max, point_min=point_min, prj_scen_code=prj_scen_code, squid=squid, taxon_kingdom=taxon_kingdom, taxon_phylum=taxon_phylum, taxon_class=taxon_class, taxon_order=taxon_order, taxon_family=taxon_family, taxon_genus=taxon_genus, taxon_species=taxon_species )