Skip to content

Commit 92f8acb

Browse files
author
Jamie Hannaford
authored
Merge pull request #65 from haphan/common-merge
[rfr] Merge php-opencloud/common
2 parents f14f84d + 0eb107c commit 92f8acb

File tree

210 files changed

+6174
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+6174
-304
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"name": "Jamie Hannaford",
66
"email": "jamie.hannaford@rackspace.com",
77
"homepage" : "https://github.com/jamiehannaford"
8+
},
9+
{
10+
"name": "Ha Phan",
11+
"email": "thanhha.work@gmail.com",
12+
"homepage" : "https://github.com/haphan"
813
}
914
],
1015
"autoload": {
@@ -25,7 +30,9 @@
2530
}
2631
],
2732
"require": {
28-
"php-opencloud/common": "^1.0.5"
33+
"php": "~7.0",
34+
"guzzlehttp/guzzle": "~6.1",
35+
"justinrainbow/json-schema": "~1.3"
2936
},
3037
"require-dev": {
3138
"phpunit/phpunit": "~4.0",

src/BlockStorage/v2/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace OpenStack\BlockStorage\v2;
44

5-
use OpenCloud\Common\Api\AbstractApi;
5+
use OpenStack\Common\Api\AbstractApi;
66

77
class Api extends AbstractApi
88
{

src/BlockStorage/v2/Models/Snapshot.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace OpenStack\BlockStorage\v2\Models;
44

5-
use OpenCloud\Common\Resource\OperatorResource;
6-
use OpenCloud\Common\Resource\Creatable;
7-
use OpenCloud\Common\Resource\Deletable;
8-
use OpenCloud\Common\Resource\HasMetadata;
9-
use OpenCloud\Common\Resource\HasWaiterTrait;
10-
use OpenCloud\Common\Resource\Listable;
11-
use OpenCloud\Common\Resource\Retrievable;
12-
use OpenCloud\Common\Resource\Updateable;
13-
use OpenCloud\Common\Transport\Utils;
5+
use OpenStack\Common\Resource\OperatorResource;
6+
use OpenStack\Common\Resource\Creatable;
7+
use OpenStack\Common\Resource\Deletable;
8+
use OpenStack\Common\Resource\HasMetadata;
9+
use OpenStack\Common\Resource\HasWaiterTrait;
10+
use OpenStack\Common\Resource\Listable;
11+
use OpenStack\Common\Resource\Retrievable;
12+
use OpenStack\Common\Resource\Updateable;
13+
use OpenStack\Common\Transport\Utils;
1414
use Psr\Http\Message\ResponseInterface;
1515

1616
/**

src/BlockStorage/v2/Models/Volume.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php declare (strict_types=1);
22
namespace OpenStack\BlockStorage\v2\Models;
33

4-
use OpenCloud\Common\Resource\OperatorResource;
5-
use OpenCloud\Common\Resource\Creatable;
6-
use OpenCloud\Common\Resource\Deletable;
7-
use OpenCloud\Common\Resource\HasMetadata;
8-
use OpenCloud\Common\Resource\HasWaiterTrait;
9-
use OpenCloud\Common\Resource\Listable;
10-
use OpenCloud\Common\Resource\Retrievable;
11-
use OpenCloud\Common\Resource\Updateable;
12-
use OpenCloud\Common\Transport\Utils;
4+
use OpenStack\Common\Resource\OperatorResource;
5+
use OpenStack\Common\Resource\Creatable;
6+
use OpenStack\Common\Resource\Deletable;
7+
use OpenStack\Common\Resource\HasMetadata;
8+
use OpenStack\Common\Resource\HasWaiterTrait;
9+
use OpenStack\Common\Resource\Listable;
10+
use OpenStack\Common\Resource\Retrievable;
11+
use OpenStack\Common\Resource\Updateable;
12+
use OpenStack\Common\Transport\Utils;
1313
use Psr\Http\Message\ResponseInterface;
1414

1515
/**

src/BlockStorage/v2/Models/VolumeAttachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php declare (strict_types=1);
22
namespace OpenStack\BlockStorage\v2\Models;
33

4-
use OpenCloud\Common\Resource\Listable;
5-
use OpenCloud\Common\Resource\OperatorResource;
4+
use OpenStack\Common\Resource\Listable;
5+
use OpenStack\Common\Resource\OperatorResource;
66

77
/**
88
* @property \OpenStack\BlockStorage\v2\Api $api

src/BlockStorage/v2/Models/VolumeType.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace OpenStack\BlockStorage\v2\Models;
44

5-
use OpenCloud\Common\Resource\OperatorResource;
6-
use OpenCloud\Common\Resource\Creatable;
7-
use OpenCloud\Common\Resource\Deletable;
8-
use OpenCloud\Common\Resource\Listable;
9-
use OpenCloud\Common\Resource\Updateable;
5+
use OpenStack\Common\Resource\OperatorResource;
6+
use OpenStack\Common\Resource\Creatable;
7+
use OpenStack\Common\Resource\Deletable;
8+
use OpenStack\Common\Resource\Listable;
9+
use OpenStack\Common\Resource\Updateable;
1010

1111
/**
1212
* @property \OpenStack\BlockStorage\v2\Api $api

src/BlockStorage/v2/Params.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace OpenStack\BlockStorage\v2;
44

5-
use OpenCloud\Common\Api\AbstractParams;
5+
use OpenStack\Common\Api\AbstractParams;
66

77
class Params extends AbstractParams
88
{

src/BlockStorage/v2/Service.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use OpenStack\BlockStorage\v2\Models\Snapshot;
66
use OpenStack\BlockStorage\v2\Models\Volume;
77
use OpenStack\BlockStorage\v2\Models\VolumeType;
8-
use OpenCloud\Common\Service\AbstractService;
8+
use OpenStack\Common\Service\AbstractService;
99

1010
/**
1111
* @property \OpenStack\BlockStorage\v2\Api $api

src/Common/Api/AbstractApi.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare (strict_types = 1);
2+
3+
namespace OpenStack\Common\Api;
4+
5+
abstract class AbstractApi implements ApiInterface
6+
{
7+
protected $params;
8+
9+
protected function isRequired(array $param): array
10+
{
11+
return array_merge($param, ['required' => true]);
12+
}
13+
14+
protected function notRequired(array $param): array
15+
{
16+
return array_merge($param, ['required' => false]);
17+
}
18+
19+
protected function query(array $param): array
20+
{
21+
return array_merge($param, ['location' => AbstractParams::QUERY]);
22+
}
23+
24+
protected function url(array $param): array
25+
{
26+
return array_merge($param, ['location' => AbstractParams::URL]);
27+
}
28+
29+
public function documented(array $param): array
30+
{
31+
return array_merge($param, ['required' => true]);
32+
}
33+
}

src/Common/Api/AbstractParams.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php declare (strict_types=1);
2+
3+
namespace OpenStack\Common\Api;
4+
5+
abstract class AbstractParams
6+
{
7+
// locations
8+
const QUERY = 'query';
9+
const HEADER = 'header';
10+
const URL = 'url';
11+
const JSON = 'json';
12+
const RAW = 'raw';
13+
14+
// types
15+
const STRING_TYPE = "string";
16+
const BOOL_TYPE = "boolean";
17+
const BOOLEAN_TYPE = self::BOOL_TYPE;
18+
const OBJECT_TYPE = "object";
19+
const ARRAY_TYPE = "array";
20+
const NULL_TYPE = "NULL";
21+
const INT_TYPE = 'integer';
22+
const INTEGER_TYPE = self::INT_TYPE;
23+
24+
public static function isSupportedLocation(string $val): bool
25+
{
26+
return in_array($val, [self::QUERY, self::HEADER, self::URL, self::JSON, self::RAW]);
27+
}
28+
29+
public function limit(): array
30+
{
31+
return [
32+
'type' => self::INT_TYPE,
33+
'location' => 'query',
34+
'description' => <<<DESC
35+
This will limit the total amount of elements returned in a list up to the number specified. For example, specifying a
36+
limit of 10 will return 10 elements, regardless of the actual count.
37+
DESC
38+
];
39+
}
40+
41+
public function marker(): array
42+
{
43+
return [
44+
'type' => 'string',
45+
'location' => 'query',
46+
'description' => <<<DESC
47+
Specifying a marker will begin the list from the value specified. Elements will have a particular attribute that
48+
identifies them, such as a name or ID. The marker value will search for an element whose identifying attribute matches
49+
the marker value, and begin the list from there.
50+
DESC
51+
];
52+
}
53+
54+
public function id(string $type): array
55+
{
56+
return [
57+
'description' => sprintf("The unique ID, or identifier, for the %s", $type),
58+
'type' => self::STRING_TYPE,
59+
'location' => self::JSON,
60+
];
61+
}
62+
63+
public function idPath(): array
64+
{
65+
return [
66+
'type' => self::STRING_TYPE,
67+
'location' => self::URL,
68+
'description' => 'The unique ID of the resource',
69+
];
70+
}
71+
72+
public function name(string $resource): array
73+
{
74+
return [
75+
'description' => sprintf("The name of the %s", $resource),
76+
'type' => self::STRING_TYPE,
77+
'location' => self::JSON,
78+
];
79+
}
80+
81+
82+
public function sortDir(): array
83+
{
84+
return [
85+
'type' => self::STRING_TYPE,
86+
'location' => self::QUERY,
87+
'description' => "Sorts by one or more sets of attribute and sort direction combinations.",
88+
'enum' => ['asc', 'desc']
89+
];
90+
}
91+
92+
public function sortKey(): array
93+
{
94+
return [
95+
'type' => self::STRING_TYPE,
96+
'location' => self::QUERY,
97+
'description' => "Sorts by one or more sets of attribute and sort direction combinations.",
98+
];
99+
}
100+
}

0 commit comments

Comments
 (0)