Skip to content

Commit 949ac57

Browse files
Ernesto J. Pama Jrhaphan
authored andcommitted
Proposed microversion implementation
1 parent d7bf04e commit 949ac57

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/Common/Service/Builder.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public function createService(string $namespace, array $serviceOptions = []): Se
8383

8484
list($apiClass, $serviceClass) = $this->getClasses($namespace);
8585

86+
/** @var Client $client */
87+
$client = $options['httpClient'];
88+
8689
return new $serviceClass($options['httpClient'], new $apiClass());
8790
}
8891

@@ -97,9 +100,15 @@ private function stockHttpClient(array &$options, string $serviceName)
97100
$stack = $this->getStack($options['authHandler'], $token);
98101
}
99102

103+
$microversion = null;
104+
if (isset($options['microversion'])) {
105+
$microversion = $options['microversion'];
106+
}
107+
dump($microversion);
108+
100109
$this->addDebugMiddleware($options, $stack);
101110

102-
$options['httpClient'] = $this->httpClient($baseUrl, $stack);
111+
$options['httpClient'] = $this->httpClient($baseUrl, $stack, $microversion);
103112
}
104113
}
105114

@@ -137,17 +146,20 @@ private function getStack(callable $authHandler, Token $token = null): HandlerSt
137146
return $stack;
138147
}
139148

140-
private function httpClient(string $baseUrl, HandlerStack $stack): ClientInterface
149+
private function httpClient(string $baseUrl, HandlerStack $stack, string $microversion = null): ClientInterface
141150
{
142151
$clientOptions = [
143152
'base_uri' => Utils::normalizeUrl($baseUrl),
144153
'handler' => $stack,
145154
];
146155

156+
if ($microversion) {
157+
$clientOptions['headers']['X-OpenStack-Nova-API-Version'] = $microversion;
158+
}
159+
147160
if (isset($this->globalOptions['requestOptions'])) {
148161
$clientOptions = array_merge($this->globalOptions['requestOptions'], $clientOptions);
149162
}
150-
151163
return new Client($clientOptions);
152164
}
153165

src/Compute/v2/Api.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ public function getKeypair(): array
600600
'method' => 'GET',
601601
'path' => 'os-keypairs/{name}',
602602
'params' => [
603-
'name' => $this->isRequired($this->params->keypairName())
603+
'name' => $this->isRequired($this->params->keypairName()),
604+
'userId' => $this->isRequired($this->params->userId())
604605
],
605606
];
606607
}
@@ -610,7 +611,9 @@ public function getKeypairs(): array
610611
return [
611612
'method' => 'GET',
612613
'path' => 'os-keypairs',
613-
'params' => [],
614+
'params' => [
615+
'userId' => $this->params->userId()
616+
],
614617
];
615618
}
616619

src/Compute/v2/Params.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,15 @@ public function keypairName(): array
451451
];
452452
}
453453

454+
public function userId(): array
455+
{
456+
return [
457+
'type' => self::STRING_TYPE,
458+
'sentAs' => 'user_id',
459+
'location' => self::URL
460+
];
461+
}
462+
454463
public function flavorRam(): array
455464
{
456465
return [

0 commit comments

Comments
 (0)