Skip to content

Commit b8ab704

Browse files
Merge customizations for Bedrock Runtime
1 parent a87b593 commit b8ab704

File tree

10 files changed

+105
-59
lines changed

10 files changed

+105
-59
lines changed

apis/bedrock-runtime/2023-09-30/api-2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,4 +2173,4 @@
21732173
"min":1
21742174
}
21752175
}
2176-
}
2176+
}

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/client_operation_list.rb

Lines changed: 71 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,51 @@ def initialize(options)
1414
client_examples = options.fetch(:client_examples, {})
1515
paginators = options.fetch(:paginators, {})
1616
operation_waiters = Waiter.build_operations_map(options[:waiters])
17-
18-
@operations = api['operations'].inject([]) do |ops, (name, operation)|
17+
@operations = api['operations'].each_with_object([]) do |(name, operation), ops|
1918
method_name = Underscore.underscore(name)
2019
waiters = operation_waiters[method_name]
21-
2220
async_client = options[:async_client] || false
2321
es_output = AwsSdkCodeGenerator::Helper.eventstream_output?(operation, api)
2422
es_input = AwsSdkCodeGenerator::Helper.eventstream_input?(operation, api)
25-
if es_input || es_output
26-
# eventstreaming operations
27-
if protocol_settings['h2'] == 'eventstream'
28-
# h2 supported, only generate for async client
29-
if async_client
30-
if es_input == es_output
31-
# input & output eventstream sharing
32-
# same eventstream shape
33-
# see EventStreamModule
34-
es_input = "Input" + es_input
35-
es_output = "Output" + es_output
36-
end
23+
24+
if async_client
25+
if es_input || es_output
26+
if es_input == es_output
27+
# handle input & output eventstream sharing the same eventstream shape
28+
es_input = "Input" + es_input
29+
es_output = "Output" + es_output
30+
end
31+
32+
case protocol_settings['h2']
33+
when 'required'
34+
# When h2 is required, the operation must be sent over H2.
35+
raise NotImplementedError, 'H2 required is not implemented yet'
36+
when 'optional'
37+
# When h2 is optional, only bidirectional eventstreaming operations will be on the async client. Other
38+
# operations MAY be on the async client, but we currently do not do this. (They are disjoint).
39+
next unless es_input && es_output
40+
41+
ops << Operation.new(
42+
name: method_name,
43+
documentation: ClientOperationDocumentation.new(
44+
name: name,
45+
module_name: module_name,
46+
method_name: method_name,
47+
operation: operation,
48+
api: api,
49+
protocol: protocol,
50+
examples: examples,
51+
client_examples: client_examples[method_name] || [],
52+
async_client: true
53+
).to_s,
54+
streaming: AwsSdkCodeGenerator::Helper.operation_streaming?(operation, api),
55+
eventstream_output: es_output,
56+
eventstream_input: es_input
57+
)
58+
when 'eventstream'
59+
# When h2 is eventstream, all eventstream operations must be sent over H2. This includes all operations that
60+
# have any input OR output structures targeted with event traits. Other operations MAY use h2, but we
61+
# currently do not do this.
3762
ops << Operation.new(
3863
name: method_name,
3964
documentation: ClientOperationDocumentation.new(
@@ -52,8 +77,12 @@ def initialize(options)
5277
eventstream_input: es_input
5378
)
5479
end
55-
elsif !es_input && es_output && !async_client
56-
# http1.1 only support eventstream at output
80+
end
81+
else
82+
# We only support eventstream output on the sync client (http 1.1)
83+
# We arguably should not have this here (put it on the async client instead) however we must
84+
# keep doing so for backwards compatibility.
85+
if !es_input && es_output && protocol_settings['h2'] != 'eventstream'
5786
ops << Operation.new(
5887
name: method_name,
5988
documentation: ClientOperationDocumentation.new(
@@ -71,31 +100,29 @@ def initialize(options)
71100
eventstream_output: es_output,
72101
eventstream_input: false
73102
)
103+
# Bidirectional eventstreaming operations are not added to the sync client
104+
elsif !es_input && !es_output
105+
ops << Operation.new(
106+
name: method_name,
107+
documentation: ClientOperationDocumentation.new(
108+
name: name,
109+
module_name: module_name,
110+
method_name: method_name,
111+
operation: operation,
112+
api: api,
113+
protocol: protocol,
114+
examples: examples,
115+
client_examples: client_examples[method_name] || [],
116+
async_client: false,
117+
pager: paginators && paginators['pagination'][name],
118+
waiters: waiters
119+
).to_s,
120+
streaming: AwsSdkCodeGenerator::Helper.operation_streaming?(operation, api),
121+
eventstream_output: false,
122+
eventstream_input: false
123+
)
74124
end
75-
elsif !async_client
76-
# non streaming operations
77-
# generate at sync client only
78-
ops << Operation.new(
79-
name: method_name,
80-
documentation: ClientOperationDocumentation.new(
81-
name: name,
82-
module_name: module_name,
83-
method_name: method_name,
84-
operation: operation,
85-
api: api,
86-
protocol: protocol,
87-
examples: examples,
88-
client_examples: client_examples[method_name] || [],
89-
async_client: false,
90-
pager: paginators && paginators['pagination'][name],
91-
waiters: waiters
92-
).to_s,
93-
streaming: AwsSdkCodeGenerator::Helper.operation_streaming?(operation, api),
94-
eventstream_output: false,
95-
eventstream_input: false
96-
)
97125
end
98-
99126
ops
100127
end
101128
end
@@ -113,10 +140,10 @@ def initialize(options)
113140
@streaming = options.fetch(:streaming)
114141
@eventstream_output = !!options.fetch(:eventstream_output)
115142
@eventstream_input = !!options.fetch(:eventstream_input)
116-
@output_eventstream_member = @eventstream_output ?
117-
options.fetch(:eventstream_output) : nil
118-
@input_eventstream_member = @eventstream_input ?
119-
options.fetch(:eventstream_input) : nil
143+
@output_eventstream_member =
144+
@eventstream_output ? options.fetch(:eventstream_output) : nil
145+
@input_eventstream_member =
146+
@eventstream_input ? options.fetch(:eventstream_input) : nil
120147
@bidirectional = @eventstream_output && @eventstream_input
121148
end
122149

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/code_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def source_files(options = {})
7474
codegenerated_plugins.each { |p| y.yield(p.path, p.source) }
7575

7676
y.yield("#{prefix}/client.rb", client_class(codegenerated_plugins))
77-
if @service.protocol_settings['h2'] == 'eventstream'
77+
if @service.protocol_settings['h2']
7878
y.yield("#{prefix}/async_client.rb", async_client_class(codegenerated_plugins))
7979
end
8080
y.yield("#{prefix}/errors.rb", errors_module)

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/helper.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ def operation_streaming?(operation, api)
129129
end
130130

131131
def operation_eventstreaming?(operation, api)
132-
!!eventstream_input?(operation, api) ||
133-
!!eventstream_output?(operation, api)
132+
!!eventstream_input?(operation, api) || !!eventstream_output?(operation, api)
133+
end
134+
135+
def operation_bidirectional_eventstreaming?(operation, api)
136+
!!eventstream_input?(operation, api) && !!eventstream_output?(operation, api)
134137
end
135138

136139
def eventstream_output?(operation, api)
@@ -185,8 +188,7 @@ def gem_lib_path(gem_name)
185188
end
186189

187190
module_function :deep_copy, :operation_streaming?, :downcase_first, :wrap_string, :apig_prefix,
188-
:eventstream_output?, :eventstream_input?, :operation_eventstreaming?, :pascal_case,
189-
:gem_lib_path
190-
191+
:eventstream_output?, :eventstream_input?, :operation_eventstreaming?, :operation_bidirectional_eventstreaming?,
192+
:pascal_case, :gem_lib_path
191193
end
192194
end

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/client_api_module.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ def operations
259259
o.auth = operation['auth'] if operation.key?('auth')
260260
o.require_apikey = operation['requiresApiKey'] if operation.key?('requiresApiKey')
261261
o.pager = pager(operation_name)
262-
o.async = @service.protocol_settings['h2'] == 'eventstream' &&
263-
AwsSdkCodeGenerator::Helper.operation_eventstreaming?(operation, @service.api)
262+
o.async = async(operation)
264263
end
265264
end
266265
end
@@ -281,6 +280,20 @@ def apig_authorizer
281280
end
282281
end
283282

283+
def async(operation)
284+
# When h2 is eventstream, all eventstream operations must be sent over H2. This includes all operations that
285+
# have any input OR output structures targeted with event traits. Other operations MAY use h2, but we
286+
# currently do not do this.
287+
(@service.protocol_settings['h2'] == 'eventstream' &&
288+
AwsSdkCodeGenerator::Helper.operation_eventstreaming?(operation, @service.api)) ||
289+
# When h2 is optional, only bidirectional eventstreaming operations will be on the async client. Other
290+
# operations MAY be on the async client, but we currently do not do this. (They are disjoint).
291+
(@service.protocol_settings['h2'] == 'optional' &&
292+
AwsSdkCodeGenerator::Helper.operation_bidirectional_eventstreaming?(operation, @service.api)) ||
293+
# When h2 is required, the operation must be sent over H2.
294+
@service.protocol_settings['h2'] == 'required'
295+
end
296+
284297
def endpoint_operation
285298
@service.api['operations'].each do |name, ref|
286299
return underscore(name) if ref['endpointoperation']

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/service_module.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,11 @@ def autoloads
9797
paths << auto_load(path, resource_name)
9898
end
9999
end
100-
if @service.api['metadata']['protocolSettings'] &&
101-
@service.api['metadata']['protocolSettings']['h2'] == 'eventstream'
100+
101+
if @service.api['metadata']['protocolSettings'] && @service.api['metadata']['protocolSettings']['h2']
102102
paths << auto_load("#{@prefix}/async_client", :AsyncClient)
103-
paths << auto_load("#{@prefix}/event_streams", :EventStreams)
104-
elsif eventstream_shape?
105-
paths << auto_load("#{@prefix}/event_streams", :EventStreams)
106103
end
104+
paths << auto_load("#{@prefix}/event_streams", :EventStreams) if eventstream_shape?
107105

108106
paths
109107
end

build_tools/customizations.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def dynamodb_example_deep_transform(subsegment, keys)
6363
end
6464
end
6565

66+
api('BedrockRuntime') do |api|
67+
api['metadata']['protocolSettings'] = {'h2' => 'optional'}
68+
end
69+
6670
api('CloudFront') do |api|
6771
api['shapes'].each do |_, shape|
6872
if shape['members'] && shape['members']['MaxItems'] && shape['members']['MaxItems']['shape'] == 'string'

gems/aws-sdk-bedrockruntime/lib/aws-sdk-bedrockruntime.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module Plugins
5454
autoload :EndpointParameters, 'aws-sdk-bedrockruntime/endpoint_parameters'
5555
autoload :EndpointProvider, 'aws-sdk-bedrockruntime/endpoint_provider'
5656
autoload :Endpoints, 'aws-sdk-bedrockruntime/endpoints'
57+
autoload :AsyncClient, 'aws-sdk-bedrockruntime/async_client'
5758
autoload :EventStreams, 'aws-sdk-bedrockruntime/event_streams'
5859

5960
GEM_VERSION = '1.43.0'

gems/aws-sdk-bedrockruntime/lib/aws-sdk-bedrockruntime/client_api.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ module ClientApi
954954
"auth" => ["aws.auth#sigv4"],
955955
"endpointPrefix" => "bedrock-runtime",
956956
"protocol" => "rest-json",
957+
"protocolSettings" => {"h2"=>"optional"},
957958
"protocols" => ["rest-json"],
958959
"serviceFullName" => "Amazon Bedrock Runtime",
959960
"serviceId" => "Bedrock Runtime",

gems/aws-sdk-securityhub/lib/aws-sdk-securityhub/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5278,7 +5278,7 @@ def get_configuration_policy(params = {}, options = {})
52785278
# resp.to_h outputs the following:
52795279
# {
52805280
# association_status: "FAILED",
5281-
# association_status_message: "Configuration Policy a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 couldn\u2019t be applied to account 111122223333 in us-east-1 Region. Retry your request.",
5281+
# association_status_message: "Configuration Policy a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 couldn’t be applied to account 111122223333 in us-east-1 Region. Retry your request.",
52825282
# association_type: "INHERITED",
52835283
# configuration_policy_id: "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
52845284
# target_id: "111122223333",

0 commit comments

Comments
 (0)