├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── analytics ├── README.md ├── buildspec-integ-test.yaml ├── buildspec.yaml ├── pom.xml ├── sam │ ├── app │ │ └── template.yaml │ └── cicd │ │ └── template.yaml └── src │ └── test │ ├── java │ └── software │ │ └── amazon │ │ └── serverless │ │ └── apprepo │ │ ├── api │ │ └── client │ │ │ ├── AWSServerlessApplicationRepository.java │ │ │ ├── AWSServerlessApplicationRepositoryClient.java │ │ │ ├── AWSServerlessApplicationRepositoryClientBuilder.java │ │ │ ├── AbstractAWSServerlessApplicationRepository.java │ │ │ ├── auth │ │ │ └── CognitoAuthorizer.java │ │ │ ├── model │ │ │ ├── AWSServerlessApplicationRepositoryException.java │ │ │ ├── Application.java │ │ │ ├── ApplicationList.java │ │ │ ├── ApplicationSummary.java │ │ │ ├── BadRequestException.java │ │ │ ├── ConflictException.java │ │ │ ├── CreateApplicationInput.java │ │ │ ├── CreateApplicationRequest.java │ │ │ ├── CreateApplicationResult.java │ │ │ ├── DeleteApplicationRequest.java │ │ │ ├── DeleteApplicationResult.java │ │ │ ├── GetApplicationRequest.java │ │ │ ├── GetApplicationResult.java │ │ │ ├── InternalServerErrorException.java │ │ │ ├── ListApplicationsRequest.java │ │ │ ├── ListApplicationsResult.java │ │ │ ├── NotFoundException.java │ │ │ ├── TooManyRequestsException.java │ │ │ ├── UnauthorizedException.java │ │ │ ├── UpdateApplicationInput.java │ │ │ ├── UpdateApplicationRequest.java │ │ │ ├── UpdateApplicationResult.java │ │ │ └── transform │ │ │ │ ├── ApplicationJsonUnmarshaller.java │ │ │ │ ├── ApplicationListJsonUnmarshaller.java │ │ │ │ ├── ApplicationListMarshaller.java │ │ │ │ ├── ApplicationMarshaller.java │ │ │ │ ├── ApplicationSummaryJsonUnmarshaller.java │ │ │ │ ├── ApplicationSummaryMarshaller.java │ │ │ │ ├── CreateApplicationInputJsonUnmarshaller.java │ │ │ │ ├── CreateApplicationInputMarshaller.java │ │ │ │ ├── CreateApplicationRequestMarshaller.java │ │ │ │ ├── CreateApplicationRequestProtocolMarshaller.java │ │ │ │ ├── CreateApplicationResultJsonUnmarshaller.java │ │ │ │ ├── DeleteApplicationRequestMarshaller.java │ │ │ │ ├── DeleteApplicationRequestProtocolMarshaller.java │ │ │ │ ├── DeleteApplicationResultJsonUnmarshaller.java │ │ │ │ ├── GetApplicationRequestMarshaller.java │ │ │ │ ├── GetApplicationRequestProtocolMarshaller.java │ │ │ │ ├── GetApplicationResultJsonUnmarshaller.java │ │ │ │ ├── ListApplicationsRequestMarshaller.java │ │ │ │ ├── ListApplicationsRequestProtocolMarshaller.java │ │ │ │ ├── ListApplicationsResultJsonUnmarshaller.java │ │ │ │ ├── UpdateApplicationInputJsonUnmarshaller.java │ │ │ │ ├── UpdateApplicationInputMarshaller.java │ │ │ │ ├── UpdateApplicationRequestMarshaller.java │ │ │ │ ├── UpdateApplicationRequestProtocolMarshaller.java │ │ │ │ └── UpdateApplicationResultJsonUnmarshaller.java │ │ │ └── package-info.java │ │ └── cucumber │ │ ├── ApplicationsService_IT.java │ │ ├── features │ │ └── AthenaQuery.feature │ │ ├── guice │ │ ├── ApplicationModule.java │ │ ├── CognitoAuthorizerImpl.java │ │ └── CukeInjectorSource.java │ │ └── steps │ │ ├── AWSServerlessApplicationRepositoryRecordingClient.java │ │ ├── AthenaQuerySteps.java │ │ ├── CognitoUserManager.java │ │ ├── S3Helper.java │ │ ├── SetupAndTeardownSteps.java │ │ └── TestEnv.java │ └── resources │ ├── cucumber.properties │ ├── integ-test-env.template.yaml │ └── log4j2.properties ├── backend ├── README.md ├── buildspec-integ-test.yaml ├── buildspec.yaml ├── images │ └── back_end_diagram.png ├── pom.xml ├── sam │ ├── app │ │ ├── api.template.yaml │ │ ├── database.template.yaml │ │ └── template.yaml │ └── cicd │ │ └── template.yaml ├── src │ ├── main │ │ ├── java │ │ │ └── software │ │ │ │ └── amazon │ │ │ │ └── serverless │ │ │ │ └── apprepo │ │ │ │ ├── api │ │ │ │ ├── exception │ │ │ │ │ ├── ApiException.java │ │ │ │ │ ├── ApiExceptionMapper.java │ │ │ │ │ ├── BadRequestApiException.java │ │ │ │ │ ├── ConflictApiException.java │ │ │ │ │ ├── InternalServerApiException.java │ │ │ │ │ └── NotFoundApiException.java │ │ │ │ └── impl │ │ │ │ │ ├── ApplicationRecord.java │ │ │ │ │ ├── ApplicationsService.java │ │ │ │ │ └── pagination │ │ │ │ │ ├── DynamoDbStartKeySerializer.java │ │ │ │ │ ├── EncryptedTokenSerializer.java │ │ │ │ │ ├── InvalidTokenException.java │ │ │ │ │ ├── PaginationTokenSerializer.java │ │ │ │ │ ├── TimeBasedTokenSerializer.java │ │ │ │ │ ├── TokenSerializer.java │ │ │ │ │ └── jackson │ │ │ │ │ ├── AttributeValueDeserializer.java │ │ │ │ │ ├── AttributeValueSerializer.java │ │ │ │ │ ├── SdkBytesDeserializer.java │ │ │ │ │ └── SdkBytesSerializer.java │ │ │ │ └── container │ │ │ │ ├── ApiLambdaHandler.java │ │ │ │ ├── CorsHeadersResponseFilter.java │ │ │ │ ├── config │ │ │ │ ├── ConfigProvider.java │ │ │ │ ├── Env.java │ │ │ │ └── SsmConfigProvider.java │ │ │ │ └── factory │ │ │ │ ├── DynamoDbClientFactory.java │ │ │ │ ├── KmsClientFactory.java │ │ │ │ └── SsmConfigProviderFactory.java │ │ └── resources │ │ │ └── log4j.properties │ └── test │ │ ├── java │ │ └── software │ │ │ └── amazon │ │ │ └── serverless │ │ │ └── apprepo │ │ │ ├── api │ │ │ ├── client │ │ │ │ ├── AWSServerlessApplicationRepository.java │ │ │ │ ├── AWSServerlessApplicationRepositoryClient.java │ │ │ │ ├── AWSServerlessApplicationRepositoryClientBuilder.java │ │ │ │ ├── AbstractAWSServerlessApplicationRepository.java │ │ │ │ ├── auth │ │ │ │ │ └── CognitoAuthorizer.java │ │ │ │ ├── model │ │ │ │ │ ├── AWSServerlessApplicationRepositoryException.java │ │ │ │ │ ├── Application.java │ │ │ │ │ ├── ApplicationList.java │ │ │ │ │ ├── ApplicationSummary.java │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ ├── CreateApplicationInput.java │ │ │ │ │ ├── CreateApplicationRequest.java │ │ │ │ │ ├── CreateApplicationResult.java │ │ │ │ │ ├── DeleteApplicationRequest.java │ │ │ │ │ ├── DeleteApplicationResult.java │ │ │ │ │ ├── GetApplicationRequest.java │ │ │ │ │ ├── GetApplicationResult.java │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ ├── ListApplicationsRequest.java │ │ │ │ │ ├── ListApplicationsResult.java │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ ├── TooManyRequestsException.java │ │ │ │ │ ├── UnauthorizedException.java │ │ │ │ │ ├── UpdateApplicationInput.java │ │ │ │ │ ├── UpdateApplicationRequest.java │ │ │ │ │ ├── UpdateApplicationResult.java │ │ │ │ │ └── transform │ │ │ │ │ │ ├── ApplicationJsonUnmarshaller.java │ │ │ │ │ │ ├── ApplicationListJsonUnmarshaller.java │ │ │ │ │ │ ├── ApplicationListMarshaller.java │ │ │ │ │ │ ├── ApplicationMarshaller.java │ │ │ │ │ │ ├── ApplicationSummaryJsonUnmarshaller.java │ │ │ │ │ │ ├── ApplicationSummaryMarshaller.java │ │ │ │ │ │ ├── CreateApplicationInputJsonUnmarshaller.java │ │ │ │ │ │ ├── CreateApplicationInputMarshaller.java │ │ │ │ │ │ ├── CreateApplicationRequestMarshaller.java │ │ │ │ │ │ ├── CreateApplicationRequestProtocolMarshaller.java │ │ │ │ │ │ ├── CreateApplicationResultJsonUnmarshaller.java │ │ │ │ │ │ ├── DeleteApplicationRequestMarshaller.java │ │ │ │ │ │ ├── DeleteApplicationRequestProtocolMarshaller.java │ │ │ │ │ │ ├── DeleteApplicationResultJsonUnmarshaller.java │ │ │ │ │ │ ├── GetApplicationRequestMarshaller.java │ │ │ │ │ │ ├── GetApplicationRequestProtocolMarshaller.java │ │ │ │ │ │ ├── GetApplicationResultJsonUnmarshaller.java │ │ │ │ │ │ ├── ListApplicationsRequestMarshaller.java │ │ │ │ │ │ ├── ListApplicationsRequestProtocolMarshaller.java │ │ │ │ │ │ ├── ListApplicationsResultJsonUnmarshaller.java │ │ │ │ │ │ ├── UpdateApplicationInputJsonUnmarshaller.java │ │ │ │ │ │ ├── UpdateApplicationInputMarshaller.java │ │ │ │ │ │ ├── UpdateApplicationRequestMarshaller.java │ │ │ │ │ │ ├── UpdateApplicationRequestProtocolMarshaller.java │ │ │ │ │ │ └── UpdateApplicationResultJsonUnmarshaller.java │ │ │ │ └── package-info.java │ │ │ ├── exception │ │ │ │ └── ApiExceptionMapperTest.java │ │ │ └── impl │ │ │ │ ├── ApplicationsServiceTest.java │ │ │ │ └── pagination │ │ │ │ ├── DynamoDbStartKeySerializerTest.java │ │ │ │ ├── EncryptedTokenSerializerTest.java │ │ │ │ └── TimeBasedTokenSerializerTest.java │ │ │ └── cucumber │ │ │ ├── ApplicationsService_IT.java │ │ │ ├── features │ │ │ ├── CreateApplication.feature │ │ │ ├── DeleteApplication.feature │ │ │ ├── GetApplication.feature │ │ │ ├── ListApplications.feature │ │ │ └── UpdateApplication.feature │ │ │ ├── guice │ │ │ ├── ApplicationModule.java │ │ │ ├── CognitoAuthorizerImpl.java │ │ │ └── CukeInjectorSource.java │ │ │ └── steps │ │ │ ├── AWSServerlessApplicationRepositoryRecordingClient.java │ │ │ ├── CognitoUserManager.java │ │ │ ├── CommonSteps.java │ │ │ ├── CreateApplicationSteps.java │ │ │ ├── DeleteApplicationSteps.java │ │ │ ├── GetApplicationSteps.java │ │ │ ├── ListApplicationsSteps.java │ │ │ ├── SetupAndTeardownSteps.java │ │ │ ├── TestEnv.java │ │ │ └── UpdateApplicationSteps.java │ │ └── resources │ │ ├── cucumber.properties │ │ └── integ-test-env.template.yaml └── swagger │ └── api.yaml ├── bin ├── delete-stack.sh ├── deploy.sh ├── generate-sdk.sh └── package.sh ├── buildspec.yaml ├── images └── architecture_diagram.png ├── ops ├── README.md ├── buildspec.yaml ├── images │ ├── alarm-email.png │ ├── alarms.png │ └── dashboard.png └── sam │ ├── app │ ├── alarm.template.yaml │ ├── dashboard.template.yaml │ └── template.yaml │ └── cicd │ └── template.yaml ├── pom.xml ├── sam └── app │ └── template.yaml └── static-website ├── .browserslistrc ├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── README.md ├── babel.config.js ├── bin └── package-static-website.sh ├── buildspec-integ-test.yaml ├── buildspec.yaml ├── images └── sign-in.png ├── nightwatch.conf.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── public ├── favicon.ico └── index.html ├── sam ├── app │ └── template.yaml └── cicd │ └── template.yaml ├── src ├── App.vue ├── assets │ └── logo.png ├── components │ ├── Breadcrumb.vue │ ├── ErrorAlert.vue │ └── Nav.vue ├── config.js ├── main.js ├── plugins │ └── bootstrap-vue.js ├── router.js ├── services │ └── sar-api.js ├── store │ ├── actions.type.js │ ├── auth.module.js │ ├── index.js │ ├── mutations.type.js │ └── sar.module.js └── views │ ├── Applications.vue │ ├── EditApplication.vue │ ├── Home.vue │ ├── NewApplication.vue │ ├── SignIn.vue │ └── ViewApplication.vue ├── tests ├── e2e │ ├── custom-assertions │ │ └── elementCount.js │ ├── page-objects │ │ ├── appDetails.js │ │ ├── editApp.js │ │ ├── myApps.js │ │ ├── publishApp.js │ │ ├── signIn.js │ │ └── welcome.js │ ├── specs │ │ └── applications.js │ └── utils │ │ └── cognitoAdmin.js ├── setup.js └── unit │ ├── .eslintrc.js │ ├── components │ └── Nav.spec.js │ └── views │ ├── Applications.spec.js │ ├── EditApplication.spec.js │ ├── Home.spec.js │ ├── NewApplication.spec.js │ └── ViewApplication.spec.js └── vue.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | /eclipse-bin/ 2 | *.iml 3 | .classpath 4 | .settings 5 | .project 6 | build 7 | .*.sw[op] 8 | */.DS_Store 9 | .idea/ 10 | *target/ 11 | 12 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## realworld-serverless-application ![Build Status](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoidk1hV1NVOVR6WkJSbjdEN3Evc0lDN2t1ZEQ2ZFVuTDV5Q1ZHMDF5NFZBZTBIWVZxbEtIN2w5NGNPRGxkQmpZVzJaQTVaV1I3Mm5tT1FYN1IxYmFGY1hBPSIsIml2UGFyYW1ldGVyU3BlYyI6Ijc2QU1Qc2lUTXY4Ny9Za2EiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master) 2 | 3 | This project is an adaptation of the [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/). Its primary objective is to serve as a case study of how to build a real world application using a combination of serverless technologies and approaches. The project captures key architectural components, code structure, deployment techniques, testing approaches, and operational practices of the AWS Serverless Application Repository - a production-grade AWS service, written in Java and built using serverless technologies. It is comprised of 4 components. 4 | 5 | ![Architecture Diagram](https://github.com/awslabs/realworld-serverless-application/raw/master/images/architecture_diagram.png) 6 | 7 | To get started, see the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide. For more details, read our [blog post](https://aws.amazon.com/blogs/opensource/real-world-serverless-application) and see our [project wiki](https://github.com/awslabs/realworld-serverless-application/wiki). 8 | 9 | ## License 10 | 11 | This project is licensed under the Apache-2.0 License. 12 | -------------------------------------------------------------------------------- /analytics/README.md: -------------------------------------------------------------------------------- 1 | # realworld-serverless-application-analytics 2 | 3 | realworld-serverless-application-analytics is the analytics component of a larger project providing business intelligence queries via Amazon Athena for the application. It can be deployed together with the other system components to produce an example serverless application demonstrating real world patterns and best practices for serverless applications. 4 | 5 | To get started with the full project, follow the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide. 6 | 7 | ## License 8 | 9 | This project is licensed under the Apache-2.0 License. 10 | -------------------------------------------------------------------------------- /analytics/buildspec-integ-test.yaml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | install: 5 | runtime-versions: 6 | java: openjdk8 7 | build: 8 | commands: 9 | - TEST_STAGE=integtests`date +%s` 10 | - cd backend 11 | - mvn clean package -DpackageBucket=${PACKAGE_BUCKET} 12 | - cd .. 13 | - ./bin/deploy.sh -n $TEST_STAGE-backend -t backend/target/sam/app/packaged-template.yaml -o "Stage=$TEST_STAGE" 14 | - cd analytics 15 | - mvn clean verify -Dintegtests.stage=${TEST_STAGE} -DpackageBucket=${PACKAGE_BUCKET} 16 | finally: 17 | - cd $CODEBUILD_SRC_DIR 18 | # Cleanup commands end with "|| true" to ensure that all of them are executed. It's ok if they fail trying to delete a resource that was never created due to a build phase error. 19 | - ./bin/delete-stack.sh -n $TEST_STAGE-backend || true -------------------------------------------------------------------------------- /analytics/buildspec.yaml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | install: 5 | runtime-versions: 6 | java: openjdk8 # Runtime version is required in the build spec even though this module does not use java 7 | build: 8 | commands: 9 | - bin/package.sh -n analytics 10 | artifacts: 11 | files: 12 | - analytics/target/sam/app/packaged-template.yaml 13 | discard-paths: yes 14 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/AbstractAWSServerlessApplicationRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client; 5 | 6 | import javax.annotation.Generated; 7 | import software.amazon.serverless.apprepo.api.client.model.*; 8 | import com.amazonaws.*; 9 | import com.amazonaws.opensdk.*; 10 | import com.amazonaws.opensdk.model.*; 11 | 12 | /** 13 | * Abstract implementation of {@code AWSServerlessApplicationRepository}. 14 | */ 15 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 16 | public class AbstractAWSServerlessApplicationRepository implements AWSServerlessApplicationRepository { 17 | 18 | protected AbstractAWSServerlessApplicationRepository() { 19 | } 20 | 21 | @Override 22 | public CreateApplicationResult createApplication(CreateApplicationRequest request) { 23 | throw new java.lang.UnsupportedOperationException(); 24 | } 25 | 26 | @Override 27 | public DeleteApplicationResult deleteApplication(DeleteApplicationRequest request) { 28 | throw new java.lang.UnsupportedOperationException(); 29 | } 30 | 31 | @Override 32 | public GetApplicationResult getApplication(GetApplicationRequest request) { 33 | throw new java.lang.UnsupportedOperationException(); 34 | } 35 | 36 | @Override 37 | public ListApplicationsResult listApplications(ListApplicationsRequest request) { 38 | throw new java.lang.UnsupportedOperationException(); 39 | } 40 | 41 | @Override 42 | public UpdateApplicationResult updateApplication(UpdateApplicationRequest request) { 43 | throw new java.lang.UnsupportedOperationException(); 44 | } 45 | 46 | @Override 47 | public void shutdown() { 48 | throw new java.lang.UnsupportedOperationException(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/auth/CognitoAuthorizer.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.auth; 5 | 6 | import javax.annotation.Generated; 7 | import com.amazonaws.ImmutableRequest; 8 | import com.amazonaws.SignableRequest; 9 | import com.amazonaws.auth.RequestSigner; 10 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository; 11 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepositoryClientBuilder; 12 | 13 | /** 14 | * A default implementation of {@link RequestSigner} that puts a generated token into the header. An implementation of 15 | * this can to be supplied during construction of a {@link AWSServerlessApplicationRepository} via 16 | * {@link AWSServerlessApplicationRepositoryClientBuilder#signer(CognitoAuthorizer)} like so 17 | * 18 | *
19 |  * 
20 |  *  AWSServerlessApplicationRepository client = AWSServerlessApplicationRepository.builder().signer((CognitoAuthorizer) request -> "some token").build();
21 |  * 
22 |  * 
23 | */ 24 | @FunctionalInterface 25 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 26 | public interface CognitoAuthorizer extends RequestSigner { 27 | 28 | /** 29 | * Generate a token that will be added to Authorization in the header of the request during signing 30 | * 31 | * @param request 32 | * an immutable view of the request for which to generate a token 33 | * @return the token to use for signing 34 | */ 35 | String generateToken(ImmutableRequest request); 36 | 37 | /** 38 | * @see RequestSigner#sign(SignableRequest) 39 | */ 40 | @Override 41 | default void sign(SignableRequest request) { 42 | request.addHeader("Authorization", generateToken(request)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/AWSServerlessApplicationRepositoryException.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import com.amazonaws.opensdk.SdkErrorHttpMetadata; 7 | import com.amazonaws.opensdk.internal.BaseException; 8 | import com.amazonaws.annotation.SdkInternalApi; 9 | import javax.annotation.Generated; 10 | 11 | /** 12 | * Base exception for all service exceptions thrown by realworld-serverless-application-backend-dev 13 | */ 14 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 15 | public class AWSServerlessApplicationRepositoryException extends com.amazonaws.SdkBaseException implements BaseException { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | private SdkErrorHttpMetadata sdkHttpMetadata; 20 | 21 | private String message; 22 | 23 | /** 24 | * Constructs a new AWSServerlessApplicationRepositoryException with the specified error message. 25 | * 26 | * @param message 27 | * Describes the error encountered. 28 | */ 29 | public AWSServerlessApplicationRepositoryException(String message) { 30 | super(message); 31 | this.message = message; 32 | } 33 | 34 | @Override 35 | public AWSServerlessApplicationRepositoryException sdkHttpMetadata(SdkErrorHttpMetadata sdkHttpMetadata) { 36 | this.sdkHttpMetadata = sdkHttpMetadata; 37 | return this; 38 | } 39 | 40 | @Override 41 | public SdkErrorHttpMetadata sdkHttpMetadata() { 42 | return sdkHttpMetadata; 43 | } 44 | 45 | @SdkInternalApi 46 | @Override 47 | public void setMessage(String message) { 48 | this.message = message; 49 | } 50 | 51 | @Override 52 | public String getMessage() { 53 | return message; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/BadRequestException.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class BadRequestException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new BadRequestException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public BadRequestException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public BadRequestException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/ConflictException.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class ConflictException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new ConflictException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public ConflictException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public ConflictException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/DeleteApplicationResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import java.io.Serializable; 7 | import javax.annotation.Generated; 8 | 9 | /** 10 | * 11 | * @see AWS 12 | * API Documentation 13 | */ 14 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 15 | public class DeleteApplicationResult extends com.amazonaws.opensdk.BaseResult implements Serializable, Cloneable { 16 | 17 | /** 18 | * Returns a string representation of this object; useful for testing and debugging. 19 | * 20 | * @return A string representation of this object. 21 | * 22 | * @see java.lang.Object#toString() 23 | */ 24 | @Override 25 | public String toString() { 26 | StringBuilder sb = new StringBuilder(); 27 | sb.append("{"); 28 | sb.append("}"); 29 | return sb.toString(); 30 | } 31 | 32 | @Override 33 | public boolean equals(Object obj) { 34 | if (this == obj) 35 | return true; 36 | if (obj == null) 37 | return false; 38 | 39 | if (obj instanceof DeleteApplicationResult == false) 40 | return false; 41 | DeleteApplicationResult other = (DeleteApplicationResult) obj; 42 | return true; 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | final int prime = 31; 48 | int hashCode = 1; 49 | 50 | return hashCode; 51 | } 52 | 53 | @Override 54 | public DeleteApplicationResult clone() { 55 | try { 56 | return (DeleteApplicationResult) super.clone(); 57 | } catch (CloneNotSupportedException e) { 58 | throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class InternalServerErrorException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new InternalServerErrorException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public InternalServerErrorException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public InternalServerErrorException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/NotFoundException.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class NotFoundException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new NotFoundException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public NotFoundException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public NotFoundException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/TooManyRequestsException.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class TooManyRequestsException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new TooManyRequestsException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public TooManyRequestsException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public TooManyRequestsException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class UnauthorizedException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new UnauthorizedException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public UnauthorizedException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public UnauthorizedException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationListMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import java.util.List; 7 | import javax.annotation.Generated; 8 | 9 | import com.amazonaws.SdkClientException; 10 | import software.amazon.serverless.apprepo.api.client.model.*; 11 | 12 | import com.amazonaws.protocol.*; 13 | import com.amazonaws.annotation.SdkInternalApi; 14 | 15 | /** 16 | * ApplicationListMarshaller 17 | */ 18 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 19 | @SdkInternalApi 20 | public class ApplicationListMarshaller { 21 | 22 | private static final MarshallingInfo APPLICATIONS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD) 23 | .marshallLocationName("applications").build(); 24 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD) 25 | .marshallLocationName("nextToken").build(); 26 | 27 | private static final ApplicationListMarshaller instance = new ApplicationListMarshaller(); 28 | 29 | public static ApplicationListMarshaller getInstance() { 30 | return instance; 31 | } 32 | 33 | /** 34 | * Marshall the given parameter object. 35 | */ 36 | public void marshall(ApplicationList applicationList, ProtocolMarshaller protocolMarshaller) { 37 | 38 | if (applicationList == null) { 39 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 40 | } 41 | 42 | try { 43 | protocolMarshaller.marshall(applicationList.getApplications(), APPLICATIONS_BINDING); 44 | protocolMarshaller.marshall(applicationList.getNextToken(), NEXTTOKEN_BINDING); 45 | } catch (Exception e) { 46 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationSummaryMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import software.amazon.serverless.apprepo.api.client.model.*; 10 | 11 | import com.amazonaws.protocol.*; 12 | import com.amazonaws.annotation.SdkInternalApi; 13 | 14 | /** 15 | * ApplicationSummaryMarshaller 16 | */ 17 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 18 | @SdkInternalApi 19 | public class ApplicationSummaryMarshaller { 20 | 21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 22 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("applicationId").build(); 23 | private static final MarshallingInfo CREATIONTIME_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 24 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("creationTime").build(); 25 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build(); 27 | 28 | private static final ApplicationSummaryMarshaller instance = new ApplicationSummaryMarshaller(); 29 | 30 | public static ApplicationSummaryMarshaller getInstance() { 31 | return instance; 32 | } 33 | 34 | /** 35 | * Marshall the given parameter object. 36 | */ 37 | public void marshall(ApplicationSummary applicationSummary, ProtocolMarshaller protocolMarshaller) { 38 | 39 | if (applicationSummary == null) { 40 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 41 | } 42 | 43 | try { 44 | protocolMarshaller.marshall(applicationSummary.getApplicationId(), APPLICATIONID_BINDING); 45 | protocolMarshaller.marshall(applicationSummary.getCreationTime(), CREATIONTIME_BINDING); 46 | protocolMarshaller.marshall(applicationSummary.getDescription(), DESCRIPTION_BINDING); 47 | } catch (Exception e) { 48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import software.amazon.serverless.apprepo.api.client.model.*; 10 | 11 | import com.amazonaws.protocol.*; 12 | import com.amazonaws.annotation.SdkInternalApi; 13 | 14 | /** 15 | * CreateApplicationRequestMarshaller 16 | */ 17 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 18 | @SdkInternalApi 19 | public class CreateApplicationRequestMarshaller { 20 | 21 | private static final MarshallingInfo CREATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED) 22 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build(); 23 | 24 | private static final CreateApplicationRequestMarshaller instance = new CreateApplicationRequestMarshaller(); 25 | 26 | public static CreateApplicationRequestMarshaller getInstance() { 27 | return instance; 28 | } 29 | 30 | /** 31 | * Marshall the given parameter object. 32 | */ 33 | public void marshall(CreateApplicationRequest createApplicationRequest, ProtocolMarshaller protocolMarshaller) { 34 | 35 | if (createApplicationRequest == null) { 36 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 37 | } 38 | 39 | try { 40 | protocolMarshaller.marshall(createApplicationRequest.getCreateApplicationInput(), CREATEAPPLICATIONINPUT_BINDING); 41 | } catch (Exception e) { 42 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import com.amazonaws.Request; 10 | 11 | import com.amazonaws.http.HttpMethodName; 12 | import software.amazon.serverless.apprepo.api.client.model.*; 13 | import com.amazonaws.transform.Marshaller; 14 | 15 | import com.amazonaws.protocol.*; 16 | import com.amazonaws.annotation.SdkInternalApi; 17 | 18 | /** 19 | * CreateApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class CreateApplicationRequestProtocolMarshaller implements Marshaller, CreateApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications") 26 | .httpMethodName(HttpMethodName.POST).hasExplicitPayloadMember(true).hasPayloadMembers(true).serviceName("AWSServerlessApplicationRepository") 27 | .build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public CreateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(CreateApplicationRequest createApplicationRequest) { 36 | 37 | if (createApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | createApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | CreateApplicationRequestMarshaller.getInstance().marshall(createApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import java.math.*; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import software.amazon.serverless.apprepo.api.client.model.*; 11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 12 | import com.amazonaws.transform.*; 13 | 14 | import com.fasterxml.jackson.core.JsonToken; 15 | import static com.fasterxml.jackson.core.JsonToken.*; 16 | 17 | /** 18 | * CreateApplicationResult JSON Unmarshaller 19 | */ 20 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 21 | public class CreateApplicationResultJsonUnmarshaller implements Unmarshaller { 22 | 23 | public CreateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 24 | CreateApplicationResult createApplicationResult = new CreateApplicationResult(); 25 | 26 | int originalDepth = context.getCurrentDepth(); 27 | String currentParentElement = context.getCurrentParentElement(); 28 | int targetDepth = originalDepth + 1; 29 | 30 | JsonToken token = context.getCurrentToken(); 31 | if (token == null) 32 | token = context.nextToken(); 33 | if (token == VALUE_NULL) { 34 | return createApplicationResult; 35 | } 36 | 37 | while (true) { 38 | if (token == null) 39 | break; 40 | 41 | createApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context)); 42 | token = context.nextToken(); 43 | } 44 | 45 | return createApplicationResult; 46 | } 47 | 48 | private static CreateApplicationResultJsonUnmarshaller instance; 49 | 50 | public static CreateApplicationResultJsonUnmarshaller getInstance() { 51 | if (instance == null) 52 | instance = new CreateApplicationResultJsonUnmarshaller(); 53 | return instance; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import software.amazon.serverless.apprepo.api.client.model.*; 10 | 11 | import com.amazonaws.protocol.*; 12 | import com.amazonaws.annotation.SdkInternalApi; 13 | 14 | /** 15 | * DeleteApplicationRequestMarshaller 16 | */ 17 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 18 | @SdkInternalApi 19 | public class DeleteApplicationRequestMarshaller { 20 | 21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 22 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build(); 23 | 24 | private static final DeleteApplicationRequestMarshaller instance = new DeleteApplicationRequestMarshaller(); 25 | 26 | public static DeleteApplicationRequestMarshaller getInstance() { 27 | return instance; 28 | } 29 | 30 | /** 31 | * Marshall the given parameter object. 32 | */ 33 | public void marshall(DeleteApplicationRequest deleteApplicationRequest, ProtocolMarshaller protocolMarshaller) { 34 | 35 | if (deleteApplicationRequest == null) { 36 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 37 | } 38 | 39 | try { 40 | protocolMarshaller.marshall(deleteApplicationRequest.getApplicationId(), APPLICATIONID_BINDING); 41 | } catch (Exception e) { 42 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import com.amazonaws.Request; 10 | 11 | import com.amazonaws.http.HttpMethodName; 12 | import software.amazon.serverless.apprepo.api.client.model.*; 13 | import com.amazonaws.transform.Marshaller; 14 | 15 | import com.amazonaws.protocol.*; 16 | import com.amazonaws.annotation.SdkInternalApi; 17 | 18 | /** 19 | * DeleteApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class DeleteApplicationRequestProtocolMarshaller implements Marshaller, DeleteApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY) 26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.DELETE).hasExplicitPayloadMember(false).hasPayloadMembers(false) 27 | .serviceName("AWSServerlessApplicationRepository").build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public DeleteApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(DeleteApplicationRequest deleteApplicationRequest) { 36 | 37 | if (deleteApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | deleteApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | DeleteApplicationRequestMarshaller.getInstance().marshall(deleteApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import java.math.*; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import software.amazon.serverless.apprepo.api.client.model.*; 11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 12 | import com.amazonaws.transform.*; 13 | 14 | import static com.fasterxml.jackson.core.JsonToken.*; 15 | 16 | /** 17 | * DeleteApplicationResult JSON Unmarshaller 18 | */ 19 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 20 | public class DeleteApplicationResultJsonUnmarshaller implements Unmarshaller { 21 | 22 | public DeleteApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 23 | DeleteApplicationResult deleteApplicationResult = new DeleteApplicationResult(); 24 | 25 | return deleteApplicationResult; 26 | } 27 | 28 | private static DeleteApplicationResultJsonUnmarshaller instance; 29 | 30 | public static DeleteApplicationResultJsonUnmarshaller getInstance() { 31 | if (instance == null) 32 | instance = new DeleteApplicationResultJsonUnmarshaller(); 33 | return instance; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import software.amazon.serverless.apprepo.api.client.model.*; 10 | 11 | import com.amazonaws.protocol.*; 12 | import com.amazonaws.annotation.SdkInternalApi; 13 | 14 | /** 15 | * GetApplicationRequestMarshaller 16 | */ 17 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 18 | @SdkInternalApi 19 | public class GetApplicationRequestMarshaller { 20 | 21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 22 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build(); 23 | 24 | private static final GetApplicationRequestMarshaller instance = new GetApplicationRequestMarshaller(); 25 | 26 | public static GetApplicationRequestMarshaller getInstance() { 27 | return instance; 28 | } 29 | 30 | /** 31 | * Marshall the given parameter object. 32 | */ 33 | public void marshall(GetApplicationRequest getApplicationRequest, ProtocolMarshaller protocolMarshaller) { 34 | 35 | if (getApplicationRequest == null) { 36 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 37 | } 38 | 39 | try { 40 | protocolMarshaller.marshall(getApplicationRequest.getApplicationId(), APPLICATIONID_BINDING); 41 | } catch (Exception e) { 42 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import com.amazonaws.Request; 10 | 11 | import com.amazonaws.http.HttpMethodName; 12 | import software.amazon.serverless.apprepo.api.client.model.*; 13 | import com.amazonaws.transform.Marshaller; 14 | 15 | import com.amazonaws.protocol.*; 16 | import com.amazonaws.annotation.SdkInternalApi; 17 | 18 | /** 19 | * GetApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class GetApplicationRequestProtocolMarshaller implements Marshaller, GetApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY) 26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false) 27 | .serviceName("AWSServerlessApplicationRepository").build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public GetApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(GetApplicationRequest getApplicationRequest) { 36 | 37 | if (getApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | getApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | GetApplicationRequestMarshaller.getInstance().marshall(getApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import java.math.*; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import software.amazon.serverless.apprepo.api.client.model.*; 11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 12 | import com.amazonaws.transform.*; 13 | 14 | import com.fasterxml.jackson.core.JsonToken; 15 | import static com.fasterxml.jackson.core.JsonToken.*; 16 | 17 | /** 18 | * GetApplicationResult JSON Unmarshaller 19 | */ 20 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 21 | public class GetApplicationResultJsonUnmarshaller implements Unmarshaller { 22 | 23 | public GetApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 24 | GetApplicationResult getApplicationResult = new GetApplicationResult(); 25 | 26 | int originalDepth = context.getCurrentDepth(); 27 | String currentParentElement = context.getCurrentParentElement(); 28 | int targetDepth = originalDepth + 1; 29 | 30 | JsonToken token = context.getCurrentToken(); 31 | if (token == null) 32 | token = context.nextToken(); 33 | if (token == VALUE_NULL) { 34 | return getApplicationResult; 35 | } 36 | 37 | while (true) { 38 | if (token == null) 39 | break; 40 | 41 | getApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context)); 42 | token = context.nextToken(); 43 | } 44 | 45 | return getApplicationResult; 46 | } 47 | 48 | private static GetApplicationResultJsonUnmarshaller instance; 49 | 50 | public static GetApplicationResultJsonUnmarshaller getInstance() { 51 | if (instance == null) 52 | instance = new GetApplicationResultJsonUnmarshaller(); 53 | return instance; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import software.amazon.serverless.apprepo.api.client.model.*; 10 | 11 | import com.amazonaws.protocol.*; 12 | import com.amazonaws.annotation.SdkInternalApi; 13 | 14 | /** 15 | * ListApplicationsRequestMarshaller 16 | */ 17 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 18 | @SdkInternalApi 19 | public class ListApplicationsRequestMarshaller { 20 | 21 | private static final MarshallingInfo MAXITEMS_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 22 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("maxItems").build(); 23 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 24 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("nextToken").build(); 25 | 26 | private static final ListApplicationsRequestMarshaller instance = new ListApplicationsRequestMarshaller(); 27 | 28 | public static ListApplicationsRequestMarshaller getInstance() { 29 | return instance; 30 | } 31 | 32 | /** 33 | * Marshall the given parameter object. 34 | */ 35 | public void marshall(ListApplicationsRequest listApplicationsRequest, ProtocolMarshaller protocolMarshaller) { 36 | 37 | if (listApplicationsRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | protocolMarshaller.marshall(listApplicationsRequest.getMaxItems(), MAXITEMS_BINDING); 43 | protocolMarshaller.marshall(listApplicationsRequest.getNextToken(), NEXTTOKEN_BINDING); 44 | } catch (Exception e) { 45 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import com.amazonaws.Request; 10 | 11 | import com.amazonaws.http.HttpMethodName; 12 | import software.amazon.serverless.apprepo.api.client.model.*; 13 | import com.amazonaws.transform.Marshaller; 14 | 15 | import com.amazonaws.protocol.*; 16 | import com.amazonaws.annotation.SdkInternalApi; 17 | 18 | /** 19 | * ListApplicationsRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class ListApplicationsRequestProtocolMarshaller implements Marshaller, ListApplicationsRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications") 26 | .httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false).serviceName("AWSServerlessApplicationRepository") 27 | .build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public ListApplicationsRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(ListApplicationsRequest listApplicationsRequest) { 36 | 37 | if (listApplicationsRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | listApplicationsRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | ListApplicationsRequestMarshaller.getInstance().marshall(listApplicationsRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import java.math.*; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import software.amazon.serverless.apprepo.api.client.model.*; 11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 12 | import com.amazonaws.transform.*; 13 | 14 | import com.fasterxml.jackson.core.JsonToken; 15 | import static com.fasterxml.jackson.core.JsonToken.*; 16 | 17 | /** 18 | * ListApplicationsResult JSON Unmarshaller 19 | */ 20 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 21 | public class ListApplicationsResultJsonUnmarshaller implements Unmarshaller { 22 | 23 | public ListApplicationsResult unmarshall(JsonUnmarshallerContext context) throws Exception { 24 | ListApplicationsResult listApplicationsResult = new ListApplicationsResult(); 25 | 26 | int originalDepth = context.getCurrentDepth(); 27 | String currentParentElement = context.getCurrentParentElement(); 28 | int targetDepth = originalDepth + 1; 29 | 30 | JsonToken token = context.getCurrentToken(); 31 | if (token == null) 32 | token = context.nextToken(); 33 | if (token == VALUE_NULL) { 34 | return listApplicationsResult; 35 | } 36 | 37 | while (true) { 38 | if (token == null) 39 | break; 40 | 41 | listApplicationsResult.setApplicationList(ApplicationListJsonUnmarshaller.getInstance().unmarshall(context)); 42 | token = context.nextToken(); 43 | } 44 | 45 | return listApplicationsResult; 46 | } 47 | 48 | private static ListApplicationsResultJsonUnmarshaller instance; 49 | 50 | public static ListApplicationsResultJsonUnmarshaller getInstance() { 51 | if (instance == null) 52 | instance = new ListApplicationsResultJsonUnmarshaller(); 53 | return instance; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationInputMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import software.amazon.serverless.apprepo.api.client.model.*; 10 | 11 | import com.amazonaws.protocol.*; 12 | import com.amazonaws.annotation.SdkInternalApi; 13 | 14 | /** 15 | * UpdateApplicationInputMarshaller 16 | */ 17 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 18 | @SdkInternalApi 19 | public class UpdateApplicationInputMarshaller { 20 | 21 | private static final MarshallingInfo AUTHOR_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD) 22 | .marshallLocationName("author").build(); 23 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 24 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build(); 25 | private static final MarshallingInfo HOMEPAGEURL_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("homePageUrl").build(); 27 | 28 | private static final UpdateApplicationInputMarshaller instance = new UpdateApplicationInputMarshaller(); 29 | 30 | public static UpdateApplicationInputMarshaller getInstance() { 31 | return instance; 32 | } 33 | 34 | /** 35 | * Marshall the given parameter object. 36 | */ 37 | public void marshall(UpdateApplicationInput updateApplicationInput, ProtocolMarshaller protocolMarshaller) { 38 | 39 | if (updateApplicationInput == null) { 40 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 41 | } 42 | 43 | try { 44 | protocolMarshaller.marshall(updateApplicationInput.getAuthor(), AUTHOR_BINDING); 45 | protocolMarshaller.marshall(updateApplicationInput.getDescription(), DESCRIPTION_BINDING); 46 | protocolMarshaller.marshall(updateApplicationInput.getHomePageUrl(), HOMEPAGEURL_BINDING); 47 | } catch (Exception e) { 48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import software.amazon.serverless.apprepo.api.client.model.*; 10 | 11 | import com.amazonaws.protocol.*; 12 | import com.amazonaws.annotation.SdkInternalApi; 13 | 14 | /** 15 | * UpdateApplicationRequestMarshaller 16 | */ 17 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 18 | @SdkInternalApi 19 | public class UpdateApplicationRequestMarshaller { 20 | 21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 22 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build(); 23 | private static final MarshallingInfo UPDATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED) 24 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build(); 25 | 26 | private static final UpdateApplicationRequestMarshaller instance = new UpdateApplicationRequestMarshaller(); 27 | 28 | public static UpdateApplicationRequestMarshaller getInstance() { 29 | return instance; 30 | } 31 | 32 | /** 33 | * Marshall the given parameter object. 34 | */ 35 | public void marshall(UpdateApplicationRequest updateApplicationRequest, ProtocolMarshaller protocolMarshaller) { 36 | 37 | if (updateApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | protocolMarshaller.marshall(updateApplicationRequest.getApplicationId(), APPLICATIONID_BINDING); 43 | protocolMarshaller.marshall(updateApplicationRequest.getUpdateApplicationInput(), UPDATEAPPLICATIONINPUT_BINDING); 44 | } catch (Exception e) { 45 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import javax.annotation.Generated; 7 | 8 | import com.amazonaws.SdkClientException; 9 | import com.amazonaws.Request; 10 | 11 | import com.amazonaws.http.HttpMethodName; 12 | import software.amazon.serverless.apprepo.api.client.model.*; 13 | import com.amazonaws.transform.Marshaller; 14 | 15 | import com.amazonaws.protocol.*; 16 | import com.amazonaws.annotation.SdkInternalApi; 17 | 18 | /** 19 | * UpdateApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class UpdateApplicationRequestProtocolMarshaller implements Marshaller, UpdateApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY) 26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.PATCH).hasExplicitPayloadMember(true).hasPayloadMembers(true) 27 | .serviceName("AWSServerlessApplicationRepository").build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public UpdateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(UpdateApplicationRequest updateApplicationRequest) { 36 | 37 | if (updateApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | updateApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | UpdateApplicationRequestMarshaller.getInstance().marshall(updateApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import java.math.*; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import software.amazon.serverless.apprepo.api.client.model.*; 11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; 12 | import com.amazonaws.transform.*; 13 | 14 | import com.fasterxml.jackson.core.JsonToken; 15 | import static com.fasterxml.jackson.core.JsonToken.*; 16 | 17 | /** 18 | * UpdateApplicationResult JSON Unmarshaller 19 | */ 20 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 21 | public class UpdateApplicationResultJsonUnmarshaller implements Unmarshaller { 22 | 23 | public UpdateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 24 | UpdateApplicationResult updateApplicationResult = new UpdateApplicationResult(); 25 | 26 | int originalDepth = context.getCurrentDepth(); 27 | String currentParentElement = context.getCurrentParentElement(); 28 | int targetDepth = originalDepth + 1; 29 | 30 | JsonToken token = context.getCurrentToken(); 31 | if (token == null) 32 | token = context.nextToken(); 33 | if (token == VALUE_NULL) { 34 | return updateApplicationResult; 35 | } 36 | 37 | while (true) { 38 | if (token == null) 39 | break; 40 | 41 | updateApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context)); 42 | token = context.nextToken(); 43 | } 44 | 45 | return updateApplicationResult; 46 | } 47 | 48 | private static UpdateApplicationResultJsonUnmarshaller instance; 49 | 50 | public static UpdateApplicationResultJsonUnmarshaller getInstance() { 51 | if (instance == null) 52 | instance = new UpdateApplicationResultJsonUnmarshaller(); 53 | return instance; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/api/client/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | */ 4 | 5 | /** 6 | * 7 | */ 8 | package software.amazon.serverless.apprepo.api.client; 9 | 10 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/ApplicationsService_IT.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber; 2 | 3 | import io.cucumber.junit.Cucumber; 4 | import io.cucumber.junit.CucumberOptions; 5 | import org.junit.runner.RunWith; 6 | 7 | /** 8 | * Junit entry point for cucumber tests. 9 | */ 10 | @RunWith(Cucumber.class) 11 | @CucumberOptions(features = "src/test/java/software/amazon/serverless/apprepo/cucumber/features", 12 | glue = "software.amazon.serverless.apprepo.cucumber.steps", 13 | tags = {"not @NotImplemented"},// Use @NotImplemented tag for scenarios that have not been implemented 14 | plugin = {"pretty"}) 15 | public class ApplicationsService_IT { 16 | } 17 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/features/AthenaQuery.feature: -------------------------------------------------------------------------------- 1 | Feature: Analyze Data 2 | As an administrator, I would like to analyze the customer usage of the service 3 | 4 | Scenario: User creates an application 5 | When a user creates an application 6 | Then a new application should be created 7 | And the administrator can analyze the data with Athena queries 8 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CognitoAuthorizerImpl.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.guice; 2 | 3 | import com.amazonaws.ImmutableRequest; 4 | import software.amazon.serverless.apprepo.api.client.auth.CognitoAuthorizer; 5 | import software.amazon.serverless.apprepo.cucumber.steps.CognitoUserManager; 6 | 7 | import java.util.UUID; 8 | 9 | import lombok.RequiredArgsConstructor; 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | /** 13 | * Implementation of {@link CognitoAuthorizer} to provide signer for API requests. 14 | */ 15 | @Slf4j 16 | @RequiredArgsConstructor 17 | public class CognitoAuthorizerImpl implements CognitoAuthorizer { 18 | private final CognitoUserManager cognitoUserManager; 19 | 20 | @Override 21 | public String generateToken(ImmutableRequest request) { 22 | try { 23 | return cognitoUserManager.generateIdToken(); 24 | } catch (Throwable t) { 25 | log.warn("Exception thrown when generating token", t); 26 | return UUID.randomUUID().toString(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CukeInjectorSource.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.guice; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.google.inject.Guice; 5 | import com.google.inject.Injector; 6 | 7 | import cucumber.runtime.java.guice.InjectorSource; 8 | 9 | /** 10 | * Guice injector source for Cucumber. 11 | */ 12 | public class CukeInjectorSource implements InjectorSource { 13 | @Override 14 | public Injector getInjector() { 15 | return Guice.createInjector(Lists.newArrayList(new ApplicationModule())); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/S3Helper.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.steps; 2 | 3 | 4 | import lombok.RequiredArgsConstructor; 5 | import lombok.extern.slf4j.Slf4j; 6 | import software.amazon.awssdk.services.s3.S3Client; 7 | import software.amazon.awssdk.services.s3.model.DeleteObjectRequest; 8 | import software.amazon.awssdk.services.s3.model.ListObjectsV2Request; 9 | import software.amazon.awssdk.services.s3.paginators.ListObjectsV2Iterable; 10 | 11 | @RequiredArgsConstructor 12 | @Slf4j 13 | public class S3Helper { 14 | private final S3Client s3Client; 15 | 16 | public void emptyBucket(String bucketName){ 17 | log.info("Emptying bucket {}", bucketName); 18 | 19 | ListObjectsV2Iterable listObjectsV2Responses = s3Client.listObjectsV2Paginator(ListObjectsV2Request.builder() 20 | .bucket(bucketName) 21 | .build()); 22 | 23 | listObjectsV2Responses.stream() 24 | .flatMap(r -> r.contents().stream()) 25 | .forEach(s3Object -> { 26 | log.info("deleting {}", s3Object.key()); 27 | s3Client.deleteObject(DeleteObjectRequest.builder() 28 | .bucket(bucketName) 29 | .key(s3Object.key()) 30 | .build()); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /analytics/src/test/resources/cucumber.properties: -------------------------------------------------------------------------------- 1 | guice.injector-source=software.amazon.serverless.apprepo.cucumber.guice.CukeInjectorSource 2 | -------------------------------------------------------------------------------- /analytics/src/test/resources/integ-test-env.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Description: >- 3 | This template creates the resources for integration tests. 4 | 5 | Parameters: 6 | Stage: 7 | Type: String 8 | Description: The stage where the application is running in, e.g., dev, prod. 9 | Resources: 10 | IntegTestClient: 11 | Type: AWS::Cognito::UserPoolClient 12 | Properties: 13 | UserPoolId: !Sub '{{resolve:ssm:/applications/apprepo/${Stage}/cognito/userpool/ApplicationsApi/Id:1}}' 14 | GenerateSecret: false 15 | ExplicitAuthFlows: 16 | - ADMIN_NO_SRP_AUTH 17 | 18 | AthenaQueryResultsBucket: 19 | Type: AWS::S3::Bucket 20 | 21 | IntegTestClientId: 22 | Type: "AWS::SSM::Parameter" 23 | Properties: 24 | Name: !Sub "/applications/apprepo/${Stage}/cognito/userpoolclient/IntegTest/Id" 25 | Type: "String" 26 | Value: !Ref IntegTestClient 27 | Description: "Integration test Cognito User Pool Client ID." 28 | 29 | AthenaQueryResultsBucketName: 30 | Type: "AWS::SSM::Parameter" 31 | Properties: 32 | Name: !Sub "/applications/apprepo/${Stage}/s3/AthenaQueryResultsBucketName/IntegTest/Name" 33 | Type: "String" 34 | Value: !Ref AthenaQueryResultsBucket 35 | Description: "Integration test Cognito User Pool Client ID." -------------------------------------------------------------------------------- /analytics/src/test/resources/log4j2.properties: -------------------------------------------------------------------------------- 1 | name=config 2 | appenders=console 3 | appender.console.type=Console 4 | appender.console.name=STDOUT 5 | appender.console.layout.type=PatternLayout 6 | appender.console.layout.pattern=%d{dd-MM-yyyy HH:mm:ss} [%-5p] (%F:%L) - %m%n 7 | rootLogger.level=info 8 | rootLogger.appenderRefs=stdout 9 | rootLogger.appenderRef.stdout.ref=STDOUT -------------------------------------------------------------------------------- /backend/README.md: -------------------------------------------------------------------------------- 1 | # realworld-serverless-application-backend 2 | 3 | realworld-serverless-application-backend is the backend component of a larger project providing a REST API for the application. It can be deployed together with the other system components to produce an example serverless application demonstrating real world patterns and best practices for serverless applications. 4 | 5 | To get started with the full project, follow the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide. 6 | 7 | ## License 8 | 9 | This project is licensed under the Apache-2.0 License. 10 | -------------------------------------------------------------------------------- /backend/buildspec-integ-test.yaml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | install: 5 | runtime-versions: 6 | java: openjdk8 7 | build: 8 | commands: 9 | - cd backend 10 | - STAGE=integ-tests-`date +%s` 11 | - mvn clean verify -Dintegtests.stage=${STAGE} -DpackageBucket=${PACKAGE_BUCKET} 12 | 13 | -------------------------------------------------------------------------------- /backend/buildspec.yaml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | install: 5 | runtime-versions: 6 | java: openjdk8 7 | build: 8 | commands: 9 | - cd backend 10 | - mvn clean package -DpackageBucket=${PACKAGE_BUCKET} 11 | artifacts: 12 | files: 13 | - backend/target/sam/app/packaged-template.yaml 14 | discard-paths: yes 15 | -------------------------------------------------------------------------------- /backend/images/back_end_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/backend/images/back_end_diagram.png -------------------------------------------------------------------------------- /backend/sam/app/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: 'AWS::Serverless-2016-10-31' 3 | Description: >- 4 | This application creates a backend service using serverless technologies such as API Gateway, Lambda etc. 5 | 6 | Metadata: 7 | AWS::ServerlessRepo::Application: 8 | Name: realworld-serverless-application-backend 9 | Description: >- 10 | This application creates a backend service using serverless technologies such as API Gateway, Lambda etc. 11 | Author: AWS Serverless Application Repository 12 | SpdxLicenseId: Apache-2.0 13 | Labels: [github, serverless, sam] 14 | HomePageUrl: https://github.com/awslabs/realworld-serverless-application 15 | SemanticVersion: 1.0.1 16 | SourceCodeUrl: https://github.com/awslabs/realworld-serverless-application/tree/1.0.1 17 | LicenseUrl: ../../../LICENSE 18 | ReadmeUrl: ../../README.md 19 | 20 | Parameters: 21 | Stage: 22 | Type: String 23 | Description: The stage where the application is running in, e.g., dev, prod. 24 | Default: 'test' 25 | 26 | Resources: 27 | Api: 28 | Type: 'AWS::Serverless::Application' 29 | Properties: 30 | Location: 'api.template.yaml' 31 | Parameters: 32 | Stage: !Ref Stage 33 | DependsOn: Database 34 | Database: 35 | Type: 'AWS::Serverless::Application' 36 | Properties: 37 | Location: 'database.template.yaml' 38 | Parameters: 39 | Stage: !Ref Stage 40 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/exception/ApiException.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.exception; 2 | 3 | import javax.ws.rs.WebApplicationException; 4 | import javax.ws.rs.core.MediaType; 5 | import javax.ws.rs.core.Response; 6 | 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | /** 10 | * API exception that can be converted to JAX-RS {@link Response}. 11 | */ 12 | @Slf4j 13 | public class ApiException extends WebApplicationException { 14 | /** 15 | * Construct an ApiException with body object and status code. 16 | * 17 | * @param exception the exception object that will be deserialized to JSON string 18 | * as the response body. 19 | * @param statusCode response status code. 20 | */ 21 | public ApiException(final Object exception, final Response.Status statusCode) { 22 | super(Response.status(statusCode) 23 | .entity(exception) 24 | .type(MediaType.APPLICATION_JSON) 25 | .build()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/exception/ApiExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.exception; 2 | 3 | import javax.ws.rs.core.Response; 4 | import javax.ws.rs.ext.ExceptionMapper; 5 | import javax.ws.rs.ext.Provider; 6 | 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | /** 10 | * Exception mapper that maps throwables that are not {@link ApiException} 11 | * to {@link InternalServerApiException}. 12 | */ 13 | @Provider 14 | @Slf4j 15 | public class ApiExceptionMapper implements ExceptionMapper { 16 | @Override 17 | public Response toResponse(final Throwable throwable) { 18 | if (throwable instanceof ApiException) { 19 | log.info("4xx exception is thrown", throwable); 20 | ApiException apiException = (ApiException) throwable; 21 | return apiException.getResponse(); 22 | } else { 23 | log.error("5xx exception is thrown", throwable); 24 | return new InternalServerApiException().getResponse(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/exception/BadRequestApiException.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.exception; 2 | 3 | import io.swagger.model.BadRequestException; 4 | 5 | import javax.ws.rs.core.Response; 6 | 7 | /** 8 | * Bad Request Api exception. 9 | */ 10 | public class BadRequestApiException extends ApiException { 11 | public BadRequestApiException(final BadRequestException exception) { 12 | super(exception, Response.Status.BAD_REQUEST); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/exception/ConflictApiException.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.exception; 2 | 3 | import io.swagger.model.ConflictException; 4 | 5 | import javax.ws.rs.core.Response; 6 | 7 | /** 8 | * Conflict Api exception. 9 | */ 10 | public class ConflictApiException extends ApiException { 11 | public ConflictApiException(final ConflictException exception) { 12 | super(exception, Response.Status.CONFLICT); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/exception/InternalServerApiException.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.exception; 2 | 3 | import io.swagger.model.InternalServerErrorException; 4 | 5 | import javax.ws.rs.core.Response; 6 | 7 | /** 8 | * Internal Server Api Exception. 9 | */ 10 | public class InternalServerApiException extends ApiException { 11 | /** 12 | * Construct an InternalServerApiException that converts 13 | * to 500 Interal Server Error response. 14 | */ 15 | public InternalServerApiException() { 16 | super(new InternalServerErrorException() 17 | .errorCode("InternalError") 18 | .message("Internal Server Error."), 19 | Response.Status.INTERNAL_SERVER_ERROR); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/exception/NotFoundApiException.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.exception; 2 | 3 | import io.swagger.model.NotFoundException; 4 | 5 | import javax.ws.rs.core.Response; 6 | 7 | /** 8 | * Not Found Api exception. 9 | */ 10 | public class NotFoundApiException extends ApiException { 11 | public NotFoundApiException(final NotFoundException exception) { 12 | super(exception, Response.Status.NOT_FOUND); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/InvalidTokenException.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.impl.pagination; 2 | 3 | /** 4 | * Exception for invalid token. 5 | */ 6 | public class InvalidTokenException extends Exception { 7 | public InvalidTokenException(final String message) { 8 | super(message); 9 | } 10 | 11 | public InvalidTokenException(final String message, final Exception exception) { 12 | super(message, exception); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/TimeBasedTokenSerializer.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.impl.pagination; 2 | 3 | import java.time.Duration; 4 | import java.time.Instant; 5 | import java.time.format.DateTimeParseException; 6 | 7 | import lombok.RequiredArgsConstructor; 8 | import org.apache.commons.lang3.StringUtils; 9 | 10 | /** 11 | * Implementation of {@link TokenSerializer} that adds time information 12 | * to ensure the token will expire. 13 | */ 14 | @RequiredArgsConstructor 15 | public class TimeBasedTokenSerializer implements TokenSerializer { 16 | static final String TIMESTAMP_DEMILITER = "&"; 17 | 18 | private final Duration ttl; 19 | 20 | @Override 21 | public String deserialize(final String token) throws InvalidTokenException { 22 | validateTimestamp(token); 23 | String decodedToken = StringUtils.substringBeforeLast(token, TIMESTAMP_DEMILITER); 24 | if (StringUtils.isBlank(decodedToken)) { 25 | throw new InvalidTokenException("The token is blank."); 26 | } 27 | return decodedToken; 28 | } 29 | 30 | @Override 31 | public String serialize(final String token) { 32 | StringBuilder tokenBuilder = new StringBuilder(token); 33 | tokenBuilder.append(TIMESTAMP_DEMILITER); 34 | tokenBuilder.append(Instant.now().toString()); 35 | return tokenBuilder.toString(); 36 | } 37 | 38 | private void validateTimestamp(final String tokenString) throws InvalidTokenException { 39 | String timestampString = StringUtils.substringAfterLast(tokenString, TIMESTAMP_DEMILITER); 40 | Instant timestamp; 41 | try { 42 | timestamp = Instant.parse(timestampString); 43 | } catch (DateTimeParseException e) { 44 | throw new InvalidTokenException( 45 | String.format("Invalid timestamp string %s in token.", timestampString), e); 46 | } 47 | 48 | if (timestamp.plus(ttl).isBefore(Instant.now())) { 49 | throw new InvalidTokenException( 50 | String.format("Token %s has expired after timeout limit %s.", timestamp, ttl)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/TokenSerializer.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.impl.pagination; 2 | 3 | /** 4 | * Serialize/deserialize a token to/from a String. 5 | * 6 | * @param type of the token 7 | */ 8 | public interface TokenSerializer { 9 | /** 10 | * Deserialize the token into type T. 11 | * 12 | * @param tokenString token in String. 13 | * @return deserialized token. 14 | * @throws InvalidTokenException throws when the token in String is invalid. 15 | */ 16 | T deserialize(String tokenString) throws InvalidTokenException; 17 | 18 | /** 19 | * Serialize the token into a String. 20 | * 21 | * @param token the token to be serialized. 22 | * @return serialized token in String. 23 | */ 24 | String serialize(T token); 25 | } 26 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/jackson/SdkBytesDeserializer.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.impl.pagination.jackson; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import com.fasterxml.jackson.databind.DeserializationContext; 6 | import com.fasterxml.jackson.databind.JsonDeserializer; 7 | 8 | import java.io.IOException; 9 | import java.nio.charset.Charset; 10 | 11 | import lombok.RequiredArgsConstructor; 12 | import software.amazon.awssdk.core.SdkBytes; 13 | 14 | /** 15 | * Jackson Json Deserializer for {@link SdkBytes}. 16 | */ 17 | @RequiredArgsConstructor 18 | public class SdkBytesDeserializer extends JsonDeserializer { 19 | private final Charset charset; 20 | 21 | /** 22 | * Construct SdkBytesDeserializer using default charset. 23 | */ 24 | public SdkBytesDeserializer() { 25 | this(Charset.defaultCharset()); 26 | } 27 | 28 | @Override 29 | public SdkBytes deserialize(JsonParser jsonParser, 30 | DeserializationContext deserializationContext) 31 | throws IOException, JsonProcessingException { 32 | return SdkBytes.fromString(jsonParser.getValueAsString(), charset); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/jackson/SdkBytesSerializer.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.impl.pagination.jackson; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | import java.nio.charset.Charset; 9 | 10 | import lombok.RequiredArgsConstructor; 11 | import software.amazon.awssdk.core.SdkBytes; 12 | 13 | /** 14 | * Jackson Json Serializer for {@link SdkBytes}. 15 | */ 16 | @RequiredArgsConstructor 17 | public class SdkBytesSerializer extends JsonSerializer { 18 | private final Charset charset; 19 | 20 | /** 21 | * Construct SdkBytesSerializer using default charset. 22 | */ 23 | public SdkBytesSerializer() { 24 | this(Charset.defaultCharset()); 25 | } 26 | 27 | @Override 28 | public void serialize(SdkBytes sdkBytes, JsonGenerator jsonGenerator, 29 | SerializerProvider serializerProvider) throws IOException { 30 | jsonGenerator.writeString(sdkBytes.asString(charset)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/container/CorsHeadersResponseFilter.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.container; 2 | 3 | import javax.ws.rs.container.ContainerRequestContext; 4 | import javax.ws.rs.container.ContainerResponseContext; 5 | import javax.ws.rs.container.ContainerResponseFilter; 6 | import javax.ws.rs.ext.Provider; 7 | 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | /** 11 | * Request filter to support CORS. 12 | */ 13 | @Provider 14 | @Slf4j 15 | public class CorsHeadersResponseFilter implements ContainerResponseFilter { 16 | @Override 17 | public void filter(ContainerRequestContext requestContext, 18 | ContainerResponseContext responseContext) { 19 | String origin = "*"; 20 | log.info("Set CORS header to allow request from {}", origin); 21 | responseContext.getHeaders().add("Access-Control-Allow-Origin", origin); 22 | } 23 | } -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/container/config/ConfigProvider.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.container.config; 2 | 3 | import java.time.Duration; 4 | 5 | /** 6 | * Provides configuration value based on name. 7 | */ 8 | public interface ConfigProvider { 9 | /** 10 | * Get Applications DynamoDB Table name. 11 | * 12 | * @return String 13 | */ 14 | String getApplicationsTableName(); 15 | 16 | /** 17 | * Get KMS key id. 18 | * 19 | * @return key id String. 20 | */ 21 | String getKmsKeyId(); 22 | 23 | /** 24 | * Get pagination token ttl. 25 | * 26 | * @return ttl duration. 27 | */ 28 | Duration getPaginationTokenTtl(); 29 | } 30 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/container/config/Env.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.container.config; 2 | 3 | /** 4 | * System environment variable helper class. 5 | */ 6 | public final class Env { 7 | private static String getEnv(final String key) { 8 | return System.getenv(key); 9 | } 10 | 11 | private static String getStage() { 12 | return getEnv("STAGE"); 13 | } 14 | 15 | public static String getSsmConfigKeyPrefix() { 16 | return String.format("/applications/apprepo/%s/", getStage()); 17 | } 18 | 19 | public static String getRegion() { 20 | return getEnv("AWS_REGION"); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/container/config/SsmConfigProvider.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.container.config; 2 | 3 | import java.time.Duration; 4 | 5 | import lombok.RequiredArgsConstructor; 6 | import software.amazon.awssdk.services.ssm.model.ParameterNotFoundException; 7 | import software.amazon.serverless.ssmcachingclient.SsmParameterCachingClient; 8 | 9 | /** 10 | * Provide config value from AWS SSM. 11 | */ 12 | @RequiredArgsConstructor 13 | public class SsmConfigProvider implements ConfigProvider { 14 | private static final Duration DEFAULT_PAGINATION_TOKEN_TTL = Duration.ofHours(1); 15 | private static final String APPLICATIONS_TABLE_NAME_CONFIG_KEY = "ddb/Applications/TableName"; 16 | private static final String KMS_KEY_ID_CONFIG_KEY = "kms/pagination/KeyId"; 17 | private static final String PAGINATION_TOKEN_TTL_IN_SECONDS_CONFIG_KEY = 18 | "configuration/pagination/TtlInSeconds"; 19 | 20 | private final SsmParameterCachingClient ssm; 21 | 22 | @Override 23 | public String getApplicationsTableName() { 24 | return ssm.getAsString(APPLICATIONS_TABLE_NAME_CONFIG_KEY); 25 | } 26 | 27 | @Override 28 | public String getKmsKeyId() { 29 | return ssm.getAsString(KMS_KEY_ID_CONFIG_KEY); 30 | } 31 | 32 | @Override 33 | public Duration getPaginationTokenTtl() { 34 | try { 35 | String ttlString = ssm.getAsString(PAGINATION_TOKEN_TTL_IN_SECONDS_CONFIG_KEY); 36 | return Duration.ofSeconds(Long.parseLong(ttlString)); 37 | } catch (ParameterNotFoundException e) { 38 | return DEFAULT_PAGINATION_TOKEN_TTL; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/container/factory/DynamoDbClientFactory.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.container.factory; 2 | 3 | import java.time.Duration; 4 | 5 | import org.glassfish.hk2.api.Factory; 6 | 7 | import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider; 8 | import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; 9 | import software.amazon.awssdk.core.retry.RetryPolicy; 10 | import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; 11 | import software.amazon.awssdk.regions.Region; 12 | import software.amazon.awssdk.services.dynamodb.DynamoDbClient; 13 | 14 | import software.amazon.serverless.apprepo.container.config.Env; 15 | 16 | /** 17 | * Factory for {@link DynamoDbClient} for HK2 DI wiring. 18 | */ 19 | public class DynamoDbClientFactory implements Factory { 20 | // Creating the DynamoDB client followed AWS SDK v2 best practice to improve Lambda performance: 21 | // https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/client-configuration-starttime.html 22 | private static final DynamoDbClient dynamoDbClient = DynamoDbClient.builder() 23 | .region(Region.of(Env.getRegion())) 24 | .credentialsProvider(EnvironmentVariableCredentialsProvider.create()) 25 | .overrideConfiguration(ClientOverrideConfiguration.builder() 26 | .apiCallAttemptTimeout(Duration.ofSeconds(1)) 27 | .retryPolicy(RetryPolicy.builder().numRetries(10).build()) 28 | .build()) 29 | .httpClientBuilder(UrlConnectionHttpClient.builder()).build(); 30 | 31 | @Override 32 | public DynamoDbClient provide() { 33 | return dynamoDbClient; 34 | } 35 | 36 | @Override 37 | public void dispose(DynamoDbClient dynamoDbClient) { 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/container/factory/KmsClientFactory.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.container.factory; 2 | 3 | import org.glassfish.hk2.api.Factory; 4 | 5 | import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider; 6 | import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; 7 | import software.amazon.awssdk.regions.Region; 8 | import software.amazon.awssdk.services.kms.KmsClient; 9 | 10 | import software.amazon.serverless.apprepo.container.config.Env; 11 | 12 | /** 13 | * Factory for {@link KmsClient} for HK2 DI wiring. 14 | */ 15 | public class KmsClientFactory implements Factory { 16 | // Creating the DynamoDB client followed AWS SDK v2 best practice to improve Lambda performance: 17 | // https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/client-configuration-starttime.html 18 | private static final KmsClient kmsClient = KmsClient.builder() 19 | .region(Region.of(Env.getRegion())) 20 | .credentialsProvider(EnvironmentVariableCredentialsProvider.create()) 21 | .httpClientBuilder(UrlConnectionHttpClient.builder()).build(); 22 | 23 | @Override 24 | public KmsClient provide() { 25 | return kmsClient; 26 | } 27 | 28 | @Override 29 | public void dispose(KmsClient kmsClient) { 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /backend/src/main/java/software/amazon/serverless/apprepo/container/factory/SsmConfigProviderFactory.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.container.factory; 2 | 3 | import java.time.Duration; 4 | 5 | import org.glassfish.hk2.api.Factory; 6 | 7 | import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider; 8 | import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; 9 | import software.amazon.awssdk.regions.Region; 10 | import software.amazon.awssdk.services.ssm.SsmClient; 11 | 12 | import software.amazon.serverless.apprepo.container.config.ConfigProvider; 13 | import software.amazon.serverless.apprepo.container.config.Env; 14 | import software.amazon.serverless.apprepo.container.config.SsmConfigProvider; 15 | import software.amazon.serverless.ssmcachingclient.SsmParameterCachingClient; 16 | 17 | /** 18 | * Factory for {@link SsmConfigProvider} for HK2 DI wiring. 19 | */ 20 | public class SsmConfigProviderFactory implements Factory { 21 | private static final ConfigProvider configProvider; 22 | 23 | static { 24 | SsmClient ssm = SsmClient.builder() 25 | .region(Region.of(Env.getRegion())) 26 | .credentialsProvider(EnvironmentVariableCredentialsProvider.create()) 27 | .httpClientBuilder(UrlConnectionHttpClient.builder()) 28 | .build(); 29 | configProvider = new SsmConfigProvider(new SsmParameterCachingClient(ssm, 30 | Duration.ofMinutes(5), Env.getSsmConfigKeyPrefix())); 31 | } 32 | 33 | @Override 34 | public ConfigProvider provide() { 35 | return configProvider; 36 | } 37 | 38 | @Override 39 | public void dispose(ConfigProvider configProvider) { 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /backend/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log=. 2 | log4j.rootLogger=INFO, LAMBDA 3 | #Define the LAMBDA appender 4 | log4j.appender.LAMBDA=com.amazonaws.services.lambda.runtime.log4j.LambdaAppender 5 | log4j.appender.LAMBDA.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.LAMBDA.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} <%X{AWSRequestId}> [%t] %-5p %c{1}:%L - %m%n 7 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/AbstractAWSServerlessApplicationRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client; 5 | 6 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationRequest; 7 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationResult; 8 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest; 9 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationResult; 10 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest; 11 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationResult; 12 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsRequest; 13 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsResult; 14 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationRequest; 15 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationResult; 16 | 17 | import javax.annotation.Generated; 18 | 19 | /** 20 | * Abstract implementation of {@code AWSServerlessApplicationRepository}. 21 | */ 22 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 23 | public class AbstractAWSServerlessApplicationRepository implements AWSServerlessApplicationRepository { 24 | 25 | protected AbstractAWSServerlessApplicationRepository() { 26 | } 27 | 28 | @Override 29 | public CreateApplicationResult createApplication(CreateApplicationRequest request) { 30 | throw new java.lang.UnsupportedOperationException(); 31 | } 32 | 33 | @Override 34 | public DeleteApplicationResult deleteApplication(DeleteApplicationRequest request) { 35 | throw new java.lang.UnsupportedOperationException(); 36 | } 37 | 38 | @Override 39 | public GetApplicationResult getApplication(GetApplicationRequest request) { 40 | throw new java.lang.UnsupportedOperationException(); 41 | } 42 | 43 | @Override 44 | public ListApplicationsResult listApplications(ListApplicationsRequest request) { 45 | throw new java.lang.UnsupportedOperationException(); 46 | } 47 | 48 | @Override 49 | public UpdateApplicationResult updateApplication(UpdateApplicationRequest request) { 50 | throw new java.lang.UnsupportedOperationException(); 51 | } 52 | 53 | @Override 54 | public void shutdown() { 55 | throw new java.lang.UnsupportedOperationException(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/auth/CognitoAuthorizer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.auth; 5 | 6 | import com.amazonaws.ImmutableRequest; 7 | import com.amazonaws.SignableRequest; 8 | import com.amazonaws.auth.RequestSigner; 9 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository; 10 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepositoryClientBuilder; 11 | 12 | import javax.annotation.Generated; 13 | 14 | /** 15 | * A default implementation of {@link RequestSigner} that puts a generated token into the header. An implementation of 16 | * this can to be supplied during construction of a {@link AWSServerlessApplicationRepository} via 17 | * {@link AWSServerlessApplicationRepositoryClientBuilder#signer(CognitoAuthorizer)} like so 18 | * 19 | *
20 |  * 
21 |  *  AWSServerlessApplicationRepository client = AWSServerlessApplicationRepository.builder().signer((CognitoAuthorizer) request -> "some token").build();
22 |  * 
23 |  * 
24 | */ 25 | @FunctionalInterface 26 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 27 | public interface CognitoAuthorizer extends RequestSigner { 28 | 29 | /** 30 | * Generate a token that will be added to Authorization in the header of the request during signing 31 | * 32 | * @param request 33 | * an immutable view of the request for which to generate a token 34 | * @return the token to use for signing 35 | */ 36 | String generateToken(ImmutableRequest request); 37 | 38 | /** 39 | * @see RequestSigner#sign(SignableRequest) 40 | */ 41 | @Override 42 | default void sign(SignableRequest request) { 43 | request.addHeader("Authorization", generateToken(request)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/AWSServerlessApplicationRepositoryException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import com.amazonaws.annotation.SdkInternalApi; 7 | import com.amazonaws.opensdk.SdkErrorHttpMetadata; 8 | import com.amazonaws.opensdk.internal.BaseException; 9 | 10 | import javax.annotation.Generated; 11 | 12 | /** 13 | * Base exception for all service exceptions thrown by backend service 14 | */ 15 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 16 | public class AWSServerlessApplicationRepositoryException extends com.amazonaws.SdkBaseException implements BaseException { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | private SdkErrorHttpMetadata sdkHttpMetadata; 21 | 22 | private String message; 23 | 24 | /** 25 | * Constructs a new AWSServerlessApplicationRepositoryException with the specified error message. 26 | * 27 | * @param message 28 | * Describes the error encountered. 29 | */ 30 | public AWSServerlessApplicationRepositoryException(String message) { 31 | super(message); 32 | this.message = message; 33 | } 34 | 35 | @Override 36 | public AWSServerlessApplicationRepositoryException sdkHttpMetadata(SdkErrorHttpMetadata sdkHttpMetadata) { 37 | this.sdkHttpMetadata = sdkHttpMetadata; 38 | return this; 39 | } 40 | 41 | @Override 42 | public SdkErrorHttpMetadata sdkHttpMetadata() { 43 | return sdkHttpMetadata; 44 | } 45 | 46 | @SdkInternalApi 47 | @Override 48 | public void setMessage(String message) { 49 | this.message = message; 50 | } 51 | 52 | @Override 53 | public String getMessage() { 54 | return message; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/BadRequestException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class BadRequestException extends AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new BadRequestException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public BadRequestException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public BadRequestException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/ConflictException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class ConflictException extends AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new ConflictException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public ConflictException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public ConflictException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/DeleteApplicationResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import java.io.Serializable; 7 | import javax.annotation.Generated; 8 | 9 | /** 10 | * 11 | * @see AWS 12 | * API Documentation 13 | */ 14 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 15 | public class DeleteApplicationResult extends com.amazonaws.opensdk.BaseResult implements Serializable, Cloneable { 16 | 17 | /** 18 | * Returns a string representation of this object; useful for testing and debugging. 19 | * 20 | * @return A string representation of this object. 21 | * 22 | * @see java.lang.Object#toString() 23 | */ 24 | @Override 25 | public String toString() { 26 | StringBuilder sb = new StringBuilder(); 27 | sb.append("{"); 28 | sb.append("}"); 29 | return sb.toString(); 30 | } 31 | 32 | @Override 33 | public boolean equals(Object obj) { 34 | if (this == obj) 35 | return true; 36 | if (obj == null) 37 | return false; 38 | 39 | if (obj instanceof DeleteApplicationResult == false) 40 | return false; 41 | DeleteApplicationResult other = (DeleteApplicationResult) obj; 42 | return true; 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | final int prime = 31; 48 | int hashCode = 1; 49 | 50 | return hashCode; 51 | } 52 | 53 | @Override 54 | public DeleteApplicationResult clone() { 55 | try { 56 | return (DeleteApplicationResult) super.clone(); 57 | } catch (CloneNotSupportedException e) { 58 | throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class InternalServerErrorException extends AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new InternalServerErrorException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public InternalServerErrorException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public InternalServerErrorException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/NotFoundException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class NotFoundException extends AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new NotFoundException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public NotFoundException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public NotFoundException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/TooManyRequestsException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class TooManyRequestsException extends AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new TooManyRequestsException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public TooManyRequestsException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public TooManyRequestsException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model; 5 | 6 | import javax.annotation.Generated; 7 | 8 | /** 9 | * 10 | */ 11 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 12 | public class UnauthorizedException extends AWSServerlessApplicationRepositoryException { 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String errorCode; 16 | 17 | /** 18 | * Constructs a new UnauthorizedException with the specified error message. 19 | * 20 | * @param message 21 | * Describes the error encountered. 22 | */ 23 | public UnauthorizedException(String message) { 24 | super(message); 25 | } 26 | 27 | /** 28 | * @param errorCode 29 | */ 30 | 31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 32 | public void setErrorCode(String errorCode) { 33 | this.errorCode = errorCode; 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | 40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode") 41 | public String getErrorCode() { 42 | return this.errorCode; 43 | } 44 | 45 | /** 46 | * @param errorCode 47 | * @return Returns a reference to this object so that method calls can be chained together. 48 | */ 49 | 50 | public UnauthorizedException errorCode(String errorCode) { 51 | setErrorCode(errorCode); 52 | return this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationListMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import software.amazon.serverless.apprepo.api.client.model.ApplicationList; 13 | 14 | import java.util.List; 15 | import javax.annotation.Generated; 16 | 17 | /** 18 | * ApplicationListMarshaller 19 | */ 20 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 21 | @SdkInternalApi 22 | public class ApplicationListMarshaller { 23 | 24 | private static final MarshallingInfo APPLICATIONS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD) 25 | .marshallLocationName("applications").build(); 26 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD) 27 | .marshallLocationName("nextToken").build(); 28 | 29 | private static final ApplicationListMarshaller instance = new ApplicationListMarshaller(); 30 | 31 | public static ApplicationListMarshaller getInstance() { 32 | return instance; 33 | } 34 | 35 | /** 36 | * Marshall the given parameter object. 37 | */ 38 | public void marshall(ApplicationList applicationList, ProtocolMarshaller protocolMarshaller) { 39 | 40 | if (applicationList == null) { 41 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 42 | } 43 | 44 | try { 45 | protocolMarshaller.marshall(applicationList.getApplications(), APPLICATIONS_BINDING); 46 | protocolMarshaller.marshall(applicationList.getNextToken(), NEXTTOKEN_BINDING); 47 | } catch (Exception e) { 48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationSummaryMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import software.amazon.serverless.apprepo.api.client.model.ApplicationSummary; 13 | 14 | import javax.annotation.Generated; 15 | 16 | /** 17 | * ApplicationSummaryMarshaller 18 | */ 19 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 20 | @SdkInternalApi 21 | public class ApplicationSummaryMarshaller { 22 | 23 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 24 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("applicationId").build(); 25 | private static final MarshallingInfo CREATIONTIME_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("creationTime").build(); 27 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 28 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build(); 29 | 30 | private static final ApplicationSummaryMarshaller instance = new ApplicationSummaryMarshaller(); 31 | 32 | public static ApplicationSummaryMarshaller getInstance() { 33 | return instance; 34 | } 35 | 36 | /** 37 | * Marshall the given parameter object. 38 | */ 39 | public void marshall(ApplicationSummary applicationSummary, ProtocolMarshaller protocolMarshaller) { 40 | 41 | if (applicationSummary == null) { 42 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 43 | } 44 | 45 | try { 46 | protocolMarshaller.marshall(applicationSummary.getApplicationId(), APPLICATIONID_BINDING); 47 | protocolMarshaller.marshall(applicationSummary.getCreationTime(), CREATIONTIME_BINDING); 48 | protocolMarshaller.marshall(applicationSummary.getDescription(), DESCRIPTION_BINDING); 49 | } catch (Exception e) { 50 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import com.amazonaws.protocol.StructuredPojo; 13 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationRequest; 14 | 15 | import javax.annotation.Generated; 16 | 17 | /** 18 | * CreateApplicationRequestMarshaller 19 | */ 20 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 21 | @SdkInternalApi 22 | public class CreateApplicationRequestMarshaller { 23 | 24 | private static final MarshallingInfo CREATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED) 25 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build(); 26 | 27 | private static final CreateApplicationRequestMarshaller instance = new CreateApplicationRequestMarshaller(); 28 | 29 | public static CreateApplicationRequestMarshaller getInstance() { 30 | return instance; 31 | } 32 | 33 | /** 34 | * Marshall the given parameter object. 35 | */ 36 | public void marshall(CreateApplicationRequest createApplicationRequest, ProtocolMarshaller protocolMarshaller) { 37 | 38 | if (createApplicationRequest == null) { 39 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 40 | } 41 | 42 | try { 43 | protocolMarshaller.marshall(createApplicationRequest.getCreateApplicationInput(), CREATEAPPLICATIONINPUT_BINDING); 44 | } catch (Exception e) { 45 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.Request; 7 | import com.amazonaws.SdkClientException; 8 | import com.amazonaws.annotation.SdkInternalApi; 9 | import com.amazonaws.http.HttpMethodName; 10 | import com.amazonaws.protocol.OperationInfo; 11 | import com.amazonaws.protocol.Protocol; 12 | import com.amazonaws.protocol.ProtocolRequestMarshaller; 13 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationRequest; 14 | import com.amazonaws.transform.Marshaller; 15 | 16 | import javax.annotation.Generated; 17 | 18 | /** 19 | * CreateApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class CreateApplicationRequestProtocolMarshaller implements Marshaller, CreateApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications") 26 | .httpMethodName(HttpMethodName.POST).hasExplicitPayloadMember(true).hasPayloadMembers(true).serviceName("AWSServerlessApplicationRepository") 27 | .build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public CreateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(CreateApplicationRequest createApplicationRequest) { 36 | 37 | if (createApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | createApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | CreateApplicationRequestMarshaller.getInstance().marshall(createApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL; 7 | 8 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationResult; 9 | import com.amazonaws.transform.JsonUnmarshallerContext; 10 | import com.amazonaws.transform.Unmarshaller; 11 | import com.fasterxml.jackson.core.JsonToken; 12 | 13 | import javax.annotation.Generated; 14 | 15 | /** 16 | * CreateApplicationResult JSON Unmarshaller 17 | */ 18 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 19 | public class CreateApplicationResultJsonUnmarshaller implements Unmarshaller { 20 | 21 | public CreateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 22 | CreateApplicationResult createApplicationResult = new CreateApplicationResult(); 23 | 24 | int originalDepth = context.getCurrentDepth(); 25 | String currentParentElement = context.getCurrentParentElement(); 26 | int targetDepth = originalDepth + 1; 27 | 28 | JsonToken token = context.getCurrentToken(); 29 | if (token == null) 30 | token = context.nextToken(); 31 | if (token == VALUE_NULL) { 32 | return createApplicationResult; 33 | } 34 | 35 | while (true) { 36 | if (token == null) 37 | break; 38 | 39 | createApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context)); 40 | token = context.nextToken(); 41 | } 42 | 43 | return createApplicationResult; 44 | } 45 | 46 | private static CreateApplicationResultJsonUnmarshaller instance; 47 | 48 | public static CreateApplicationResultJsonUnmarshaller getInstance() { 49 | if (instance == null) 50 | instance = new CreateApplicationResultJsonUnmarshaller(); 51 | return instance; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest; 13 | 14 | import javax.annotation.Generated; 15 | 16 | /** 17 | * DeleteApplicationRequestMarshaller 18 | */ 19 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 20 | @SdkInternalApi 21 | public class DeleteApplicationRequestMarshaller { 22 | 23 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 24 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build(); 25 | 26 | private static final DeleteApplicationRequestMarshaller instance = new DeleteApplicationRequestMarshaller(); 27 | 28 | public static DeleteApplicationRequestMarshaller getInstance() { 29 | return instance; 30 | } 31 | 32 | /** 33 | * Marshall the given parameter object. 34 | */ 35 | public void marshall(DeleteApplicationRequest deleteApplicationRequest, ProtocolMarshaller protocolMarshaller) { 36 | 37 | if (deleteApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | protocolMarshaller.marshall(deleteApplicationRequest.getApplicationId(), APPLICATIONID_BINDING); 43 | } catch (Exception e) { 44 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.Request; 7 | import com.amazonaws.SdkClientException; 8 | import com.amazonaws.annotation.SdkInternalApi; 9 | import com.amazonaws.http.HttpMethodName; 10 | import com.amazonaws.protocol.OperationInfo; 11 | import com.amazonaws.protocol.Protocol; 12 | import com.amazonaws.protocol.ProtocolRequestMarshaller; 13 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest; 14 | import com.amazonaws.transform.Marshaller; 15 | 16 | import javax.annotation.Generated; 17 | 18 | /** 19 | * DeleteApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class DeleteApplicationRequestProtocolMarshaller implements Marshaller, DeleteApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY) 26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.DELETE).hasExplicitPayloadMember(false).hasPayloadMembers(false) 27 | .serviceName("AWSServerlessApplicationRepository").build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public DeleteApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(DeleteApplicationRequest deleteApplicationRequest) { 36 | 37 | if (deleteApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | deleteApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | DeleteApplicationRequestMarshaller.getInstance().marshall(deleteApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationResult; 7 | import com.amazonaws.transform.JsonUnmarshallerContext; 8 | import com.amazonaws.transform.Unmarshaller; 9 | 10 | import javax.annotation.Generated; 11 | 12 | /** 13 | * DeleteApplicationResult JSON Unmarshaller 14 | */ 15 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 16 | public class DeleteApplicationResultJsonUnmarshaller implements Unmarshaller { 17 | 18 | public DeleteApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 19 | DeleteApplicationResult deleteApplicationResult = new DeleteApplicationResult(); 20 | 21 | return deleteApplicationResult; 22 | } 23 | 24 | private static DeleteApplicationResultJsonUnmarshaller instance; 25 | 26 | public static DeleteApplicationResultJsonUnmarshaller getInstance() { 27 | if (instance == null) 28 | instance = new DeleteApplicationResultJsonUnmarshaller(); 29 | return instance; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest; 13 | 14 | import javax.annotation.Generated; 15 | 16 | /** 17 | * GetApplicationRequestMarshaller 18 | */ 19 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 20 | @SdkInternalApi 21 | public class GetApplicationRequestMarshaller { 22 | 23 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 24 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build(); 25 | 26 | private static final GetApplicationRequestMarshaller instance = new GetApplicationRequestMarshaller(); 27 | 28 | public static GetApplicationRequestMarshaller getInstance() { 29 | return instance; 30 | } 31 | 32 | /** 33 | * Marshall the given parameter object. 34 | */ 35 | public void marshall(GetApplicationRequest getApplicationRequest, ProtocolMarshaller protocolMarshaller) { 36 | 37 | if (getApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | protocolMarshaller.marshall(getApplicationRequest.getApplicationId(), APPLICATIONID_BINDING); 43 | } catch (Exception e) { 44 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.Request; 7 | import com.amazonaws.SdkClientException; 8 | import com.amazonaws.annotation.SdkInternalApi; 9 | import com.amazonaws.http.HttpMethodName; 10 | import com.amazonaws.protocol.OperationInfo; 11 | import com.amazonaws.protocol.Protocol; 12 | import com.amazonaws.protocol.ProtocolRequestMarshaller; 13 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest; 14 | import com.amazonaws.transform.Marshaller; 15 | 16 | import javax.annotation.Generated; 17 | 18 | /** 19 | * GetApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class GetApplicationRequestProtocolMarshaller implements Marshaller, GetApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY) 26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false) 27 | .serviceName("AWSServerlessApplicationRepository").build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public GetApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(GetApplicationRequest getApplicationRequest) { 36 | 37 | if (getApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | getApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | GetApplicationRequestMarshaller.getInstance().marshall(getApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL; 7 | 8 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationResult; 9 | import com.amazonaws.transform.JsonUnmarshallerContext; 10 | import com.amazonaws.transform.Unmarshaller; 11 | import com.fasterxml.jackson.core.JsonToken; 12 | 13 | import javax.annotation.Generated; 14 | 15 | /** 16 | * GetApplicationResult JSON Unmarshaller 17 | */ 18 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 19 | public class GetApplicationResultJsonUnmarshaller implements Unmarshaller { 20 | 21 | public GetApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 22 | GetApplicationResult getApplicationResult = new GetApplicationResult(); 23 | 24 | int originalDepth = context.getCurrentDepth(); 25 | String currentParentElement = context.getCurrentParentElement(); 26 | int targetDepth = originalDepth + 1; 27 | 28 | JsonToken token = context.getCurrentToken(); 29 | if (token == null) 30 | token = context.nextToken(); 31 | if (token == VALUE_NULL) { 32 | return getApplicationResult; 33 | } 34 | 35 | while (true) { 36 | if (token == null) 37 | break; 38 | 39 | getApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context)); 40 | token = context.nextToken(); 41 | } 42 | 43 | return getApplicationResult; 44 | } 45 | 46 | private static GetApplicationResultJsonUnmarshaller instance; 47 | 48 | public static GetApplicationResultJsonUnmarshaller getInstance() { 49 | if (instance == null) 50 | instance = new GetApplicationResultJsonUnmarshaller(); 51 | return instance; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsRequest; 13 | 14 | import javax.annotation.Generated; 15 | 16 | /** 17 | * ListApplicationsRequestMarshaller 18 | */ 19 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 20 | @SdkInternalApi 21 | public class ListApplicationsRequestMarshaller { 22 | 23 | private static final MarshallingInfo MAXITEMS_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 24 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("maxItems").build(); 25 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 26 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("nextToken").build(); 27 | 28 | private static final ListApplicationsRequestMarshaller instance = new ListApplicationsRequestMarshaller(); 29 | 30 | public static ListApplicationsRequestMarshaller getInstance() { 31 | return instance; 32 | } 33 | 34 | /** 35 | * Marshall the given parameter object. 36 | */ 37 | public void marshall(ListApplicationsRequest listApplicationsRequest, ProtocolMarshaller protocolMarshaller) { 38 | 39 | if (listApplicationsRequest == null) { 40 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 41 | } 42 | 43 | try { 44 | protocolMarshaller.marshall(listApplicationsRequest.getMaxItems(), MAXITEMS_BINDING); 45 | protocolMarshaller.marshall(listApplicationsRequest.getNextToken(), NEXTTOKEN_BINDING); 46 | } catch (Exception e) { 47 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.Request; 7 | import com.amazonaws.SdkClientException; 8 | import com.amazonaws.annotation.SdkInternalApi; 9 | import com.amazonaws.http.HttpMethodName; 10 | import com.amazonaws.protocol.OperationInfo; 11 | import com.amazonaws.protocol.Protocol; 12 | import com.amazonaws.protocol.ProtocolRequestMarshaller; 13 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsRequest; 14 | import com.amazonaws.transform.Marshaller; 15 | 16 | import javax.annotation.Generated; 17 | 18 | /** 19 | * ListApplicationsRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class ListApplicationsRequestProtocolMarshaller implements Marshaller, ListApplicationsRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications") 26 | .httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false).serviceName("AWSServerlessApplicationRepository") 27 | .build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public ListApplicationsRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(ListApplicationsRequest listApplicationsRequest) { 36 | 37 | if (listApplicationsRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | listApplicationsRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | ListApplicationsRequestMarshaller.getInstance().marshall(listApplicationsRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL; 7 | 8 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsResult; 9 | import com.amazonaws.transform.JsonUnmarshallerContext; 10 | import com.amazonaws.transform.Unmarshaller; 11 | import com.fasterxml.jackson.core.JsonToken; 12 | 13 | import javax.annotation.Generated; 14 | 15 | /** 16 | * ListApplicationsResult JSON Unmarshaller 17 | */ 18 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 19 | public class ListApplicationsResultJsonUnmarshaller implements Unmarshaller { 20 | 21 | public ListApplicationsResult unmarshall(JsonUnmarshallerContext context) throws Exception { 22 | ListApplicationsResult listApplicationsResult = new ListApplicationsResult(); 23 | 24 | int originalDepth = context.getCurrentDepth(); 25 | String currentParentElement = context.getCurrentParentElement(); 26 | int targetDepth = originalDepth + 1; 27 | 28 | JsonToken token = context.getCurrentToken(); 29 | if (token == null) 30 | token = context.nextToken(); 31 | if (token == VALUE_NULL) { 32 | return listApplicationsResult; 33 | } 34 | 35 | while (true) { 36 | if (token == null) 37 | break; 38 | 39 | listApplicationsResult.setApplicationList(ApplicationListJsonUnmarshaller.getInstance().unmarshall(context)); 40 | token = context.nextToken(); 41 | } 42 | 43 | return listApplicationsResult; 44 | } 45 | 46 | private static ListApplicationsResultJsonUnmarshaller instance; 47 | 48 | public static ListApplicationsResultJsonUnmarshaller getInstance() { 49 | if (instance == null) 50 | instance = new ListApplicationsResultJsonUnmarshaller(); 51 | return instance; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationInputMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationInput; 13 | 14 | import javax.annotation.Generated; 15 | 16 | /** 17 | * UpdateApplicationInputMarshaller 18 | */ 19 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 20 | @SdkInternalApi 21 | public class UpdateApplicationInputMarshaller { 22 | 23 | private static final MarshallingInfo AUTHOR_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD) 24 | .marshallLocationName("author").build(); 25 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build(); 27 | private static final MarshallingInfo HOMEPAGEURL_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 28 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("homePageUrl").build(); 29 | 30 | private static final UpdateApplicationInputMarshaller instance = new UpdateApplicationInputMarshaller(); 31 | 32 | public static UpdateApplicationInputMarshaller getInstance() { 33 | return instance; 34 | } 35 | 36 | /** 37 | * Marshall the given parameter object. 38 | */ 39 | public void marshall(UpdateApplicationInput updateApplicationInput, ProtocolMarshaller protocolMarshaller) { 40 | 41 | if (updateApplicationInput == null) { 42 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 43 | } 44 | 45 | try { 46 | protocolMarshaller.marshall(updateApplicationInput.getAuthor(), AUTHOR_BINDING); 47 | protocolMarshaller.marshall(updateApplicationInput.getDescription(), DESCRIPTION_BINDING); 48 | protocolMarshaller.marshall(updateApplicationInput.getHomePageUrl(), HOMEPAGEURL_BINDING); 49 | } catch (Exception e) { 50 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.SdkClientException; 7 | import com.amazonaws.annotation.SdkInternalApi; 8 | import com.amazonaws.protocol.MarshallLocation; 9 | import com.amazonaws.protocol.MarshallingInfo; 10 | import com.amazonaws.protocol.MarshallingType; 11 | import com.amazonaws.protocol.ProtocolMarshaller; 12 | import com.amazonaws.protocol.StructuredPojo; 13 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationRequest; 14 | 15 | import javax.annotation.Generated; 16 | 17 | /** 18 | * UpdateApplicationRequestMarshaller 19 | */ 20 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 21 | @SdkInternalApi 22 | public class UpdateApplicationRequestMarshaller { 23 | 24 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING) 25 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build(); 26 | private static final MarshallingInfo UPDATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED) 27 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build(); 28 | 29 | private static final UpdateApplicationRequestMarshaller instance = new UpdateApplicationRequestMarshaller(); 30 | 31 | public static UpdateApplicationRequestMarshaller getInstance() { 32 | return instance; 33 | } 34 | 35 | /** 36 | * Marshall the given parameter object. 37 | */ 38 | public void marshall(UpdateApplicationRequest updateApplicationRequest, ProtocolMarshaller protocolMarshaller) { 39 | 40 | if (updateApplicationRequest == null) { 41 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 42 | } 43 | 44 | try { 45 | protocolMarshaller.marshall(updateApplicationRequest.getApplicationId(), APPLICATIONID_BINDING); 46 | protocolMarshaller.marshall(updateApplicationRequest.getUpdateApplicationInput(), UPDATEAPPLICATIONINPUT_BINDING); 47 | } catch (Exception e) { 48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestProtocolMarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import com.amazonaws.Request; 7 | import com.amazonaws.SdkClientException; 8 | import com.amazonaws.annotation.SdkInternalApi; 9 | import com.amazonaws.http.HttpMethodName; 10 | import com.amazonaws.protocol.OperationInfo; 11 | import com.amazonaws.protocol.Protocol; 12 | import com.amazonaws.protocol.ProtocolRequestMarshaller; 13 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationRequest; 14 | import com.amazonaws.transform.Marshaller; 15 | 16 | import javax.annotation.Generated; 17 | 18 | /** 19 | * UpdateApplicationRequest Marshaller 20 | */ 21 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 22 | @SdkInternalApi 23 | public class UpdateApplicationRequestProtocolMarshaller implements Marshaller, UpdateApplicationRequest> { 24 | 25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY) 26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.PATCH).hasExplicitPayloadMember(true).hasPayloadMembers(true) 27 | .serviceName("AWSServerlessApplicationRepository").build(); 28 | 29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory; 30 | 31 | public UpdateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) { 32 | this.protocolFactory = protocolFactory; 33 | } 34 | 35 | public Request marshall(UpdateApplicationRequest updateApplicationRequest) { 36 | 37 | if (updateApplicationRequest == null) { 38 | throw new SdkClientException("Invalid argument passed to marshall(...)"); 39 | } 40 | 41 | try { 42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING, 43 | updateApplicationRequest); 44 | 45 | protocolMarshaller.startMarshalling(); 46 | UpdateApplicationRequestMarshaller.getInstance().marshall(updateApplicationRequest, protocolMarshaller); 47 | return protocolMarshaller.finishMarshalling(); 48 | } catch (Exception e) { 49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationResultJsonUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package software.amazon.serverless.apprepo.api.client.model.transform; 5 | 6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL; 7 | 8 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationResult; 9 | import com.amazonaws.transform.JsonUnmarshallerContext; 10 | import com.amazonaws.transform.Unmarshaller; 11 | import com.fasterxml.jackson.core.JsonToken; 12 | 13 | import javax.annotation.Generated; 14 | 15 | /** 16 | * UpdateApplicationResult JSON Unmarshaller 17 | */ 18 | @Generated("com.amazonaws:aws-java-sdk-code-generator") 19 | public class UpdateApplicationResultJsonUnmarshaller implements Unmarshaller { 20 | 21 | public UpdateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception { 22 | UpdateApplicationResult updateApplicationResult = new UpdateApplicationResult(); 23 | 24 | int originalDepth = context.getCurrentDepth(); 25 | String currentParentElement = context.getCurrentParentElement(); 26 | int targetDepth = originalDepth + 1; 27 | 28 | JsonToken token = context.getCurrentToken(); 29 | if (token == null) 30 | token = context.nextToken(); 31 | if (token == VALUE_NULL) { 32 | return updateApplicationResult; 33 | } 34 | 35 | while (true) { 36 | if (token == null) 37 | break; 38 | 39 | updateApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context)); 40 | token = context.nextToken(); 41 | } 42 | 43 | return updateApplicationResult; 44 | } 45 | 46 | private static UpdateApplicationResultJsonUnmarshaller instance; 47 | 48 | public static UpdateApplicationResultJsonUnmarshaller getInstance() { 49 | if (instance == null) 50 | instance = new UpdateApplicationResultJsonUnmarshaller(); 51 | return instance; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/client/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | /** 6 | * 7 | */ 8 | package software.amazon.serverless.apprepo.api.client; 9 | 10 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/exception/ApiExceptionMapperTest.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.exception; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import io.swagger.model.InternalServerErrorException; 6 | import io.swagger.model.NotFoundException; 7 | 8 | import javax.ws.rs.core.MediaType; 9 | import javax.ws.rs.core.Response; 10 | 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | 14 | public class ApiExceptionMapperTest { 15 | private ApiExceptionMapper exceptionMapper; 16 | 17 | @Before 18 | public void setup() { 19 | exceptionMapper = new ApiExceptionMapper(); 20 | } 21 | 22 | @Test 23 | public void toResponse_apiException() { 24 | NotFoundException exception = new NotFoundException(); 25 | Response response = exceptionMapper.toResponse(new NotFoundApiException(exception)); 26 | assertThat(response.getStatus()).isEqualTo(404); 27 | assertThat(response.getMediaType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); 28 | assertThat(response.getEntity()).isEqualTo(exception); 29 | } 30 | 31 | @Test 32 | public void toResponse_otherException() { 33 | InternalServerErrorException exception = new InternalServerErrorException() 34 | .errorCode("InternalError") 35 | .message("Internal Server Error."); 36 | Response response = exceptionMapper.toResponse(new IllegalArgumentException()); 37 | assertThat(response.getStatus()).isEqualTo(500); 38 | assertThat(response.getMediaType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); 39 | assertThat(response.getEntity()).isEqualTo(exception); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/impl/pagination/EncryptedTokenSerializerTest.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.impl.pagination; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 5 | import static org.mockito.ArgumentMatchers.any; 6 | import static org.mockito.Mockito.when; 7 | 8 | import java.util.UUID; 9 | 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.mockito.Mock; 13 | import org.mockito.MockitoAnnotations; 14 | import software.amazon.awssdk.core.SdkBytes; 15 | import software.amazon.awssdk.services.kms.KmsClient; 16 | import software.amazon.awssdk.services.kms.model.DecryptRequest; 17 | import software.amazon.awssdk.services.kms.model.DecryptResponse; 18 | import software.amazon.awssdk.services.kms.model.EncryptRequest; 19 | import software.amazon.awssdk.services.kms.model.EncryptResponse; 20 | 21 | public class EncryptedTokenSerializerTest { 22 | private static final String KEY_ID = UUID.randomUUID().toString(); 23 | 24 | @Mock 25 | private KmsClient kms; 26 | private TokenSerializer serializer; 27 | 28 | @Before 29 | public void setup() { 30 | MockitoAnnotations.initMocks(this); 31 | serializer = new EncryptedTokenSerializer(kms, KEY_ID); 32 | } 33 | 34 | @Test 35 | public void testSerializeAndDeserialize() throws Exception { 36 | String plainText = "cat"; 37 | String cipherText = "dog"; 38 | EncryptResponse encryptResponse = EncryptResponse.builder() 39 | .ciphertextBlob(SdkBytes.fromUtf8String(cipherText)) 40 | .build(); 41 | DecryptResponse decryptResponse = DecryptResponse.builder() 42 | .plaintext(SdkBytes.fromUtf8String(plainText)) 43 | .build(); 44 | when(kms.encrypt(any(EncryptRequest.class))).thenReturn(encryptResponse); 45 | when(kms.decrypt(any(DecryptRequest.class))).thenReturn(decryptResponse); 46 | 47 | String encodedToken = serializer.serialize(plainText); 48 | assertThat(serializer.deserialize(encodedToken)) 49 | .isEqualTo(plainText); 50 | } 51 | 52 | @Test 53 | public void deserialize_nonBase64() { 54 | assertThatThrownBy(() -> serializer.deserialize("something")) 55 | .isInstanceOf(InvalidTokenException.class); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/api/impl/pagination/TimeBasedTokenSerializerTest.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.api.impl.pagination; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 5 | 6 | import java.time.Duration; 7 | import java.time.Instant; 8 | 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | 12 | public class TimeBasedTokenSerializerTest { 13 | private final static long TOKEN_TTL_IN_SECOND = 3600; 14 | private TokenSerializer serializer; 15 | 16 | @Before 17 | public void setup() { 18 | serializer = new TimeBasedTokenSerializer(Duration.ofSeconds(TOKEN_TTL_IN_SECOND)); 19 | } 20 | 21 | @Test 22 | public void testSerializeAndDeserialize() throws Exception { 23 | String plainToken = "something"; 24 | String encodedToken = serializer.serialize(plainToken); 25 | assertThat(serializer.deserialize(encodedToken)) 26 | .isEqualTo(plainToken); 27 | } 28 | 29 | @Test 30 | public void deserialize_noTimestamp() { 31 | assertThatThrownBy(() -> serializer.deserialize("something")) 32 | .isInstanceOf(InvalidTokenException.class); 33 | } 34 | 35 | @Test 36 | public void deserialize_timestampNonBase64() { 37 | assertThatThrownBy(() -> serializer.deserialize("&something")) 38 | .isInstanceOf(InvalidTokenException.class); 39 | } 40 | 41 | @Test 42 | public void deserialize_tokenExpired() { 43 | Instant expiredInstant = Instant.now().minusSeconds(TOKEN_TTL_IN_SECOND + 1); 44 | assertThatThrownBy(() -> serializer.deserialize("something&" + expiredInstant.toString())) 45 | .isInstanceOf(InvalidTokenException.class); 46 | } 47 | 48 | @Test 49 | public void deserialize_noToken() { 50 | assertThatThrownBy(() -> serializer.deserialize("&" + Instant.now().toString())) 51 | .isInstanceOf(InvalidTokenException.class); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/ApplicationsService_IT.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber; 2 | 3 | import io.cucumber.junit.Cucumber; 4 | import io.cucumber.junit.CucumberOptions; 5 | import org.junit.runner.RunWith; 6 | 7 | /** 8 | * Junit entry point for cucumber tests. 9 | */ 10 | @RunWith(Cucumber.class) 11 | @CucumberOptions(features = "src/test/java/software/amazon/serverless/apprepo/cucumber/features", 12 | glue = "software.amazon.serverless.apprepo.cucumber.steps", 13 | tags = {"not @NotImplemented"},// Use @NotImplemented tag for scenarios that have not been implemented 14 | plugin = {"pretty"}) 15 | public class ApplicationsService_IT { 16 | } 17 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/CreateApplication.feature: -------------------------------------------------------------------------------- 1 | Feature: CreateApplication 2 | As a user, I would like to create an application. 3 | 4 | Scenario: User creates an application 5 | When a user creates an application 6 | Then a new application should be created 7 | 8 | Scenario: User creates an application with the same id 9 | Given a user has an application 10 | When the user creates an application with the same id 11 | Then the call should fail because the application already exists 12 | 13 | Scenario: User creates an application without application id 14 | When a user creates an application without application id 15 | Then the call should fail because of bad request 16 | 17 | Scenario: User creates an application without author 18 | When a user creates an application without author 19 | Then the call should fail because of bad request 20 | 21 | Scenario: User creates an application without description 22 | When a user creates an application without description 23 | Then the call should fail because of bad request 24 | 25 | Scenario: User creates an application with invalid application id 26 | When a user creates an application with invalid application id 27 | Then the call should fail because of bad request 28 | 29 | Scenario: User creates an application with invalid author 30 | When a user creates an application with invalid author 31 | Then the call should fail because of bad request 32 | 33 | Scenario: User creates an application with invalid description 34 | When a user creates an application with invalid description 35 | Then the call should fail because of bad request 36 | 37 | Scenario: User creates an application with invalid home page URL 38 | When a user creates an application with invalid home page URL 39 | Then the call should fail because of bad request -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/DeleteApplication.feature: -------------------------------------------------------------------------------- 1 | Feature: DeleteApplication 2 | As a user, I would like to delete my application. 3 | 4 | Scenario: User deletes an application 5 | Given a user has an application 6 | When the user deletes the application 7 | Then the application should be deleted 8 | And the application should no longer be listed 9 | 10 | Scenario: User deletes a non-existent application 11 | When a user deletes a non-existent application 12 | Then the call should fail because the application does not exist 13 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/GetApplication.feature: -------------------------------------------------------------------------------- 1 | Feature: GetApplication 2 | As a user, I would like to get the details of my application. 3 | 4 | Scenario: User gets an application 5 | Given a user has an application 6 | When the user gets the application 7 | Then the application should be returned 8 | 9 | Scenario: User gets a non-existent application 10 | When a user gets a non-existent application 11 | Then the call should fail because the application does not exist 12 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/ListApplications.feature: -------------------------------------------------------------------------------- 1 | Feature: ListApplications 2 | As a user, I would like to see what applications I have. 3 | 4 | Scenario: User lists applications 5 | Given a user has an application 6 | And the user creates another application 7 | When the user lists applications 8 | Then all applications should be listed 9 | And the listed applications should be in alphabetical order 10 | 11 | Scenario: User lists applications with pagination 12 | Given a user has an application 13 | And the user creates another application 14 | And the user creates another application 15 | When the user lists applications with 2 max items 16 | Then 2 applications should be listed 17 | And the user lists applications with next token 18 | Then 1 applications should be listed 19 | 20 | Scenario: Unauthorized user lists applications 21 | When an unauthorized user lists applications 22 | Then the call should fail because of access denied -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/UpdateApplication.feature: -------------------------------------------------------------------------------- 1 | Feature: UpdateApplication 2 | As a user, I would like to update my application. 3 | 4 | Scenario: User updates an application 5 | Given a user has an application 6 | When the user updates the application 7 | Then the application should be updated 8 | 9 | Scenario: User updates an application with no update 10 | Given a user has an application 11 | When the user updates the application with no update 12 | Then the call should fail because there is no update 13 | 14 | Scenario: User updates a non-existent application 15 | When a user updates a non-existent application 16 | Then the call should fail because the application does not exist 17 | 18 | Scenario: User updates an application with invalid author 19 | Given a user has an application 20 | When the user updates the application with invalid author 21 | Then the call should fail because of bad request 22 | 23 | Scenario: User updates an application with invalid description 24 | Given a user has an application 25 | When the user updates the application with invalid description 26 | Then the call should fail because of bad request 27 | 28 | Scenario: User updates an application with invalid home page URL 29 | Given a user has an application 30 | When the user updates the application with invalid home page URL 31 | Then the call should fail because of bad request -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CognitoAuthorizerImpl.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.guice; 2 | 3 | import com.amazonaws.ImmutableRequest; 4 | import software.amazon.serverless.apprepo.api.client.auth.CognitoAuthorizer; 5 | import software.amazon.serverless.apprepo.cucumber.steps.CognitoUserManager; 6 | 7 | import java.util.UUID; 8 | 9 | import lombok.RequiredArgsConstructor; 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | /** 13 | * Implementation of {@link CognitoAuthorizer} to provide signer for API requests. 14 | */ 15 | @Slf4j 16 | @RequiredArgsConstructor 17 | public class CognitoAuthorizerImpl implements CognitoAuthorizer { 18 | private final CognitoUserManager cognitoUserManager; 19 | 20 | @Override 21 | public String generateToken(ImmutableRequest request) { 22 | try { 23 | return cognitoUserManager.generateIdToken(); 24 | } catch (Throwable t) { 25 | log.warn("Exception thrown when generating token", t); 26 | return UUID.randomUUID().toString(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CukeInjectorSource.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.guice; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.google.inject.Guice; 5 | import com.google.inject.Injector; 6 | 7 | import cucumber.runtime.java.guice.InjectorSource; 8 | 9 | /** 10 | * Guice injector source for Cucumber. 11 | */ 12 | public class CukeInjectorSource implements InjectorSource { 13 | @Override 14 | public Injector getInjector() { 15 | return Guice.createInjector(Lists.newArrayList(new ApplicationModule())); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/CommonSteps.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.steps; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository; 6 | import software.amazon.serverless.apprepo.api.client.model.BadRequestException; 7 | import software.amazon.serverless.apprepo.api.client.model.NotFoundException; 8 | import software.amazon.serverless.apprepo.api.client.model.UnauthorizedException; 9 | import com.google.inject.Inject; 10 | 11 | import io.cucumber.java.en.Then; 12 | import lombok.extern.slf4j.Slf4j; 13 | 14 | /** 15 | * Implementation of common steps in multiple features. 16 | */ 17 | @Slf4j 18 | public class CommonSteps { 19 | @Inject 20 | private AWSServerlessApplicationRepository appRepo; 21 | 22 | @Then("^the call should fail because the application does not exist$") 23 | public void the_call_should_fail_because_the_application_does_not_exist() { 24 | assertThat(TestEnv.getLastException()) 25 | .isNotNull() 26 | .isInstanceOf(NotFoundException.class); 27 | } 28 | 29 | @Then("^the call should fail because of bad request$") 30 | public void the_call_should_fail_because_of_bad_request() { 31 | assertThat(TestEnv.getLastException()) 32 | .isNotNull() 33 | .isInstanceOf(BadRequestException.class); 34 | } 35 | 36 | @Then("^the call should fail because of access denied$") 37 | public void the_call_should_fail_because_of_access_denied() { 38 | assertThat(TestEnv.getLastException()) 39 | .isNotNull() 40 | .isInstanceOf(UnauthorizedException.class); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/DeleteApplicationSteps.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.steps; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 5 | 6 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository; 7 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest; 8 | import software.amazon.serverless.apprepo.api.client.model.NotFoundException; 9 | import com.google.common.base.Preconditions; 10 | import com.google.inject.Inject; 11 | 12 | import java.util.UUID; 13 | 14 | import io.cucumber.java.en.Then; 15 | import io.cucumber.java.en.When; 16 | import lombok.extern.slf4j.Slf4j; 17 | 18 | /** 19 | * Implementation of the steps in DeleteApplication.feature. 20 | */ 21 | @Slf4j 22 | public class DeleteApplicationSteps { 23 | @Inject 24 | private AWSServerlessApplicationRepository appRepo; 25 | 26 | @When("^the user deletes the application$") 27 | public void the_user_deletes_the_application() { 28 | assertThat(TestEnv.getLastException()).isNull(); 29 | Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists"); 30 | 31 | appRepo.deleteApplication(new DeleteApplicationRequest().applicationId(TestEnv.getApplicationId())); 32 | } 33 | 34 | @When("^a user deletes a non-existent application$") 35 | public void a_user_deletes_a_non_existent_application() { 36 | try { 37 | appRepo.deleteApplication(new DeleteApplicationRequest() 38 | .applicationId("applicationId" + UUID.randomUUID().toString())); 39 | } catch (Exception e) { 40 | // do nothing and verify exception in the next step 41 | } 42 | } 43 | 44 | @Then("^the application should be deleted$") 45 | public void the_application_should_be_deleted() { 46 | assertThat(TestEnv.getLastException()).isNull(); 47 | Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists"); 48 | assertThatThrownBy(() -> appRepo.deleteApplication(new DeleteApplicationRequest() 49 | .applicationId("applicationId" + UUID.randomUUID().toString()))) 50 | .isInstanceOf(NotFoundException.class); 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/GetApplicationSteps.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.steps; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository; 6 | import software.amazon.serverless.apprepo.api.client.model.Application; 7 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest; 8 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationResult; 9 | import com.google.common.base.Preconditions; 10 | import com.google.inject.Inject; 11 | 12 | import java.util.UUID; 13 | 14 | import io.cucumber.java.en.Then; 15 | import io.cucumber.java.en.When; 16 | import lombok.extern.slf4j.Slf4j; 17 | 18 | /** 19 | * Implementation of the steps in GetApplication.feature. 20 | */ 21 | @Slf4j 22 | public class GetApplicationSteps { 23 | @Inject 24 | private AWSServerlessApplicationRepository appRepo; 25 | 26 | @When("^the user gets the application$") 27 | public void the_user_gets_the_application() { 28 | assertThat(TestEnv.getLastException()).isNull(); 29 | Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists"); 30 | 31 | GetApplicationResult result = appRepo.getApplication(new GetApplicationRequest().applicationId(TestEnv.getApplicationId())); 32 | TestEnv.setApplication(result.getApplication()); 33 | } 34 | 35 | @When("^a user gets a non-existent application$") 36 | public void a_user_gets_a_non_existent_application() { 37 | try { 38 | appRepo.getApplication(new GetApplicationRequest() 39 | .applicationId("applicationId-" + UUID.randomUUID().toString())); 40 | } catch (Exception e) { 41 | // do nothing and verify exception in the next step 42 | } 43 | } 44 | 45 | @Then("^the application should be returned$") 46 | public void the_application_should_be_returned() { 47 | assertThat(TestEnv.getLastException()).isNull(); 48 | Application application = TestEnv.getApplication(); 49 | assertThat(application.getApplicationId()).isEqualTo(TestEnv.getApplicationId()); 50 | assertThat(application.getAuthor()).isEqualTo(TestEnv.getAuthor()); 51 | assertThat(application.getDescription()).isEqualTo(TestEnv.getApplicationDescription()); 52 | assertThat(application.getHomePageUrl()).isEqualTo(TestEnv.getHomePageUrl()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/SetupAndTeardownSteps.java: -------------------------------------------------------------------------------- 1 | package software.amazon.serverless.apprepo.cucumber.steps; 2 | 3 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository; 4 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest; 5 | import com.google.inject.Inject; 6 | 7 | import java.time.Duration; 8 | import java.time.Instant; 9 | 10 | import io.cucumber.core.api.Scenario; 11 | import io.cucumber.java.After; 12 | import io.cucumber.java.Before; 13 | import lombok.extern.slf4j.Slf4j; 14 | 15 | /** 16 | * Setup and teardown implementation. 17 | */ 18 | @Slf4j 19 | public class SetupAndTeardownSteps { 20 | @Inject 21 | private AWSServerlessApplicationRepository appRepo; 22 | @Inject 23 | private CognitoUserManager cognitoUserManager; 24 | 25 | @Before 26 | public void beforeScenario(final Scenario s) { 27 | TestEnv.reset(); 28 | Instant startedAt = Instant.now(); 29 | TestEnv.setScenarioStartedAt(startedAt); 30 | cognitoUserManager.setupCognitoUser(); 31 | log.info("Starting scenario \"{}\" at {}", s.getName(), startedAt); 32 | } 33 | 34 | @After 35 | public void afterScenario(Scenario s) { 36 | TestEnv.getApplications().forEach(app -> tryDeleteApplication(app.getApplicationId())); 37 | 38 | try { 39 | cognitoUserManager.cleanupCognitoUser(); 40 | } catch (Throwable t) { 41 | log.warn(String.format("Failed to clean up cognito user %s", TestEnv.getUsername()), t); 42 | } 43 | 44 | Instant endedAt = Instant.now(); 45 | long durationMillis = Duration.between(TestEnv.getScenarioStartedAt(), endedAt).toMillis(); 46 | if (s.isFailed()) { 47 | log.info("Failed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis); 48 | log.info("TestData: {}", TestEnv.getTestData().toString()); 49 | } else { 50 | log.info("Completed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis); 51 | } 52 | 53 | } 54 | 55 | private void tryDeleteApplication(String applicationId) { 56 | try { 57 | log.info("Cleaning up application {}", applicationId); 58 | appRepo.deleteApplication(new DeleteApplicationRequest().applicationId(applicationId)); 59 | } catch (Throwable t) { 60 | log.warn("Failed to clean up application {}", applicationId, t); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /backend/src/test/resources/cucumber.properties: -------------------------------------------------------------------------------- 1 | guice.injector-source=software.amazon.serverless.apprepo.cucumber.guice.CukeInjectorSource 2 | -------------------------------------------------------------------------------- /backend/src/test/resources/integ-test-env.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Description: >- 3 | This template creates the resources for integration tests. 4 | 5 | Parameters: 6 | Stage: 7 | Type: String 8 | Description: The stage where the application is running in, e.g., dev, prod. 9 | Resources: 10 | IntegTestClient: 11 | Type: AWS::Cognito::UserPoolClient 12 | Properties: 13 | UserPoolId: !Sub '{{resolve:ssm:/applications/apprepo/${Stage}/cognito/userpool/ApplicationsApi/Id:1}}' 14 | GenerateSecret: false 15 | ExplicitAuthFlows: 16 | - ADMIN_NO_SRP_AUTH 17 | 18 | IntegTestClientId: 19 | Type: "AWS::SSM::Parameter" 20 | Properties: 21 | Name: !Sub "/applications/apprepo/${Stage}/cognito/userpoolclient/IntegTest/${AWS::StackName}/Id" 22 | Type: "String" 23 | Value: !Ref IntegTestClient 24 | Description: "Integration test Cognito User Pool Client ID." -------------------------------------------------------------------------------- /bin/delete-stack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Delete a CloudFormation stack. This is best effort and failing to delete a stack won't fail the script. 4 | # 5 | # This script assumes following are installed on the build host: 6 | # - AWS CLI 7 | 8 | usage() { 9 | echo "Usage:" 10 | echo " delete-stack.sh -n Delete CloudFormation stack by name." 11 | echo "Example:" 12 | echo " delete-stack.sh -n my-stack" 13 | } 14 | 15 | arg_parse() { 16 | while getopts "n:" opt; do 17 | case ${opt} in 18 | n ) 19 | STACK_NAME=${OPTARG} 20 | ;; 21 | \? ) 22 | usage 23 | exit 1 24 | ;; 25 | esac 26 | done 27 | shift $((OPTIND -1)) 28 | 29 | if [[ -z ${STACK_NAME} ]] 30 | then 31 | usage 32 | exit 1; 33 | fi 34 | } 35 | 36 | main() { 37 | arg_parse "$@" 38 | echo "Deleting stack: ${STACK_NAME}" 39 | aws cloudformation delete-stack --stack-name ${STACK_NAME} 40 | exit 0 41 | } 42 | 43 | # Spin up hook 44 | main "$@" -------------------------------------------------------------------------------- /bin/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Deploy a SAM template. 5 | # 6 | # This script assumes following are installed on the build host: 7 | # - AWS CLI 8 | 9 | set -e # fail script on any individual command failing 10 | 11 | usage() { 12 | echo "Usage:" 13 | echo " deploy.sh -n -t