Skip to content

Commit

Permalink
release 0.0.8-beta source code
Browse files Browse the repository at this point in the history
  • Loading branch information
unionsdk committed Oct 30, 2023
1 parent 9a71a33 commit 2694d5f
Show file tree
Hide file tree
Showing 27 changed files with 146 additions and 97 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# 0.0.8-beta 2023-10-30

### G42Cloud SDK MPC

- _Features_
- None
- _Bug Fix_
- None
- _Change_
- **CreateThumbnailsTask**
- changes of request param
- `- thumbnail_para.percent`
- `- thumbnail_para.type: enum value [PERCENT]`
- **CreateTranscodingTask**
- changes of request param
- `- thumbnail.params.percent`
- `- thumbnail.params.type: enum value [PERCENT]`

# 0.0.7-beta 2023-08-26

### G42Cloud SDK SMS
Expand Down
4 changes: 2 additions & 2 deletions Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"api",
"core"
],
"version": "0.0.7-beta",
"version": "0.0.8-beta",
"type": "library",
"license": "Apache-2.0",
"authors": [
Expand All @@ -25,6 +25,6 @@
"guzzlehttp/psr7": "1.4.2",
"guzzlehttp/promises": "1.3.1",
"psr/http-message": "1.0.1",
"monolog/monolog": "1.23.0"
"monolog/monolog": ">=2.4.0"
}
}
56 changes: 46 additions & 10 deletions Core/src/Http/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class HttpClient
protected $logger;
protected $httpHandler;

const X_REQUEST_ID = "X-Request-Id";
const X_REQUEST_ID_LOWER = "x-request-id";

public function __construct(
HttpConfig $httpConfig = null,
HttpHandler $httpHandler = null,
Expand Down Expand Up @@ -108,7 +111,7 @@ public function doRequestSync(SdkRequest $sdkRequest)
$response, 'logger' => $this->logger]);
}
$responseStatusCode = $response->getStatusCode();
$requestId = $response->getHeaders()['X-Request-Id'][0];
$requestId = $this->parseRequestId($response);
$responseBody = $response->getBody();
$sdkError = $this->getSdkErrorMessage($requestId,
$responseBody, $responseStatusCode);
Expand All @@ -126,6 +129,38 @@ public function doRequestSync(SdkRequest $sdkRequest)
return $response;
}

private function getFirstIdFromArray($headers, $key) {
$requestKeys = $headers[$key];
if (count($requestKeys) < 1) {
return '';
}
return $requestKeys[0];
}

/**
* @param $response http response
* @return mixed|string request id from response header
*/
public function parseRequestId($response) {
if ($response->hasHeader(self::X_REQUEST_ID)) {
$headers = $response->getHeaders();
if (array_key_exists(self::X_REQUEST_ID, $headers)) {
return $this->getFirstIdFromArray($headers, self::X_REQUEST_ID);
}
if (array_key_exists(self::X_REQUEST_ID_LOWER, $headers)) {
return $this->getFirstIdFromArray($headers, self::X_REQUEST_ID_LOWER);
}
return '';
}
// parse requestId from other key
$requestKeys = array_filter(array_keys($response->getHeaders()), function ($key){
return preg_match('/^x-([a-zA-z\-]+)?request-id$/', (string) $key);
});
$requestKey = array_shift($requestKeys);
return $requestKey != null && isset($response->getHeaders()[$requestKey]) ?
$response->getHeaders()[$requestKey][0] : '';
}

