/** * Applies the listeners needed to parse client models. * * @param Service $api API to create a parser for * @return callable * @throws \UnexpectedValueException */ public static function createParser(Service $api) { static $mapping = ['json' => 'Aws\\Api\\Parser\\JsonRpcParser', 'query' => 'Aws\\Api\\Parser\\QueryParser', 'rest-json' => 'Aws\\Api\\Parser\\RestJsonParser', 'rest-xml' => 'Aws\\Api\\Parser\\RestXmlParser']; $proto = $api->getProtocol(); if (isset($mapping[$proto])) { return new $mapping[$proto]($api); } elseif ($proto == 'ec2') { return new QueryParser($api, null, false); } throw new \UnexpectedValueException('Unknown protocol: ' . $api->getProtocol()); }
public static function _apply_api_provider($value, array &$args) { $api = new Service($value, $args['service'], $args['version']); $args['api'] = $api; $args['error_parser'] = Service::createErrorParser($api->getProtocol()); $args['serializer'] = Service::createSerializer($api, $args['endpoint']); }