OCISDK/OCISDK/GeneralElement/GeneralElemenClient.cs
/// <summary>
/// Returns the Region the bucket resides in. 
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Returns the Region the bucket resides in.
Returns the Region the bucket resides in .
public List<string> GetBucketLocation(GetBucketLocationRequest request)
        {
            ListRegionSubscriptionsRequest listRegionSubscriptionsRequest = new ListRegionSubscriptionsRequest
            { 
                TenancyId = base.Config.TenancyId
            };
            var regions = IdentityClient.ListRegionSubscriptions(listRegionSubscriptionsRequest);
            var nameSpaceName = GetNamespace(request);
            List<string> res = new List<string>();
            foreach (var region in regions.Items)
            {
                ObjectStorageClient.SetRegion(region.RegionName);
                GetBucketRequest getBucketRequest = new GetBucketRequest
                {
                    NamespaceName = nameSpaceName,
                    BucketName = request.BucketName
                };
                try
                {
                    var b = ObjectStorageClient.GetBucket(getBucketRequest);
                    if (b.Bucket != null)
                    {
                        res.Add(region.RegionName);
                    }
                }
                catch (WebException we)
                {
                    if (!(we.Status.Equals(WebExceptionStatus.ProtocolError) && ((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.NotFound))
                    {
                        throw;
                    }
                }
            }
            if (res.Count <= 0)
            {
                throw new Exception("NoSuchBucket");
            }
            return res;
        }
public List < string > GetBucketLocation ( GetBucketLocationRequest request ) { ListRegionSubscriptionsRequest listRegionSubscriptionsRequest = new ListRegionSubscriptionsRequest { TenancyId = base . Config . TenancyId } ; var regions = IdentityClient . ListRegionSubscriptions ( listRegionSubscriptionsRequest ) ; var nameSpaceName = GetNamespace ( request ) ; List < string > res = new List < string > ( ) ; foreach ( var region in regions . Items ) { ObjectStorageClient . SetRegion ( region . RegionName ) ; GetBucketRequest getBucketRequest = new GetBucketRequest { NamespaceName = nameSpaceName , BucketName = request . BucketName } ; try { var b = ObjectStorageClient . GetBucket ( getBucketRequest ) ; if ( b . Bucket != null ) { res . Add ( region . RegionName ) ; } } catch ( WebException we ) { if ( ! ( we . Status . Equals ( WebExceptionStatus . ProtocolError ) && ( ( HttpWebResponse ) we . Response ) . StatusCode == HttpStatusCode . NotFound ) ) { throw ; } } } if ( res . Count <= 0 ) { throw new Exception ( " " ) ; } return res ; }
Returns the Region the bucket resides in.
Returns the Region the bucket resides in .
None
request
GetBucketLocationRequest
None