-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add baseline code for other API endpoints (#11)
* Add baseline code for other API endpoints - Add code for get ad update lambdas - Add OpenAPI spec - Build lambda containers in CI - Deploy lambdas for each endpoint - Update tests to check each endpoint and assert final state This includes adding `docs/schemas/lpa.json`, which can serve as a public JSON Schema definition _and_ get used in the OpenAPI doc. For VEGA-2104 #minor * Fix typo #patch Co-authored-by: Gemma Taylor <[email protected]> --------- Co-authored-by: Gemma Taylor <[email protected]>
- Loading branch information
Showing
27 changed files
with
465 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API. | ||
# See https://redoc.ly/docs/cli/ for more information. | ||
docs/schemas/lpa.json: | ||
spec: | ||
- '#/$id' | ||
- '#/$schema' | ||
docs/openapi/openapi.yaml: | ||
spec: | ||
- >- | ||
#/components/schemas/Update/properties/changes/items/properties/old/nullable | ||
- >- | ||
#/components/schemas/Update/properties/changes/items/properties/new/nullable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$id": "https://opg.service.justice.gov.uk/schema/lpa/2023-10", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "LPA", | ||
"description": "Digital representation of a Lasting Power of Attorney", | ||
"type": "object", | ||
"properties": { | ||
"uid": { | ||
"type": "string", | ||
"pattern": "M-([A-Z0-9]{4})-([A-Z0-9]{4})-([A-Z0-9]{4})", | ||
"example": "M-789Q-P4DF-4UX3" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ go 1.21.0 | |
|
||
use ( | ||
./lambda/create | ||
./lambda/get | ||
./lambda/shared | ||
./lambda/update | ||
./mock-apigw | ||
./signer | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module github.com/ministryofjustice/opg-data-lpa-deed/lambda/get | ||
|
||
go 1.21.0 | ||
|
||
toolchain go1.21.3 | ||
|
||
require ( | ||
github.com/aws/aws-lambda-go v1.41.0 | ||
github.com/ministryofjustice/opg-data-lpa-deed/lambda/shared v0.0.0-20231012101804-da267f23d7db | ||
github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y= | ||
github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/ministryofjustice/opg-data-lpa-deed/lambda/shared v0.0.0-20231012101804-da267f23d7db h1:HcdoeSkWe5Bkokl3SvmaOlPNsCk+T78oQqVDrFNgsD8= | ||
github.com/ministryofjustice/opg-data-lpa-deed/lambda/shared v0.0.0-20231012101804-da267f23d7db/go.mod h1:uarvaw7JMaubij8CuiO2bNcJBp8zWEdiU+AVqe78Ggc= | ||
github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90 h1:mxTHIeCYV7LDZPN7C44wwLlBTUsgQ0G8FQprsrsKXaA= | ||
github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90/go.mod h1:1RmCNi6dkAv8umAgNHp8RkuBoSKLlxp1UtfsGYH7ufc= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= | ||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/aws/aws-lambda-go/events" | ||
"github.com/aws/aws-lambda-go/lambda" | ||
"github.com/ministryofjustice/opg-data-lpa-deed/lambda/shared" | ||
"github.com/ministryofjustice/opg-go-common/logging" | ||
) | ||
|
||
type Logger interface { | ||
Print(...interface{}) | ||
} | ||
|
||
type Lambda struct { | ||
store shared.Client | ||
logger Logger | ||
} | ||
|
||
func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { | ||
response := events.APIGatewayProxyResponse{ | ||
StatusCode: 500, | ||
Body: "{\"code\":\"INTERNAL_SERVER_ERROR\",\"detail\":\"Internal server error\"}", | ||
} | ||
|
||
lpa, err := l.store.Get(ctx, event.PathParameters["uid"]) | ||
|
||
if err != nil { | ||
l.logger.Print(err) | ||
return shared.ProblemInternalServerError.Respond() | ||
} | ||
|
||
body, err := json.Marshal(lpa) | ||
|
||
if err != nil { | ||
l.logger.Print(err) | ||
return shared.ProblemInternalServerError.Respond() | ||
} | ||
|
||
response.StatusCode = 200 | ||
response.Body = string(body) | ||
|
||
return response, nil | ||
} | ||
|
||
func main() { | ||
l := &Lambda{ | ||
store: shared.NewDynamoDB(os.Getenv("DDB_TABLE_NAME_DEEDS")), | ||
logger: logging.New(os.Stdout, "opg-data-lpa-deed"), | ||
} | ||
|
||
lambda.Start(l.HandleEvent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.