import * as plugins from './smartbucket.plugins'; import { SmartBucket } from './smartbucket.classes.smartbucket'; export class Bucket { public static async createFromName(smartbucketRef: SmartBucket, bucketNameArg: string) { const buckets = await smartbucketRef.minioClient.listBuckets(); const foundBucket = buckets.find(bucket => { return bucket.name === bucketNameArg; }); if (foundBucket) { console.log(`bucket with name ${bucketNameArg} exists.`) console.log(`Taking this as base for new Bucket instance`); return new this(smartbucketRef, bucketNameArg); } } public smartbucketRef: SmartBucket; public name: string; constructor(smartbucketRef: SmartBucket, bucketName: string) { this.smartbucketRef = smartbucketRef; this.name = bucketName; } }