public function doRequestAsync(SdkRequest $sdkRequest)
{
if (isset($this->httpHandler)) {
Expand All @@ -144,7 +179,7 @@ function (RequestException $e) use ($sdkRequest) {
if ($e->hasResponse()) {
$response = $e->getResponse();
$responseStatusCode = $response->getStatusCode();
$requestId = $response->getHeaders()['X-Request-Id'][0];
$requestId = $this->parseRequestId($response);
$responseBody = $response->getBody();
$sdkError = $this->getSdkErrorMessage($requestId,
$responseBody, $responseStatusCode);
Expand Down Expand Up @@ -248,38 +283,38 @@ private function parseExceptionType($errorMessage)
switch ($errorKey) {
case 'cURL error 6':
if (isset($this->logger)) {
$this->logger->addError('HostUnreachableException occurred.'
$this->logger->error('HostUnreachableException occurred.'
.$msg);
}
throw new HostUnreachableException($msg);
case 'cURL error 60':
if (isset($this->logger)) {
$this->logger->addError('SslHandShakeException occurred.'
$this->logger->error('SslHandShakeException occurred.'
.$msg);
}
throw new SslHandShakeException($msg);
case 'cURL error 28':
if (isset($this->logger)) {
$this->logger->addError('CallTimeoutException occurred.'
$this->logger->error('CallTimeoutException occurred.'
.$msg);
}
throw new CallTimeoutException($msg);
case 'cURL error 47':
if (isset($this->logger)) {
$this->logger->addError('RetryOutageException occurred.'
$this->logger->error('RetryOutageException occurred.'
.$msg);
}
throw new RetryOutageException($msg);
case 'CURL error 55':
// should handle error for reset by peer, throw connection exception
if (isset($this->logger)) {
$this->logger->addError('reset by server error occurred.'
$this->logger->error('reset by server error occurred.'
.$msg);
}
throw new ConnectionException($msg, 504, null);
default:
if (isset($this->logger)) {
$this->logger->addError('SdkException occurred.'
$this->logger->error('SdkException occurred.'
.$msg);
}
throw new SdkException($errorMessage);
Expand Down Expand Up @@ -324,11 +359,12 @@ private function parseErrorCodeAndMessageFromFirstArrayElem($responseBodyArr, $k
private function recordRequestIdToLog($sdkRequest, $response)
{
$contentLength = $this->getContentLength($response);
$requestId = $this->parseRequestId($response);
if (isset($this->logger)) {
$this->logger->addInfo(' "'.$sdkRequest->method.' '.
$this->logger->info(' "'.$sdkRequest->method.' '.
$sdkRequest->url.'" '
.' '.$response->getStatusCode().' '.$contentLength
.' '.$response->getHeaders()['X-Request-Id'][0]);
.' '.$requestId);
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="https://www.g42cloud.com/"><img src="https://upload.wikimedia.org/wikipedia/en/4/43/Group_42_Logo.jpg"></a>
<a href="https://www.g42cloud.com/"><img src="https://upload.wikimedia.org/wikipedia/en/thumb/9/94/Group_42_logo.png/330px-Group_42_logo.png"></a>
</p>

<h1 align="center">G42 Cloud Php Software Development Kit (Php SDK)</h1>
Expand Down
4 changes: 2 additions & 2 deletions Services/Cdn/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"api",
"cdn"
],
"version": "0.0.7-beta",
"version": "0.0.8-beta",
"type": "library",
"license": "Apache-2.0",
"authors": [
Expand All @@ -20,7 +20,7 @@
],
"minimum-stability": "dev",
"require": {
"g42cloud/cloud-sdk-core": "0.0.7-beta"
"g42cloud/cloud-sdk-core": "0.0.8-beta"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions Services/Cse/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"api",
"cse"
],
"version": "0.0.7-beta",
"version": "0.0.8-beta",
"type": "library",
"license": "Apache-2.0",
"authors": [
Expand All @@ -20,7 +20,7 @@
],
"minimum-stability": "dev",
"require": {
"g42cloud/cloud-sdk-core": "0.0.7-beta"
"g42cloud/cloud-sdk-core": "0.0.8-beta"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions Services/Ecs/V2/EcsAsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -4401,9 +4401,9 @@ public function updateServerAsyncWithHttpInfo($request){
}

/**
* 修改云服务器销毁时间
* 修改云服务器定时删除时间
*
* 修改按需服务器,设置定时销毁时间。如果设置的销毁时间为空,表示取消销毁时间
* 修改按需服务器,设置定时删除时间。如果设置的定时删除时间为空字符串,表示取消定时删除
*
* 该接口支持企业项目细粒度权限的校验,具体细粒度请参见 ecs:cloudServers:put。
*
Expand Down
4 changes: 2 additions & 2 deletions Services/Ecs/V2/EcsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -4213,9 +4213,9 @@ public function updateServerWithHttpInfo($request)
}

/**
* 修改云服务器销毁时间
* 修改云服务器定时删除时间
*
* 修改按需服务器,设置定时销毁时间。如果设置的销毁时间为空,表示取消销毁时间
* 修改按需服务器,设置定时删除时间。如果设置的定时删除时间为空字符串,表示取消定时删除
*
* 该接口支持企业项目细粒度权限的校验,具体细粒度请参见 ecs:cloudServers:put。
*
Expand Down
14 changes: 7 additions & 7 deletions Services/Ecs/V2/Model/NovaCreateServersOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class NovaCreateServersOption implements ModelInterface, ArrayAccess

/**
* Array of property to type mappings. Used for (de)serialization
* autoTerminateTime 弹性云服务器自动释放时间。 时间格式例如:2020-01-19T03:30:52Z
* autoTerminateTime 弹性云服务器定时删除时间。 时间格式例如:2020-01-19T03:30:52Z
* imageRef 镜像ID或者镜像资源的URL。 - 镜像ID示例:3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 镜像URL示例:http://glance.openstack.example.com/images/3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 指定卷作为系统卷创弹性云服务器时,不需填写该参数;非卷创建弹性云服务器时需填写有效的UUID参数,否则API将返回400错误。 > 说明: > - 对于部分规格的弹性云服务器,不能支持公有云平台提供的所有公共镜像。具体规格的镜像支持列表,请登录管理控制台,以“创建弹性云服务器”页面系统自动过滤的镜像信息为准,并在镜像服务页面查询镜像ID。 > - 如果创建失败,请尝试修改参数配置。
* flavorRef 规格ID或URL。
* name 弹性云服务器名称,长度大于0小于256字节。 > 说明: > > 云服务器内部主机名(hostname)命名规则遵循 [RFC 952](https://tools.ietf.org/html/rfc952)和[RFC 1123](https://tools.ietf.org/html/rfc1123)命名规范,建议使用a-zA-z或0-9以及中划线\"-\"组成的名称命名,\"_\"将在弹性云服务器内部默认转化为\"-\"。
Expand Down Expand Up @@ -64,7 +64,7 @@ class NovaCreateServersOption implements ModelInterface, ArrayAccess

/**
* Array of property to format mappings. Used for (de)serialization
* autoTerminateTime 弹性云服务器自动释放时间。 时间格式例如:2020-01-19T03:30:52Z
* autoTerminateTime 弹性云服务器定时删除时间。 时间格式例如:2020-01-19T03:30:52Z
* imageRef 镜像ID或者镜像资源的URL。 - 镜像ID示例:3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 镜像URL示例:http://glance.openstack.example.com/images/3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 指定卷作为系统卷创弹性云服务器时,不需填写该参数;非卷创建弹性云服务器时需填写有效的UUID参数,否则API将返回400错误。 > 说明: > - 对于部分规格的弹性云服务器,不能支持公有云平台提供的所有公共镜像。具体规格的镜像支持列表,请登录管理控制台,以“创建弹性云服务器”页面系统自动过滤的镜像信息为准,并在镜像服务页面查询镜像ID。 > - 如果创建失败,请尝试修改参数配置。
* flavorRef 规格ID或URL。
* name 弹性云服务器名称,长度大于0小于256字节。 > 说明: > > 云服务器内部主机名(hostname)命名规则遵循 [RFC 952](https://tools.ietf.org/html/rfc952)和[RFC 1123](https://tools.ietf.org/html/rfc1123)命名规范,建议使用a-zA-z或0-9以及中划线\"-\"组成的名称命名,\"_\"将在弹性云服务器内部默认转化为\"-\"。
Expand Down Expand Up @@ -129,7 +129,7 @@ public static function openAPIFormats()
/**
* Array of attributes where the key is the local name,
* and the value is the original name
* autoTerminateTime 弹性云服务器自动释放时间。 时间格式例如:2020-01-19T03:30:52Z
* autoTerminateTime 弹性云服务器定时删除时间。 时间格式例如:2020-01-19T03:30:52Z
* imageRef 镜像ID或者镜像资源的URL。 - 镜像ID示例:3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 镜像URL示例:http://glance.openstack.example.com/images/3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 指定卷作为系统卷创弹性云服务器时,不需填写该参数;非卷创建弹性云服务器时需填写有效的UUID参数,否则API将返回400错误。 > 说明: > - 对于部分规格的弹性云服务器,不能支持公有云平台提供的所有公共镜像。具体规格的镜像支持列表,请登录管理控制台,以“创建弹性云服务器”页面系统自动过滤的镜像信息为准,并在镜像服务页面查询镜像ID。 > - 如果创建失败,请尝试修改参数配置。
* flavorRef 规格ID或URL。
* name 弹性云服务器名称,长度大于0小于256字节。 > 说明: > > 云服务器内部主机名(hostname)命名规则遵循 [RFC 952](https://tools.ietf.org/html/rfc952)和[RFC 1123](https://tools.ietf.org/html/rfc1123)命名规范,建议使用a-zA-z或0-9以及中划线\"-\"组成的名称命名,\"_\"将在弹性云服务器内部默认转化为\"-\"。
Expand Down Expand Up @@ -173,7 +173,7 @@ public static function openAPIFormats()

/**
* Array of attributes to setter functions (for deserialization of responses)
* autoTerminateTime 弹性云服务器自动释放时间。 时间格式例如:2020-01-19T03:30:52Z
* autoTerminateTime 弹性云服务器定时删除时间。 时间格式例如:2020-01-19T03:30:52Z
* imageRef 镜像ID或者镜像资源的URL。 - 镜像ID示例:3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 镜像URL示例:http://glance.openstack.example.com/images/3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 指定卷作为系统卷创弹性云服务器时,不需填写该参数;非卷创建弹性云服务器时需填写有效的UUID参数,否则API将返回400错误。 > 说明: > - 对于部分规格的弹性云服务器,不能支持公有云平台提供的所有公共镜像。具体规格的镜像支持列表,请登录管理控制台,以“创建弹性云服务器”页面系统自动过滤的镜像信息为准,并在镜像服务页面查询镜像ID。 > - 如果创建失败,请尝试修改参数配置。
* flavorRef 规格ID或URL。
* name 弹性云服务器名称,长度大于0小于256字节。 > 说明: > > 云服务器内部主机名(hostname)命名规则遵循 [RFC 952](https://tools.ietf.org/html/rfc952)和[RFC 1123](https://tools.ietf.org/html/rfc1123)命名规范,建议使用a-zA-z或0-9以及中划线\"-\"组成的名称命名,\"_\"将在弹性云服务器内部默认转化为\"-\"。
Expand Down Expand Up @@ -217,7 +217,7 @@ public static function openAPIFormats()

/**
* Array of attributes to getter functions (for serialization of requests)
* autoTerminateTime 弹性云服务器自动释放时间。 时间格式例如:2020-01-19T03:30:52Z
* autoTerminateTime 弹性云服务器定时删除时间。 时间格式例如:2020-01-19T03:30:52Z
* imageRef 镜像ID或者镜像资源的URL。 - 镜像ID示例:3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 镜像URL示例:http://glance.openstack.example.com/images/3b8d6fef-af77-42ab-b8b7-5a7f0f0af8f2 - 指定卷作为系统卷创弹性云服务器时,不需填写该参数;非卷创建弹性云服务器时需填写有效的UUID参数,否则API将返回400错误。 > 说明: > - 对于部分规格的弹性云服务器,不能支持公有云平台提供的所有公共镜像。具体规格的镜像支持列表,请登录管理控制台,以“创建弹性云服务器”页面系统自动过滤的镜像信息为准,并在镜像服务页面查询镜像ID。 > - 如果创建失败,请尝试修改参数配置。
* flavorRef 规格ID或URL。
* name 弹性云服务器名称,长度大于0小于256字节。 > 说明: > > 云服务器内部主机名(hostname)命名规则遵循 [RFC 952](https://tools.ietf.org/html/rfc952)和[RFC 1123](https://tools.ietf.org/html/rfc1123)命名规范,建议使用a-zA-z或0-9以及中划线\"-\"组成的名称命名,\"_\"将在弹性云服务器内部默认转化为\"-\"。
Expand Down Expand Up @@ -411,7 +411,7 @@ public function valid()

/**
* Gets autoTerminateTime
* 弹性云服务器自动释放时间。 时间格式例如:2020-01-19T03:30:52Z
* 弹性云服务器定时删除时间。 时间格式例如:2020-01-19T03:30:52Z
*
* @return string|null
*/
Expand All @@ -423,7 +423,7 @@ public function getAutoTerminateTime()
/**
* Sets autoTerminateTime
*
* @param string|null $autoTerminateTime 弹性云服务器自动释放时间。 时间格式例如:2020-01-19T03:30:52Z
* @param string|null $autoTerminateTime 弹性云服务器定时删除时间。 时间格式例如:2020-01-19T03:30:52Z
*
* @return $this
*/
Expand Down
Loading

0 comments on commit 2694d5f

Please sign in to comment.