Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -83,8 +83,8 @@ class Operation extends AbstractModel
{
if ($this->errors === null) {
if ($errors = $this['errors']) {
foreach ($errors as &$error) {
$error = $this->shapeFor($error);
foreach ($errors as $key => $error) {
$errors[$key] = $this->shapeFor($error);
}
$this->errors = $errors;
} else {

View File

@@ -13,6 +13,7 @@ use Psr\Http\Message\ResponseInterface;
*/
abstract class AbstractRestParser extends AbstractParser
{
use PayloadParserTrait;
/**
* Parses a payload from a response.
*
@@ -109,6 +110,10 @@ abstract class AbstractRestParser extends AbstractParser
break;
case 'timestamp':
try {
if (!empty($shape['timestampFormat'])
&& $shape['timestampFormat'] === 'unixTimestamp') {
$value = DateTimeResult::fromEpoch($value);
}
$value = new DateTimeResult($value);
break;
} catch (\Exception $e) {
@@ -116,6 +121,11 @@ abstract class AbstractRestParser extends AbstractParser
// output structure.
return;
}
case 'string':
if ($shape['jsonvalue']) {
$value = $this->parseJson(base64_decode($value));
}
break;
}
$result[$name] = $value;

View File

@@ -43,6 +43,10 @@ class JsonParser
return $target;
case 'timestamp':
if (!empty($shape['timestampFormat'])
&& $shape['timestampFormat'] !== 'unixTimestamp') {
return new DateTimeResult($value);
}
// The Unix epoch (or Unix time or POSIX time or Unix
// timestamp) is the number of seconds that have elapsed since
// January 1, 1970 (midnight UTC/GMT).

View File

@@ -124,11 +124,15 @@ class XmlParser
private function parse_boolean(Shape $shape, $value)
{
return $value == 'true' ? true : false;
return $value == 'true';
}
private function parse_timestamp(Shape $shape, $value)
{
if (!empty($shape['timestampFormat'])
&& $shape['timestampFormat'] === 'unixTimestamp') {
return DateTimeResult::fromEpoch((string) $value);
}
return new DateTimeResult($value);
}
}

View File

@@ -62,8 +62,8 @@ class JsonBody
case 'list':
$items = $shape->getMember();
foreach ($value as &$v) {
$v = $this->format($items, $v);
foreach ($value as $k => $v) {
$value[$k] = $this->format($items, $v);
}
return $value;
@@ -72,8 +72,8 @@ class JsonBody
return new \stdClass;
}
$values = $shape->getValue();
foreach ($value as &$v) {
$v = $this->format($values, $v);
foreach ($value as $k => $v) {
$value[$k] = $this->format($values, $v);
}
return $value;
@@ -81,7 +81,10 @@ class JsonBody
return base64_encode($value);
case 'timestamp':
return TimestampShape::format($value, 'unixTimestamp');
$timestampFormat = !empty($shape['timestampFormat'])
? $shape['timestampFormat']
: 'unixTimestamp';
return TimestampShape::format($value, $timestampFormat);
default:
return $value;

View File

@@ -144,7 +144,10 @@ class QueryParamBuilder
$prefix,
array &$query
) {
$query[$prefix] = TimestampShape::format($value, 'iso8601');
$timestampFormat = !empty($shape['timestampFormat'])
? $shape['timestampFormat']
: 'iso8601';
$query[$prefix] = TimestampShape::format($value, $timestampFormat);
}
protected function format_boolean(Shape $shape, $value, $prefix, array &$query)

View File

@@ -9,6 +9,8 @@ use Aws\Api\StructureShape;
use Aws\Api\TimestampShape;
use Aws\CommandInterface;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Uri;
use GuzzleHttp\Psr7\UriResolver;
use Psr\Http\Message\RequestInterface;
/**
@@ -121,8 +123,20 @@ abstract class RestSerializer
private function applyHeader($name, Shape $member, $value, array &$opts)
{
if ($member->getType() == 'timestamp') {
$value = TimestampShape::format($value, 'rfc822');
if ($member->getType() === 'timestamp') {
$timestampFormat = !empty($member['timestampFormat'])
? $member['timestampFormat']
: 'rfc822';
$value = TimestampShape::format($value, $timestampFormat);
}
if ($member['jsonvalue']) {
$value = json_encode($value);
if (empty($value) && JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException('Unable to encode the provided value'
. ' with \'json_encode\'. ' . json_last_error_msg());
}
$value = base64_encode($value);
}
$opts['headers'][$member['locationName'] ?: $name] = $value;
@@ -146,10 +160,16 @@ abstract class RestSerializer
? $opts['query'] + $value
: $value;
} elseif ($value !== null) {
if ($member->getType() === 'boolean') {
$type = $member->getType();
if ($type === 'boolean') {
$value = $value ? 'true' : 'false';
} elseif ($type === 'timestamp') {
$timestampFormat = !empty($member['timestampFormat'])
? $member['timestampFormat']
: 'iso8601';
$value = TimestampShape::format($value, $timestampFormat);
}
$opts['query'][$member['locationName'] ?: $name] = $value;
}
}
@@ -175,11 +195,13 @@ abstract class RestSerializer
$k = $isGreedy ? substr($matches[1], 0, -1) : $matches[1];
if (!isset($varspecs[$k])) {
return '';
} elseif ($isGreedy) {
return str_replace('%2F', '/', rawurlencode($varspecs[$k]));
} else {
return rawurlencode($varspecs[$k]);
}
if ($isGreedy) {
return str_replace('%2F', '/', rawurlencode($varspecs[$k]));
}
return rawurlencode($varspecs[$k]);
},
$operation['http']['requestUri']
);
@@ -192,6 +214,6 @@ abstract class RestSerializer
// Expand path place holders using Amazon's slightly different URI
// template syntax.
return Psr7\Uri::resolve($this->endpoint, $relative);
return UriResolver::resolve($this->endpoint, new Uri($relative));
}
}

View File

@@ -38,7 +38,7 @@ class XmlBody
$xml = new XMLWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');
$this->format($shape, $shape['locationName'], $args, $xml);
$this->format($shape, $shape['locationName'] ?: $shape['name'], $args, $xml);
$xml->endDocument();
return $xml->outputMemory();
@@ -142,7 +142,7 @@ class XmlBody
$elementName = $items['locationName'] ?: 'member';
}
foreach ($value as &$v) {
foreach ($value as $v) {
$this->format($items, $elementName, $v, $xml);
}
@@ -187,7 +187,10 @@ class XmlBody
XMLWriter $xml
) {
$this->startElement($shape, $name, $xml);
$xml->writeRaw(TimestampShape::format($value, 'iso8601'));
$timestampFormat = !empty($shape['timestampFormat'])
? $shape['timestampFormat']
: 'iso8601';
$xml->writeRaw(TimestampShape::format($value, $timestampFormat));
$xml->endElement();
}

View File

@@ -43,10 +43,12 @@ class Service extends AbstractModel
], $defaultMeta = [
'apiVersion' => null,
'serviceFullName' => null,
'serviceId' => null,
'endpointPrefix' => null,
'signingName' => null,
'signatureVersion' => null,
'protocol' => null
'protocol' => null,
'uid' => null
];
$definition += $defaults;
@@ -86,7 +88,9 @@ class Service extends AbstractModel
if (isset($mapping[$proto])) {
return new $mapping[$proto]($api, $endpoint);
} elseif ($proto == 'ec2') {
}
if ($proto == 'ec2') {
return new QuerySerializer($api, $endpoint, new Ec2ParamBuilder());
}
@@ -139,7 +143,9 @@ class Service extends AbstractModel
$proto = $api->getProtocol();
if (isset($mapping[$proto])) {
return new $mapping[$proto]($api);
} elseif ($proto == 'ec2') {
}
if ($proto == 'ec2') {
return new QueryParser($api, null, false);
}
@@ -158,6 +164,16 @@ class Service extends AbstractModel
return $this->definition['metadata']['serviceFullName'];
}
/**
* Get the service id
*
* @return string
*/
public function getServiceId()
{
return $this->definition['metadata']['serviceId'];
}
/**
* Get the API version of the service
*
@@ -221,6 +237,16 @@ class Service extends AbstractModel
return $this->definition['metadata']['protocol'];
}
/**
* Get the uid string used by the service
*
* @return string
*/
public function getUid()
{
return $this->definition['metadata']['uid'];
}
/**
* Check if the description has a specific operation by name.
*
@@ -282,7 +308,9 @@ class Service extends AbstractModel
{
if (!$key) {
return $this['metadata'];
} elseif (isset($this->definition['metadata'][$key])) {
}
if (isset($this->definition['metadata'][$key])) {
return $this->definition['metadata'][$key];
}

View File

@@ -189,6 +189,14 @@ class Validator
private function check_string(Shape $shape, $value)
{
if ($shape['jsonvalue']) {
if (!self::canJsonEncode($value)) {
$this->addError('must be a value encodable with \'json_encode\'.'
. ' Found ' . Aws\describe_type($value));
}
return;
}
if (!$this->checkCanString($value)) {
$this->addError('must be a string or an object that implements '
. '__toString(). Found ' . Aws\describe_type($value));
@@ -257,4 +265,9 @@ class Validator
. ' '
. $message;
}
private function canJsonEncode($data)
{
return !is_resource($data);
}
}