2020-11-26 22:23:20 +01:00
const AWS = require ( "aws-sdk" )
2021-01-11 18:18:22 +01:00
const SCHEMA = {
2021-01-15 18:29:46 +01:00
docs : "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html" ,
2021-02-19 16:07:43 +01:00
description :
"Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance." ,
2021-02-18 17:58:10 +01:00
friendlyName : "Amazon S3" ,
2021-01-11 18:18:22 +01:00
datasource : {
region : {
type : "string" ,
required : true ,
default : "us-east-1" ,
} ,
accessKeyId : {
2021-01-13 17:39:47 +01:00
type : "password" ,
2021-01-11 18:18:22 +01:00
required : true ,
} ,
secretAccessKey : {
2021-01-13 17:39:47 +01:00
type : "password" ,
2021-01-11 18:18:22 +01:00
required : true ,
} ,
2020-11-26 22:23:20 +01:00
} ,
2021-01-13 17:39:47 +01:00
query : {
read : {
2021-01-22 13:22:28 +01:00
type : "fields" ,
fields : {
bucket : {
type : "string" ,
required : true ,
2021-01-13 17:39:47 +01:00
} ,
} ,
} ,
} ,
2020-11-26 22:23:20 +01:00
}
class S3Integration {
constructor ( config ) {
this . config = config
this . connect ( )
this . client = new AWS . S3 ( )
}
async connect ( ) {
AWS . config . update ( this . config )
}
2021-01-13 17:39:47 +01:00
async read ( query ) {
2020-11-26 22:23:20 +01:00
const response = await this . client
. listObjects ( {
2021-01-13 17:39:47 +01:00
Bucket : query . bucket ,
2020-11-26 22:23:20 +01:00
} )
. promise ( )
return response . Contents
}
}
module . exports = {
2021-01-11 18:18:22 +01:00
schema : SCHEMA ,
2020-11-26 22:23:20 +01:00
integration : S3Integration ,
}