public function doAction($request, $iSigner = null, $credential = null, $autoRetry = true, $maxRetryNumber = 3) { if (null == $this->iClientProfile && (null == $iSigner || null == $credential || null == $request->getRegionId() || null == $request->getAcceptFormat())) { throw new ClientException("No active profile found.", "SDK.InvalidProfile"); } if (null == $iSigner) { $iSigner = $this->iClientProfile->getSigner(); } if (null == $credential) { $credential = $this->iClientProfile->getCredential(); } $request = $this->prepareRequest($request); $domain = EndpointProvider::findProductDomain($request->getRegionId(), $request->getProduct()); if (null == $domain) { throw new ClientException("Can not find endpoint to access.", "SDK.InvalidRegionId"); } $requestUrl = $request->composeUrl($iSigner, $credential, $domain); $httpResponse = HttpHelper::curl($requestUrl, $request->getMethod(), null, $request->getHeaders()); $retryTimes = 1; while (500 <= $httpResponse->getStatus() && $autoRetry && $retryTimes < $maxRetryNumber) { $requestUrl = $request->composeUrl($iSigner, $credential); $httpResponse = HttpHelper::curl($requestUrl, null, $request->getHeaders()); $retryTimes++; } return $httpResponse; }
private function setEndpoints() { $regionIds = array("cn-hangzhou", "cn-beijing", "cn-qingdao", "cn-hongkong", "cn-shanghai", "us-west-1", "cn-shenzhen", "ap-southeast-1"); $productDomains = array(new ProductDomain("Ecs", "ecs.aliyuncs.com"), new ProductDomain("Rds", "rds.aliyuncs.com"), new ProductDomain("BatchCompute", "batchCompute.aliyuncs.com"), new ProductDomain("Bss", "bss.aliyuncs.com"), new ProductDomain("Oms", "oms.aliyuncs.com"), new ProductDomain("Slb", "slb.aliyuncs.com"), new ProductDomain("Oss", "oss-cn-hangzhou.aliyuncs.com"), new ProductDomain("OssAdmin", "oss-admin.aliyuncs.com"), new ProductDomain("Sts", "sts.aliyuncs.com"), new ProductDomain("Yundun", "yundun-cn-hangzhou.aliyuncs.com"), new ProductDomain("Risk", "risk-cn-hangzhou.aliyuncs.com"), new ProductDomain("Drds", "drds.aliyuncs.com"), new ProductDomain("M-kvstore", "m-kvstore.aliyuncs.com"), new ProductDomain("Ram", "ram.aliyuncs.com"), new ProductDomain("Cms", "metrics.aliyuncs.com"), new ProductDomain("Crm", "crm-cn-hangzhou.aliyuncs.com"), new ProductDomain("Ocs", "pop-ocs.aliyuncs.com"), new ProductDomain("Ots", "ots-pop.aliyuncs.com"), new ProductDomain("Dqs", "dqs.aliyuncs.com"), new ProductDomain("Location", "location.aliyuncs.com"), new ProductDomain("Ubsms", "ubsms.aliyuncs.com"), new ProductDomain("Ubsms-inner", "ubsms-inner.aliyuncs.com")); $endpoint = new Endpoint("cn-hangzhou", $regionIds, $productDomains); $endpoints = array($endpoint); EndpointProvider::setEndpoints($endpoints); }
<?php /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ use Sts\Core\Regions\Endpoint; use Sts\Core\Regions\EndpointProvider; use Sts\Core\Regions\ProductDomain; $regionIds = array("cn-hangzhou", "cn-beijing", "cn-qingdao", "cn-hongkong", "cn-shanghai", "us-west-1", "cn-shenzhen", "ap-southeast-1"); $productDomains = array(new ProductDomain("Ecs", "ecs.aliyuncs.com"), new ProductDomain("Rds", "rds.aliyuncs.com"), new ProductDomain("BatchCompute", "batchCompute.aliyuncs.com"), new ProductDomain("Bss", "bss.aliyuncs.com"), new ProductDomain("Oms", "oms.aliyuncs.com"), new ProductDomain("Slb", "slb.aliyuncs.com"), new ProductDomain("Oss", "oss-cn-hangzhou.aliyuncs.com"), new ProductDomain("OssAdmin", "oss-admin.aliyuncs.com"), new ProductDomain("Sts", "sts.aliyuncs.com"), new ProductDomain("Yundun", "yundun-cn-hangzhou.aliyuncs.com"), new ProductDomain("Risk", "risk-cn-hangzhou.aliyuncs.com"), new ProductDomain("Drds", "drds.aliyuncs.com"), new ProductDomain("M-kvstore", "m-kvstore.aliyuncs.com"), new ProductDomain("Ram", "ram.aliyuncs.com"), new ProductDomain("Cms", "metrics.aliyuncs.com"), new ProductDomain("Crm", "crm-cn-hangzhou.aliyuncs.com"), new ProductDomain("Ocs", "pop-ocs.aliyuncs.com"), new ProductDomain("Ots", "ots-pop.aliyuncs.com"), new ProductDomain("Dqs", "dqs.aliyuncs.com"), new ProductDomain("Location", "location.aliyuncs.com"), new ProductDomain("Ubsms", "ubsms.aliyuncs.com"), new ProductDomain("Ubsms-inner", "ubsms-inner.aliyuncs.com")); $endpoint = new Endpoint("cn-hangzhou", $regionIds, $productDomains); $endpoints = array($endpoint); EndpointProvider::setEndpoints($endpoints);