private function buildEndpoint(Operation $operation, array $args, array $opts)
 {
     $varspecs = [];
     // Create an associative array of varspecs used in expansions
     foreach ($operation->getInput()->getMembers() as $name => $member) {
         if ($member['location'] == 'uri') {
             $varspecs[$member['locationName'] ?: $name] = isset($args[$name]) ? $args[$name] : null;
         }
     }
     $relative = preg_replace_callback('/\\{([^\\}]+)\\}/', function (array $matches) use($varspecs) {
         $isGreedy = substr($matches[1], -1, 1) == '+';
         $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]);
         }
     }, $operation['http']['requestUri']);
     // Add the query string variables or appending to one if needed.
     if (!empty($opts['query'])) {
         $append = Psr7\build_query($opts['query']);
         $relative .= strpos($relative, '?') ? "&{$append}" : "?{$append}";
     }
     // Expand path place holders using Amazon's slightly different URI
     // template syntax.
     return Psr7\Uri::resolve($this->endpoint, $relative);
 }
 /**
  * Builds the URI template for a REST based request.
  *
  * @param Operation $operation
  * @param array     $args
  *
  * @return array
  */
 private function buildEndpoint(Operation $operation, array $args)
 {
     $varspecs = [];
     // Create an associative array of varspecs used in expansions
     foreach ($operation->getInput()->getMembers() as $name => $member) {
         if ($member['location'] == 'uri') {
             $varspecs[$member['locationName'] ?: $name] = isset($args[$name]) ? $args[$name] : null;
         }
     }
     // Expand path place holders using Amazon's slightly different URI
     // template syntax.
     return $this->endpoint->combine(preg_replace_callback('/\\{([^\\}]+)\\}/', function (array $matches) use($varspecs) {
         $isGreedy = substr($matches[1], -1, 1) == '+';
         $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]);
         }
     }, $operation['http']['requestUri']));
 }