コード例 #1
0
        /// <summary>
        /// Performs a partial or full update of a bucket's user-defined metadata.
        ///
        /// Use UpdateBucket to move a bucket from one compartment to another within the same tenancy.
        /// Supply the compartmentID of the compartment that you want to move the bucket to.
        /// For more information about moving resources between compartments, see Moving Resources to a Different Compartment.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <UpdateBucketResponse> UpdateBucket(UpdateBucketRequest request)
        {
            var uri = new Uri(GetEndPointNoneVersion(ObjectStorageServices.Bucket(request.NamespaceName, request.BucketName), this.Region));

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                IfMatch            = request.IfMatch,
                OpcClientRequestId = request.OpcClientRequestId
            };
            var webResponse = await this.RestClientAsync.Post(uri, request.UpdateBucketDetails, httpRequestHeaderParam);

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new UpdateBucketResponse()
                    {
                        Bucket = JsonSerializer.Deserialize <Bucket>(response),
                        ETag = webResponse.Headers.Get("ETag"),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id")
                    });
                }
        }
コード例 #2
0
        /// <summary>
        /// Gets the current representation of the given bucket in the given Object Storage namespace.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public GetBucketResponse GetBucket(GetBucketRequest request)
        {
            var uri = new Uri($"{GetEndPointNoneVersion(ObjectStorageServices.Bucket(request.NamespaceName), this.Region)}/{request.BucketName}/");

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                IfMatch            = request.IfMatch,
                IfNoneMatch        = request.IfNoneMatch,
                OpcClientRequestId = request.OpcClientRequestId
            };
            var webResponse = this.RestClient.Get(uri, httpRequestHeaderParam, request.Fields);

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new GetBucketResponse()
                    {
                        Bucket = JsonSerializer.Deserialize <Bucket>(response),
                        ETag = webResponse.Headers.Get("ETag"),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id")
                    });
                }
        }
コード例 #3
0
        /// <summary>
        /// Deletes a bucket if the bucket is already empty.
        /// If the bucket is not empty, use DeleteObject first.
        /// In addition, you cannot delete a bucket that has a multipart upload in progress or a pre-authenticated request associated with that bucket.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <DeleteBucketResponse> DeleteBucket(DeleteBucketRequest request)
        {
            var uri = new Uri(GetEndPointNoneVersion(ObjectStorageServices.Bucket(request.NamespaceName, request.BucketName), this.Region));

            var webResponse = await this.RestClientAsync.Delete(uri, new HttpRequestHeaderParam()
            {
                IfMatch = request.IfMatch
            });

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new DeleteBucketResponse()
                    {
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id")
                    });
                }
        }
コード例 #4
0
        /// <summary>
        /// Gets a list of all BucketSummary items in a compartment. A BucketSummary contains only summary fields for the bucket and does not
        /// contain fields like the user-defined metadata.
        /// To use this and other API operations, you must be authorized in an IAM policy. If you are not authorized, talk to an administrator.
        /// If you are an administrator who needs to write policies to give users access, see Getting Started with Policies.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ListBucketsResponse ListBuckets(ListBucketsRequest request)
        {
            var uri = new Uri($"{GetEndPointNoneVersion(ObjectStorageServices.Bucket(request.NamespaceName), this.Region)}?{request.GetOptionQuery()}");

            var webResponse = this.RestClient.Get(uri, new HttpRequestHeaderParam {
                OpcClientRequestId = request.OpcClientRequestId
            });

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new ListBucketsResponse()
                    {
                        Items = JsonSerializer.Deserialize <List <BucketSummary> >(response),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id")
                    });
                }
        }
コード例 #5
0
        /// <summary>
        /// Efficiently checks to see if a bucket exists and gets the current entity tag (ETag) for the bucket.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <HeadBucketResponse> HeadBucket(HeadBucketRequest request)
        {
            var uri = new Uri($"{GetEndPointNoneVersion(ObjectStorageServices.Bucket(request.NamespaceName, request.BucketName), this.Region)}");

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                IfMatch            = request.IfMatch,
                IfNoneMatch        = request.IfNoneMatch,
                OpcClientRequestId = request.OpcClientRequestId
            };
            var webResponse = await this.RestClientAsync.Head(uri, httpRequestHeaderParam);

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    return(new HeadBucketResponse()
                    {
                        ETag = webResponse.Headers.Get("ETag"),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id")
                    });
                }
        }
コード例 #6
0
        /// <summary>
        /// Creates a bucket in the given namespace with a bucket name and optional user-defined metadata. Avoid entering confidential information in bucket names.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public CreateBucketResponse CreateBucket(CreateBucketRequest request)
        {
            var uri = new Uri(GetEndPointNoneVersion(ObjectStorageServices.Bucket(request.NamespaceName), this.Region));

            var webResponse = this.RestClient.Post(uri, request.CreateBucketDetails, new HttpRequestHeaderParam()
            {
                OpcClientRequestId = request.OpcClientRequestId
            });

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new CreateBucketResponse()
                    {
                        Bucket = JsonSerializer.Deserialize <Bucket>(response),
                        ETag = webResponse.Headers.Get("ETag"),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id"),
                        Location = webResponse.Headers.Get("Location")
                    });
                }
        }