public async Task <HttpResponse> DoActionAsync <T>(AcsRequest <T> request, string regionId, Credential credential, CancellationToken cancellationToken) where T : AcsResponse { var signer = Signer.GetSigner(new LegacyCredentials(credential)); FormatType?format = null; if (null == request.RegionId) { request.RegionId = regionId; } if (request.ProductDomain == null) { request.ProductDomain = EndpointUserConfig.GetProductDomain(request.Product, request.RegionId); if (request.ProductDomain == null) { request.SetProductDomain(); } } List <Endpoint> endpoints = null; if (null != clientProfile) { format = clientProfile.GetFormat(); if (request.ProductDomain == null) { endpoints = await clientProfile.GetEndpointsAsync(request.Product, request.RegionId, request.LocationProduct, request.LocationEndpointType, cancellationToken).ConfigureAwait(false); } } return(await DoActionAsync(request, AutoRetry, MaxRetryNumber, request.RegionId, credential, signer, format, endpoints, cancellationToken).ConfigureAwait(false)); }
public HttpResponse DoAction <T>(AcsRequest <T> request, string regionId, Credential credential) where T : AcsResponse { var signer = Signer.GetSigner(new LegacyCredentials(credential)); FormatType?format = null; if (null == request.RegionId) { request.RegionId = regionId; } if (request.ProductDomain == null) { request.ProductDomain = EndpointUserConfig.GetProductDomain(request.Product, request.RegionId); if (request.ProductDomain == null) { request.SetProductDomain(); } } List <Endpoint> endpoints = null; if (null != clientProfile) { format = clientProfile.GetFormat(); if (request.ProductDomain == null) { endpoints = clientProfile.GetEndpoints(request.Product, request.RegionId, request.LocationProduct, request.LocationEndpointType); } } return(DoAction(request, AutoRetry, MaxRetryNumber, request.RegionId, credential, signer, format, endpoints)); }
public void TestAddEndpointWithNullParam() { string productId = "mock_product_id"; string regionId = "mock_region_id"; EndpointUserConfig.AddEndpoint(productId, regionId, null); ProductDomain productDomain = EndpointUserConfig.GetProductDomain(productId, regionId); Assert.Null(productDomain); }
public void TestAddEndpoint() { string productId = "product_id"; string regionId = "region_id"; string domain = "mock_domain"; EndpointUserConfig.AddEndpoint(productId, regionId, domain); ProductDomain productDomain = EndpointUserConfig.GetProductDomain(productId, regionId); Assert.Equal(domain, productDomain.DomainName); Assert.Equal(productId, productDomain.ProductName); }
public async Task <HttpResponse> DoActionAsync <T>(AcsRequest <T> request, bool autoRetry, int maxRetryNumber, IClientProfile profile, CancellationToken cancellationToken) where T : AcsResponse { if (null == profile) { throw new ClientException("SDK.InvalidProfile", "No active profile found."); } var retry = autoRetry; var retryNumber = maxRetryNumber; var region = profile.GetRegionId(); if (null == request.RegionId) { request.RegionId = region; } if (request.ProductDomain == null) { request.ProductDomain = EndpointUserConfig.GetProductDomain(request.Product, request.RegionId); if (request.ProductDomain == null) { request.SetProductDomain(); } } var credentials = await credentialsProvider.GetCredentialsAsync(cancellationToken).ConfigureAwait(false); if (credentials == null) { credentials = await new DefaultCredentialProvider().GetAlibabaCloudClientCredentialAsync(cancellationToken).ConfigureAwait(false); } var signer = Signer.GetSigner(credentials); var format = profile.GetFormat(); List <Endpoint> endpoints = null; if (request.ProductDomain == null) { endpoints = await clientProfile.GetEndpointsAsync(request.Product, request.RegionId, request.LocationProduct, request.LocationEndpointType, cancellationToken).ConfigureAwait(false); } return(await DoActionAsync(request, retry, retryNumber, request.RegionId, credentials, signer, format, endpoints, cancellationToken).ConfigureAwait(false)); }
public HttpResponse DoAction <T>(AcsRequest <T> request, bool autoRetry, int maxRetryNumber, IClientProfile profile) where T : AcsResponse { if (null == profile) { throw new ClientException("SDK.InvalidProfile", "No active profile found."); } var retry = autoRetry; var retryNumber = maxRetryNumber; var region = profile.GetRegionId(); if (null == request.RegionId) { request.RegionId = region; } if (request.ProductDomain == null) { request.ProductDomain = EndpointUserConfig.GetProductDomain(request.Product, request.RegionId); if (request.ProductDomain == null) { request.SetProductDomain(); } } var credentials = credentialsProvider.GetCredentials(); if (credentials == null) { credentials = new DefaultCredentialProvider().GetAlibabaCloudClientCredential(); } var signer = Signer.GetSigner(credentials); var format = profile.GetFormat(); List <Endpoint> endpoints = null; if (request.ProductDomain == null) { endpoints = clientProfile.GetEndpoints(request.Product, request.RegionId, request.LocationProduct, request.LocationEndpointType); } return(DoAction(request, retry, retryNumber, request.RegionId, credentials, signer, format, endpoints)); }
public void TestGetNotExistEndpoint() { ProductDomain productDomain = EndpointUserConfig.GetProductDomain("not_exist_product", "region_id"); Assert.Null(productDomain); }