コード例 #1
0
        public DescribeEndpointResponse DescribeEndpoint(String regionId, String locationProduct,
                                                         Credential credential, LocationConfig locationConfig)
        {
            if (isEmpty(locationProduct))
            {
                return(null);
            }

            DescribeEndpointRequest request = new DescribeEndpointRequest();

            request.AcceptFormat    = FormatType.JSON;
            request.Id              = regionId;
            request.RegionId        = locationConfig.RegionId;
            request.LocationProduct = locationProduct;
            request.EndpointType    = DEFAULT_ENDPOINT_TYPE;

            ProductDomain domain = new ProductDomain(locationConfig.Product, locationConfig.Endpoint);

            try
            {
                HttpRequest  httpRequest  = request.SignRequest(signer, credential, FormatType.JSON, domain);
                HttpResponse httpResponse = HttpResponse.GetResponse(httpRequest);
                if (httpResponse.isSuccess())
                {
                    String data = System.Text.Encoding.UTF8.GetString(httpResponse.Content);
                    DescribeEndpointResponse response = getEndpointResponse(data, DEFAULT_ENDPOINT_TYPE);
                    if (null == response || isEmpty(response.Endpoint))
                    {
                        return(null);
                    }
                    return(response);
                }
                AcsError error = readError(httpResponse, FormatType.JSON);
                if (500 <= httpResponse.Status)
                {
                    Console.WriteLine("Invoke_Error, requestId:" + error.RequestId + "; code:" + error.ErrorCode
                                      + "; Msg" + error.ErrorMessage);
                    return(null);
                }
                Console.WriteLine("Invoke_Error, requestId:" + error.RequestId + "; code:" + error.ErrorCode
                                  + "; Msg" + error.ErrorMessage);
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine("Invoke Remote Error,Msg" + e.Message);
                return(null);
            }
        }
コード例 #2
0
 public static ProductDomain FindProductDomain(String regionId, String product,
                                               List <Endpoint> endpoints, IAcsClient acsClient)
 {
     if (null == regionId || null == product || null == endpoints)
     {
         return(null);
     }
     foreach (Endpoint endpoint in endpoints)
     {
         if (endpoint.RegionIds.Contains(regionId))
         {
             ProductDomain domain = FindProductDomainByProduct(endpoint.ProductDomains, product);
             return(domain);
         }
     }
     if ("Location".Equals(product))
     {
         return(new ProductDomain("Location", "location.aliyuncs.com"));
     }
     return(null);
 }