Create WIP
This commit is contained in:
parent
f6d4a97cdd
commit
6a1dd4b0aa
|
@ -48,6 +48,41 @@ module S3Module {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
|
create: {
|
||||||
|
type: QueryType.FIELDS,
|
||||||
|
fields: {
|
||||||
|
bucket: {
|
||||||
|
display: "New Bucket",
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
location: {
|
||||||
|
required: true,
|
||||||
|
default: "us-east-1",
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
},
|
||||||
|
grantFullControl: {
|
||||||
|
display: "Grant full control",
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
},
|
||||||
|
grantRead: {
|
||||||
|
display: "Grant read",
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
},
|
||||||
|
grantReadAcp: {
|
||||||
|
display: "Grant read ACP",
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
},
|
||||||
|
grantWrite: {
|
||||||
|
display: "Grant write",
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
},
|
||||||
|
grantWriteAcp: {
|
||||||
|
display: "Grant write ACP",
|
||||||
|
type: DatasourceFieldType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
read: {
|
read: {
|
||||||
type: QueryType.FIELDS,
|
type: QueryType.FIELDS,
|
||||||
fields: {
|
fields: {
|
||||||
|
@ -85,6 +120,33 @@ module S3Module {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
extra: {
|
||||||
|
acl: {
|
||||||
|
required: false,
|
||||||
|
displayName: "ACL",
|
||||||
|
type: DatasourceFieldType.LIST,
|
||||||
|
data: {
|
||||||
|
create: [
|
||||||
|
"private",
|
||||||
|
"public-read",
|
||||||
|
"public-read-write",
|
||||||
|
"authenticated-read",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
objectOwnership: {
|
||||||
|
required: false,
|
||||||
|
displayName: "Object ownership",
|
||||||
|
type: DatasourceFieldType.LIST,
|
||||||
|
data: {
|
||||||
|
create: [
|
||||||
|
"BucketOwnerPreferred",
|
||||||
|
"ObjectWriter",
|
||||||
|
"BucketOwnerEnforced",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class S3Integration implements IntegrationBase {
|
class S3Integration implements IntegrationBase {
|
||||||
|
@ -102,6 +164,36 @@ module S3Module {
|
||||||
this.client = new AWS.S3(this.config)
|
this.client = new AWS.S3(this.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async create(query: {
|
||||||
|
bucket: string,
|
||||||
|
location: string,
|
||||||
|
grantFullControl: string,
|
||||||
|
grantRead: string,
|
||||||
|
grantReadAcp: string,
|
||||||
|
grantWrite: string,
|
||||||
|
grantWriteAcp: string,
|
||||||
|
extra: {
|
||||||
|
acl: string,
|
||||||
|
objectOwnership: string,
|
||||||
|
}}) {
|
||||||
|
const response = await this.client.createBucket({
|
||||||
|
Bucket: query.bucket,
|
||||||
|
// ACL: query.extra?.acl,
|
||||||
|
CreateBucketConfiguration: {
|
||||||
|
LocationConstraint: query.location
|
||||||
|
},
|
||||||
|
GrantFullControl: query.grantFullControl,
|
||||||
|
GrantRead: query.grantRead,
|
||||||
|
GrantReadACP: query.grantReadAcp,
|
||||||
|
GrantWrite: query.grantWrite,
|
||||||
|
GrantWriteACP: query.grantWriteAcp,
|
||||||
|
}, (err: any) => {
|
||||||
|
console.log("ERR ", err)
|
||||||
|
})
|
||||||
|
.promise()
|
||||||
|
return response.Contents
|
||||||
|
}
|
||||||
|
|
||||||
async read(query: {
|
async read(query: {
|
||||||
bucket: string
|
bucket: string
|
||||||
delimiter: string
|
delimiter: string
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe("S3 Integration", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("calls the read method with the correct params", async () => {
|
it("calls the read method with the correct params", async () => {
|
||||||
const response = await config.integration.read({
|
await config.integration.read({
|
||||||
bucket: "test",
|
bucket: "test",
|
||||||
delimiter: "/",
|
delimiter: "/",
|
||||||
marker: "file.txt",
|
marker: "file.txt",
|
||||||
|
@ -31,4 +31,34 @@ describe("S3 Integration", () => {
|
||||||
Prefix: "directory/"
|
Prefix: "directory/"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("calls the create method with the correct params", async () => {
|
||||||
|
await config.integration.create({
|
||||||
|
bucket: "test",
|
||||||
|
location: "af-south-1",
|
||||||
|
grantFullControl: "me",
|
||||||
|
grantRead: "him",
|
||||||
|
grantReadAcp: "her",
|
||||||
|
grantWrite: "she",
|
||||||
|
grantWriteAcp: "he",
|
||||||
|
objectLockEnabledForBucket: true
|
||||||
|
}, {
|
||||||
|
acl: "private",
|
||||||
|
objectOwnership: "BucketOwnerPreferred"
|
||||||
|
})
|
||||||
|
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
||||||
|
Bucket: "test",
|
||||||
|
CreateBucketConfiguration: {
|
||||||
|
LocationConstraint: "af-south-1"
|
||||||
|
},
|
||||||
|
GrantFullControl: "me",
|
||||||
|
GrantRead: "him",
|
||||||
|
GrantReadAcp: "her",
|
||||||
|
GrantWrite: "she",
|
||||||
|
GrantWriteAcp: "he",
|
||||||
|
ObjectLockEnabledForBucket: true,
|
||||||
|
ACL: "private",
|
||||||
|
ObjectOwnership: "BucketOwnerPreferred"
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
Loading…
Reference in New Issue