-
Notifications
You must be signed in to change notification settings - Fork 21
Issue 6748: Rest API shell #6788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
bd08907
6749: Initial maven commit
rtjd6554 4175a4c
6749: Rest api design framework
rtjd6554 6cd1287
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 2142f36
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 744490d
6749: Refactor location of restapi code
rtjd6554 89168d9
6749: Update config for chunks and names
rtjd6554 b6a99ec
6749: Update poms
rtjd6554 3b90ef4
6749: Update chunk-config
rtjd6554 83ea654
6749: Optional stack option
rtjd6554 ed4fd08
6749: Refactor restapi stack
rtjd6554 d29df6f
6749: Update dependency to fix build
rtjd6554 2a6f90a
6749: Update documentation
rtjd6554 6fc8cbe
6749: Update versioning number for testing
rtjd6554 7841ae4
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 b7380ed
6749: Update documentation
rtjd6554 d9e1221
6749: Commented out section
rtjd6554 06e9f10
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 ab33692
6749: Remove extra module and relocate into cdk
rtjd6554 9d8b904
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 143a24f
6749: CfnApi variant
rtjd6554 e27f8cc
6749: Add integration
rtjd6554 808de8b
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 febe991
6749: Add route
rtjd6554 5ff81f3
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 28b9505
6749: Update default properties for apigateway creation
rtjd6554 09a1e7c
6749: Update cfnOutput
rtjd6554 f3a652b
6749: Update for url details
rtjd6554 54e60b2
6749: Update method signature
rtjd6554 f2aabdb
6749: Tidy up changes
rtjd6554 f2c761e
6749: Lambda handlers
rtjd6554 913b6b0
6749: Resolve spot bugs issue
rtjd6554 7d3b6ee
6749: Update generated documentation
rtjd6554 9e57c2c
6749: Simplfy constructor
rtjd6554 9ee5a37
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 3e2fdb4
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 6769041
6749: Capitalisations
rtjd6554 435eaaa
6749: Review comments update
rtjd6554 dab43dc
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 46e677f
6749: Fix dependencies
rtjd6554 2ac11a7
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 1118c90
6749: Add logging group
rtjd6554 33011e0
6749: Adjust integrationType to not use older import
rtjd6554 2adc778
6749: Refactor into seperate module
rtjd6554 72dc22e
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 309f5e8
9749: Update pom.xml
rtjd6554 71c1205
Update pom with copyright
rtjd6554 1251986
6749: Remove bad character
rtjd6554 1267df6
6749: Update text description
rtjd6554 3d9465f
6749: Update chunks
rtjd6554 e90e1e4
6749: Correct typo
rtjd6554 7742b60
6749: Basis logic for logging
rtjd6554 a099766
6749: Switch to HTTPApi
rtjd6554 11c003a
6749: Correct approval for default instance
rtjd6554 03ba16c
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 c13e3d0
6749: Update pom dependencies
rtjd6554 637fd10
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 dc41bc4
6749: Adjust lambda sample actions
rtjd6554 40c821e
6749: Update lambda handleEvent
rtjd6554 2aa5b13
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 3423d8b
6749: Adjust scope declaration
rtjd6554 83f7ad8
6749: Update scopes and ids
rtjd6554 e7d51a0
6749: Update javadoc
rtjd6554 d08fa20
6749: Update gateway settings
rtjd6554 71034d7
6749: Update gateway method arguments
rtjd6554 9dedbc4
6749: Update log group declaration
rtjd6554 aa39b67
6749: Typo corrections
rtjd6554 931d838
6749: Adjust class usages
rtjd6554 7eabf33
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 c901c48
6749: Update arguments
rtjd6554 79ebead
6749: Update documentation
rtjd6554 5a8ae71
6749: Update approval
rtjd6554 6cebc82
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 265a53f
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 cffed96
6749: Update stub method to provide simple response
rtjd6554 8de1b83
6749: Replace core dependency with slf4j due to maven warning
rtjd6554 c56b498
6749: Update system test properties
rtjd6554 00024b7
6749: Adjusted based on review comments
rtjd6554 e72b951
6749: Adjust lambda ID
rtjd6554 b59edcf
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 b9725b6
6749: Update based on review comments
rtjd6554 df41d33
6749: Method simplification
rtjd6554 f862e5a
6749: Update property group for REST APJ url
rtjd6554 ca51ce4
6749: Update zip.xml
rtjd6554 58b5e7c
Merge branch 'develop' into 6749-rest-api-shell
rtjd6554 4fe1236
6749: Update LambdaJar with RestAPI
rtjd6554 f20acfc
6749: Update documentation
rtjd6554 f4ca67b
6749: Update handler
rtjd6554 f443897
Merge branch 'develop' into 6749-rest-api-shell
patchwork01 5a48cd0
6749: Relocate rest-api out of deployment module
rtjd6554 ae61e1b
6749: Remove rest-api reference
rtjd6554 c35d719
6749: Added missing module reference
rtjd6554 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
85 changes: 85 additions & 0 deletions
85
java/deployment/cdk/src/main/java/sleeper/cdk/stack/RestApiStack.java
This file contains hidden or 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,85 @@ | ||
| /* | ||
| * Copyright 2022-2026 Crown Copyright | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package sleeper.cdk.stack; | ||
|
|
||
| import software.amazon.awscdk.CfnOutput; | ||
| import software.amazon.awscdk.CfnOutputProps; | ||
| import software.amazon.awscdk.Duration; | ||
| import software.amazon.awscdk.NestedStack; | ||
| import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpLambdaIntegration; | ||
| import software.amazon.awscdk.services.apigatewayv2.AddRoutesOptions; | ||
| import software.amazon.awscdk.services.apigatewayv2.HttpApi; | ||
| import software.amazon.awscdk.services.apigatewayv2.HttpMethod; | ||
| import software.amazon.awscdk.services.lambda.IFunction; | ||
| import software.constructs.Construct; | ||
|
|
||
| import sleeper.cdk.artefacts.SleeperInstanceArtefacts; | ||
| import sleeper.cdk.lambda.SleeperLambdaCode; | ||
| import sleeper.cdk.stack.core.LoggingStack.LogGroupRef; | ||
| import sleeper.cdk.util.Utils; | ||
| import sleeper.core.deploy.LambdaHandler; | ||
| import sleeper.core.properties.instance.CdkDefinedInstanceProperty; | ||
| import sleeper.core.properties.instance.InstanceProperties; | ||
| import sleeper.core.util.EnvironmentUtils; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static sleeper.core.properties.instance.CommonProperty.ID; | ||
|
|
||
| /** | ||
| * REST API for interacting with the Sleeper instance. | ||
| * Utilises API Gateway. | ||
| */ | ||
| public class RestApiStack extends NestedStack { | ||
|
|
||
| public RestApiStack(Construct scope, String id, InstanceProperties instanceProperties, | ||
| SleeperInstanceArtefacts artefacts, SleeperCoreStacks coreStacks) { | ||
| super(scope, id); | ||
| setUpRestApi(instanceProperties, artefacts, coreStacks); | ||
| } | ||
|
|
||
| private void setUpRestApi(InstanceProperties instanceProperties, SleeperInstanceArtefacts artefacts, | ||
| SleeperCoreStacks coreStacks) { | ||
| String instanceId = Utils.cleanInstanceId(instanceProperties.get(ID)); | ||
| SleeperLambdaCode lambdaCode = artefacts.lambdaCodeAtScope(this); | ||
| Map<String, String> env = EnvironmentUtils.createDefaultEnvironment(instanceProperties); | ||
| String functionName = String.join("-", "sleeper", instanceId, "rest-api-handler"); | ||
| IFunction lambda = lambdaCode.buildFunction(LambdaHandler.REST_API_HANDLER, "RestApiHandlerlambda", builder -> builder | ||
| .functionName(functionName) | ||
| .description("Implements a REST API for interacting with Sleeper") | ||
| .environment(env) | ||
| .memorySize(1024) | ||
| .logGroup(coreStacks.getLogGroup(LogGroupRef.REST_API_HANDLER)) | ||
| .timeout(Duration.seconds(29))); | ||
|
|
||
| HttpApi restHttpApi = HttpApi.Builder.create(this, "RestApi") | ||
| .description("Sleeper REST API") | ||
| .apiName(lambda.getFunctionName()) | ||
| .build(); | ||
|
|
||
| HttpLambdaIntegration integration = HttpLambdaIntegration.Builder.create(instanceId, lambda).build(); | ||
| restHttpApi.addRoutes(AddRoutesOptions.builder() | ||
| .path("/sleeper") | ||
| .methods(List.of(HttpMethod.GET)) | ||
| .integration(integration).build()); | ||
|
|
||
| new CfnOutput(this, "RestApiUrl", CfnOutputProps.builder() | ||
| .value(restHttpApi.getApiEndpoint()) | ||
| .build()); | ||
| instanceProperties.set(CdkDefinedInstanceProperty.REST_API_URL, restHttpApi.getApiEndpoint()); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.