Skip to content

Latest commit

 

History

History
74 lines (50 loc) · 2.65 KB

README.md

File metadata and controls

74 lines (50 loc) · 2.65 KB

api-gateway-client

CircleCI

An HTTP request library with AWS Signature v4 signed requests. generic client library that connects to AWS Regions and Endpoints, without generating an SDK for the API.

This API was inspired by awscurl

Installation

Maven

<dependency>
  <groupId>tk.k2zinger</groupId>
  <artifactId>api-gateway-client</artifactId>
  <version>0.2</version>
</dependency>

Examples

HTTP GET

        ApiGatewayResponse response = ApiGatewayClientBuilder.standard()
            .withUri("https://xxxxxx.execute-api.us-east-1.amazonaws.com/yyyyyy")
            .build()
            .sendRequest();

        System.out.println(response.getResponseCode());
        System.out.println(response.getContent());
        
        JsonNode responseJson = response.getContentAsJson();

HTTP POST

        ApiGatewayResponse response = ApiGatewayClientBuilder.standard()
            .withMethod("POST")
            .withUri("https://xxxxxx.execute-api.us-east-1.amazonaws.com/yyyyyy")
            .withBody("{\"key1\": \"value1\",\"key2\": \"value2\"}")
            .build()
            .sendRequest();

        System.out.println(response.getResponseCode());
        System.out.println(response.getContent());
        
        JsonNode responseJson = response.getContentAsJson();

Usage

withUri: the url to connect to

withMethod: currently GET and POST are the only supported operations, defaults to GET

withHeaders: additional headers to add to the request (note: these headers are overwritten if they have the same name as the headers used to generate the AWS v4 Signature!

withBody: the string data to send in POST requests

withAccessKey: AWS access key

withSecretKey: AWS secret key

withSecurityToken: interchangable with withSessionToken, populates the x-amz-security-token header and adds it to the AWS v4 Signature

withSessionToken: see withSecurityToken

withApiKey: adds the header x-api-key

withRegion: see AWS Regions and Endpoints, defaults to us-east-1

withProfile: which profile to use within the credentials profiles file, see Named Profiles

withService: AWS service, defaults to execute-api