diff --git a/README.md b/README.md index f4fd890..bc52760 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repository implements the [Three Letter Abbreviations (TLA) Sample Applicat It can easily be deployed on AWS. The following graphic gives an architecture overview of the app: -![TLA Sample App - Implemented Serverless](./docs/images/Architecture_Overview.png) +![TLA Sample App - Implemented Serverless](./docs/images/Architecture_Overview.jpg) The app uses the following AWS services: * **Amazon API Gateway** now serves the RESTful HTTP API to access the TLA's. @@ -144,9 +144,7 @@ _Note_ that you will need to replace `{baseUrl}` with the URLs you get from `sls | /tlas | GET | Get all TLA groups including their TLAs (accepted TLAs only). | | /tlas?status=PROPOSED | GET | Get TLAs in PROPOSED state. | | /tlas | POST | Create a new TLA group (see sample payload below). Containing TLAs will be in PROPOSED state. | -| /tlas/{groupName} | GET | Get all TLAs of a specific group. | | /tlas/{groupName} | POST | Create a new TLA within an existing group (see sample payload below). The created TLA will be in PROPOSED state. | -| /tlas/all/{name} | GET | Search for a TLA over all groups. This query can return multiple TLAs as a single TLA is only unique within one group. | | /tlas/{groupName}/{name}/accept | PUT | Accept a proposed TLA ([state transition operation](https://microservice-api-patterns.org/patterns/responsibility/operationResponsibilities/StateTransitionOperation): PROPOSED -> ACCEPTED). | #### Get All TLA Groups @@ -226,70 +224,6 @@ The `/tlas` (GET) endpoint returns all TLAs of all TLA groups that are in the `A Note that the endpoint returns all TLAs in state `ACCEPTED` by default. Use the query parameter `status` with the value `PROPOSED` to list TLAs in the `PROPOSED` state (see example below under "Query Proposed TLAs"). -#### Get TLAs of a Specific Group -The endpoint `/tlas/{groupName}` (GET) returns all TLAs of a specific group. - -**Sample CURL**: `curl -X GET {baseUrl}/tlas/DDD` - -**Sample output:** - -```json -{ - "name": "DDD", - "description": "Domain-Driven Design", - "tlas": [ - { - "name": "ACL", - "meaning": "Anticorruption Layer", - "alternativeMeanings": [] - }, - { - "name": "CF", - "meaning": "Conformist", - "alternativeMeanings": [] - }, - { - "name": "OHS", - "meaning": "Open Host Service", - "alternativeMeanings": [] - }, - { - "name": "PL", - "meaning": "Published Language", - "alternativeMeanings": [] - }, - { - "name": "SK", - "meaning": "Shared Kernel", - "alternativeMeanings": [] - } - ] -} -``` - -#### Search TLA in All Groups -With the endpoint `/tlas/all/{name}` (GET) you can search for a TLA through all groups. Note that this might return multiple results, as TLAs are only unique within one group. - -**Sample CURL**: `curl -X GET {baseUrl}/tlas/all/ACL` - -**Sample output:** - -```json -[ - { - "name": "DDD", - "description": "Domain-Driven Design", - "tlas": [ - { - "name": "ACL", - "meaning": "Anticorruption Layer", - "alternativeMeanings": [] - } - ] - } -] -``` - #### Create new TLA Group Via `/tlas` (POST) you can create a new TLA group. diff --git a/docs/images/Architecture_Detail.jpg b/docs/images/Architecture_Detail.jpg index c6e47f9..25d7a6c 100644 Binary files a/docs/images/Architecture_Detail.jpg and b/docs/images/Architecture_Detail.jpg differ diff --git a/docs/images/Architecture_Overview.jpg b/docs/images/Architecture_Overview.jpg new file mode 100644 index 0000000..15b6516 Binary files /dev/null and b/docs/images/Architecture_Overview.jpg differ diff --git a/docs/images/Architecture_Overview.png b/docs/images/Architecture_Overview.png deleted file mode 100644 index a17c78d..0000000 Binary files a/docs/images/Architecture_Overview.png and /dev/null differ diff --git a/manager/serverless.yml b/manager/serverless.yml index 433ccf9..5da0163 100644 --- a/manager/serverless.yml +++ b/manager/serverless.yml @@ -51,18 +51,6 @@ functions: - httpApi: path: /tlas method: get - readAllTlas: - handler: TLAManager.Infrastructure::TLAManager.Infrastructure.WebApi.Functions.GetAllTlasFunction::GetAllTlasAsync - events: - - httpApi: - path: /tlas/all/{name} - method: get - readTlaGroupByName: - handler: TLAManager.Infrastructure::TLAManager.Infrastructure.WebApi.Functions.GetTlaGroupByNameFunction::GetTlaGroupByNameAsync - events: - - httpApi: - path: /tlas/{groupName} - method: get addNewTlaGroup: handler: TLAManager.Infrastructure::TLAManager.Infrastructure.WebApi.Functions.AddTlaGroupFunction::AddTlaGroupAsync events: diff --git a/manager/src/TLAManager.Infrastructure/WebApi/Functions/GetAllTlasFunction.cs b/manager/src/TLAManager.Infrastructure/WebApi/Functions/GetAllTlasFunction.cs deleted file mode 100644 index e5a35ca..0000000 --- a/manager/src/TLAManager.Infrastructure/WebApi/Functions/GetAllTlasFunction.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Net; -using Amazon.Lambda.APIGatewayEvents; -using Amazon.Lambda.Core; -using Microsoft.Extensions.DependencyInjection; -using TLAManager.Infrastructure.WebApi.Mappers; -using TLAManager.Services; - -namespace TLAManager.Infrastructure.WebApi.Functions; - -public class GetAllTlasFunction : FunctionBase -{ - private static readonly string NameParam = "name"; - - public async Task GetAllTlasAsync(APIGatewayProxyRequest request, ILambdaContext context) - { - context.Logger.LogInformation($"{nameof(GetAllTlasFunction)} called"); - - using var scope = ServiceProvider.CreateScope(); - var service = scope.ServiceProvider.GetService()!; - var responseFactory = scope.ServiceProvider.GetService()!; - - try - { - var name = request.PathParameters[NameParam]; - var tlaGroups = await service.FindAllTlasByNameAsync(name); - var tlaGroupDtos = tlaGroups - .Select(TlaApiDtoMapper.TlaGroupToDto) - .ToList(); - - context.Logger.LogInformation($"{nameof(GetAllTlasFunction)} returning {tlaGroups.Count} TLA groups"); - - var statusCode = tlaGroupDtos.Any() ? HttpStatusCode.OK : HttpStatusCode.NotFound; - return responseFactory.CreateResponse(tlaGroupDtos, statusCode); - } - catch (Exception e) - { - context.Logger.LogError(e, "Internal error has happened"); - return new APIGatewayProxyResponse - { - StatusCode = (int)HttpStatusCode.InternalServerError, - Body = $"Internal error has happened: {e.Message}" - }; - } - } -} \ No newline at end of file diff --git a/manager/src/TLAManager.Infrastructure/WebApi/Functions/GetTlaGroupByNameFunction.cs b/manager/src/TLAManager.Infrastructure/WebApi/Functions/GetTlaGroupByNameFunction.cs deleted file mode 100644 index 78da396..0000000 --- a/manager/src/TLAManager.Infrastructure/WebApi/Functions/GetTlaGroupByNameFunction.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Net; -using Amazon.Lambda.APIGatewayEvents; -using Amazon.Lambda.Core; -using Microsoft.Extensions.DependencyInjection; -using TLAManager.Services; -using TLAManager.Infrastructure.WebApi.Mappers; -using TLAManager.Services.Exceptions; - -namespace TLAManager.Infrastructure.WebApi.Functions; - -public class GetTlaGroupByNameFunction : FunctionBase -{ - private static readonly string GroupNameParam = "groupName"; - - public async Task GetTlaGroupByNameAsync(APIGatewayProxyRequest request, - ILambdaContext context) - { - context.Logger.LogInformation($"{nameof(GetTlaGroupByNameFunction)} called"); - - using var scope = ServiceProvider.CreateScope(); - var service = scope.ServiceProvider.GetService()!; - var responseFactory = scope.ServiceProvider.GetService()!; - - try - { - var name = request.PathParameters[GroupNameParam]; - var tlaGroup = await service.FindGroupByNameAsync(name); - var tlaGroupDto = TlaApiDtoMapper.TlaGroupToDto(tlaGroup); - return responseFactory.CreateResponse(tlaGroupDto, HttpStatusCode.OK); - } - catch (TLAGroupNameDoesNotExistException e) - { - context.Logger.LogError(e, "TLA group not found"); - return responseFactory.CreateErrorResponse(HttpStatusCode.NotFound, e.Message, context); - } - catch (TLAGroupNameNotValidException e) - { - context.Logger.LogError(e, "TLA group name not valid"); - return responseFactory.CreateErrorResponse(HttpStatusCode.NotFound, e.Message, context); - } - catch (Exception e) - { - context.Logger.LogError(e, "Internal server error"); - return responseFactory.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message, context); - } - } -} \ No newline at end of file diff --git a/manager/src/TLAManager.Services/ITlaGroupsApplicationService.cs b/manager/src/TLAManager.Services/ITlaGroupsApplicationService.cs index 0f4ed35..54972fe 100644 --- a/manager/src/TLAManager.Services/ITlaGroupsApplicationService.cs +++ b/manager/src/TLAManager.Services/ITlaGroupsApplicationService.cs @@ -6,8 +6,6 @@ public interface ITlaGroupsApplicationService { Task> FindAllTlaGroupsAsync(); Task> FindAllTlaGroupsAsync(TLAStatus status); - Task> FindAllTlasByNameAsync(string name); - Task FindGroupByNameAsync(string name); Task AddTlaGroupAsync(TLAGroup tlaGroup); Task AddTlaAsync(string groupName, ThreeLetterAbbreviation tla); Task AcceptTlaAsync(string groupName, string tlaName); diff --git a/manager/src/TLAManager.Services/TlaGroupsApplicationService.cs b/manager/src/TLAManager.Services/TlaGroupsApplicationService.cs index d6cb9ed..c7e74cb 100644 --- a/manager/src/TLAManager.Services/TlaGroupsApplicationService.cs +++ b/manager/src/TLAManager.Services/TlaGroupsApplicationService.cs @@ -18,26 +18,6 @@ public async Task> FindAllTlaGroupsAsync(TLAStatus status) .ToList(); } - public async Task> FindAllTlasByNameAsync(string name) - { - var groups = await FindAllTlaGroupsAsync(TLAStatus.Accepted); - return groups.Where(group => group.Tlas.Any(tla => tla.Name.Name.Equals(name))) - .Select(group => new TLAGroup( - group.Name, - group.Description, - new List - { - group.Tlas.First(tla => tla.Name.Name.Equals(name)) - } - )) - .ToList(); - } - - public async Task FindGroupByNameAsync(string name) - { - return FilterTlaStatus(await GetGroupByNameAsync(name), TLAStatus.Accepted); - } - public async Task AddTlaGroupAsync(TLAGroup tlaGroup) { if (await TlaGroupAlreadyExistsAsync(tlaGroup.Name))