Ejemplo n.º 1
0
    def download_studies(self):
        ret_data, retcode = self.study_api_instance.download_studies(
            user=self._user, auths=self._auths)
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=ret_data, status=retcode))

        return ret_data
Ejemplo n.º 2
0
    def update_study(self, study_code, study_detail):
        ret_data, retcode = self.study_api_instance.update_study(
            study_code, study_detail, user=self._user, auths=self._auths)
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=ret_data, status=retcode))

        return ret_data
Ejemplo n.º 3
0
    def delete_sampling_event(self, sampling_event_id):

        ret, retcode = self.se_api_instance.delete_sampling_event(
            sampling_event_id, user=self._user, auths=self._auths)

        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=ret, status=retcode))
Ejemplo n.º 4
0
    def get_country_metadata(self, country_value):
        metadata, retcode = self.metadata_api_instance.get_country_metadata(
            country_value, user=self._user, auths=self._auths)

        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=metadata, status=retcode))

        return metadata
Ejemplo n.º 5
0
    def create_sampling_event(self, sampling_event):

        created, retcode = self.se_api_instance.create_sampling_event(
            sampling_event, user=self._user, auths=self._auths)

        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=f'"{created}"\n', status=retcode))

        return created
Ejemplo n.º 6
0
    def download_sampling_event(self, sampling_event_id):

        existing, retcode = self.se_api_instance.download_sampling_event(
            sampling_event_id, user=self._user, auths=self._auths)

        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=existing, status=retcode))

        return existing
Ejemplo n.º 7
0
    def download_partner_location(self, partner_name):

        ret, retcode = self.location_api_instance.download_partner_location(
            partner_name, user=self._user, auths=self._auths)

        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=ret, status=retcode))

        return ret
Ejemplo n.º 8
0
    def update_location(self, location_id, location):

        updated, retcode = self.location_api_instance.update_location(
            location_id, location, user=self._user, auths=self._auths)

        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=updated, status=retcode))

        return updated
