コード例 #1
0
        public ResultResponce getBuckettagging(string BucketName)
        {
            ResultResponce result = new ResultResponce();

            if (string.IsNullOrEmpty(BucketName) || string.IsNullOrWhiteSpace(BucketName))
            {
                result.Error        = true;
                result.ErrorMessage = "Please provide valid bucket Name.";
                return(result);
            }
            try
            {
                GetBucketTaggingResponse responce = s3Client.GetBucketTagging(new GetBucketTaggingRequest()
                {
                    BucketName = BucketName
                });

                result.Error = false;
                result.Data  = responce.TagSet;
                return(result);
            }
            catch (Exception ex)
            {
                result.Error        = true;
                result.ErrorMessage = ex.Message;
                return(result);
            }
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetBucketTaggingResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Tag", targetDepth + 1))
                    {
                        response.TagSet.Add(TagUnmarshaller.Instance.Unmarshall(context));

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }



            return;
        }
コード例 #3
0
 public async Task GetEmptyBucketTagging(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         GetBucketTaggingResponse getResp = await client.GetBucketTaggingAsync(tempBucket).ConfigureAwait(false);
         Assert.Equal(404, getResp.StatusCode);
     }).ConfigureAwait(false);
 }
コード例 #4
0
 public async Task GetEmptyBucketTagging()
 {
     await CreateTempBucketAsync(async x =>
     {
         GetBucketTaggingResponse getResp = await BucketClient.GetBucketTaggingAsync(x).ConfigureAwait(false);
         Assert.Equal(404, getResp.StatusCode);
     }).ConfigureAwait(false);
 }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetBucketTaggingResponse response = new GetBucketTaggingResponse();

            UnmarshallResult(context, response);

            return(response);
        }
コード例 #6
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetBucketTaggingResponse getBucketTaggingResponse = new GetBucketTaggingResponse();

            while (context.Read())
            {
                if (context.get_IsStartElement())
                {
                    UnmarshallResult(context, getBucketTaggingResponse);
                }
            }
            return(getBucketTaggingResponse);
        }
コード例 #7
0
    public async Task GetPutDeleteBucketTagging(S3Provider provider, string _, ISimpleClient client)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            IDictionary <string, string> tags = new Dictionary <string, string>();
            tags.Add("MyKey", "MyValue");
            tags.Add("MyKey2", "MyValue2");

            PutBucketTaggingResponse putResp = await client.PutBucketTaggingAsync(tempBucket, tags).ConfigureAwait(false);
            Assert.True(putResp.IsSuccess);

            GetBucketTaggingResponse getResp = await client.GetBucketTaggingAsync(tempBucket).ConfigureAwait(false);
            Assert.True(getResp.IsSuccess);

            Assert.Equal(tags, getResp.Tags);

            DeleteBucketTaggingResponse deleteResp = await client.DeleteBucketTaggingAsync(tempBucket).ConfigureAwait(false);
            Assert.True(deleteResp.IsSuccess);
        }).ConfigureAwait(false);
    }
コード例 #8
0
        public async Task GetPutDeleteBucketTagging()
        {
            await CreateTempBucketAsync(async x =>
            {
                IDictionary <string, string> tags = new Dictionary <string, string>();
                tags.Add("MyKey", "MyValue");
                tags.Add("MyKey2", "MyValue2");

                PutBucketTaggingResponse putResp = await BucketClient.PutBucketTaggingAsync(x, tags).ConfigureAwait(false);
                Assert.True(putResp.IsSuccess);

                GetBucketTaggingResponse getResp = await BucketClient.GetBucketTaggingAsync(x).ConfigureAwait(false);
                Assert.True(getResp.IsSuccess);

                Assert.Equal(tags, getResp.Tags);

                DeleteBucketTaggingResponse deleteResp = await BucketClient.DeleteBucketTaggingAsync(x).ConfigureAwait(false);
                Assert.True(deleteResp.IsSuccess);
            }).ConfigureAwait(false);
        }
コード例 #9
0
        static void ReadBucketTags()
        {
            string bucket = Common.InputString("Bucket:", null, false);

            GetBucketTaggingRequest request = new GetBucketTaggingRequest();

            request.BucketName = bucket;

            GetBucketTaggingResponse response = _S3Client.GetBucketTaggingAsync(request).Result;

            if (response != null)
            {
                Console.WriteLine("Success");
                foreach (Tag curr in response.TagSet)
                {
                    Console.WriteLine("  " + curr.Key + ": " + curr.Value);
                }
            }
            else
            {
                Console.WriteLine("Failed");
            }
        }
コード例 #10
0
        private static void GetBucketTagging()
        {
            try
            {
                GetBucketTaggingRequest request = new GetBucketTaggingRequest()
                {
                    BucketName = bucketName
                };
                GetBucketTaggingResponse response = client.GetBucketTagging(request);

                Console.WriteLine("Get bucket Tagging response: {0}", response.StatusCode);
                foreach (var tag in response.Tags)
                {
                    Console.WriteLine("Get bucket Tagging response Key: {0}" + tag.Key);
                    Console.WriteLine("Get bucket Tagging response Value:{0} " + tag.Value);
                }
            }
            catch (ObsException ex)
            {
                Console.WriteLine("Exception errorcode: {0}, when get bucket tagging.", ex.ErrorCode);
                Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage);
            }
        }
コード例 #11
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetBucketTaggingResponse response)
        {
            int currentDepth = context.get_CurrentDepth();
            int num          = currentDepth + 1;

            if (context.get_IsStartOfDocument())
            {
                num += 2;
            }
            while (context.Read())
            {
                if (context.get_IsStartElement() || context.get_IsAttribute())
                {
                    if (context.TestExpression("Tag", num + 1))
                    {
                        response.TagSet.Add(TagUnmarshaller.Instance.Unmarshall(context));
                    }
                }
                else if (context.get_IsEndElement() && context.get_CurrentDepth() < currentDepth)
                {
                    break;
                }
            }
        }