Esempio n. 1
0
        /// 删除存储桶清单任务
        public void DeleteBucketInventory()
        {
            //.cssg-snippet-body-start:[delete-bucket-inventory]
            try
            {
                string inventoryId = "aInventoryId";
                string bucket      = "examplebucket-1250000000"; //格式:BucketName-APPID
                DeleteBucketInventoryRequest deleteRequest = new DeleteBucketInventoryRequest(bucket);
                deleteRequest.SetInventoryId(inventoryId);
                DeleteBucketInventoryResult deleteResult = cosXml.deleteBucketInventory(deleteRequest);

                //请求成功
                Console.WriteLine(deleteResult.GetResultInfo());
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                //请求失败
                Console.WriteLine("CosClientException: " + clientEx);
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                //请求失败
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());
            }
            //.cssg-snippet-body-end
        }
Esempio n. 2
0
        public void TestBucketInventory()
        {
            try
            {
                string inventoryId = "id1";

                PutBucketInventoryRequest putRequest = new PutBucketInventoryRequest(bucket, inventoryId);

                putRequest.IsEnable(true);
                putRequest.SetScheduleFrequency("Daily");
                putRequest.SetIncludedObjectVersions("All");
                putRequest.SetDestination("CSV", QCloudServer.Instance().uin, QCloudServer.Instance().bucketForObjectTest, region, "list1");
                putRequest.SetFilter("dir/");
                putRequest.SetOptionalFields("SIZE");
                putRequest.SetOptionalFields("ETag");
                putRequest.EnableSSE();
                PutBucketInventoryResult putResult = cosXml.PutBucketInventory(putRequest);

                Assert.IsTrue(putResult.httpCode == 200);

                GetBucketInventoryRequest getRequest = new GetBucketInventoryRequest(bucket);

                getRequest.SetInventoryId(inventoryId);
                GetBucketInventoryResult getResult  = cosXml.GetBucketInventory(getRequest);
                InventoryConfiguration   testConfig = getResult.inventoryConfiguration;

                // Console.WriteLine(getResult.GetResultInfo());
                Assert.IsNotEmpty((getResult.GetResultInfo()));

                ListBucketInventoryRequest listRequest = new ListBucketInventoryRequest(bucket);
                ListBucketInventoryResult  listResult  = cosXml.ListBucketInventory(listRequest);
                Assert.IsTrue(listResult.httpCode == 200);
                Assert.NotNull(listResult.GetResultInfo());
                Assert.IsEmpty(listResult.listInventoryConfiguration.continuationToken);
                Assert.False(listResult.listInventoryConfiguration.isTruncated);
                Assert.AreEqual(listResult.listInventoryConfiguration.inventoryConfigurations.Count, 1);
                InventoryConfiguration testConfig2 = listResult.listInventoryConfiguration.inventoryConfigurations[0];

                InventoryConfiguration[] configurations = new InventoryConfiguration[] { testConfig, testConfig2 };

                foreach (InventoryConfiguration configuration in configurations)
                {
                    Assert.NotNull(configuration);
                    Assert.NotNull(configuration.destination.cosBucketDestination.accountId);
                    Assert.NotNull(configuration.destination.cosBucketDestination.bucket);
                    Assert.NotNull(configuration.destination.cosBucketDestination.encryption.sSECOS);
                    Assert.NotNull(configuration.destination.cosBucketDestination.format);
                    Assert.NotNull(configuration.destination.cosBucketDestination.prefix);
                    Assert.True(configuration.isEnabled);
                    Assert.NotNull(configuration.schedule.frequency);
                    Assert.NotNull(configuration.includedObjectVersions);
                    Assert.NotNull(configuration.filter.prefix);
                    Assert.AreEqual(configuration.optionalFields.fields.Count, 2);
                }

                DeleteBucketInventoryRequest deleteRequest = new DeleteBucketInventoryRequest(bucket);

                deleteRequest.SetInventoryId(inventoryId);
                DeleteBucketInventoryResult deleteResult = cosXml.DeleteBucketInventory(deleteRequest);
                Assert.IsTrue(putResult.httpCode == 200);
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());

                if (serverEx.statusCode != 409 && serverEx.statusCode != 451)
                {
                    Assert.Fail();
                }
            }
        }
Esempio n. 3
0
 public void DeleteInventoryAsync(DeleteBucketInventoryRequest request, OnSuccessCallback <CosResult> successCallback, OnFailedCallback failCallback)
 {
     Schedue(request, new Model.Bucket.DeleteBucketInventoryResult(), successCallback, failCallback);
 }
Esempio n. 4
0
 public DeleteBucketInventoryResult DeleteBucketInventory(DeleteBucketInventoryRequest request)
 {
     return((Model.Bucket.DeleteBucketInventoryResult)Excute(request, new Model.Bucket.DeleteBucketInventoryResult()));
 }