def get_allele(self, profile_id, locations ): """Does a POST request to /genotypes/{profile_id}. Allele data Args: locations (string): Allele location separated by space profile_id (string): Genetic Profile Id 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 += "/genotypes/{profile_id}" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters(query_builder, { "profile_id": profile_id }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "Authorization": "Bearer "+ Configuration.o_auth_access_token, "user-agent": "WeGene SDK", "accept": "application/json", } # Prepare parameters parameters = { "locations": ' '.join(locations) } # Prepare and invoke the API call request to fetch the response response = requests.post(query_url, headers=headers, data=parameters) # Error handling using HTTP status codes if response.status_code < 200 or response.status_code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.status_code, response.json()) return response.json()
def get_allele(self, profile_id, locations): """Does a POST request to /genotypes/{profile_id}. Allele data Args: locations (string): Allele location separated by space profile_id (string): Genetic Profile Id 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 += "/genotypes/{profile_id}" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters( query_builder, {"profile_id": profile_id}) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "Authorization": "Bearer " + Configuration.o_auth_access_token, "user-agent": "WeGene SDK", "accept": "application/json", } # Prepare parameters parameters = {"locations": ' '.join(locations)} # Prepare and invoke the API call request to fetch the response response = requests.post(query_url, headers=headers, data=parameters) # Error handling using HTTP status codes if response.status_code < 200 or response.status_code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.status_code, response.json()) return response.json()
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "description": "description", "mag": "mag", "odds": "odds", "result": "result", "sex": "sex", "rank": "rank", "caseid": "caseid", "score": "score", "percent": "percent", "risk": "risk", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "met": "met", "metabolic": "metabolic", "sports_speed": "sports_speed", "sports_times": "sports_times", "sports_type": "sports_type", "total_consume": "total_consume", "total_intake": "total_intake", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "gene": "gene", "genotype": "genotype", "genotypeid": "genotypeid", "mag": "mag", "orientation": "orientation", "repute": "repute", "rsid": "rsid", "snpid": "snpid", "summary": "summary", "tsummary": "tsummary", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "met": "met", "metabolic": "metabolic", "sports_speed": "sports_speed", "sports_times": "sports_times", "sports_type": "sports_type", "total_consume": "total_consume", "total_intake": "total_intake", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "gene": "gene", "genotype": "genotype", "genotypeid": "genotypeid", "mag": "mag", "orientation": "orientation", "repute": "repute", "rsid": "rsid", "snpid": "snpid", "summary": "summary", "tsummary": "tsummary", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "description": "description", "mag": "mag", "odds": "odds", "result": "result", "sex": "sex", "rank": "rank", "caseid": "caseid", "score": "score", "percent": "percent", "risk": "risk", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "african": "african", "middle_eastern": "middle_eastern", "ne_asian": "ne_asian", "se_asian": "se_asian", "chinese_nation": "chinese_nation", "central_asian": "central_asian", "european": "european", "american": "american", "south_asian": "south_asian", "oceanian": "oceanian", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def get_user(self): """Does a GET request to /user/. Endpoint for basic user information Returns: User: 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 += "/user/" # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "Authorization": "Bearer " + Configuration.o_auth_access_token, "user-agent": "WeGene SDK", "accept": "application/json", } # Prepare and invoke the API call request to fetch the response response = requests.get(query_url, headers=headers) # Error handling using HTTP status codes if response.status_code < 200 or response.status_code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.status_code, response.json()) # Try to cast response to desired type if isinstance(response.json(), dict): # Response is already in a dictionary, return the object try: return User(**response.json()) except TypeError: raise APIException("Invalid JSON returned", response.status_code, response.json()) # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.status_code, response.json())
def get_user(self): """Does a GET request to /user/. Endpoint for basic user information Returns: User: 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 += "/user/" # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "Authorization": "Bearer " + Configuration.o_auth_access_token, "user-agent": "WeGene SDK", "accept": "application/json", } # Prepare and invoke the API call request to fetch the response response = requests.get(query_url, headers=headers) # Error handling using HTTP status codes if response.status_code < 200 or response.status_code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.status_code, response.json()) # Try to cast response to desired type if isinstance(response.json(), dict): # Response is already in a dictionary, return the object try: return User(**response.json()) except TypeError: raise APIException("Invalid JSON returned", response.status_code, response.json()) # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.status_code, response.json())
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "id": "id", "profiles": "profiles", "email": "email", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "id": "id", "profiles": "profiles", "email": "email", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "uygur": "uygur", "ny": "ny", "finnish_russian": "finnish_russian", "iranian": "iranian", "dai": "dai", "spanish": "spanish", "han_southern": "han_southern", "han_northern": "han_northern", "somali": "somali", "tungus": "tungus", "sardinian": "sardinian", "mayan": "mayan", "mongolian": "mongolian", "egyptian": "egyptian", "pima": "pima", "gaoshan": "gaoshan", "lahu": "lahu", "cambodian": "cambodian", "korean": "korean", "french": "french", "english": "english", "balkan": "balkan", "sindhi": "sindhi", "papuan": "papuan", "hungarian": "hungarian", "kinh": "kinh", "japanese": "japanese", "eskimo": "eskimo", "saudi": "saudi", "mbuti": "mbuti", "she": "she", "tibetan": "tibetan", "yoruba": "yoruba", "bantusa": "bantusa", "ashkenazi": "ashkenazi", "mala": "mala", "yakut": "yakut", "bengali": "bengali", "thai": "thai", "kyrgyz": "kyrgyz", "uzbek": "uzbek", "miao_yao": "miao_yao", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def get_demographics(self, profile_id): """Does a POST request to /demographics/{profile_id}. Athletigen based on genetic information Args: profile_id (string): Genetic profile id Returns: Report: 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 += "/demographics/{profile_id}" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters(query_builder, { "profile_id": profile_id }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "Authorization": "Bearer " + Configuration.o_auth_access_token, "user-agent": "WeGene SDK", "accept": "application/json", } # Prepare parameters parameters = { } # Prepare and invoke the API call request to fetch the response response = requests.post(query_url, headers=headers, data=parameters) # Error handling using HTTP status codes if response.status_code < 200 or response.status_code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.status_code, response.json()) # Try to cast response to desired type if isinstance(response.json(), dict): # Response is already in a dictionary, return the object try: return Demographics(**response.json()) except TypeError: raise APIException("Invalid JSON returned", response.status_code, response.json()) # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.status_code, response.json())
def resolve_names(self): """Creates a dictionary representation of this object. This method converts an object to a dictionary that represents the format that the model should be in when passed into an API Request. Because of this, the generated dictionary may have different property names to that of the model itself. Returns: dict: The dictionary representing the object. """ # Create a mapping from Model property names to API property names replace_names = { "uygur": "uygur", "ny": "ny", "finnish_russian": "finnish_russian", "iranian": "iranian", "dai": "dai", "spanish": "spanish", "han_southern": "han_southern", "han_northern": "han_northern", "somali": "somali", "tungus": "tungus", "sardinian": "sardinian", "mayan": "mayan", "mongolian": "mongolian", "egyptian": "egyptian", "pima": "pima", "gaoshan": "gaoshan", "lahu": "lahu", "cambodian": "cambodian", "korean": "korean", "french": "french", "english": "english", "balkan": "balkan", "sindhi": "sindhi", "papuan": "papuan", "hungarian": "hungarian", "kinh": "kinh", "japanese": "japanese", "eskimo": "eskimo", "saudi": "saudi", "mbuti": "mbuti", "she": "she", "tibetan": "tibetan", "yoruba": "yoruba", "bantusa": "bantusa", "ashkenazi": "ashkenazi", "mala": "mala", "yakut": "yakut", "bengali": "bengali", "thai": "thai", "kyrgyz": "kyrgyz", "uzbek": "uzbek", "miao_yao": "miao_yao", } retval = dict() return APIHelper.resolve_names(self, replace_names, retval)
def get_drug(self, profile_id, report_id): """Does a POST request to /health/drug/{profile_id}. Drug response based on genetic information Args: profile_id (string): Genetic profile Id report_id (string): Report Id for the specific drug response to look Returns: Report: 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 += "/health/drug/{profile_id}" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters( query_builder, {"profile_id": profile_id}) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "Authorization": "Bearer " + Configuration.o_auth_access_token, "user-agent": "WeGene SDK", "accept": "application/json", } # Prepare parameters parameters = {"report_id": report_id} # Prepare and invoke the API call request to fetch the response response = requests.post(query_url, headers=headers, data=parameters) # Error handling using HTTP status codes if response.status_code < 200 or response.status_code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.status_code, response.json()) # Try to cast response to desired type if isinstance(response.json(), dict): # Response is already in a dictionary, return the object try: return Report(**response.json()) except TypeError: raise APIException("Invalid JSON returned", response.status_code, response.json()) # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.status_code, response.json())
def get_advice(self, profile_id, sex, age, height, weight, health_target): """Does a POST request to /sport/advise/{profile_id}. Sports advice based on genetic and individual information Args: age (int): Age of the user health_target (string): Target for sport, only supporting slimming now height (int): Height of the user profile_id (string): Genetic profile Id sex (string): Sex of the user weight (int): Weight of the user Returns: SportAdvice: 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 += "/sport/advise/{profile_id}" # Process optional template parameters query_builder = APIHelper.append_url_with_template_parameters(query_builder, { "profile_id": profile_id }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "Authorization": "Bearer "+ Configuration.o_auth_access_token, "user-agent": "APIMATIC 2.0", "accept": "application/json", } # Prepare parameters parameters = { "age": age, "health_target": health_target, "height": height, "sex": sex, "weight": weight } # Prepare and invoke the API call request to fetch the response response = unirest.post(query_url, headers=headers, params=parameters) # 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) # Try to cast response to desired type if isinstance(response.body, dict): # Response is already in a dictionary, return the object try: return SportAdvice(**response.body) except TypeError: raise APIException("Invalid JSON returned", response.code, response.body) # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.code, response.body)