aws-sdk-core 3.100.0 → 3.191.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1815 -0
- data/LICENSE.txt +202 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +153 -0
- data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
- data/lib/aws-defaults.rb +3 -0
- data/lib/aws-sdk-core/arn.rb +28 -0
- data/lib/aws-sdk-core/arn_parser.rb +2 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +23 -7
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +16 -10
- data/lib/aws-sdk-core/async_client_stubs.rb +2 -0
- data/lib/aws-sdk-core/binary/decode_handler.rb +2 -0
- data/lib/aws-sdk-core/binary/encode_handler.rb +14 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_parser.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +2 -0
- data/lib/aws-sdk-core/binary.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +2 -0
- data/lib/aws-sdk-core/client_stubs.rb +22 -13
- data/lib/aws-sdk-core/credential_provider.rb +5 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +31 -6
- data/lib/aws-sdk-core/credentials.rb +2 -0
- data/lib/aws-sdk-core/deprecations.rb +2 -0
- data/lib/aws-sdk-core/eager_loader.rb +2 -0
- data/lib/aws-sdk-core/ec2_metadata.rb +238 -0
- data/lib/aws-sdk-core/ecs_credentials.rb +188 -53
- data/lib/aws-sdk-core/endpoint_cache.rb +2 -0
- data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
- data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
- data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
- data/lib/aws-sdk-core/endpoints/function.rb +80 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +131 -0
- data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
- data/lib/aws-sdk-core/endpoints/url.rb +60 -0
- data/lib/aws-sdk-core/endpoints.rb +78 -0
- data/lib/aws-sdk-core/errors.rb +27 -5
- data/lib/aws-sdk-core/event_emitter.rb +2 -0
- data/lib/aws-sdk-core/ini_parser.rb +9 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +167 -38
- data/lib/aws-sdk-core/json/builder.rb +2 -0
- data/lib/aws-sdk-core/json/error_handler.rb +22 -1
- data/lib/aws-sdk-core/json/handler.rb +10 -1
- data/lib/aws-sdk-core/json/json_engine.rb +12 -8
- data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
- data/lib/aws-sdk-core/json/parser.rb +36 -1
- data/lib/aws-sdk-core/json.rb +10 -26
- data/lib/aws-sdk-core/log/formatter.rb +15 -3
- data/lib/aws-sdk-core/log/handler.rb +2 -0
- data/lib/aws-sdk-core/log/param_filter.rb +37 -12
- data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
- data/lib/aws-sdk-core/pageable_response.rb +91 -32
- data/lib/aws-sdk-core/pager.rb +5 -0
- data/lib/aws-sdk-core/param_converter.rb +2 -0
- data/lib/aws-sdk-core/param_validator.rb +56 -6
- data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
- data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +342 -0
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +3 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +2 -0
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +52 -7
- data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +8 -2
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +8 -6
- data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
- data/lib/aws-sdk-core/plugins/http_checksum.rb +11 -1
- data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/invocation_id.rb +2 -0
- data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +36 -6
- data/lib/aws-sdk-core/plugins/logging.rb +4 -0
- data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
- data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
- data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +146 -17
- data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
- data/lib/aws-sdk-core/plugins/response_paging.rb +3 -1
- data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +9 -4
- data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +2 -0
- data/lib/aws-sdk-core/plugins/retry_errors.rb +29 -8
- data/lib/aws-sdk-core/plugins/sign.rb +206 -0
- data/lib/aws-sdk-core/plugins/signature_v2.rb +3 -0
- data/lib/aws-sdk-core/plugins/signature_v4.rb +30 -31
- data/lib/aws-sdk-core/plugins/stub_responses.rb +10 -1
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +2 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +119 -14
- data/lib/aws-sdk-core/process_credentials.rb +14 -15
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/handler.rb +2 -0
- data/lib/aws-sdk-core/query/param.rb +2 -0
- data/lib/aws-sdk-core/query/param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/param_list.rb +2 -0
- data/lib/aws-sdk-core/query.rb +2 -0
- data/lib/aws-sdk-core/refreshing_credentials.rb +50 -17
- data/lib/aws-sdk-core/refreshing_token.rb +71 -0
- data/lib/aws-sdk-core/resources/collection.rb +2 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -1
- data/lib/aws-sdk-core/rest/request/body.rb +21 -1
- data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +2 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +16 -6
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +45 -29
- data/lib/aws-sdk-core/rest/response/body.rb +2 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
- data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
- data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
- data/lib/aws-sdk-core/rest.rb +2 -0
- data/lib/aws-sdk-core/shared_config.rb +163 -8
- data/lib/aws-sdk-core/shared_credentials.rb +9 -1
- data/lib/aws-sdk-core/sso_credentials.rb +172 -0
- data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
- data/lib/aws-sdk-core/static_token_provider.rb +14 -0
- data/lib/aws-sdk-core/structure.rb +19 -6
- data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
- data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
- data/lib/aws-sdk-core/stubbing/stub_data.rb +13 -0
- data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
- data/lib/aws-sdk-core/token.rb +31 -0
- data/lib/aws-sdk-core/token_provider.rb +15 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
- data/lib/aws-sdk-core/type_builder.rb +2 -0
- data/lib/aws-sdk-core/util.rb +2 -0
- data/lib/aws-sdk-core/waiters/errors.rb +2 -0
- data/lib/aws-sdk-core/waiters/poller.rb +6 -2
- data/lib/aws-sdk-core/waiters/waiter.rb +2 -0
- data/lib/aws-sdk-core/waiters.rb +2 -0
- data/lib/aws-sdk-core/xml/builder.rb +4 -2
- data/lib/aws-sdk-core/xml/default_list.rb +2 -0
- data/lib/aws-sdk-core/xml/default_map.rb +2 -0
- data/lib/aws-sdk-core/xml/doc_builder.rb +8 -1
- data/lib/aws-sdk-core/xml/error_handler.rb +9 -0
- data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/oga.rb +4 -0
- data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
- data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
- data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +7 -0
- data/lib/aws-sdk-core/xml.rb +2 -0
- data/lib/aws-sdk-core.rb +29 -3
- data/lib/aws-sdk-sso/client.rb +630 -0
- data/lib/aws-sdk-sso/client_api.rb +190 -0
- data/lib/aws-sdk-sso/customizations.rb +1 -0
- data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-sso/endpoints.rb +72 -0
- data/lib/aws-sdk-sso/errors.rb +102 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-sso/resource.rb +26 -0
- data/lib/aws-sdk-sso/types.rb +317 -0
- data/lib/aws-sdk-sso.rb +59 -0
- data/lib/aws-sdk-ssooidc/client.rb +935 -0
- data/lib/aws-sdk-ssooidc/client_api.rb +271 -0
- data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-ssooidc/endpoints.rb +72 -0
- data/lib/aws-sdk-ssooidc/errors.rb +321 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-ssooidc/resource.rb +26 -0
- data/lib/aws-sdk-ssooidc/types.rb +755 -0
- data/lib/aws-sdk-ssooidc.rb +59 -0
- data/lib/aws-sdk-sts/client.rb +655 -490
- data/lib/aws-sdk-sts/client_api.rb +21 -2
- data/lib/aws-sdk-sts/customizations.rb +2 -0
- data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
- data/lib/aws-sdk-sts/endpoint_provider.rb +112 -0
- data/lib/aws-sdk-sts/endpoints.rb +136 -0
- data/lib/aws-sdk-sts/errors.rb +3 -1
- data/lib/aws-sdk-sts/plugins/endpoints.rb +86 -0
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +7 -1
- data/lib/aws-sdk-sts/presigner.rb +16 -10
- data/lib/aws-sdk-sts/resource.rb +3 -1
- data/lib/aws-sdk-sts/types.rb +416 -316
- data/lib/aws-sdk-sts.rb +14 -3
- data/lib/seahorse/client/async_base.rb +2 -1
- data/lib/seahorse/client/async_response.rb +2 -0
- data/lib/seahorse/client/base.rb +3 -0
- data/lib/seahorse/client/block_io.rb +5 -2
- data/lib/seahorse/client/configuration.rb +7 -5
- data/lib/seahorse/client/events.rb +2 -0
- data/lib/seahorse/client/h2/connection.rb +29 -24
- data/lib/seahorse/client/h2/handler.rb +6 -5
- data/lib/seahorse/client/handler.rb +2 -0
- data/lib/seahorse/client/handler_builder.rb +2 -0
- data/lib/seahorse/client/handler_list.rb +2 -0
- data/lib/seahorse/client/handler_list_entry.rb +2 -0
- data/lib/seahorse/client/http/async_response.rb +2 -0
- data/lib/seahorse/client/http/headers.rb +2 -0
- data/lib/seahorse/client/http/request.rb +2 -0
- data/lib/seahorse/client/http/response.rb +3 -1
- data/lib/seahorse/client/logging/formatter.rb +2 -0
- data/lib/seahorse/client/logging/handler.rb +2 -0
- data/lib/seahorse/client/managed_file.rb +2 -0
- data/lib/seahorse/client/net_http/connection_pool.rb +12 -4
- data/lib/seahorse/client/net_http/handler.rb +19 -8
- data/lib/seahorse/client/net_http/patches.rb +14 -86
- data/lib/seahorse/client/networking_error.rb +2 -0
- data/lib/seahorse/client/plugin.rb +3 -0
- data/lib/seahorse/client/plugin_list.rb +2 -0
- data/lib/seahorse/client/plugins/content_length.rb +13 -5
- data/lib/seahorse/client/plugins/endpoint.rb +2 -0
- data/lib/seahorse/client/plugins/h2.rb +9 -4
- data/lib/seahorse/client/plugins/logging.rb +2 -0
- data/lib/seahorse/client/plugins/net_http.rb +39 -3
- data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
- data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
- data/lib/seahorse/client/plugins/request_callback.rb +141 -0
- data/lib/seahorse/client/plugins/response_target.rb +8 -8
- data/lib/seahorse/client/request.rb +2 -0
- data/lib/seahorse/client/request_context.rb +2 -0
- data/lib/seahorse/client/response.rb +8 -0
- data/lib/seahorse/model/api.rb +2 -0
- data/lib/seahorse/model/authorizer.rb +2 -0
- data/lib/seahorse/model/operation.rb +8 -0
- data/lib/seahorse/model/shapes.rb +27 -0
- data/lib/seahorse/util.rb +12 -1
- data/lib/seahorse/version.rb +2 -0
- data/lib/seahorse.rb +3 -0
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -0
- data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +93 -19
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module Endpoints
|
7
|
+
# generic matcher functions for service endpoints
|
8
|
+
# @api private
|
9
|
+
module Matchers
|
10
|
+
# Regex that extracts anything in square brackets
|
11
|
+
BRACKET_REGEX = /\[(.*?)\]/.freeze
|
12
|
+
|
13
|
+
# CORE
|
14
|
+
|
15
|
+
# isSet(value: Option<T>) bool
|
16
|
+
def self.set?(value)
|
17
|
+
!value.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
# not(value: bool) bool
|
21
|
+
def self.not(bool)
|
22
|
+
!bool
|
23
|
+
end
|
24
|
+
|
25
|
+
# getAttr(value: Object | Array, path: string) Document
|
26
|
+
def self.attr(value, path)
|
27
|
+
parts = path.split('.')
|
28
|
+
|
29
|
+
val = if (index = parts.first[BRACKET_REGEX, 1])
|
30
|
+
# remove brackets and index from part before indexing
|
31
|
+
value[parts.first.gsub(BRACKET_REGEX, '')][index.to_i]
|
32
|
+
else
|
33
|
+
value[parts.first]
|
34
|
+
end
|
35
|
+
|
36
|
+
if parts.size == 1
|
37
|
+
val
|
38
|
+
else
|
39
|
+
attr(val, parts.slice(1..-1).join('.'))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.substring(input, start, stop, reverse)
|
44
|
+
return nil if start >= stop || input.size < stop
|
45
|
+
|
46
|
+
return nil if input.chars.any? { |c| c.ord > 127 }
|
47
|
+
|
48
|
+
return input[start...stop] unless reverse
|
49
|
+
|
50
|
+
r_start = input.size - stop
|
51
|
+
r_stop = input.size - start
|
52
|
+
input[r_start...r_stop]
|
53
|
+
end
|
54
|
+
|
55
|
+
# stringEquals(value1: string, value2: string) bool
|
56
|
+
def self.string_equals?(value1, value2)
|
57
|
+
value1 == value2
|
58
|
+
end
|
59
|
+
|
60
|
+
# booleanEquals(value1: bool, value2: bool) bool
|
61
|
+
def self.boolean_equals?(value1, value2)
|
62
|
+
value1 == value2
|
63
|
+
end
|
64
|
+
|
65
|
+
# uriEncode(value: string) string
|
66
|
+
def self.uri_encode(value)
|
67
|
+
CGI.escape(value.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
|
68
|
+
end
|
69
|
+
|
70
|
+
# parseUrl(value: string) Option<URL>
|
71
|
+
def self.parse_url(value)
|
72
|
+
URL.new(value).as_json
|
73
|
+
rescue ArgumentError, URI::InvalidURIError
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
|
77
|
+
# isValidHostLabel(value: string, allowSubDomains: bool) bool
|
78
|
+
def self.valid_host_label?(value, allow_sub_domains = false)
|
79
|
+
return false if value.empty?
|
80
|
+
|
81
|
+
if allow_sub_domains
|
82
|
+
labels = value.split('.', -1)
|
83
|
+
return labels.all? { |l| valid_host_label?(l) }
|
84
|
+
end
|
85
|
+
|
86
|
+
!!(value =~ /\A(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\z/)
|
87
|
+
end
|
88
|
+
|
89
|
+
# AWS
|
90
|
+
|
91
|
+
# aws.partition(value: string) Option<Partition>
|
92
|
+
def self.aws_partition(value)
|
93
|
+
partition =
|
94
|
+
Aws::Partitions.find { |p| p.region?(value) } ||
|
95
|
+
Aws::Partitions.find { |p| value.match(p.region_regex) } ||
|
96
|
+
Aws::Partitions.find { |p| p.name == 'aws' }
|
97
|
+
|
98
|
+
return nil unless partition
|
99
|
+
|
100
|
+
partition.metadata
|
101
|
+
end
|
102
|
+
|
103
|
+
# aws.parseArn(value: string) Option<ARN>
|
104
|
+
def self.aws_parse_arn(value)
|
105
|
+
arn = Aws::ARNParser.parse(value)
|
106
|
+
json = arn.as_json
|
107
|
+
# HACK: because of poor naming and also requirement of splitting
|
108
|
+
resource = json.delete('resource')
|
109
|
+
json['resourceId'] = resource.split(%r{[:\/]}, -1)
|
110
|
+
json
|
111
|
+
rescue Aws::Errors::InvalidARNError
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
|
115
|
+
# aws.isVirtualHostableS3Bucket(value: string, allowSubDomains: bool) bool
|
116
|
+
def self.aws_virtual_hostable_s3_bucket?(value, allow_sub_domains = false)
|
117
|
+
return false if value.empty?
|
118
|
+
|
119
|
+
if allow_sub_domains
|
120
|
+
labels = value.split('.', -1)
|
121
|
+
return labels.all? { |l| aws_virtual_hostable_s3_bucket?(l) }
|
122
|
+
end
|
123
|
+
|
124
|
+
# must be between 3 and 63 characters long, no uppercase
|
125
|
+
value =~ /\A(?!-)[a-z0-9-]{3,63}(?<!-)\z/ &&
|
126
|
+
# not an IP address
|
127
|
+
value !~ /(\d+\.){3}\d+/
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Endpoints
|
5
|
+
# This class is deprecated. It is used by the Runtime endpoint
|
6
|
+
# resolution approach. It has been replaced by a code generated
|
7
|
+
# approach in each service gem. It can be removed in a new
|
8
|
+
# major version. It has to exist because
|
9
|
+
# old service gems can use a new core version.
|
10
|
+
# @api private
|
11
|
+
class Reference
|
12
|
+
def initialize(ref:)
|
13
|
+
@ref = ref
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :ref
|
17
|
+
|
18
|
+
def resolve(parameters, assigns)
|
19
|
+
if parameters.class.singleton_class::PARAM_MAP.key?(@ref)
|
20
|
+
member_name = parameters.class.singleton_class::PARAM_MAP[@ref]
|
21
|
+
parameters[member_name]
|
22
|
+
elsif assigns.key?(@ref)
|
23
|
+
assigns[@ref]
|
24
|
+
else
|
25
|
+
raise ArgumentError,
|
26
|
+
"Reference #{@ref} is not a param or an assigned value."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Endpoints
|
5
|
+
# This class is deprecated. It is used by the Runtime endpoint
|
6
|
+
# resolution approach. It has been replaced by a code generated
|
7
|
+
# approach in each service gem. It can be removed in a new
|
8
|
+
# major version. It has to exist because
|
9
|
+
# old service gems can use a new core version.
|
10
|
+
# @api private
|
11
|
+
class Rule
|
12
|
+
# Resolves a value that is a function, reference, or template string.
|
13
|
+
def resolve_value(value, parameters, assigns)
|
14
|
+
if value.is_a?(Hash) && value['fn']
|
15
|
+
Function.new(fn: value['fn'], argv: value['argv'])
|
16
|
+
.call(parameters, assigns)
|
17
|
+
elsif value.is_a?(Hash) && value['ref']
|
18
|
+
Reference.new(ref: value['ref']).resolve(parameters, assigns)
|
19
|
+
else
|
20
|
+
Templater.resolve(value, parameters, assigns)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Endpoints
|
5
|
+
# This class is deprecated. It is used by the Runtime endpoint
|
6
|
+
# resolution approach. It has been replaced by a code generated
|
7
|
+
# approach in each service gem. It can be removed in a new
|
8
|
+
# major version. It has to exist because
|
9
|
+
# old service gems can use a new core version.
|
10
|
+
# @api private
|
11
|
+
class RuleSet
|
12
|
+
def initialize(version:, service_id:, parameters:, rules:)
|
13
|
+
@version = version
|
14
|
+
@service_id = service_id
|
15
|
+
@parameters = parameters
|
16
|
+
@rules = RuleSet.rules_from_json(rules || [])
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :version
|
20
|
+
attr_reader :service_id
|
21
|
+
attr_reader :parameters
|
22
|
+
attr_reader :rules
|
23
|
+
|
24
|
+
def self.rules_from_json(rules_json)
|
25
|
+
rules_json.each.with_object([]) do |rule, rules|
|
26
|
+
if rule['type'] == 'endpoint'
|
27
|
+
rules << EndpointRule.new(
|
28
|
+
conditions: rule['conditions'],
|
29
|
+
endpoint: rule['endpoint'],
|
30
|
+
documentation: rule['documentation']
|
31
|
+
)
|
32
|
+
elsif rule['type'] == 'error'
|
33
|
+
rules << ErrorRule.new(
|
34
|
+
conditions: rule['conditions'],
|
35
|
+
error: rule['error'],
|
36
|
+
documentation: rule['documentation']
|
37
|
+
)
|
38
|
+
elsif rule['type'] == 'tree'
|
39
|
+
rules << TreeRule.new(
|
40
|
+
conditions: rule['conditions'],
|
41
|
+
rules: rule['rules'],
|
42
|
+
documentation: rule['documentation']
|
43
|
+
)
|
44
|
+
else
|
45
|
+
# should not happen
|
46
|
+
raise "Unknown endpoint rule type: #{rule}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Aws
|
2
|
+
module Endpoints
|
3
|
+
# This class is deprecated. It is used by the Runtime endpoint
|
4
|
+
# resolution approach. It has been replaced by a code generated
|
5
|
+
# approach in each service gem. It can be removed in a new
|
6
|
+
# major version. It has to exist because
|
7
|
+
# old service gems can use a new core version.
|
8
|
+
# @api private
|
9
|
+
class RulesProvider
|
10
|
+
def initialize(rule_set)
|
11
|
+
@rule_set = rule_set
|
12
|
+
end
|
13
|
+
|
14
|
+
def resolve_endpoint(parameters)
|
15
|
+
obj = resolve_rules(parameters)
|
16
|
+
case obj
|
17
|
+
when Endpoint
|
18
|
+
obj
|
19
|
+
when ArgumentError
|
20
|
+
raise obj
|
21
|
+
else
|
22
|
+
raise ArgumentError, 'No endpoint could be resolved'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def resolve_rules(parameters)
|
29
|
+
@rule_set.rules.each do |rule|
|
30
|
+
output = rule.match(parameters)
|
31
|
+
return output if output
|
32
|
+
end
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Endpoints
|
5
|
+
# Does substitutions for templated endpoint strings
|
6
|
+
|
7
|
+
# This class is deprecated. It is used by the Runtime endpoint
|
8
|
+
# resolution approach. It has been replaced by a code generated
|
9
|
+
# approach in each service gem. It can be removed in a new
|
10
|
+
# major version. It has to exist because
|
11
|
+
# old service gems can use a new core version.
|
12
|
+
# @api private
|
13
|
+
module Templater
|
14
|
+
class << self
|
15
|
+
def resolve(string, parameters, assigns)
|
16
|
+
# scans for strings in curly brackets {}
|
17
|
+
string.scan(/\{.+?\}/).each do |capture|
|
18
|
+
value = capture[1..-2] # strips curly brackets
|
19
|
+
string = string.gsub(capture, replace(value, parameters, assigns))
|
20
|
+
end
|
21
|
+
string
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Replaces the captured value with values from parameters or assign
|
27
|
+
def replace(capture, parameters, assigns)
|
28
|
+
# Pound sigil is used for getAttr calls
|
29
|
+
indexes = capture.split('#')
|
30
|
+
|
31
|
+
# no sigil found, just do substitution
|
32
|
+
if indexes.size == 1
|
33
|
+
extract_value(capture, parameters, assigns)
|
34
|
+
# sigil was found, need to call getAttr
|
35
|
+
elsif indexes.size == 2
|
36
|
+
ref, property = indexes
|
37
|
+
param = extract_value(ref, parameters, assigns)
|
38
|
+
Matchers.attr(param, property)
|
39
|
+
else
|
40
|
+
raise "Invalid templatable value: #{capture}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Checks both parameters and assigns hash for the referenced value
|
45
|
+
def extract_value(key, parameters, assigns)
|
46
|
+
if assigns.key?(key)
|
47
|
+
assigns[key]
|
48
|
+
elsif parameters.class.singleton_class::PARAM_MAP.key?(key)
|
49
|
+
member_name = parameters.class.singleton_class::PARAM_MAP[key]
|
50
|
+
parameters[member_name]
|
51
|
+
else
|
52
|
+
raise "Templatable value not found: #{key}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Endpoints
|
5
|
+
# This class is deprecated. It is used by the Runtime endpoint
|
6
|
+
# resolution approach. It has been replaced by a code generated
|
7
|
+
# approach in each service gem. It can be removed in a new
|
8
|
+
# major version. It has to exist because
|
9
|
+
# old service gems can use a new core version.
|
10
|
+
# @api private
|
11
|
+
class TreeRule
|
12
|
+
def initialize(type: 'tree', conditions:, rules:, documentation: nil)
|
13
|
+
@type = type
|
14
|
+
@conditions = Condition.from_json(conditions)
|
15
|
+
@rules = RuleSet.rules_from_json(rules)
|
16
|
+
@documentation = documentation
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :type
|
20
|
+
attr_reader :conditions
|
21
|
+
attr_reader :error
|
22
|
+
attr_reader :documentation
|
23
|
+
|
24
|
+
def match(parameters, assigned = {})
|
25
|
+
assigns = assigned.dup
|
26
|
+
matched = conditions.all? do |condition|
|
27
|
+
output = condition.match?(parameters, assigns)
|
28
|
+
assigns = assigns.merge(condition.assigned) if condition.assign
|
29
|
+
output
|
30
|
+
end
|
31
|
+
resolve_rules(parameters, assigns) if matched
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def resolve_rules(parameters, assigns)
|
37
|
+
@rules.each do |rule|
|
38
|
+
output = rule.match(parameters, assigns)
|
39
|
+
return output if output
|
40
|
+
end
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ipaddr'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module Endpoints
|
7
|
+
|
8
|
+
# @api private
|
9
|
+
class URL
|
10
|
+
def initialize(url)
|
11
|
+
uri = URI(url)
|
12
|
+
@scheme = uri.scheme
|
13
|
+
# only support http and https schemes
|
14
|
+
raise ArgumentError unless %w[https http].include?(@scheme)
|
15
|
+
|
16
|
+
# do not support query
|
17
|
+
raise ArgumentError if uri.query
|
18
|
+
|
19
|
+
@authority = _authority(url, uri)
|
20
|
+
@path = uri.path
|
21
|
+
@normalized_path = uri.path + (uri.path[-1] == '/' ? '' : '/')
|
22
|
+
@is_ip = _is_ip(uri.host)
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :scheme
|
26
|
+
attr_reader :authority
|
27
|
+
attr_reader :path
|
28
|
+
attr_reader :normalized_path
|
29
|
+
attr_reader :is_ip
|
30
|
+
|
31
|
+
def as_json(_options = {})
|
32
|
+
{
|
33
|
+
'scheme' => scheme,
|
34
|
+
'authority' => authority,
|
35
|
+
'path' => path,
|
36
|
+
'normalizedPath' => normalized_path,
|
37
|
+
'isIp' => is_ip
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def _authority(url, uri)
|
44
|
+
# don't include port if it's default and not parsed originally
|
45
|
+
if uri.default_port == uri.port && !url.include?(":#{uri.port}")
|
46
|
+
uri.host
|
47
|
+
else
|
48
|
+
"#{uri.host}:#{uri.port}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def _is_ip(authority)
|
53
|
+
IPAddr.new(authority)
|
54
|
+
true
|
55
|
+
rescue IPAddr::InvalidAddressError
|
56
|
+
false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'endpoints/rule'
|
4
|
+
require_relative 'endpoints/condition'
|
5
|
+
require_relative 'endpoints/endpoint_rule'
|
6
|
+
require_relative 'endpoints/endpoint'
|
7
|
+
require_relative 'endpoints/error_rule'
|
8
|
+
require_relative 'endpoints/function'
|
9
|
+
require_relative 'endpoints/matchers'
|
10
|
+
require_relative 'endpoints/reference'
|
11
|
+
require_relative 'endpoints/rules_provider'
|
12
|
+
require_relative 'endpoints/rule_set'
|
13
|
+
require_relative 'endpoints/templater'
|
14
|
+
require_relative 'endpoints/tree_rule'
|
15
|
+
require_relative 'endpoints/url'
|
16
|
+
|
17
|
+
module Aws
|
18
|
+
# @api private
|
19
|
+
module Endpoints
|
20
|
+
class << self
|
21
|
+
def resolve_auth_scheme(context, endpoint)
|
22
|
+
if endpoint && (auth_schemes = endpoint.properties['authSchemes'])
|
23
|
+
auth_scheme = auth_schemes.find do |scheme|
|
24
|
+
Aws::Plugins::Sign::SUPPORTED_AUTH_TYPES.include?(scheme['name'])
|
25
|
+
end
|
26
|
+
raise 'No supported auth scheme for this endpoint.' unless auth_scheme
|
27
|
+
|
28
|
+
merge_signing_defaults(auth_scheme, context.config)
|
29
|
+
else
|
30
|
+
default_auth_scheme(context)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def default_auth_scheme(context)
|
37
|
+
case default_api_authtype(context)
|
38
|
+
when 'v4', 'v4-unsigned-body'
|
39
|
+
auth_scheme = { 'name' => 'sigv4' }
|
40
|
+
merge_signing_defaults(auth_scheme, context.config)
|
41
|
+
when 's3', 's3v4'
|
42
|
+
auth_scheme = {
|
43
|
+
'name' => 'sigv4',
|
44
|
+
'disableDoubleEncoding' => true,
|
45
|
+
'disableNormalizePath' => true
|
46
|
+
}
|
47
|
+
merge_signing_defaults(auth_scheme, context.config)
|
48
|
+
when 'bearer'
|
49
|
+
{ 'name' => 'bearer' }
|
50
|
+
when 'none', nil
|
51
|
+
{ 'name' => 'none' }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def merge_signing_defaults(auth_scheme, config)
|
56
|
+
if %w[sigv4 sigv4a sigv4-s3express].include?(auth_scheme['name'])
|
57
|
+
auth_scheme['signingName'] ||= sigv4_name(config)
|
58
|
+
if auth_scheme['name'] == 'sigv4a'
|
59
|
+
auth_scheme['signingRegionSet'] ||= ['*']
|
60
|
+
else
|
61
|
+
auth_scheme['signingRegion'] ||= config.region
|
62
|
+
end
|
63
|
+
end
|
64
|
+
auth_scheme
|
65
|
+
end
|
66
|
+
|
67
|
+
def default_api_authtype(context)
|
68
|
+
context.config.api.operation(context.operation_name)['authtype'] ||
|
69
|
+
context.config.api.metadata['signatureVersion']
|
70
|
+
end
|
71
|
+
|
72
|
+
def sigv4_name(config)
|
73
|
+
config.api.metadata['signingName'] ||
|
74
|
+
config.api.metadata['endpointPrefix']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/aws-sdk-core/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
module Errors
|
3
5
|
|
@@ -10,14 +12,14 @@ module Aws
|
|
10
12
|
class ServiceError < RuntimeError
|
11
13
|
|
12
14
|
# @param [Seahorse::Client::RequestContext] context
|
13
|
-
# @param [String] message
|
15
|
+
# @param [String, nil] message
|
14
16
|
# @param [Aws::Structure] data
|
15
17
|
def initialize(context, message, data = Aws::EmptyStructure.new)
|
16
18
|
@code = self.class.code
|
17
|
-
@message = message if message && !message.empty?
|
18
19
|
@context = context
|
19
20
|
@data = data
|
20
|
-
|
21
|
+
@message = message && !message.empty? ? message : self.class.to_s
|
22
|
+
super(@message)
|
21
23
|
end
|
22
24
|
|
23
25
|
# @return [String]
|
@@ -28,11 +30,11 @@ module Aws
|
|
28
30
|
attr_reader :context
|
29
31
|
|
30
32
|
# @return [Aws::Structure]
|
31
|
-
|
33
|
+
attr_accessor :data
|
32
34
|
|
33
35
|
class << self
|
34
36
|
|
35
|
-
# @return [String]
|
37
|
+
# @return [String, nil]
|
36
38
|
attr_accessor :code
|
37
39
|
|
38
40
|
end
|
@@ -205,6 +207,26 @@ module Aws
|
|
205
207
|
# payload with either invalid version number or malformed contents
|
206
208
|
class InvalidProcessCredentialsPayload < RuntimeError; end
|
207
209
|
|
210
|
+
# Raised when SSO Credentials are invalid
|
211
|
+
class InvalidSSOCredentials < RuntimeError; end
|
212
|
+
|
213
|
+
# Raised when SSO Token is invalid
|
214
|
+
class InvalidSSOToken < RuntimeError; end
|
215
|
+
|
216
|
+
# Raised when a client is unable to sign a request because
|
217
|
+
# the bearer token is not configured or available
|
218
|
+
class MissingBearerTokenError < RuntimeError
|
219
|
+
def initialize(*args)
|
220
|
+
msg = 'unable to sign request without token set'
|
221
|
+
super(msg)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
# Raised when there is a circular reference in chained
|
227
|
+
# source_profiles
|
228
|
+
class SourceProfileCircularReferenceError < RuntimeError; end
|
229
|
+
|
208
230
|
# Raised when a client is constructed and region is not specified.
|
209
231
|
class MissingRegionError < ArgumentError
|
210
232
|
def initialize(*args)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
# @api private
|
3
5
|
class IniParser
|
@@ -6,6 +8,8 @@ module Aws
|
|
6
8
|
def ini_parse(raw)
|
7
9
|
current_profile = nil
|
8
10
|
current_prefix = nil
|
11
|
+
item = nil
|
12
|
+
previous_item = nil
|
9
13
|
raw.lines.inject({}) do |acc, line|
|
10
14
|
line = line.split(/^|\s;/).first # remove comments
|
11
15
|
profile = line.match(/^\[([^\[\]]+)\]\s*(#.+)?$/) unless line.nil?
|
@@ -15,11 +19,16 @@ module Aws
|
|
15
19
|
current_profile = named_profile[1] if named_profile
|
16
20
|
elsif current_profile
|
17
21
|
unless line.nil?
|
22
|
+
previous_item = item
|
18
23
|
item = line.match(/^(.+?)\s*=\s*(.+?)\s*$/)
|
19
24
|
prefix = line.match(/^(.+?)\s*=\s*$/)
|
20
25
|
end
|
21
26
|
if item && item[1].match(/^\s+/)
|
22
27
|
# Need to add lines to a nested configuration.
|
28
|
+
if current_prefix.nil? && previous_item[2].strip.empty?
|
29
|
+
current_prefix = previous_item[1]
|
30
|
+
acc[current_profile][current_prefix] = {}
|
31
|
+
end
|
23
32
|
inner_item = line.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/)
|
24
33
|
acc[current_profile] ||= {}
|
25
34
|
acc[current_profile][current_prefix] ||= {}
|