Ejemplo n.º 9
0
    def merge_individuals(self, individual_id1, individual_id2):

        found_events, retcode = self.i_api_instance.merge_individuals(
            individual_id1, individual_id2, user=self._user, auths=self._auths)

        self._logger.debug("PUT /v1/individual/{}/{} {}".format(
            individual_id1, individual_id2, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 10
0
    def download_sampling_events_by_location(self, location_id):

        found_events, retcode = self.se_api_instance.download_sampling_events_by_location(
            location_id, start=0, count=0, user=self._user, auths=self._auths)

        self._logger.debug("GET /v1/samplingEvents/location/{} {}".format(
            location_id, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 11
0
    def download_individual(self, individual_id):

        found_events, retcode = self.i_api_instance.download_individual(
            individual_id, user=self._user, auths=self._auths)

        self._logger.debug("GET /v1/individual/{} {}".format(
            individual_id, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 12
0
    def download_location(self, location_id):

        ret, retcode = self.location_api_instance.download_location(
            location_id, user=self._user, auths=self._auths)

        self._logger.debug("GET /v1/location/{} {}".format(
            location_id, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=ret, status=retcode))

        return ret
Ejemplo n.º 13
0
    def delete_assay_datum(self, assay_datum_id):

        found_events, retcode = self.ad_api_instance.delete_assay_datum(
            assay_datum_id, user=self._user, auths=self._auths)

        self._logger.debug("DELETE /v1/derivativeSample/{}  {}".format(
            assay_datum_id, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 14
0
    def create_individual(self, individual):

        found_events, retcode = self.i_api_instance.create_individual(
            individual, user=self._user, auths=self._auths)

        self._logger.debug("POST /v1/individual {} {}".format(
            individual, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 15
0
    def download_derivative_sample(self, derivative_sample_id):

        found_events, retcode = self.ds_api_instance.download_derivative_sample(
            derivative_sample_id, user=self._user, auths=self._auths)

        self._logger.debug("GET /v1/derivativeSample/{}  {}".format(
            derivative_sample_id, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 16
0
    def delete_original_sample(self, original_sample_id):

        found_events, retcode = self.os_api_instance.delete_original_sample(
            original_sample_id, user=self._user, auths=self._auths)

        self._logger.debug("DELETE /v1/originalSample/{}  {}".format(
            original_sample_id, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 17
0
    def delete_event_set(self, event_set_id):

        api_response, retcode = self.es_api_instance.delete_event_set(
            event_set_id, user=self._user, auths=self._auths)

        if retcode >= 400:
            if retcode != 422:  # Already exists
                self._logger.debug(
                    "Exception when calling EventSetApi->delete_event_set: \n")
                raise ApiException(
                    http_resp=HTTPResponse(body=api_response, status=retcode))

        return api_response
Ejemplo n.º 18
0
    def update_sampling_event(self, sampling_event_id, sampling_event):
        ret, retcode = self.se_api_instance.update_sampling_event(
            sampling_event_id,
            sampling_event,
            user=self._user,
            auths=self._auths)

        self._logger.debug("POST /v1/samplingEvent/{} {}".format(
            sampling_event_id, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=f'"{ret}"\n', status=retcode))

        return ret
Ejemplo n.º 19
0
    def merge_sampling_events(self, sampling_event_id1, sampling_event_id2):
        ret, retcode = self.se_api_instance.merge_sampling_events(
            sampling_event_id1,
            sampling_event_id2,
            user=self._user,
            auths=self._auths)

        self._logger.debug("PUT /v1/samplingEvent/merge/{}/{} {}".format(
            sampling_event_id1, sampling_event_id2, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=ret, status=retcode))

        return ret
Ejemplo n.º 20
0
    def merge_original_samples(self, original_sample_id1, original_sample_id2):

        found_events, retcode = self.os_api_instance.merge_original_samples(
            original_sample_id1,
            original_sample_id2,
            user=self._user,
            auths=self._auths)

        self._logger.debug("PUT /v1/originalSample/{}/{} {}".format(
            original_sample_id1, original_sample_id2, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 21
0
    def download_sampling_events_by_study(self,
                                          study_name,
                                          start=None,
                                          count=None):

        found_events, retcode = self.se_api_instance.download_sampling_events_by_study(
            study_name, start, count, user=self._user, auths=self._auths)

        self._logger.debug("GET /v1/samplingEvents/study/{} {}".format(
            study_name, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 22
0
    def download_assay_data_by_attr(self, attr_type, attr_value):

        found_events, retcode = self.ad_api_instance.download_assay_data_by_attr(
            attr_type,
            urllib.parse.quote_plus(attr_value),
            user=self._user,
            auths=self._auths)

        self._logger.debug("GET /v1/derivativeSamples/attr/{}/{} {}".format(
            attr_type, attr_value, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 23
0
    def merge_derivative_samples(self, derivative_sample_id1,
                                 derivative_sample_id2):

        found_events, retcode = self.ds_api_instance.merge_derivative_samples(
            derivative_sample_id1,
            derivative_sample_id2,
            user=self._user,
            auths=self._auths)

        self._logger.debug("PUT /v1/derivativeSample/merge/{}/{} {}".format(
            derivative_sample_id1, derivative_sample_id2, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 24
0
    def download_individuals_by_attr(self, prop_name, prop_value, study_name):

        found_events, retcode = self.i_api_instance.download_individuals_by_attr(
            prop_name,
            urllib.parse.quote_plus(prop_value),
            study_name,
            user=self._user,
            auths=self._auths)

        self._logger.debug("GET /v1/individuals/attr/{}/{} {}".format(
            prop_name, prop_value, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events
Ejemplo n.º 25
0
    def create_response(self, ret, retcode, response_type=None):

        if retcode >= 400:
            raise ApiException(status=retcode, reason='')

        if ret and response_type:
            if isinstance(ret, Model):
                response_dict = ret.to_dict()
            else:
                response_dict = ret

            resp_data = json.dumps(response_dict,
                                   ensure_ascii=False,
                                   cls=JSONEncoder)
            mr = MockResponse(resp_data, retcode)
            response = RESTResponse(mr)
            ret = self.api_client.deserialize(response, response_type)

        return ret
Ejemplo n.º 26
0
    def download_sampling_events_by_event_set(self,
                                              event_set_name,
                                              start=None,
                                              count=None):

        found_events, retcode = self.se_api_instance.download_sampling_events_by_event_set(
            urllib.parse.quote_plus(event_set_name),
            start,
            count,
            user=self._user,
            auths=self._auths)

        self._logger.debug("GET /v1/samplingEvents/event_set/{} {}".format(
            event_set_name, retcode))
        if retcode >= 400:
            raise ApiException(
                http_resp=HTTPResponse(body=found_events, status=retcode))

        return found_events