aws-sdk-bedrockagentcore 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::BedrockAgentCore
11
+ # Endpoint parameters used to influence endpoints per request.
12
+ #
13
+ # @!attribute region
14
+ # The AWS region used to dispatch the request.
15
+ #
16
+ # @return [String]
17
+ #
18
+ # @!attribute use_dual_stack
19
+ # When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
20
+ #
21
+ # @return [Boolean]
22
+ #
23
+ # @!attribute use_fips
24
+ # When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
25
+ #
26
+ # @return [Boolean]
27
+ #
28
+ # @!attribute endpoint
29
+ # Override the endpoint used to send this request
30
+ #
31
+ # @return [String]
32
+ #
33
+ EndpointParameters = Struct.new(
34
+ :region,
35
+ :use_dual_stack,
36
+ :use_fips,
37
+ :endpoint,
38
+ ) do
39
+ include Aws::Structure
40
+
41
+ # @api private
42
+ class << self
43
+ PARAM_MAP = {
44
+ 'Region' => :region,
45
+ 'UseDualStack' => :use_dual_stack,
46
+ 'UseFIPS' => :use_fips,
47
+ 'Endpoint' => :endpoint,
48
+ }.freeze
49
+ end
50
+
51
+ def initialize(options = {})
52
+ self[:region] = options[:region]
53
+ self[:use_dual_stack] = options[:use_dual_stack]
54
+ self[:use_dual_stack] = false if self[:use_dual_stack].nil?
55
+ self[:use_fips] = options[:use_fips]
56
+ self[:use_fips] = false if self[:use_fips].nil?
57
+ self[:endpoint] = options[:endpoint]
58
+ end
59
+
60
+ def self.create(config, options={})
61
+ new({
62
+ region: config.region,
63
+ use_dual_stack: config.use_dualstack_endpoint,
64
+ use_fips: config.use_fips_endpoint,
65
+ endpoint: (config.endpoint.to_s unless config.regional_endpoint),
66
+ }.merge(options))
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::BedrockAgentCore
11
+ class EndpointProvider
12
+ def resolve_endpoint(parameters)
13
+ if Aws::Endpoints::Matchers.set?(parameters.endpoint)
14
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
15
+ raise ArgumentError, "Invalid Configuration: FIPS and custom endpoint are not supported"
16
+ end
17
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_dual_stack, true)
18
+ raise ArgumentError, "Invalid Configuration: Dualstack and custom endpoint are not supported"
19
+ end
20
+ return Aws::Endpoints::Endpoint.new(url: parameters.endpoint, headers: {}, properties: {})
21
+ end
22
+ if Aws::Endpoints::Matchers.set?(parameters.region)
23
+ if (partition_result = Aws::Endpoints::Matchers.aws_partition(parameters.region))
24
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true) && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_dual_stack, true)
25
+ if Aws::Endpoints::Matchers.boolean_equals?(true, Aws::Endpoints::Matchers.attr(partition_result, "supportsFIPS")) && Aws::Endpoints::Matchers.boolean_equals?(true, Aws::Endpoints::Matchers.attr(partition_result, "supportsDualStack"))
26
+ return Aws::Endpoints::Endpoint.new(url: "https://bedrock-agentcore-fips.#{parameters.region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
27
+ end
28
+ raise ArgumentError, "FIPS and DualStack are enabled, but this partition does not support one or both"
29
+ end
30
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
31
+ if Aws::Endpoints::Matchers.boolean_equals?(Aws::Endpoints::Matchers.attr(partition_result, "supportsFIPS"), true)
32
+ return Aws::Endpoints::Endpoint.new(url: "https://bedrock-agentcore-fips.#{parameters.region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {})
33
+ end
34
+ raise ArgumentError, "FIPS is enabled but this partition does not support FIPS"
35
+ end
36
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_dual_stack, true)
37
+ if Aws::Endpoints::Matchers.boolean_equals?(true, Aws::Endpoints::Matchers.attr(partition_result, "supportsDualStack"))
38
+ return Aws::Endpoints::Endpoint.new(url: "https://bedrock-agentcore.#{parameters.region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
39
+ end
40
+ raise ArgumentError, "DualStack is enabled but this partition does not support DualStack"
41
+ end
42
+ return Aws::Endpoints::Endpoint.new(url: "https://bedrock-agentcore.#{parameters.region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {})
43
+ end
44
+ end
45
+ raise ArgumentError, "Invalid Configuration: Missing Region"
46
+ raise ArgumentError, 'No endpoint could be resolved'
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+
11
+ module Aws::BedrockAgentCore
12
+ # @api private
13
+ module Endpoints
14
+
15
+
16
+ def self.parameters_for_operation(context)
17
+ Aws::BedrockAgentCore::EndpointParameters.create(context.config)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,240 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::BedrockAgentCore
11
+
12
+ # When BedrockAgentCore returns an error response, the Ruby SDK constructs and raises an error.
13
+ # These errors all extend Aws::BedrockAgentCore::Errors::ServiceError < {Aws::Errors::ServiceError}
14
+ #
15
+ # You can rescue all BedrockAgentCore errors using ServiceError:
16
+ #
17
+ # begin
18
+ # # do stuff
19
+ # rescue Aws::BedrockAgentCore::Errors::ServiceError
20
+ # # rescues all BedrockAgentCore API errors
21
+ # end
22
+ #
23
+ #
24
+ # ## Request Context
25
+ # ServiceError objects have a {Aws::Errors::ServiceError#context #context} method that returns
26
+ # information about the request that generated the error.
27
+ # See {Seahorse::Client::RequestContext} for more information.
28
+ #
29
+ # ## Error Classes
30
+ # * {AccessDeniedException}
31
+ # * {ConflictException}
32
+ # * {InternalServerException}
33
+ # * {InvalidInputException}
34
+ # * {ResourceNotFoundException}
35
+ # * {RuntimeClientError}
36
+ # * {ServiceException}
37
+ # * {ServiceQuotaExceededException}
38
+ # * {ThrottledException}
39
+ # * {ThrottlingException}
40
+ # * {UnauthorizedException}
41
+ # * {ValidationException}
42
+ #
43
+ # Additionally, error classes are dynamically generated for service errors based on the error code
44
+ # if they are not defined above.
45
+ module Errors
46
+
47
+ extend Aws::Errors::DynamicErrors
48
+
49
+ class AccessDeniedException < ServiceError
50
+
51
+ # @param [Seahorse::Client::RequestContext] context
52
+ # @param [String] message
53
+ # @param [Aws::BedrockAgentCore::Types::AccessDeniedException] data
54
+ def initialize(context, message, data = Aws::EmptyStructure.new)
55
+ super(context, message, data)
56
+ end
57
+
58
+ # @return [String]
59
+ def message
60
+ @message || @data[:message]
61
+ end
62
+ end
63
+
64
+ class ConflictException < ServiceError
65
+
66
+ # @param [Seahorse::Client::RequestContext] context
67
+ # @param [String] message
68
+ # @param [Aws::BedrockAgentCore::Types::ConflictException] data
69
+ def initialize(context, message, data = Aws::EmptyStructure.new)
70
+ super(context, message, data)
71
+ end
72
+
73
+ # @return [String]
74
+ def message
75
+ @message || @data[:message]
76
+ end
77
+ end
78
+
79
+ class InternalServerException < ServiceError
80
+
81
+ # @param [Seahorse::Client::RequestContext] context
82
+ # @param [String] message
83
+ # @param [Aws::BedrockAgentCore::Types::InternalServerException] data
84
+ def initialize(context, message, data = Aws::EmptyStructure.new)
85
+ super(context, message, data)
86
+ end
87
+
88
+ # @return [String]
89
+ def message
90
+ @message || @data[:message]
91
+ end
92
+ end
93
+
94
+ class InvalidInputException < ServiceError
95
+
96
+ # @param [Seahorse::Client::RequestContext] context
97
+ # @param [String] message
98
+ # @param [Aws::BedrockAgentCore::Types::InvalidInputException] data
99
+ def initialize(context, message, data = Aws::EmptyStructure.new)
100
+ super(context, message, data)
101
+ end
102
+
103
+ # @return [String]
104
+ def message
105
+ @message || @data[:message]
106
+ end
107
+ end
108
+
109
+ class ResourceNotFoundException < ServiceError
110
+
111
+ # @param [Seahorse::Client::RequestContext] context
112
+ # @param [String] message
113
+ # @param [Aws::BedrockAgentCore::Types::ResourceNotFoundException] data
114
+ def initialize(context, message, data = Aws::EmptyStructure.new)
115
+ super(context, message, data)
116
+ end
117
+
118
+ # @return [String]
119
+ def message
120
+ @message || @data[:message]
121
+ end
122
+ end
123
+
124
+ class RuntimeClientError < ServiceError
125
+
126
+ # @param [Seahorse::Client::RequestContext] context
127
+ # @param [String] message
128
+ # @param [Aws::BedrockAgentCore::Types::RuntimeClientError] data
129
+ def initialize(context, message, data = Aws::EmptyStructure.new)
130
+ super(context, message, data)
131
+ end
132
+
133
+ # @return [String]
134
+ def message
135
+ @message || @data[:message]
136
+ end
137
+ end
138
+
139
+ class ServiceException < ServiceError
140
+
141
+ # @param [Seahorse::Client::RequestContext] context
142
+ # @param [String] message
143
+ # @param [Aws::BedrockAgentCore::Types::ServiceException] data
144
+ def initialize(context, message, data = Aws::EmptyStructure.new)
145
+ super(context, message, data)
146
+ end
147
+
148
+ # @return [String]
149
+ def message
150
+ @message || @data[:message]
151
+ end
152
+ end
153
+
154
+ class ServiceQuotaExceededException < ServiceError
155
+
156
+ # @param [Seahorse::Client::RequestContext] context
157
+ # @param [String] message
158
+ # @param [Aws::BedrockAgentCore::Types::ServiceQuotaExceededException] data
159
+ def initialize(context, message, data = Aws::EmptyStructure.new)
160
+ super(context, message, data)
161
+ end
162
+
163
+ # @return [String]
164
+ def message
165
+ @message || @data[:message]
166
+ end
167
+ end
168
+
169
+ class ThrottledException < ServiceError
170
+
171
+ # @param [Seahorse::Client::RequestContext] context
172
+ # @param [String] message
173
+ # @param [Aws::BedrockAgentCore::Types::ThrottledException] data
174
+ def initialize(context, message, data = Aws::EmptyStructure.new)
175
+ super(context, message, data)
176
+ end
177
+
178
+ # @return [String]
179
+ def message
180
+ @message || @data[:message]
181
+ end
182
+ end
183
+
184
+ class ThrottlingException < ServiceError
185
+
186
+ # @param [Seahorse::Client::RequestContext] context
187
+ # @param [String] message
188
+ # @param [Aws::BedrockAgentCore::Types::ThrottlingException] data
189
+ def initialize(context, message, data = Aws::EmptyStructure.new)
190
+ super(context, message, data)
191
+ end
192
+
193
+ # @return [String]
194
+ def message
195
+ @message || @data[:message]
196
+ end
197
+ end
198
+
199
+ class UnauthorizedException < ServiceError
200
+
201
+ # @param [Seahorse::Client::RequestContext] context
202
+ # @param [String] message
203
+ # @param [Aws::BedrockAgentCore::Types::UnauthorizedException] data
204
+ def initialize(context, message, data = Aws::EmptyStructure.new)
205
+ super(context, message, data)
206
+ end
207
+
208
+ # @return [String]
209
+ def message
210
+ @message || @data[:message]
211
+ end
212
+ end
213
+
214
+ class ValidationException < ServiceError
215
+
216
+ # @param [Seahorse::Client::RequestContext] context
217
+ # @param [String] message
218
+ # @param [Aws::BedrockAgentCore::Types::ValidationException] data
219
+ def initialize(context, message, data = Aws::EmptyStructure.new)
220
+ super(context, message, data)
221
+ end
222
+
223
+ # @return [String]
224
+ def message
225
+ @message || @data[:message]
226
+ end
227
+
228
+ # @return [String]
229
+ def reason
230
+ @data[:reason]
231
+ end
232
+
233
+ # @return [String]
234
+ def field_list
235
+ @data[:field_list]
236
+ end
237
+ end
238
+
239
+ end
240
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::BedrockAgentCore
11
+ module EventStreams
12
+ class CodeInterpreterStreamOutput
13
+
14
+ def initialize
15
+ @event_emitter = Aws::EventEmitter.new
16
+ end
17
+
18
+ def on_result_event(&block)
19
+ @event_emitter.on(:result, block) if block_given?
20
+ end
21
+
22
+ def on_access_denied_exception_event(&block)
23
+ @event_emitter.on(:access_denied_exception, block) if block_given?
24
+ end
25
+
26
+ def on_conflict_exception_event(&block)
27
+ @event_emitter.on(:conflict_exception, block) if block_given?
28
+ end
29
+
30
+ def on_internal_server_exception_event(&block)
31
+ @event_emitter.on(:internal_server_exception, block) if block_given?
32
+ end
33
+
34
+ def on_resource_not_found_exception_event(&block)
35
+ @event_emitter.on(:resource_not_found_exception, block) if block_given?
36
+ end
37
+
38
+ def on_service_quota_exceeded_exception_event(&block)
39
+ @event_emitter.on(:service_quota_exceeded_exception, block) if block_given?
40
+ end
41
+
42
+ def on_throttling_exception_event(&block)
43
+ @event_emitter.on(:throttling_exception, block) if block_given?
44
+ end
45
+
46
+ def on_validation_exception_event(&block)
47
+ @event_emitter.on(:validation_exception, block) if block_given?
48
+ end
49
+
50
+ def on_error_event(&block)
51
+ @event_emitter.on(:error, block) if block_given?
52
+ end
53
+
54
+ def on_initial_response_event(&block)
55
+ @event_emitter.on(:initial_response, block) if block_given?
56
+ end
57
+
58
+ def on_unknown_event(&block)
59
+ @event_emitter.on(:unknown_event, block) if block_given?
60
+ end
61
+
62
+ def on_event(&block)
63
+ on_result_event(&block)
64
+ on_access_denied_exception_event(&block)
65
+ on_conflict_exception_event(&block)
66
+ on_internal_server_exception_event(&block)
67
+ on_resource_not_found_exception_event(&block)
68
+ on_service_quota_exceeded_exception_event(&block)
69
+ on_throttling_exception_event(&block)
70
+ on_validation_exception_event(&block)
71
+ on_error_event(&block)
72
+ on_initial_response_event(&block)
73
+ on_unknown_event(&block)
74
+ end
75
+
76
+ # @api private
77
+ # @return Aws::EventEmitter
78
+ attr_reader :event_emitter
79
+
80
+ end
81
+
82
+ end
83
+ end
84
+
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+
11
+ module Aws::BedrockAgentCore
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::BedrockAgentCore::EndpointProvider',
17
+ rbs_type: 'untyped',
18
+ docstring: <<~DOCS) do |_cfg|
19
+ The endpoint provider used to resolve endpoints. Any object that responds to
20
+ `#resolve_endpoint(parameters)` where `parameters` is a Struct similar to
21
+ `Aws::BedrockAgentCore::EndpointParameters`.
22
+ DOCS
23
+ Aws::BedrockAgentCore::EndpointProvider.new
24
+ end
25
+
26
+ # @api private
27
+ class Handler < Seahorse::Client::Handler
28
+ def call(context)
29
+ unless context[:discovered_endpoint]
30
+ params = Aws::BedrockAgentCore::Endpoints.parameters_for_operation(context)
31
+ endpoint = context.config.endpoint_provider.resolve_endpoint(params)
32
+
33
+ context.http_request.endpoint = endpoint.url
34
+ apply_endpoint_headers(context, endpoint.headers)
35
+
36
+ context[:endpoint_params] = params
37
+ context[:endpoint_properties] = endpoint.properties
38
+ end
39
+
40
+ context[:auth_scheme] =
41
+ Aws::Endpoints.resolve_auth_scheme(context, endpoint)
42
+
43
+ with_metrics(context) { @handler.call(context) }
44
+ end
45
+
46
+ private
47
+
48
+ def with_metrics(context, &block)
49
+ metrics = []
50
+ metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
51
+ if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
52
+ metrics << 'SIGV4A_SIGNING'
53
+ end
54
+ if context.config.credentials&.credentials&.account_id
55
+ metrics << 'RESOLVED_ACCOUNT_ID'
56
+ end
57
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
58
+ end
59
+
60
+ def apply_endpoint_headers(context, headers)
61
+ headers.each do |key, values|
62
+ value = values
63
+ .compact
64
+ .map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
65
+ .join(',')
66
+
67
+ context.http_request.headers[key] = value
68
+ end
69
+ end
70
+ end
71
+
72
+ def add_handlers(handlers, _config)
73
+ handlers.add(Handler, step: :build, priority: 75)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::BedrockAgentCore
11
+
12
+ class Resource
13
+
14
+ # @param options ({})
15
+ # @option options [Client] :client
16
+ def initialize(options = {})
17
+ @client = options[:client] || Client.new(options)
18
+ end
19
+
20
+ # @return [Client]
21
+ def client
22
+ @client
23
+ end
24
+
25
+ end
26
+ end