Skip to content

Commit 26062d1

Browse files
authored
Implement support for the host prefix in operations (#1514)
* Implement support for the host prefix in operations This is needed to have a working implementation of LocationService. * Keep the original query string when possible
1 parent 3bd2f0e commit 26062d1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Definition/Operation.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ public function isEndpointOperation(): bool
203203
return $this->data['endpointoperation'] ?? false;
204204
}
205205

206+
public function getHostPrefix(): ?string
207+
{
208+
return $this->data['endpoint']['hostPrefix'] ?? null;
209+
}
210+
206211
private function getInputShape(): Shape
207212
{
208213
if (isset($this->data['input']['shape'])) {

src/Generator/InputGenerator.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,16 @@ private function inputClassRequestGetters(StructureShape $inputShape, ClassBuild
515515
}
516516
}
517517

518+
$hostPrefixArgument = '';
519+
if (null !== $hostPrefix = $operation->getHostPrefix()) {
520+
if (preg_match('/\{([a-zA-Z0-9]+)}/', $hostPrefix)) {
521+
throw new \InvalidArgumentException('Parameters are not supported in host prefix yet.');
522+
}
523+
524+
$this->requirementsRegistry->addRequirement('async-aws/core', '^1.20');
525+
$hostPrefixArgument = ', ' . var_export($hostPrefix, true);
526+
}
527+
518528
$body['uri'] .= '$uriString = ' . $uriStringCode . ';';
519529

520530
$method = var_export($operation->getHttpMethod(), true);
@@ -534,7 +544,7 @@ private function inputClassRequestGetters(StructureShape $inputShape, ClassBuild
534544
{$body['body']}
535545
536546
// Return the Request
537-
return new Request($method, \$uriString, \$query, \$headers, StreamFactory::create(\$body));
547+
return new Request($method, \$uriString, \$query, \$headers, StreamFactory::create(\$body)$hostPrefixArgument);
538548
PHP
539549
);
540550
}

0 commit comments

Comments
 (0)