private void TestBucketContents(B2Bucket bucket, B2BucketType expectedType) { Assert.IsNotNull(bucket); Assert.IsFalse(string.IsNullOrWhiteSpace(bucket.AccountId)); Assert.IsFalse(string.IsNullOrWhiteSpace(bucket.BucketId)); Assert.IsFalse(string.IsNullOrWhiteSpace(bucket.BucketName)); Assert.AreEqual(expectedType, bucket.BucketType); }
public async Task<bool> UpdateAsync(B2BucketType newType) { ThrowIfNot(B2BucketState.Present); B2BucketObject result = await _b2Client.Communicator.UpdateBucket(AccountId, BucketId, newType); _bucket = result; return true; }
private void VerifyBucketInList(B2Client client, bool shouldExist, string bucketName, B2BucketType expectedType) { IEnumerable<B2Bucket> list = client.GetBuckets(); bool exists = list.Any(s => s.BucketName == bucketName && s.BucketType == expectedType); if (shouldExist) Assert.IsTrue(exists); else Assert.IsFalse(exists); }
public static bool Update(this B2Bucket bucket, B2BucketType newType) { return Utility.AsyncRunHelper(() => bucket.UpdateAsync(newType)); }
/// <summary> /// Calls b2_update_bucket /// /// https://www.backblaze.com/b2/docs/b2_update_bucket.html /// </summary> public async Task<B2BucketObject> UpdateBucket(string accountId, string bucketId, B2BucketType bucketType) { HttpResponseMessage resp = await InternalRequest(ApiUri, "/b2api/v1/b2_update_bucket", new { accountId, bucketId, bucketType = bucketType.GetDescription() }); return JsonConvert.DeserializeObject<B2BucketObject>(await resp.Content.ReadAsStringAsync().ConfigureAwait(false)); }
public async Task<B2Bucket> CreateBucketAsync(string name, B2BucketType type) { ThrowExceptionIfNotAuthorized(); B2BucketObject bucket = await Communicator.CreateBucket(AccountId, name, type); BucketCache.RecordBucket(bucket); return new B2Bucket(this, bucket); }
public static B2Bucket CreateBucket(this B2Client client, string name, B2BucketType type) { return Utility.AsyncRunHelper(() => client.CreateBucketAsync(name, type)); }