module Aws module Api module Customizations @apis = {} @docs = {} @plugins = {} class << self def api(prefix, &block) @apis[prefix] = block end def doc(prefix, &block) @docs[prefix] = block end def plugins(prefix, options) @plugins[prefix] = { add: options[:add] || [], remove: options[:remove] || [], } end def apply_api_customizations(api) metadata = api['metadata'] || {} prefix = metadata['serviceFullName'] # event stream is not supported at V2 api = exclude_eventstream(api) if api['operations'] @apis[prefix].call(api) if @apis[prefix] end def apply_doc_customizations(api, docs) prefix = api.metadata['serviceFullName'] @docs[prefix].call(docs) if @docs[prefix] end def apply_plugins(client_class) prefix = client_class.api.metadata['serviceFullName'] if @plugins[prefix] @plugins[prefix][:add].each { |p| client_class.add_plugin(p) } @plugins[prefix][:remove].each { |p| client_class.remove_plugin(p) } end end private def exclude_eventstream(api) api['operations'].each do |name, ref| inbound = ref['input'] && is_eventstream?(api, ref['input']['shape']) outbound = ref['output'] && is_eventstream?(api, ref['output']['shape']) api['operations'].delete(name) if !!inbound || !!outbound end api end def is_eventstream?(api, shape_name) shape = api['shapes'][shape_name] if shape['type'] == 'structure' && shape['payload'] payload_ref = shape['members'][shape['payload']] api['shapes'][payload_ref['shape']]['eventstream'] else # non structure request/response shape # check if it's eventstream itself shape['eventstream'] end end end plugins('Amazon API Gateway', add: %w(Aws::Plugins::APIGatewayHeader), ) api('Amazon CloudFront') do |api| api['shapes'].each do |_, shape| if shape['members'] && shape['members']['MaxItems'] shape['members']['MaxItems']['shape'] = 'integer' end end api['operations'].keys.each do |name| symbolized = name.sub(/\d{4}_\d{2}_\d{2}$/, '') api['operations'][symbolized] = api['operations'].delete(name) end end plugins('Amazon CloudSearch Domain', add: %w(Aws::Plugins::CSDConditionalSigning Aws::Plugins::CSDSwitchToPost), remove: %w(Aws::Plugins::RegionalEndpoint), ) plugins('Amazon DynamoDB', add: %w( Aws::Plugins::DynamoDBExtendedRetries Aws::Plugins::DynamoDBSimpleAttributes Aws::Plugins::DynamoDBCRC32Validation )) api('Amazon Elastic Compute Cloud') do |api| if ENV['DOCSTRINGS'] members = api['shapes']['CopySnapshotRequest']['members'] members.delete('DestinationRegion') members.delete('PresignedUrl') end end plugins('Amazon Elastic Compute Cloud', add: %w( Aws::Plugins::EC2CopyEncryptedSnapshot Aws::Plugins::EC2RegionValidation )) api('Amazon Glacier') do |api| api['shapes']['Timestamp'] = { 'type' => 'timestamp', 'timestampFormat' => 'iso8601', } api['shapes'].each do |_, shape| if shape['members'] shape['members'].each do |name, ref| case name when /date/i then ref['shape'] = 'Timestamp' when 'limit' then ref['shape'] = 'Size' when 'partSize' then ref['shape'] = 'Size' when 'archiveSize' then ref['shape'] = 'Size' end end end end end plugins('Amazon Glacier', add: %w( Aws::Plugins::GlacierAccountId Aws::Plugins::GlacierApiVersion Aws::Plugins::GlacierChecksums )) api('AWS Import/Export') do |api| api['operations'].each do |_, operation| operation['http']['requestUri'] = '/' end end api('AWS IoT Data Plane') do |api| api['metadata'].delete('endpointPrefix') end api('AWS Lambda') do |api| api['shapes']['Timestamp']['type'] = 'timestamp' end doc('AWS Lambda') do |docs| docs['shapes']['Blob']['refs']['UpdateFunctionCodeRequest$ZipFile'] = "
.zip file containing your packaged source code.
" end plugins('Amazon Machine Learning', add: %w( Aws::Plugins::MachineLearningPredictEndpoint )) api('Amazon Route 53') do |api| api['shapes']['PageMaxItems']['type'] = 'integer' end plugins('Amazon Route 53', add: %w( Aws::Plugins::Route53IdFix )) plugins('Amazon Relational Database Service', add: %w( Aws::Plugins::RDSCrossRegionCopying )) api('Amazon Relational Database Service') do |api| api['shapes']['CopyDBSnapshotMessage']['members']['DestinationRegion'] = {"shape" => "String"} api['shapes']['CreateDBInstanceReadReplicaMessage']['members']['DestinationRegion'] = {"shape" => "String"} api['shapes']['CopyDBClusterSnapshotMessage']['members']['DestinationRegion'] = {"shape" => "String"} api['shapes']['CreateDBClusterMessage']['members']['DestinationRegion'] = {"shape" => "String"} api['shapes']['CopyDBSnapshotMessage']['members']['SourceRegion'] = {"shape" => "String"} api['shapes']['CreateDBInstanceReadReplicaMessage']['members']['SourceRegion'] = {"shape" => "String"} api['shapes']['CopyDBClusterSnapshotMessage']['members']['SourceRegion'] = {"shape" => "String"} api['shapes']['CreateDBClusterMessage']['members']['SourceRegion'] = {"shape" => "String"} end doc('Amazon Relational Database Service') do |docs| docs['shapes']['String']['refs']['CopyDBSnapshotMessage$SourceRegion'] = "The region which you are copying an encrypted snapshot from.
" + "This is a required paramter that allows SDK to compute a pre-signed Url and" +
" populate PreSignedURL
parameter on your behalf.
The region which you are copying an encrypted snapshot from.
" + "This is a required paramter that allows SDK to compute a pre-signed Url and" +
" populate PreSignedURL
parameter on your behalf.
The region which you are copying an encrypted snapshot from.
" + "This is a required paramter that allows SDK to compute a pre-signed Url and" +
" populate PreSignedURL
parameter on your behalf.
The region which you are copying an encrypted snapshot from.
" + "This is a required paramter that allows SDK to compute a pre-signed Url and" +
" populate PreSignedURL
parameter on your behalf.