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

Align config naming (GSI-702) #3

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .devcontainer/.dev_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ db_connection_str: mongodb://localhost:27017
db_name: users
kafka_servers: ["kafka:9092"]
access_request_events_topic: access_request_events
access_request_created_type: access_request_created
access_request_allowed_type: access_request_allowed
access_request_denied_type: access_request_denied
access_request_created_event_type: access_request_created
access_request_allowed_event_type: access_request_allowed
access_request_denied_event_type: access_request_denied
notification_event_type: notification
notification_event_topic: notification_events
file_registered_event_topic: internal_file_registry
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ repos:
- id: no-commit-to-branch
args: [--branch, dev, --branch, int, --branch, main]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
rev: v0.3.5
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The service requires the following configuration parameters:
```


- **`access_request_created_type`** *(string)*: The type to use for access request created events.
- **`access_request_created_event_type`** *(string)*: The type to use for access request created events.


Examples:
Expand All @@ -111,7 +111,7 @@ The service requires the following configuration parameters:
```


- **`access_request_allowed_type`** *(string)*: The type to use for access request allowed events.
- **`access_request_allowed_event_type`** *(string)*: The type to use for access request allowed events.


Examples:
Expand All @@ -121,7 +121,7 @@ The service requires the following configuration parameters:
```


- **`access_request_denied_type`** *(string)*: The type to use for access request denied events.
- **`access_request_denied_event_type`** *(string)*: The type to use for access request denied events.


Examples:
Expand Down
18 changes: 9 additions & 9 deletions config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@
"title": "Access Request Events Topic",
"type": "string"
},
"access_request_created_type": {
"access_request_created_event_type": {
"description": "The type to use for access request created events",
"examples": [
"access_request_created"
],
"title": "Access Request Created Type",
"title": "Access Request Created Event Type",
"type": "string"
},
"access_request_allowed_type": {
"access_request_allowed_event_type": {
"description": "The type to use for access request allowed events",
"examples": [
"access_request_allowed"
],
"title": "Access Request Allowed Type",
"title": "Access Request Allowed Event Type",
"type": "string"
},
"access_request_denied_type": {
"access_request_denied_event_type": {
"description": "The type to use for access request denied events",
"examples": [
"access_request_denied"
],
"title": "Access Request Denied Type",
"title": "Access Request Denied Event Type",
"type": "string"
},
"file_registered_event_topic": {
Expand Down Expand Up @@ -198,9 +198,9 @@
"notification_event_topic",
"notification_event_type",
"access_request_events_topic",
"access_request_created_type",
"access_request_allowed_type",
"access_request_denied_type",
"access_request_created_event_type",
"access_request_allowed_event_type",
"access_request_denied_event_type",
"file_registered_event_topic",
"file_registered_event_type",
"service_instance_id",
Expand Down
6 changes: 3 additions & 3 deletions example_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
access_request_allowed_type: access_request_allowed
access_request_created_type: access_request_created
access_request_denied_type: access_request_denied
access_request_allowed_event_type: access_request_allowed
access_request_created_event_type: access_request_created
access_request_denied_event_type: access_request_denied
access_request_events_topic: access_request_events
central_data_stewardship_email: test@test.abc
db_connection_str: '**********'
Expand Down
348 changes: 184 additions & 164 deletions lock/requirements-dev.txt

Large diffs are not rendered by default.

230 changes: 125 additions & 105 deletions lock/requirements.txt

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/nos/core/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ async def process_access_request_notification(
When the provided user ID does not exist in the DB.
"""
method_map = {
self._config.access_request_created_type: self._access_request_created,
self._config.access_request_allowed_type: self._access_request_allowed,
self._config.access_request_denied_type: self._access_request_denied,
self._config.access_request_created_event_type: self._access_request_created,
self._config.access_request_allowed_event_type: self._access_request_allowed,
self._config.access_request_denied_event_type: self._access_request_denied,
}
extra = { # for error logging
"user_id": user_id,
Expand Down
18 changes: 9 additions & 9 deletions src/nos/translators/inbound/event_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class EventSubTranslatorConfig(BaseSettings):
description="Name of the event topic used to consume access request events",
examples=["access_requests"],
)
access_request_created_type: str = Field(
access_request_created_event_type: str = Field(
default=...,
description="The type to use for access request created events",
examples=["access_request_created"],
)
access_request_allowed_type: str = Field(
access_request_allowed_event_type: str = Field(
default=...,
description="The type to use for access request allowed events",
examples=["access_request_allowed"],
)
access_request_denied_type: str = Field(
access_request_denied_event_type: str = Field(
default=...,
description="The type to use for access request denied events",
examples=["access_request_denied"],
Expand Down Expand Up @@ -71,9 +71,9 @@ def __init__(
config.file_registered_event_topic,
]
self.types_of_interest = [
config.access_request_created_type,
config.access_request_allowed_type,
config.access_request_denied_type,
config.access_request_created_event_type,
config.access_request_allowed_event_type,
config.access_request_denied_event_type,
config.file_registered_event_type,
]
self._config = config
Expand Down Expand Up @@ -104,9 +104,9 @@ async def _consume_validated(
) -> None:
"""Consumes an event"""
if type_ in (
self._config.access_request_created_type,
self._config.access_request_allowed_type,
self._config.access_request_denied_type,
self._config.access_request_created_event_type,
self._config.access_request_allowed_event_type,
self._config.access_request_denied_event_type,
):
await self._handle_access_request(type_, payload)
elif type_ == self._config.file_registered_event_type:
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ db_connection_str: mongodb://localhost:27017
db_name: users
kafka_servers: ["kafka:9092"]
access_request_events_topic: access_request_events
access_request_created_type: access_request_created
access_request_allowed_type: access_request_allowed
access_request_denied_type: access_request_denied
access_request_created_event_type: access_request_created
access_request_allowed_event_type: access_request_allowed
access_request_denied_event_type: access_request_denied
notification_event_type: notification
notification_event_topic: notification_events
file_registered_event_topic: internal_file_registry
Expand Down
12 changes: 6 additions & 6 deletions tests/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ async def test_access_request(

event_type_to_use = ""
if event_type == "created":
event_type_to_use = joint_fixture.config.access_request_created_type
event_type_to_use = joint_fixture.config.access_request_created_event_type
elif event_type == "allowed":
event_type_to_use = joint_fixture.config.access_request_allowed_type
event_type_to_use = joint_fixture.config.access_request_allowed_event_type
elif event_type == "denied":
event_type_to_use = joint_fixture.config.access_request_denied_type
event_type_to_use = joint_fixture.config.access_request_denied_event_type

assert event_type_to_use

Expand Down Expand Up @@ -158,9 +158,9 @@ async def test_missing_user_id(joint_fixture: JointFixture, logot: Logot):
"""Test for error handling in case of invalid user id."""
payload = access_request_payload("bogus_user_id")
for event_type in [
joint_fixture.config.access_request_created_type,
joint_fixture.config.access_request_allowed_type,
joint_fixture.config.access_request_denied_type,
joint_fixture.config.access_request_created_event_type,
joint_fixture.config.access_request_allowed_event_type,
joint_fixture.config.access_request_denied_event_type,
]:
await joint_fixture.kafka.publish_event(
payload=payload,
Expand Down
Loading