Skip to content

Commit

Permalink
refactor: allow ICATClient to use search API config where appropriate
Browse files Browse the repository at this point in the history
#258

- This change will not impact the existing use of the class in DataGateway API
  • Loading branch information
MRichards99 committed Nov 24, 2021
1 parent 1049a5f commit 8dba0e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions datagateway_api/src/datagateway_api/icat/icat_client_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
class ICATClient(Client):
"""Wrapper class to allow an object pool of client objects to be created"""

def __init__(self):
super().__init__(
config.datagateway_api.icat_url,
checkCert=config.datagateway_api.icat_check_cert,
)
def __init__(self, client_use="datagateway_api"):
if client_use == "datagateway_api":
icat_url = config.datagateway_api.icat_url
icat_check_cert = config.datagateway_api.icat_check_cert
else:
# Search API use cases
icat_url = config.search_api.icat_url
icat_check_cert = config.search_api.icat_check_cert

super().__init__(icat_url, checkCert=icat_check_cert)
# When clients are cleaned up, sessions won't be logged out
self.autoLogout = False

Expand Down
2 changes: 1 addition & 1 deletion datagateway_api/src/search_api/session_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SessionHandler:
anon user
"""

client = ICATClient()
client = ICATClient(client_use="search_api")


def client_manager(method):
Expand Down

0 comments on commit 8dba0e1

Please sign in to comment.