Skip to content

Commit

Permalink
Merge pull request #3 from solita/dev_20230815
Browse files Browse the repository at this point in the history
Dev 20230815
  • Loading branch information
henrihem authored Jan 8, 2024
2 parents aa07f4f + aa26431 commit b54ee1a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Modules:
## Installation
Install with pip (define version):
```
pip install git+https://github.com/solita/[email protected].1
pip install git+https://github.com/solita/[email protected].2
```

Include in requirements.txt (define version):
```
git+https://github.com/solita/[email protected].1
git+https://github.com/solita/[email protected].2
```

## Usage
Expand Down
25 changes: 22 additions & 3 deletions adenotifier/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down Expand Up @@ -54,6 +55,7 @@ def parse_batch(file_url: str, regexp: str):
Int batch number.
"""

batch = ""
result = re.search(regexp, file_url)

Expand All @@ -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.
"""

Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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):
Expand All @@ -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'],
Expand All @@ -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']))
Expand All @@ -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
manifests.append(manifest)

return manifests
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='adenotifier',
version='0.2.1',
version='0.2.2',
author='Taha Gad, Henri Hemminki',
author_email='[email protected], [email protected]',
description='Python library for using ADE Notify API',
Expand Down

0 comments on commit b54ee1a

Please sign in to comment.