Skip to content

bcgov/moh-organizations-api

Repository files navigation

MoH Organizations API Lifecycle:Experimental Java CI with Maven

A Spring Boot REST API for managing organizations within the Ministry of Health.

All resources require JWT authorization.

Configuration

Application configuration is specified in application.yml. Of particular importance are:

  • base-oauth-url: the token issuer.
  • organization-api-client-id: the client ID of this bearer-only client, used for aud validation. The client is expected to have add-org and get-org roles.

Run Locally

To run with Maven:

mvn spring-boot:run

To run without Maven installed:

./mvnw spring-boot:run
# or double-click mvnw.cmd on Windows

To compile and then run with Java:

mvn package -DskipTests=true
java -jar target/organizations-api.jar

Environment variables

The application does not use environment variables, but to run the integration tests you will need to provide credentials for the token issuer.

ORGANIZATIONS_API_TOKEN_CREDENTIALS

Example values:

  • client_id=SOME_CLIENT&client_secret=SOME_SECRET&grant_type=client_credentials
  • client_id=SOME_CLIENT&username=SOME_USER&password=SOME_PASSWORD&grant_type=password

The token issuer is specified by ORGANIZATIONS_API_TOKEN_URL in application-test.yml.

Running Tests

To run just the tests, execute:

mvn test

During development you may also find the tests written for the IntelliJ HTTP Client useful. They are in requests.http.

API Reference

Get all organizations

Requires a token with get-org.

GET /organizations
Authorization: Bearer {{auth_token}}

RESPONSE: HTTP 200
[
  {
    "organizationId": "00000010",
    "name": "MoH"
  },
  {
    "organizationId": "00002855",
    "name": "Other"
  }
]

Add an organization

Requires a token with add-org.

POST /organizations
Authorization: Bearer {{auth_token}}
Content-Type: application/json

{
  "organizationId": "12345678",
  "name": "Hi Mom"
}

RESPONSE: HTTP 200
Location: http://localhost:8082/organizations/12345678

Get an organization

Requires a token with get-org.

GET /organizations/{{organization-id}}
Authorization: Bearer {{auth_token}}

RESPONSE: HTTP 200
{
  "organizationId": "12345670",
  "name": "Hi Mom"
}

Update an organization

Requires a token with add-org.

The organization ID must exist.

PUT /organizations/{{organization-id}}
Authorization: Bearer {{auth_token}}
Content-Type: application/json

RESPONSE: HTTP 200
{
  "name": "Hi Dad"
}

Delete an organization

Requires a token with delete-org.

The organization ID must exist.

DELETE /organizations/{{organization-id}}
Authorization: Bearer {{auth_token}}

RESPONSE: HTTP 200

Definitions

Organization

Parameter Type Description
organizationId string Unique, Required
name string Optional

Example:

{
  "organizationId": "12345678",
  "name": "Test Name"
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published