Licensing Service - wuyichen24/spring-microservices-in-action GitHub Wiki
Description
Manage (query, add, update, delete) license records.
Technique
- Spring Data JPA
- Netflix Feign
- Netflix Eureka
- Netflix Hystrix
Available API Calls
LS1: Get a list of license records by organization ID.
- URL: http://localhost:8080/v1/organizations/{organizationId}/licenses/
- Method: GET
- Parameters:
- organizationId: The organization ID for looking up.
- Headers
- Body
- Notes:
- This call will get license records only, so it will not trigger another call from licensing service to organization service.
- This call will simulate the long-running randomly to trigger the time out exception from circuit breaker (Sometime you will see 500 error as the response).
LS2: Get a license record by organizatiion ID and license ID.
LS3: Get a license record associated with the organization record by organization ID and license ID.
- URL: http://localhost:8080/v1/organizations/{organizationId}/licenses/{licenseId}/{clientType}
- Method: GET
- Parameters:
- organizationId: The organization ID for looking up.
- licenseId: The license ID for looking up.
- clientType: The way for calling the organization service for getting the organization record. There are 3 possible values:
- rest: Use Ribbon-backed Spring RestTemplate to call.
- feign: Feign client to call.
- discovery: Use Spring DiscoveryClient with the Spring RestTemplate to call.
- Headers
KEY |
VALUE |
Authorization |
Bearer {access_token} |
- Body
- Notes:
- This call will get the license record and also get an organization record, so it will trigger another call from the licensing service to the organization service.
- Because of the organization service is protected and only be accessible with the valid access token, you need to add a valid access token to the header of this call.
LS4: Update a license by organization ID and license ID.
KEY |
VALUE |
Content-Type |
application/json |
{
"licenseId": "f3831f8c-c338-4ebe-a82a-e2fc1d1ff78a",
"organizationId": "e254f8c-c442-4ebe-a82a-e2fc1d1ff78a",
"productName": "CustomerPro",
"licenseType": "user",
"licenseMax": 100,
"licenseAllocated": 5,
"comment": "The default configuration"
}
LS5: Add a new license.
KEY |
VALUE |
Content-Type |
application/json |
{
"licenseId": "f3831f8c-c338-4ebe-a82a-e2fc1d1ff78a",
"organizationId": "e254f8c-c442-4ebe-a82a-e2fc1d1ff78a",
"productName": "CustomerPro",
"licenseType": "user",
"licenseMax": 100,
"licenseAllocated": 5,
"comment": "The default configuration"
}
LS6: Delete a license by the license ID.
Database Table(s)