diff --git a/LICENSE b/LICENSE index a51f39a..ede9e7e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Solita +Copyright (c) 2024 Solita Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 4c6874d..e10c73d 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ Modules: ## Installation Install with pip (define version): ``` -pip install git+https://github.com/solita/adenotifier.git@v0.2.1 +pip install git+https://github.com/solita/adenotifier.git@v0.2.2 ``` Include in requirements.txt (define version): ``` -git+https://github.com/solita/adenotifier.git@v0.2.1 +git+https://github.com/solita/adenotifier.git@v0.2.2 ``` ## Usage diff --git a/adenotifier/notifier.py b/adenotifier/notifier.py index 4563db6..cacf2f9 100644 --- a/adenotifier/notifier.py +++ b/adenotifier/notifier.py @@ -21,6 +21,7 @@ def search_manifests(source_system_name: str, source_entity_name: str, base_url: List [str] of manifest ids. """ + session = requests.Session() session.auth = (notify_api_key, notify_api_key_secret) session.headers.update({"Content-Type": "application/json"}) @@ -54,6 +55,7 @@ def parse_batch(file_url: str, regexp: str): Int batch number. """ + batch = "" result = re.search(regexp, file_url) @@ -71,6 +73,9 @@ def add_to_manifest(file_url: str, source: object, base_url: str, notify_api_key base_url (str): ADE Notify API base url, e.g. https://external-api.{environment}.datahub.{tenant}.saas.agiledataengine.com:443/notify-api. notify_api_key (str): ADE Notify API key. notify_api_key_secret (str): ADE Notify API key secret. + + Returns: + Manifest object. """ @@ -182,7 +187,8 @@ def add_to_manifest(file_url: str, source: object, base_url: str, notify_api_key logging.info('Single_file_manifest set as true, notifying.') manifest.notify() logging.info('Notified manifest: {0}.'.format(manifest.id)) - return + + return manifest def add_multiple_entries_to_manifest(entries: List[dict], source: object, base_url: str, notify_api_key: str, notify_api_key_secret: str, batch: int = None): """Utilizes Manifest class and other functions to add the given file_url to a manifest for the given configured data source. @@ -194,7 +200,12 @@ def add_multiple_entries_to_manifest(entries: List[dict], source: object, base_u notify_api_key (str): ADE Notify API key. notify_api_key_secret (str): ADE Notify API key secret. batch (int): Optional manifest-level batch id. + + Returns: + Manifest object. + """ + # Initialize a manifest object with mandatory attributes. manifest = Manifest( base_url = base_url, @@ -249,7 +260,7 @@ def add_multiple_entries_to_manifest(entries: List[dict], source: object, base_u manifest.notify(manifest.id) - return + return manifest def notify_manifests(source: object, base_url: str, notify_api_key: str, notify_api_key_secret: str): @@ -260,8 +271,12 @@ def notify_manifests(source: object, base_url: str, notify_api_key: str, notify_ base_url (str): ADE Notify API base url, e.g. https://external-api.{environment}.datahub.{tenant}.saas.agiledataengine.com:443/notify-api. notify_api_key (str): ADE Notify API key. notify_api_key_secret (str): ADE Notify API key secret. + + Returns: + Array of Manifest objects. """ + # Search open manifests for data source. open_manifests = search_manifests( source_system_name = source['attributes']['ade_source_system'], @@ -286,6 +301,8 @@ def notify_manifests(source: object, base_url: str, notify_api_key: str, notify_ notify_api_key_secret = notify_api_key_secret ) + manifests = [] + if (open_manifest_ids == []): # Warning if open manifests not found. logging.warning('Open manifests for source {0} not found when attempting to notify.'.format(source['id'])) @@ -295,4 +312,6 @@ def notify_manifests(source: object, base_url: str, notify_api_key: str, notify_ manifest.fetch_manifest(manifest_id) manifest.notify() logging.info('Notified manifest: {0}.'.format(manifest.id)) - return \ No newline at end of file + manifests.append(manifest) + + return manifests \ No newline at end of file diff --git a/setup.py b/setup.py index d5c2226..327c4d0 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='adenotifier', - version='0.2.1', + version='0.2.2', author='Taha Gad, Henri Hemminki', author_email='taha.gad@solita.fi, henri.hemminki@solita.fi', description='Python library for using ADE Notify API',