/// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetObjectLegalHoldResponse response = new GetObjectLegalHoldResponse();

            UnmarshallResult(context, response);

            return(response);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetObjectLegalHoldResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("LegalHold", targetDepth))
                    {
                        var unmarshaller = ObjectLockLegalHoldUnmarshaller.Instance;
                        response.LegalHold = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }

            return;
        }
Пример #3
0
    public async Task PutGetObjectLegalHold(S3Provider _, string bucket, ISimpleClient client)
    {
        string objectKey = nameof(PutGetObjectLegalHold);

        //Create an object
        await client.PutObjectAsync(bucket, objectKey, null).ConfigureAwait(false);

        //Check that there is no lock
        GetObjectLegalHoldResponse getLegalResp = await client.GetObjectLegalHoldAsync(bucket, objectKey).ConfigureAwait(false);

        Assert.Equal(404, getLegalResp.StatusCode);
        Assert.False(getLegalResp.LegalHold);

        //Set a lock
        PutObjectLegalHoldResponse putLegalResp = await client.PutObjectLegalHoldAsync(bucket, objectKey, true).ConfigureAwait(false);

        Assert.Equal(200, putLegalResp.StatusCode);

        //There should be a lock now
        GetObjectLegalHoldResponse getLegalResp2 = await client.GetObjectLegalHoldAsync(bucket, objectKey).ConfigureAwait(false);

        Assert.Equal(200, getLegalResp2.StatusCode);
        Assert.True(getLegalResp2.LegalHold);
    }
Пример #4
0
        public async Task PutGetObjectLegalHold()
        {
            string objectKey = nameof(PutGetObjectLegalHold);

            //Create an object
            await UploadAsync(objectKey).ConfigureAwait(false);

            //Check that there is no lock
            GetObjectLegalHoldResponse getLegalResp = await ObjectClient.GetObjectLegalHoldAsync(BucketName, objectKey).ConfigureAwait(false);

            Assert.Equal(404, getLegalResp.StatusCode);
            Assert.False(getLegalResp.LegalHold);

            //Set a lock
            PutObjectLegalHoldResponse putLegalResp = await ObjectClient.PutObjectLegalHoldAsync(BucketName, objectKey, true).ConfigureAwait(false);

            Assert.Equal(200, putLegalResp.StatusCode);

            //There should be a lock now
            GetObjectLegalHoldResponse getLegalResp2 = await ObjectClient.GetObjectLegalHoldAsync(BucketName, objectKey).ConfigureAwait(false);

            Assert.Equal(200, getLegalResp2.StatusCode);
            Assert.True(getLegalResp2.LegalHold);
        }