Skip to content

Commit

Permalink
change get_sample_by_name to use new endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyThiessen committed Mar 3, 2023
1 parent 29a648d commit 1d5c33f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions docs/developers/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ Sample Object or None
#### get_sample_by_name(self, project_id, sample_name)
Given a project id and sample name, returns a Sample object, or None is sample does not exist

Note: this currently uses the deprecated endpoint "/projects/{project_id}/samples/bySequencerId/{sample_name}"

**arguments:**

project_id -- id where sample is located
Expand Down
10 changes: 4 additions & 6 deletions iridauploader/api/api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

JSON_HEADERS = {"headers": {'Content-Type': 'application/json', **SESSION_HEADERS}}

MINIMUM_IRIDA_VERSION = "20.05"
MINIMUM_IRIDA_VERSION = "23.01"


class ApiCalls(object):
Expand Down Expand Up @@ -660,13 +660,11 @@ def get_sample_by_name(self, project_id, sample_name):

logging.info("Getting Sample object for project id '{}' and sample name '{}'".format(project_id, sample_name))

# This is using a deprecated end point. In a future release it will be replaced with
# /projects/{project_id}/samples/bySampleName
# and use params instead
url = f"{self.base_url}projects/{project_id}/samples/bySequencerId/{sample_name}"
url = f"{self.base_url}projects/{project_id}/samples/bySampleName"
params = {'sampleName': sample_name}

try:
response = self._session.get(url)
response = self._session.get(url, params=params)
except Exception as e:
raise ApiCalls._handle_rest_exception(url, e)
if response.status_code == HTTPStatus.OK: # 200, return sample object
Expand Down

0 comments on commit 1d5c33f

Please sign in to comment.