Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always update Pub/Sub links to GBs (#23) #28

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions wis2-gdc-management/wis2_gdc/registrar.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ def register(self, metadata: Union[dict, str], topic: str = None) -> None:
self._process_record_metric(
self.metadata['id'], f'{data_policy}_total', centre_id_labels)

if data_policy == 'core':
LOGGER.info('Core data detected: updating links')
self.update_record_links()
LOGGER.info('Updating links')
self.update_record_links(data_policy)

LOGGER.info('Publishing metadata to backend')
self._publish()
Expand Down Expand Up @@ -360,7 +359,7 @@ def _publish(self):
LOGGER.info(f'Saving to {BACKEND_TYPE} ({BACKEND_CONNECTION})')
self.backend.save_record(self.metadata)

def update_record_links(self) -> None:
def update_record_links(self, data_policy: str) -> None:
"""
Update Global Service links

Expand All @@ -379,13 +378,16 @@ def is_wis2_mqtt_link(link) -> bool:
for count, value in enumerate(self.metadata['links']):
if is_wis2_mqtt_link(value):
LOGGER.debug('Adjusting MQTT link')
channel = value.get('wmo:topic', value.get('channel'))
channel = value.get('channel', value.get('wmo:topic'))

new_link = value
_ = new_link.pop('wmo:topic', None)

if data_policy == 'core':
LOGGER.debug('Adjusting channel origin to cache')
new_link['channel'] = channel.replace('origin', 'cache')

new_link['rel'] = 'items'
new_link['channel'] = channel.replace('origin', 'cache')
new_link['type'] = 'application/geo+json'

del self.metadata['links'][count]
Expand Down
Loading