aws-sdk-s3control 1.53.0 → 1.55.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,7 @@ require_relative '../arn/outpost_bucket_arn'
6
6
  module Aws
7
7
  module S3Control
8
8
  module Plugins
9
- # When an ARN is provided for :bucket or :name in S3Control operations,
10
- # this plugin resolves the request endpoint from the ARN when possible.
9
+ # Deprecated in favor of new endpoint generation.
11
10
  # @api private
12
11
  class ARN < Seahorse::Client::Plugin
13
12
  option(
@@ -23,156 +22,7 @@ client's region instead.
23
22
  resolve_s3_use_arn_region(cfg)
24
23
  end
25
24
 
26
- # param validator is validate:50 (required to add account_id from arn)
27
- # endpoint is build:90 (populates the URI for the first time)
28
- # endpoint pattern is build:10 (prefix account id to host)
29
- def add_handlers(handlers, _config)
30
- handlers.add(ARNHandler, step: :validate, priority: 75)
31
- handlers.add(UrlHandler)
32
- end
33
-
34
- # After extracting out any ARN input, resolve a new URL with it.
35
- class UrlHandler < Seahorse::Client::Handler
36
- def call(context)
37
- if context.metadata[:s3_arn]
38
- ARN.resolve_url!(
39
- context.http_request.endpoint,
40
- context.metadata[:s3_arn][:arn],
41
- context.metadata[:s3_arn][:resolved_region],
42
- context.metadata[:s3_arn][:fips],
43
- context.metadata[:s3_arn][:dualstack],
44
- # if regional_endpoint is false, a custom endpoint was provided
45
- # in this case, we want to prefix the endpoint using the ARN
46
- !context.config.regional_endpoint
47
- )
48
- end
49
- @handler.call(context)
50
- end
51
- end
52
-
53
- # This plugin will extract out any ARN input and set context for other
54
- # plugins to use without having to translate the ARN again.
55
- class ARNHandler < Seahorse::Client::Handler
56
- def call(context)
57
- arn_member = _arn_member(context.operation.input.shape)
58
- if arn_member && (bucket = context.params[arn_member])
59
- resolved_region, arn = ARN.resolve_arn!(
60
- bucket,
61
- context.config.region,
62
- context.config.s3_use_arn_region
63
- )
64
- validate_outpost_dualstack!(context)
65
- if arn
66
- validate_config!(context, arn)
67
-
68
- if arn.is_a?(OutpostAccessPointARN) ||
69
- arn.is_a?(OutpostBucketARN)
70
- set_outpost_header!(context, arn)
71
- # disable account_id prefix for outposts urls
72
- context.config.disable_host_prefix_injection = true
73
- end
74
- set_account_param!(context, arn)
75
-
76
- # depending on the ARN's resource type, put the resource value
77
- # back onto params
78
- context.params[arn_member] = arn.input_member
79
- context.metadata[:s3_arn] = {
80
- arn: arn,
81
- resolved_region: resolved_region,
82
- fips: context.config.use_fips_endpoint,
83
- dualstack: extract_dualstack_config!(context)
84
- }
85
- end
86
- end
87
- @handler.call(context)
88
- end
89
-
90
- private
91
-
92
- # this validation has nothing to do with ARNs (can't be in
93
- # validate_config!) outposts does not support dualstack, so operations
94
- # using an outpost id should be validated too.
95
- def validate_outpost_dualstack!(context)
96
- if context.params[:outpost_id] && context[:use_dualstack_endpoint]
97
- raise ArgumentError,
98
- 'Cannot provide an Outpost ID when '\
99
- '`:use_dualstack_endpoint` is set to true.'
100
- end
101
- end
102
-
103
- # This looks for BucketName or AccessPointName, but prefers BucketName
104
- # for CreateAccessPoint because it contains both but should not have
105
- # an Access Point ARN as AccessPointName.
106
- def _arn_member(input)
107
- input.members.each do |member, ref|
108
- if ref.shape.name == 'BucketName' ||
109
- (ref.shape.name == 'AccessPointName' &&
110
- input.name != 'CreateAccessPointRequest')
111
- return member
112
- end
113
- end
114
- end
115
-
116
- # other plugins use dualstack so disable it when we're done
117
- def extract_dualstack_config!(context)
118
- dualstack = context[:use_dualstack_endpoint]
119
- context[:use_dualstack_endpoint] = false if dualstack
120
- dualstack
121
- end
122
-
123
- def validate_config!(context, arn)
124
- if !arn.support_dualstack? && context[:use_dualstack_endpoint]
125
- raise ArgumentError,
126
- 'Cannot provide an Outpost Access Point or Bucket ARN '\
127
- 'when `:use_dualstack_endpoint` is set to true.'
128
- end
129
- end
130
-
131
- def set_outpost_header!(context, arn)
132
- context.http_request.headers['x-amz-outpost-id'] = arn.outpost_id
133
- end
134
-
135
- def set_account_param!(context, arn)
136
- if context.params[:account_id] &&
137
- context.params[:account_id] != arn.account_id
138
- raise ArgumentError,
139
- 'Cannot provide an Account ID that is different from the '\
140
- 'Account ID in the ARN.'
141
- end
142
- context.params[:account_id] = arn.account_id
143
- end
144
- end
145
-
146
25
  class << self
147
- # @api private
148
- def resolve_arn!(member_value, region, use_arn_region)
149
- if Aws::ARNParser.arn?(member_value)
150
- arn = Aws::ARNParser.parse(member_value)
151
- if arn.resource.include?('bucket')
152
- s3_arn = Aws::S3Control::OutpostBucketARN.new(arn.to_h)
153
- elsif arn.resource.include?('accesspoint')
154
- s3_arn = Aws::S3Control::OutpostAccessPointARN.new(arn.to_h)
155
- else
156
- raise ArgumentError,
157
- 'Only Outpost Bucket and Outpost Access Point ARNs are '\
158
- 'currently supported.'
159
- end
160
- s3_arn.validate_arn!
161
- validate_region_config!(s3_arn, region, use_arn_region)
162
- region = s3_arn.region if use_arn_region
163
- [region, s3_arn]
164
- else
165
- [region]
166
- end
167
- end
168
-
169
- # @api private
170
- def resolve_url!(url, arn, region, fips = false, dualstack = false, has_custom_endpoint = false)
171
- custom_endpoint = url.host if has_custom_endpoint
172
- url.host = arn.host_url(region, fips, dualstack, custom_endpoint)
173
- url
174
- end
175
-
176
26
  private
177
27
 
178
28
  def resolve_s3_use_arn_region(cfg)
@@ -189,17 +39,6 @@ client's region instead.
189
39
  end
190
40
  value
191
41
  end
192
-
193
- def validate_region_config!(arn, region, use_arn_region)
194
- if use_arn_region &&
195
- !Aws::Partitions.partition(arn.partition).region?(region)
196
- raise Aws::Errors::InvalidARNPartitionError
197
- end
198
-
199
- if !use_arn_region && region != arn.region
200
- raise Aws::Errors::InvalidARNRegionError
201
- end
202
- end
203
42
  end
204
43
  end
205
44
  end
@@ -3,11 +3,11 @@
3
3
  module Aws
4
4
  module S3Control
5
5
  module Plugins
6
+ # Deprecated in favor of new endpoint generation.
6
7
  # @api private
7
8
  class Dualstack < Seahorse::Client::Plugin
8
- def add_handlers(handlers, config)
9
+ def add_handlers(handlers, _config)
9
10
  handlers.add(OptionHandler, step: :initialize)
10
- handlers.add(DualstackHandler, step: :build, priority: 11)
11
11
  end
12
12
 
13
13
  # @api private
@@ -18,39 +18,10 @@ module Aws
18
18
  dualstack = context.params.delete(:use_dualstack_endpoint)
19
19
  end
20
20
  dualstack = context.config.use_dualstack_endpoint if dualstack.nil?
21
- # Raise if :endpoint and dualstack are both provided
22
- if dualstack && !context.config.regional_endpoint
23
- raise ArgumentError,
24
- 'Cannot use both :use_dualstack_endpoint and :endpoint'
25
- end
26
21
  context[:use_dualstack_endpoint] = dualstack
27
22
  @handler.call(context)
28
23
  end
29
24
  end
30
-
31
- # @api private
32
- class DualstackHandler < Seahorse::Client::Handler
33
- def call(context)
34
- # if it's a regional endpoint and not an ARN, then construct the
35
- # endpoint. regional endpoint plugin uses the dualstack config
36
- if context.config.regional_endpoint && !context.metadata[:s3_arn]
37
- new_endpoint = Aws::Partitions::EndpointProvider.resolve(
38
- context.config.region,
39
- 's3-control',
40
- 'regional',
41
- {
42
- dualstack: context[:use_dualstack_endpoint],
43
- fips: context.config.use_fips_endpoint
44
- }
45
- )
46
- endpoint = URI.parse(context.http_request.endpoint.to_s)
47
- endpoint.host = URI.parse(new_endpoint).host
48
- context.http_request.endpoint = endpoint
49
- end
50
- @handler.call(context)
51
- end
52
- end
53
-
54
25
  end
55
26
  end
56
27
  end
@@ -0,0 +1,186 @@
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::S3Control
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::S3Control::EndpointProvider',
17
+ docstring: 'The endpoint provider used to resolve endpoints. Any '\
18
+ 'object that responds to `#resolve_endpoint(parameters)` '\
19
+ 'where `parameters` is a Struct similar to '\
20
+ '`Aws::S3Control::EndpointParameters`'
21
+ ) do |cfg|
22
+ Aws::S3Control::EndpointProvider.new
23
+ end
24
+
25
+ # @api private
26
+ class Handler < Seahorse::Client::Handler
27
+ def call(context)
28
+ # If endpoint was discovered, do not resolve or apply the endpoint.
29
+ unless context[:discovered_endpoint]
30
+ params = 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
+ end
36
+
37
+ context[:endpoint_params] = params
38
+ context[:auth_scheme] =
39
+ Aws::Endpoints.resolve_auth_scheme(context, endpoint)
40
+
41
+ @handler.call(context)
42
+ end
43
+
44
+ private
45
+
46
+ def apply_endpoint_headers(context, headers)
47
+ headers.each do |key, values|
48
+ value = values
49
+ .compact
50
+ .map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
51
+ .join(',')
52
+
53
+ context.http_request.headers[key] = value
54
+ end
55
+ end
56
+
57
+ def parameters_for_operation(context)
58
+ case context.operation_name
59
+ when :create_access_point
60
+ Aws::S3Control::Endpoints::CreateAccessPoint.build(context)
61
+ when :create_access_point_for_object_lambda
62
+ Aws::S3Control::Endpoints::CreateAccessPointForObjectLambda.build(context)
63
+ when :create_bucket
64
+ Aws::S3Control::Endpoints::CreateBucket.build(context)
65
+ when :create_job
66
+ Aws::S3Control::Endpoints::CreateJob.build(context)
67
+ when :create_multi_region_access_point
68
+ Aws::S3Control::Endpoints::CreateMultiRegionAccessPoint.build(context)
69
+ when :delete_access_point
70
+ Aws::S3Control::Endpoints::DeleteAccessPoint.build(context)
71
+ when :delete_access_point_for_object_lambda
72
+ Aws::S3Control::Endpoints::DeleteAccessPointForObjectLambda.build(context)
73
+ when :delete_access_point_policy
74
+ Aws::S3Control::Endpoints::DeleteAccessPointPolicy.build(context)
75
+ when :delete_access_point_policy_for_object_lambda
76
+ Aws::S3Control::Endpoints::DeleteAccessPointPolicyForObjectLambda.build(context)
77
+ when :delete_bucket
78
+ Aws::S3Control::Endpoints::DeleteBucket.build(context)
79
+ when :delete_bucket_lifecycle_configuration
80
+ Aws::S3Control::Endpoints::DeleteBucketLifecycleConfiguration.build(context)
81
+ when :delete_bucket_policy
82
+ Aws::S3Control::Endpoints::DeleteBucketPolicy.build(context)
83
+ when :delete_bucket_tagging
84
+ Aws::S3Control::Endpoints::DeleteBucketTagging.build(context)
85
+ when :delete_job_tagging
86
+ Aws::S3Control::Endpoints::DeleteJobTagging.build(context)
87
+ when :delete_multi_region_access_point
88
+ Aws::S3Control::Endpoints::DeleteMultiRegionAccessPoint.build(context)
89
+ when :delete_public_access_block
90
+ Aws::S3Control::Endpoints::DeletePublicAccessBlock.build(context)
91
+ when :delete_storage_lens_configuration
92
+ Aws::S3Control::Endpoints::DeleteStorageLensConfiguration.build(context)
93
+ when :delete_storage_lens_configuration_tagging
94
+ Aws::S3Control::Endpoints::DeleteStorageLensConfigurationTagging.build(context)
95
+ when :describe_job
96
+ Aws::S3Control::Endpoints::DescribeJob.build(context)
97
+ when :describe_multi_region_access_point_operation
98
+ Aws::S3Control::Endpoints::DescribeMultiRegionAccessPointOperation.build(context)
99
+ when :get_access_point
100
+ Aws::S3Control::Endpoints::GetAccessPoint.build(context)
101
+ when :get_access_point_configuration_for_object_lambda
102
+ Aws::S3Control::Endpoints::GetAccessPointConfigurationForObjectLambda.build(context)
103
+ when :get_access_point_for_object_lambda
104
+ Aws::S3Control::Endpoints::GetAccessPointForObjectLambda.build(context)
105
+ when :get_access_point_policy
106
+ Aws::S3Control::Endpoints::GetAccessPointPolicy.build(context)
107
+ when :get_access_point_policy_for_object_lambda
108
+ Aws::S3Control::Endpoints::GetAccessPointPolicyForObjectLambda.build(context)
109
+ when :get_access_point_policy_status
110
+ Aws::S3Control::Endpoints::GetAccessPointPolicyStatus.build(context)
111
+ when :get_access_point_policy_status_for_object_lambda
112
+ Aws::S3Control::Endpoints::GetAccessPointPolicyStatusForObjectLambda.build(context)
113
+ when :get_bucket
114
+ Aws::S3Control::Endpoints::GetBucket.build(context)
115
+ when :get_bucket_lifecycle_configuration
116
+ Aws::S3Control::Endpoints::GetBucketLifecycleConfiguration.build(context)
117
+ when :get_bucket_policy
118
+ Aws::S3Control::Endpoints::GetBucketPolicy.build(context)
119
+ when :get_bucket_tagging
120
+ Aws::S3Control::Endpoints::GetBucketTagging.build(context)
121
+ when :get_bucket_versioning
122
+ Aws::S3Control::Endpoints::GetBucketVersioning.build(context)
123
+ when :get_job_tagging
124
+ Aws::S3Control::Endpoints::GetJobTagging.build(context)
125
+ when :get_multi_region_access_point
126
+ Aws::S3Control::Endpoints::GetMultiRegionAccessPoint.build(context)
127
+ when :get_multi_region_access_point_policy
128
+ Aws::S3Control::Endpoints::GetMultiRegionAccessPointPolicy.build(context)
129
+ when :get_multi_region_access_point_policy_status
130
+ Aws::S3Control::Endpoints::GetMultiRegionAccessPointPolicyStatus.build(context)
131
+ when :get_public_access_block
132
+ Aws::S3Control::Endpoints::GetPublicAccessBlock.build(context)
133
+ when :get_storage_lens_configuration
134
+ Aws::S3Control::Endpoints::GetStorageLensConfiguration.build(context)
135
+ when :get_storage_lens_configuration_tagging
136
+ Aws::S3Control::Endpoints::GetStorageLensConfigurationTagging.build(context)
137
+ when :list_access_points
138
+ Aws::S3Control::Endpoints::ListAccessPoints.build(context)
139
+ when :list_access_points_for_object_lambda
140
+ Aws::S3Control::Endpoints::ListAccessPointsForObjectLambda.build(context)
141
+ when :list_jobs
142
+ Aws::S3Control::Endpoints::ListJobs.build(context)
143
+ when :list_multi_region_access_points
144
+ Aws::S3Control::Endpoints::ListMultiRegionAccessPoints.build(context)
145
+ when :list_regional_buckets
146
+ Aws::S3Control::Endpoints::ListRegionalBuckets.build(context)
147
+ when :list_storage_lens_configurations
148
+ Aws::S3Control::Endpoints::ListStorageLensConfigurations.build(context)
149
+ when :put_access_point_configuration_for_object_lambda
150
+ Aws::S3Control::Endpoints::PutAccessPointConfigurationForObjectLambda.build(context)
151
+ when :put_access_point_policy
152
+ Aws::S3Control::Endpoints::PutAccessPointPolicy.build(context)
153
+ when :put_access_point_policy_for_object_lambda
154
+ Aws::S3Control::Endpoints::PutAccessPointPolicyForObjectLambda.build(context)
155
+ when :put_bucket_lifecycle_configuration
156
+ Aws::S3Control::Endpoints::PutBucketLifecycleConfiguration.build(context)
157
+ when :put_bucket_policy
158
+ Aws::S3Control::Endpoints::PutBucketPolicy.build(context)
159
+ when :put_bucket_tagging
160
+ Aws::S3Control::Endpoints::PutBucketTagging.build(context)
161
+ when :put_bucket_versioning
162
+ Aws::S3Control::Endpoints::PutBucketVersioning.build(context)
163
+ when :put_job_tagging
164
+ Aws::S3Control::Endpoints::PutJobTagging.build(context)
165
+ when :put_multi_region_access_point_policy
166
+ Aws::S3Control::Endpoints::PutMultiRegionAccessPointPolicy.build(context)
167
+ when :put_public_access_block
168
+ Aws::S3Control::Endpoints::PutPublicAccessBlock.build(context)
169
+ when :put_storage_lens_configuration
170
+ Aws::S3Control::Endpoints::PutStorageLensConfiguration.build(context)
171
+ when :put_storage_lens_configuration_tagging
172
+ Aws::S3Control::Endpoints::PutStorageLensConfigurationTagging.build(context)
173
+ when :update_job_priority
174
+ Aws::S3Control::Endpoints::UpdateJobPriority.build(context)
175
+ when :update_job_status
176
+ Aws::S3Control::Endpoints::UpdateJobStatus.build(context)
177
+ end
178
+ end
179
+ end
180
+
181
+ def add_handlers(handlers, _config)
182
+ handlers.add(Handler, step: :build, priority: 75)
183
+ end
184
+ end
185
+ end
186
+ end