Skip to content

Commit

Permalink
Replace notifications with user journey events (GSI-669) (#14)
Browse files Browse the repository at this point in the history
* Update to uv

* Bump ghga-event-schemas version

* Add event publisher

* Replace the notification emitter with the event publisher

* Use event publisher in tests

* Bump version from 1.1.1 -> 2.0.0

* Fix missed notification references

* Remove data steward email from config

* Rename config params for event types

* Make repository docstring tweaks

* Simplify event_pub test

* Use a list for request status event dummy calls

* Use list with mock event for test_repository

* Compare events directly

* Remove events_for()

---------

Co-authored-by: TheByronHimes <[email protected]>
  • Loading branch information
TheByronHimes and TheByronHimes authored Mar 20, 2024
1 parent de0e322 commit 6a8e75f
Show file tree
Hide file tree
Showing 23 changed files with 465 additions and 740 deletions.
8 changes: 4 additions & 4 deletions .devcontainer/.dev_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ cors_allowed_headers: []
db_connection_str: "mongodb://mongodb:27017"
db_name: "access-requests"

notification_event_topic: notifications
notification_event_type: notification
access_request_events_topic: access_request_events
access_request_created_event_type: access_request_created
access_request_allowed_event_type: access_request_allowed
access_request_denied_event_type: access_request_denied

service_instance_id: "1"
kafka_servers: ["kafka:9092"]

download_access_url: "http://127.0.0.1:8080/download-access"

data_steward_email: "[email protected]"

auth_key: "{}"
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.2
rev: v0.3.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
4 changes: 2 additions & 2 deletions .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[project]
name = "ars"
version = "1.1.1"
version = "2.0.0"
description = "Access Request Service"
dependencies = [
"ghga-event-schemas~=3.0.0",
"ghga-event-schemas~=3.1.0",
"ghga-service-commons[api,auth]>=2.0.0, <3",
"hexkit[mongodb,akafka]>=2.1.0",
"httpx>=0.27.0",
Expand Down
42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ We recommend using the provided Docker container.

A pre-build version is available at [docker hub](https://hub.docker.com/repository/docker/ghga/access-request-service):
```bash
docker pull ghga/access-request-service:1.1.1
docker pull ghga/access-request-service:2.0.0
```

Or you can build the container yourself from the [`./Dockerfile`](./Dockerfile):
```bash
# Execute in the repo's root dir:
docker build -t ghga/access-request-service:1.1.1 .
docker build -t ghga/access-request-service:2.0.0 .
```

For production-ready deployment, we recommend using Kubernetes, however,
for simple use cases, you could execute the service using docker
on a single server:
```bash
# The entrypoint is preconfigured:
docker run -p 8080:8080 ghga/access-request-service:1.1.1 --help
docker run -p 8080:8080 ghga/access-request-service:2.0.0 --help
```

If you prefer not to use containers, you may install the service from source:
Expand All @@ -47,14 +47,6 @@ ars --help
### Parameters

The service requires the following configuration parameters:
- **`data_steward_email`**: An email address that can be used to notify data stewards.

- **Any of**

- *string, format: email*

- *null*

- **`access_upfront_max_days`** *(integer)*: The maximum lead time in days to request access grants. Default: `180`.

- **`access_grant_min_days`** *(integer)*: The minimum number of days that the access will be granted. Default: `7`.
Expand All @@ -71,23 +63,43 @@ The service requires the following configuration parameters:
```


- **`notification_event_topic`** *(string)*: Name of the topic used for notification events.
- **`access_request_events_topic`** *(string)*: The topic used for events related to access requests.


Examples:

```json
"access_requests"
```


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


Examples:

```json
"access_request_created"
```


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


Examples:

```json
"notifications"
"access_request_allowed"
```


- **`notification_event_type`** *(string)*: The type used for notification events.
- **`access_request_denied_event_type`** *(string)*: The type to use for 'access request denied' events.


Examples:

```json
"notification"
"access_request_denied"
```


Expand Down
52 changes: 28 additions & 24 deletions config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@
"additionalProperties": false,
"description": "Modifies the orginal Settings class provided by the user",
"properties": {
"data_steward_email": {
"anyOf": [
{
"format": "email",
"type": "string"
},
{
"type": "null"
}
],
"description": "An email address that can be used to notify data stewards",
"title": "Data Steward Email"
},
"access_upfront_max_days": {
"default": 180,
"description": "The maximum lead time in days to request access grants",
Expand All @@ -41,20 +28,36 @@
"title": "Download Access Url",
"type": "string"
},
"notification_event_topic": {
"description": "Name of the topic used for notification events.",
"access_request_events_topic": {
"description": "The topic used for events related to access requests.",
"examples": [
"access_requests"
],
"title": "Access Request Events Topic",
"type": "string"
},
"access_request_created_event_type": {
"description": "The type to use for 'access request created' events",
"examples": [
"access_request_created"
],
"title": "Access Request Created Event Type",
"type": "string"
},
"access_request_allowed_event_type": {
"description": "The type to use for 'access request allowed' events",
"examples": [
"notifications"
"access_request_allowed"
],
"title": "Notification Event Topic",
"title": "Access Request Allowed Event Type",
"type": "string"
},
"notification_event_type": {
"description": "The type used for notification events.",
"access_request_denied_event_type": {
"description": "The type to use for 'access request denied' events",
"examples": [
"notification"
"access_request_denied"
],
"title": "Notification Event Type",
"title": "Access Request Denied Event Type",
"type": "string"
},
"service_name": {
Expand Down Expand Up @@ -341,10 +344,11 @@
}
},
"required": [
"data_steward_email",
"download_access_url",
"notification_event_topic",
"notification_event_type",
"access_request_events_topic",
"access_request_created_event_type",
"access_request_allowed_event_type",
"access_request_denied_event_type",
"service_instance_id",
"kafka_servers",
"db_connection_str",
Expand Down
7 changes: 4 additions & 3 deletions example_config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
access_grant_max_days: 730
access_grant_min_days: 7
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
access_upfront_max_days: 180
api_root_path: ''
auth_algs:
Expand All @@ -16,7 +20,6 @@ cors_allow_credentials: false
cors_allowed_headers: []
cors_allowed_methods: []
cors_allowed_origins: []
data_steward_email: [email protected]
db_connection_str: '**********'
db_name: access-requests
docs_url: /docs
Expand All @@ -32,8 +35,6 @@ kafka_ssl_keyfile: ''
kafka_ssl_password: ''
log_format: null
log_level: INFO
notification_event_topic: notifications
notification_event_type: notification
openapi_url: /openapi.json
port: 8080
service_instance_id: '1'
Expand Down
3 changes: 2 additions & 1 deletion lock/requirements-dev-template.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jsonschema2md>=1.0.0
setuptools>=69.1.0

# required since switch to pyproject.toml and pip-tools
pip-tools>=7.4.0
tomli>=2.0.1
tomli_w>=1.0.0

uv>=0.1.21
Loading

0 comments on commit 6a8e75f

Please sign in to comment.