Ejemplo n.º 1
0
        public void SetUp()
        {
            //todo: I should not have to re-auth here, what's wrong with this design?
            var creds = client.GetApplicationCredentials();

            client = new ServiceStackB2Api();

            //todo: might be worth checking with support if wrong/null credentials here should be 401, not 400.
            privateTestBucket = client.OverwriteBucket(new CreateBucketRequest() { AccountId = creds.AccountId, BucketType = "allPrivate", BucketName = "PrivateTestBucket" });
            publicTestBucket = client.OverwriteBucket(new CreateBucketRequest() { AccountId = creds.AccountId, BucketType = "allPublic", BucketName = "PublicTestBucket" });

            //todo: bucket types should probably be an enum (?)
            Assert.AreEqual("allPrivate", privateTestBucket.BucketType);
            Assert.AreEqual("allPublic", publicTestBucket.BucketType);
        }
Ejemplo n.º 2
0
        public void CreateBucketWithInvalidType()
        {
            var invalidType = new Bucket()
            {
                AccountId = creds.AccountId,
                BucketName = "TestBucketWithInvalidType",
                BucketType = "invalidType"
            };

            request = new CreateBucketRequest(invalidType);
            try
            {
                client.CreateBucket(request);
            }

            catch (BadRequestException ex)
            {
                Assert.AreEqual("invalidType is not a valid value.  Valid values are: allPublic, allPrivate, snapshot", ex.Message);
            }
        }
Ejemplo n.º 3
0
        public Bucket DeleteBucketRecursively(Bucket bucketToDelete)
        {
            var remainingFileVersions = ListFileVersions(new ListFileVersionsRequest() { BucketId = bucketToDelete.BucketId });
            foreach (var fileVersion in remainingFileVersions.Files)
            {
                DeleteFileVersion(new DeleteFileVersionRequest() { FileId = fileVersion.FileId, FileName = fileVersion.FileName });
            }

            return DeleteBucket(bucketToDelete);
        }
Ejemplo n.º 4
0
 public Bucket DeleteBucket(Bucket bucketToDelete)
 {
     return
         client.Post<Bucket>(new DeleteBucketRequest() { AccountId = CurrentToken.AccountID, BucketId = bucketToDelete.BucketId });
 }
Ejemplo n.º 5
0
 public CreateBucketRequest(Bucket newBucket)
 {
     BucketName = newBucket.BucketName;
     BucketType = newBucket.BucketType;
     AccountId = newBucket.AccountId;
 }
Ejemplo n.º 6
0
 public void SetUp()
 {
     client = new ServiceStackB2Api();
     fileUploadBucket = client.GetOrCreateBucket("FileUploadTestBucket");
 }