Esempio n. 1
0
        public async Task <dynamic> CreateNewBucket([FromBody] BucketModel bucket)
        {
            dynamic    bucketOutput = null;;
            BucketsApi buckets      = new BucketsApi();
            dynamic    token        = await OAuthController.GetInternalAsync();

            buckets.Configuration.AccessToken = token.access_token;
            PostBucketsPayload bucketPayload = new PostBucketsPayload(string.Format("{0}-{1}", ClientId, bucket.bucketKey.ToLower()), null,
                                                                      PostBucketsPayload.PolicyKeyEnum.Transient);

            // obavezna je provera da li kanta već postoji!!!
            try
            {
                bucketOutput = await buckets.CreateBucketAsync(bucketPayload, "US");
            }
            catch (Exception ex)
            {
                if (ex.Message == "Error calling CreateBucket: {\"reason\":\"Bucket already exists\"}")
                {
                    dynamic allBuckets = await buckets.GetBucketsAsync("US", 100);

                    foreach (KeyValuePair <string, dynamic> actualBucket in new DynamicDictionaryItems(allBuckets.items))
                    {
                        string bucketName = actualBucket.Value.bucketKey;
                        if (bucketName.Contains(BucketName)) //kitchenconfig  designautomation
                        {
                            bucketOutput = actualBucket;
                        }
                    }
                }
            }
            return(bucketOutput);
        }
Esempio n. 2
0
        public async Task DeleteBucket([FromBody] BucketModel bucket)
        {
            BucketsApi buckets = new BucketsApi();
            dynamic    token   = await OAuthController.GetInternalAsync();

            buckets.Configuration.AccessToken = token.access_token;
            await buckets.DeleteBucketAsync(bucket.bucketKey);
        }