aws-sdk-eventbridgev2 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.
@@ -0,0 +1,102 @@
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::EventBridgeV2
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::EventBridgeV2::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::EventBridgeV2::EndpointParameters`.
22
+ DOCS
23
+ Aws::EventBridgeV2::EndpointProvider.new
24
+ end
25
+
26
+ option(
27
+ :account_id_endpoint_mode,
28
+ doc_type: 'String',
29
+ docstring: <<~DOCS) do |cfg|
30
+ The account ID endpoint mode to use. This can be one of the following values:
31
+ * `preferred` - The default behavior. Use the account ID endpoint if
32
+ available, otherwise use the standard endpoint.
33
+ * `disabled` - Never use the account ID endpoint. Only use the standard
34
+ endpoint.
35
+ * `required` - Always use the account ID endpoint. If the account ID
36
+ cannot be retrieved from credentials, an error is raised.
37
+ DOCS
38
+ value = ENV['AWS_ACCOUNT_ID_ENDPOINT_MODE']
39
+ value ||= Aws.shared_config.account_id_endpoint_mode(profile: cfg.profile)
40
+ value || 'preferred'
41
+ end
42
+
43
+ # @api private
44
+ class Handler < Seahorse::Client::Handler
45
+ def call(context)
46
+ unless context[:discovered_endpoint]
47
+ params = Aws::EventBridgeV2::Endpoints.parameters_for_operation(context)
48
+ endpoint = context.config.endpoint_provider.resolve_endpoint(params)
49
+
50
+ context.http_request.endpoint = endpoint.url
51
+ apply_endpoint_headers(context, endpoint.headers)
52
+
53
+ context[:endpoint_params] = params
54
+ context[:endpoint_properties] = endpoint.properties
55
+ end
56
+
57
+ context[:auth_scheme] =
58
+ Aws::Endpoints.resolve_auth_scheme(context, endpoint)
59
+
60
+ with_metrics(context) { @handler.call(context) }
61
+ end
62
+
63
+ private
64
+
65
+ def with_metrics(context, &block)
66
+ metrics = []
67
+ metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
68
+ if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
69
+ metrics << 'SIGV4A_SIGNING'
70
+ end
71
+ case context.config.account_id_endpoint_mode
72
+ when 'preferred'
73
+ metrics << 'ACCOUNT_ID_MODE_PREFERRED'
74
+ when 'disabled'
75
+ metrics << 'ACCOUNT_ID_MODE_DISABLED'
76
+ when 'required'
77
+ metrics << 'ACCOUNT_ID_MODE_REQUIRED'
78
+ end
79
+ if context.config.credentials&.credentials&.account_id
80
+ metrics << 'RESOLVED_ACCOUNT_ID'
81
+ end
82
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
83
+ end
84
+
85
+ def apply_endpoint_headers(context, headers)
86
+ headers.each do |key, values|
87
+ value = values
88
+ .compact
89
+ .map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
90
+ .join(',')
91
+
92
+ context.http_request.headers[key] = value
93
+ end
94
+ end
95
+ end
96
+
97
+ def add_handlers(handlers, _config)
98
+ handlers.add(Handler, step: :build, priority: 75)
99
+ end
100
+ end
101
+ end
102
+ 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::EventBridgeV2
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