Fuel Site Monitor - Reference

DOCS

Last updated: Aug 15th, 8:05am

This sections contains:

AWS4 signing protocol

This section provides details about signing the request with AccessKey and SecretKey using AWS4 signing protocol.

Using Postman

Create a request in Postman with the following configurations,

Auth typeAWS Signature
Access keyAccessKey provided to merchant
Secret keySecretKey provided to merchant

Java

    1// Create a request
    2
    3Request<Void> request = new DefaultRequest<Void>("execute-api");
    4request.setEndpoint(URI.create("https://{baseurl}"));
    5request.setHttpMethod(HttpMethodName.GET);
    6request.setResourcePath("/site-status");
    7request.addHeader("Content-Type", "application/json");
    8request.addHeader("x-api-key", "{API_Key}");
    9
    10// Define the AWS credentials
    11
    12BasicAWSCredentials awsCredentials = new BasicAWSCredentials("{AccessKey}", "{SecretKey}")
    13
    14// Sign the request with AWS4 signing protocol
    15
    16AWS4Signer signer = new AWS4Signer();
    17signer.setRegionName(Region.getRegion(Regions.fromName("us-east-1")).getName());
    18signer.setServiceName("execute-api");
    19signer.sign(request, awsCredentials);
    20
    21// Send the request
    22
    23Response<String> response = new AmazonHttpClient(new ClientConfiguration())
    24 .requestExecutionBuilder()
    25 .executionContext(new ExecutionContext(true))
    26 .request(request)
    27 .errorResponseHandler(new ErrorResponseHandler())
    28 .execute(new SuccessResponseHandler());

    NodeJS

      1var AWS = require('aws-sdk');
      2var rp = require('request-promise')
      3var aws4 = require('aws4')
      4
      5var credentials = {
      6 accessKeyId: '{AccessKey}',
      7 secretAccessKey: '{SecretKey}'
      8}
      9
      10var opts = {
      11 host: '{baseurl}',
      12 method: ‘GET’
      13 path: '/site-status',
      14 uri: ' https://{baseurl}/site-status',
      15 json: true,
      16 headers: {
      17 'x-api-key': '{API_Key}'
      18 }
      19}
      20
      21opts.region = 'us-east-1'
      22opts.service = 'execute-api'
      23
      24var signer = new aws4.RequestSigner(opts, credentials)
      25signer.sign()
      26
      27rp(opts)
      28.then( (html)=> console.log(html) )
      29.catch( (e)=> console.log('failed:' + e) )

      Generating timestamps

      You must provide startTime in yyyy-MM-dd HH:mm:ss format, where

      VariableDescription
      yyyy4-digit year
      MM2-digit month in year, for example January is 01.
      ddDay in month
      HHHour in day (0-23)
      mmMinute in hour
      ssSecond in minute

      This section provides details about generating timestamp in different programming languages.

      Java

        1DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd
        2 HH:mm:ss").withZone(ZoneId.of("UTC"));
        3String formattedCurrentUTCDateTime = dateTimeFormatter.format(Instant.now());

        Javascript

          1`function getFormattedUTCCurrentDateTime() {
          2 var currentDate = new Date();
          3 var formattedDateTime = currentDate.getUTCFullYear() + "-" +
          4 ("0" + (currentDate.getUTCMonth() + 1)).slice(-2) + "-" +
          5 ("0" + currentDate.getUTCDate()).slice(-2) + " " +
          6 ("0" + currentDate.getUTCHours()).slice(-2) + ":" +
          7 ("0" + currentDate.getUTCMinutes()).slice(-2) + ":" +
          8 ("0" + currentDate.getUTCSeconds()).slice(-2);
          9 return formattedDateTime;
          10}