Swifty Receiver API

API contains endpoints described in

openapi.yaml

receiver-endpoints.yaml

receiver-models.yaml

Environment variables

Google Pub Sub Configuration

The following environment variables are required for using Google PubSub:

    - name: ENVIRONMENT_NAME
      value: "{{ env_ }}"
    - name: GOOGLE_PROJECT_NAME
      value: "{{ project }}"
    - name: APP_MESSAGING
      value: "pubsub"
    - name: PUBSUB_TOPIC
      value: "{{ receiver_pubsub_topic }}"
    - name: LOGLEVEL
      value: "{{ DEBUG | INFO }}"

Kafka Configuration

The following environment variables are required for using Kafka:

    - name: ENVIRONMENT_NAME
      value: "{{ env_ }}"
    - name: GOOGLE_PROJECT_NAME
      value: "{{ project }}"
    - name: APP_MESSAGING
      value: "kafka"
    - name: KAFKA_TOPIC
      value: "{{ receiver_kafka_topic }}"
    - name: LOGLEVEL
      value: "{{ DEBUG | INFO }}"

GKE Managed Kafka

For running against a GKE managed Kafka server, a secret named kafka is required with the following:

{
  "bootstrap.servers": "<your-bootstrap-servers-url>",
  "sasl.mechanism": "OAUTHBEARER",
  "security.protocol": "SASL_SSL"
}

The secret will be named <env_>-kafka, where <env_> is the environment name.

Local RedPanda Kafka

For running against a local RedPanda cluster, a secret named kafka is required with the following:

{
  "bootstrap.servers": "localhost:19092",
  "username": "<username>",
  "password": "<password>",
  "security.protocol": "SASL_PLAINTEXT",
  "sasl.mechanism": "SCRAM-SHA-256"
}

In either case, if you are trying to run locally, you need to add the following environment variables.

    - name: GOOGLE_APPLICATION_CREDENTIALS
      value: /path/to/credentials.json

Additional Notes

Currently, the API requires a Bearer Token to be passed in the Authorization header. However, it is not currently checked, so any value can be used. This will be fixed in a future release.

Upon successful deployment, you should be able to post data to the endpoint and verify it gets written to the message queue.

For example:

curl --location 'https://mccpd.swiftyrx.dev/api/receiver/1/async/message' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
  "sender": "foo",
  "message_type": "RX_AVAILABLE",
  "message_object_id": "1234",
  "virtual_pharmacy": "mccpd"
}'

Should produce a response like:

{
    "status": "success",
    "message_id": "1234"
}

And you should then see the message in the message queue, as such:

pub_sub_image.png

Docker File

Dockerfile

Ansible Playbook

create_swifty_java_receiver_api.yaml