interface: add S3 api

This commit is contained in:
Liam Fitzgerald 2020-07-31 12:56:54 +10:00
parent 5c65f0db20
commit 41089c912d
3 changed files with 40 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import GroupsApi from './groups';
import LaunchApi from './launch';
import LinksApi from './links';
import PublishApi from './publish';
import S3Api from './s3';
export default class GlobalApi extends BaseApi<StoreState> {
chat = new ChatApi(this.ship, this.channel, this.store);
@ -22,6 +23,7 @@ export default class GlobalApi extends BaseApi<StoreState> {
launch = new LaunchApi(this.ship, this.channel, this.store);
links = new LinksApi(this.ship, this.channel, this.store);
publish = new PublishApi(this.ship, this.channel, this.store);
s3 = new S3Api(this.ship, this.channel, this.store);
constructor(public ship: Patp, public channel: any, public store: GlobalStore) {

View File

@ -0,0 +1,37 @@
import BaseApi from './base';
import { StoreState } from '../store/type';
import {S3Update} from '../types/s3-update';
export default class S3Api extends BaseApi<StoreState> {
setCurrentBucket(bucket: string) {
this.s3Action({ 'set-current-bucket': bucket });
}
addBucket(bucket: string) {
this.s3Action({ 'add-bucket': bucket });
}
removeBucket(bucket: string) {
this.s3Action({ 'remove-bucket': bucket });
}
setEndpoint(endpoint: string) {
this.s3Action({ setEndpoint: endpoint });
}
setAccessKeyId(accessKeyId: string) {
this.s3Action({ setAccessKeyId: accessKeyId });
}
setSecretAccessKey(secretAccessKey: string) {
this.s3Action({ setSecretAccessKey: secretAccessKey });
}
private s3Action(data: any) {
this.action('s3-store', 's3-action', data);
}
}

View File

@ -40,7 +40,7 @@ export default class S3Reducer<S extends S3State> {
currentBucket(json: S3Update, state: S) {
const data = _.get(json, 'setCurrentBucket', false);
if (data && state.s3) {
state.s3.configuration.currentBucket = data;
}
}