Fuel Site Monitor - Reference
DOCS
Last updated: Aug 15th, 8:05am
This sections contains:
Useful links
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 type | AWS Signature |
---|---|
Access key | AccessKey provided to merchant |
Secret key | SecretKey provided to merchant |
Java
1// Create a request23Request<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}");910// Define the AWS credentials1112BasicAWSCredentials awsCredentials = new BasicAWSCredentials("{AccessKey}", "{SecretKey}")1314// Sign the request with AWS4 signing protocol1516AWS4Signer signer = new AWS4Signer();17signer.setRegionName(Region.getRegion(Regions.fromName("us-east-1")).getName());18signer.setServiceName("execute-api");19signer.sign(request, awsCredentials);2021// Send the request2223Response<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')45var credentials = {6 accessKeyId: '{AccessKey}',7 secretAccessKey: '{SecretKey}'8}910var 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}2021opts.region = 'us-east-1'22opts.service = 'execute-api'2324var signer = new aws4.RequestSigner(opts, credentials)25signer.sign()2627rp(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
Variable | Description |
---|---|
yyyy | 4-digit year |
MM | 2-digit month in year, for example January is 01 . |
dd | Day in month |
HH | Hour in day (0-23) |
mm | Minute in hour |
ss | Second in minute |
This section provides details about generating timestamp in different programming languages.
Java
1DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd2 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}