From 3c1ee68296b490337f1d06417857791216a68b7f Mon Sep 17 00:00:00 2001 From: Brooks Travis Date: Wed, 11 Sep 2024 14:21:57 -0500 Subject: [PATCH] Add support for ecs member tenants --- src/folio_data_import/MARCDataImport.py | 11 +++++++++++ src/folio_data_import/UserImport.py | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/folio_data_import/MARCDataImport.py b/src/folio_data_import/MARCDataImport.py index b187c2c..14e6a6f 100644 --- a/src/folio_data_import/MARCDataImport.py +++ b/src/folio_data_import/MARCDataImport.py @@ -436,6 +436,12 @@ async def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("--gateway_url", type=str, help="The FOLIO API Gateway URL") parser.add_argument("--tenant_id", type=str, help="The FOLIO tenant ID") + parser.add_argument( + "--member_tenant_id", + type=str, + help="The FOLIO ECS member tenant ID (if applicable)", + default="", + ) parser.add_argument("--username", type=str, help="The FOLIO username") parser.add_argument("--password", type=str, help="The FOLIO password", default="") parser.add_argument( @@ -480,6 +486,11 @@ async def main() -> None: folio_client = folioclient.FolioClient( args.gateway_url, args.tenant_id, args.username, args.password ) + + # Set the member tenant id if provided to support FOLIO ECS multi-tenant environments + if args.member_tenant_id: + folio_client.okapi_headers["x-okapi-tenant"] = args.member_tenant_id + if not args.import_profile_name: import_profiles = folio_client.folio_get( "/data-import-profiles/jobProfiles", diff --git a/src/folio_data_import/UserImport.py b/src/folio_data_import/UserImport.py index acdc888..f14ff1e 100644 --- a/src/folio_data_import/UserImport.py +++ b/src/folio_data_import/UserImport.py @@ -630,6 +630,11 @@ async def main() -> None: """ parser = argparse.ArgumentParser() parser.add_argument("--tenant_id", help="The tenant id") + parser.add_argument( + "--member_tenant_id", + help="The FOLIO ECS member tenant id (if applicable)", + default="", + ) parser.add_argument("--library_name", help="The name of the library") parser.add_argument("--username", help="The FOLIO username") parser.add_argument("--okapi_url", help="The Okapi URL") @@ -672,8 +677,15 @@ async def main() -> None: args.username, args.folio_password or os.environ.get("FOLIO_PASS", "") - or getpass.getpass("Enter your FOLIO password: "), + or getpass.getpass( + "Enter your FOLIO password: ", + ), ) + + # Set the member tenant id if provided to support FOLIO ECS multi-tenant environments + if args.member_tenant_id: + folio_client.okapi_headers["x-okapi-tenant"] = args.member_tenant_id + user_file_path = Path(args.user_file_path) log_file_path = ( user_file_path.parent.parent