Class: Aws::S3Control::EndpointProvider

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-s3control/lib/aws-sdk-s3control/endpoint_provider.rb

Instance Method Summary collapse

Instance Method Details

#resolve_endpoint(parameters) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'gems/aws-sdk-s3control/lib/aws-sdk-s3control/endpoint_provider.rb', line 12

def resolve_endpoint(parameters)
  region = parameters.region
  use_fips = parameters.use_fips
  use_dual_stack = parameters.use_dual_stack
  endpoint = parameters.endpoint
   = parameters.
   = parameters.
  outpost_id = parameters.outpost_id
  bucket = parameters.bucket
  access_point_name = parameters.access_point_name
  use_arn_region = parameters.use_arn_region
  if Aws::Endpoints::Matchers.set?(region)
    if Aws::Endpoints::Matchers.set?(outpost_id)
      if (partition_result = Aws::Endpoints::Matchers.aws_partition(region))
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true) && Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(partition_result, "name"), "aws-cn")
          raise ArgumentError, "Partition does not support FIPS"
        end
        if Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.boolean_equals?(, true) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.set?())
          raise ArgumentError, "AccountId is required but not set"
        end
        if Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.valid_host_label?(, false))
          raise ArgumentError, "AccountId must only contain a-z, A-Z, 0-9 and `-`."
        end
        if Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.valid_host_label?(outpost_id, false))
          raise ArgumentError, "OutpostId must only contain a-z, A-Z, 0-9 and `-`."
        end
        if Aws::Endpoints::Matchers.valid_host_label?(region, true)
          if Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
            raise ArgumentError, "Invalid configuration: Outposts do not support dual-stack"
          end
          if Aws::Endpoints::Matchers.set?(endpoint) && (url = Aws::Endpoints::Matchers.parse_url(endpoint))
            return Aws::Endpoints::Endpoint.new(url: "#{url['scheme']}://#{url['authority']}#{url['path']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
          end
          if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true)
            return Aws::Endpoints::Endpoint.new(url: "https://s3-outposts-fips.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
          end
          return Aws::Endpoints::Endpoint.new(url: "https://s3-outposts.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        raise ArgumentError, "Invalid region: region was not a valid DNS name."
      end
      raise ArgumentError, "A valid partition could not be determined"
    end
    if Aws::Endpoints::Matchers.set?(access_point_name) && (access_point_arn = Aws::Endpoints::Matchers.aws_parse_arn(access_point_name))
      if (arn_type = Aws::Endpoints::Matchers.attr(access_point_arn, "resourceId[0]")) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(arn_type, ""))
        if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(access_point_arn, "service"), "s3-outposts")
          if Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
            raise ArgumentError, "Invalid configuration: Outpost Access Points do not support dual-stack"
          end
          if (outpost_id = Aws::Endpoints::Matchers.attr(access_point_arn, "resourceId[1]"))
            if Aws::Endpoints::Matchers.valid_host_label?(outpost_id, false)
              if Aws::Endpoints::Matchers.set?(use_arn_region) && Aws::Endpoints::Matchers.boolean_equals?(use_arn_region, false) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(access_point_arn, "region"), "#{region}"))
                raise ArgumentError, "Invalid configuration: region from ARN `#{access_point_arn['region']}` does not match client region `#{region}` and UseArnRegion is `false`"
              end
              if (partition_result = Aws::Endpoints::Matchers.aws_partition(region))
                if (arn_partition = Aws::Endpoints::Matchers.aws_partition(Aws::Endpoints::Matchers.attr(access_point_arn, "region")))
                  if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(arn_partition, "name"), Aws::Endpoints::Matchers.attr(partition_result, "name"))
                    if Aws::Endpoints::Matchers.valid_host_label?(Aws::Endpoints::Matchers.attr(access_point_arn, "region"), true)
                      if Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(access_point_arn, "accountId"), ""))
                        if Aws::Endpoints::Matchers.valid_host_label?(Aws::Endpoints::Matchers.attr(access_point_arn, "accountId"), false)
                          if Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(, "#{access_point_arn['accountId']}"))
                            raise ArgumentError, "Invalid ARN: the accountId specified in the ARN (`#{access_point_arn['accountId']}`) does not match the parameter (`#{}`)"
                          end
                          if (outpost_type = Aws::Endpoints::Matchers.attr(access_point_arn, "resourceId[2]"))
                            if (access_point_name = Aws::Endpoints::Matchers.attr(access_point_arn, "resourceId[3]"))
                              if Aws::Endpoints::Matchers.string_equals?(outpost_type, "accesspoint")
                                if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true)
                                  return Aws::Endpoints::Endpoint.new(url: "https://s3-outposts-fips.#{access_point_arn['region']}.#{arn_partition['dnsSuffix']}", headers: {"x-amz-account-id"=>["#{access_point_arn['accountId']}"], "x-amz-outpost-id"=>["#{outpost_id}"]}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{access_point_arn['region']}"}]})
                                end
                                if Aws::Endpoints::Matchers.set?(endpoint) && (url = Aws::Endpoints::Matchers.parse_url(endpoint))
                                  return Aws::Endpoints::Endpoint.new(url: "#{url['scheme']}://#{url['authority']}#{url['path']}", headers: {"x-amz-account-id"=>["#{access_point_arn['accountId']}"], "x-amz-outpost-id"=>["#{outpost_id}"]}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{access_point_arn['region']}"}]})
                                end
                                return Aws::Endpoints::Endpoint.new(url: "https://s3-outposts.#{access_point_arn['region']}.#{arn_partition['dnsSuffix']}", headers: {"x-amz-account-id"=>["#{access_point_arn['accountId']}"], "x-amz-outpost-id"=>["#{outpost_id}"]}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{access_point_arn['region']}"}]})
                              end
                              raise ArgumentError, "Expected an outpost type `accesspoint`, found `#{outpost_type}`"
                            end
                            raise ArgumentError, "Invalid ARN: expected an access point name"
                          end
                          raise ArgumentError, "Invalid ARN: Expected a 4-component resource"
                        end
                        raise ArgumentError, "Invalid ARN: The account id may only contain a-z, A-Z, 0-9 and `-`. Found: `#{access_point_arn['accountId']}`"
                      end
                      raise ArgumentError, "Invalid ARN: missing account ID"
                    end
                    raise ArgumentError, "Invalid region in ARN: `#{access_point_arn['region']}` (invalid DNS name)"
                  end
                  raise ArgumentError, "Client was configured for partition `#{partition_result['name']}` but ARN has `#{arn_partition['name']}`"
                end
                raise ArgumentError, "Could not load partition for ARN region `#{access_point_arn['region']}`"
              end
              raise ArgumentError, "A valid partition could not be determined"
            end
            raise ArgumentError, "Invalid ARN: The outpost Id must only contain a-z, A-Z, 0-9 and `-`., found: `#{outpost_id}`"
          end
          raise ArgumentError, "Invalid ARN: The Outpost Id was not set"
        end
      end
      raise ArgumentError, "Invalid ARN: No ARN type specified"
    end
    if Aws::Endpoints::Matchers.set?(bucket) && (bucket_arn = Aws::Endpoints::Matchers.aws_parse_arn(bucket))
      if (arn_type = Aws::Endpoints::Matchers.attr(bucket_arn, "resourceId[0]")) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(arn_type, ""))
        if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(bucket_arn, "service"), "s3-outposts")
          if Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
            raise ArgumentError, "Invalid configuration: Outpost buckets do not support dual-stack"
          end
          if (outpost_id = Aws::Endpoints::Matchers.attr(bucket_arn, "resourceId[1]"))
            if Aws::Endpoints::Matchers.valid_host_label?(outpost_id, false)
              if Aws::Endpoints::Matchers.set?(use_arn_region) && Aws::Endpoints::Matchers.boolean_equals?(use_arn_region, false) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(bucket_arn, "region"), "#{region}"))
                raise ArgumentError, "Invalid configuration: region from ARN `#{bucket_arn['region']}` does not match client region `#{region}` and UseArnRegion is `false`"
              end
              if (arn_partition = Aws::Endpoints::Matchers.aws_partition(Aws::Endpoints::Matchers.attr(bucket_arn, "region")))
                if (partition_result = Aws::Endpoints::Matchers.aws_partition(region))
                  if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(arn_partition, "name"), Aws::Endpoints::Matchers.attr(partition_result, "name"))
                    if Aws::Endpoints::Matchers.valid_host_label?(Aws::Endpoints::Matchers.attr(bucket_arn, "region"), true)
                      if Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(bucket_arn, "accountId"), ""))
                        if Aws::Endpoints::Matchers.valid_host_label?(Aws::Endpoints::Matchers.attr(bucket_arn, "accountId"), false)
                          if Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.string_equals?(, "#{bucket_arn['accountId']}"))
                            raise ArgumentError, "Invalid ARN: the accountId specified in the ARN (`#{bucket_arn['accountId']}`) does not match the parameter (`#{}`)"
                          end
                          if (outpost_type = Aws::Endpoints::Matchers.attr(bucket_arn, "resourceId[2]"))
                            if (bucket_name = Aws::Endpoints::Matchers.attr(bucket_arn, "resourceId[3]"))
                              if Aws::Endpoints::Matchers.string_equals?(outpost_type, "bucket")
                                if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true)
                                  return Aws::Endpoints::Endpoint.new(url: "https://s3-outposts-fips.#{bucket_arn['region']}.#{arn_partition['dnsSuffix']}", headers: {"x-amz-account-id"=>["#{bucket_arn['accountId']}"], "x-amz-outpost-id"=>["#{outpost_id}"]}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{bucket_arn['region']}"}]})
                                end
                                if Aws::Endpoints::Matchers.set?(endpoint) && (url = Aws::Endpoints::Matchers.parse_url(endpoint))
                                  return Aws::Endpoints::Endpoint.new(url: "#{url['scheme']}://#{url['authority']}#{url['path']}", headers: {"x-amz-account-id"=>["#{bucket_arn['accountId']}"], "x-amz-outpost-id"=>["#{outpost_id}"]}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{bucket_arn['region']}"}]})
                                end
                                return Aws::Endpoints::Endpoint.new(url: "https://s3-outposts.#{bucket_arn['region']}.#{arn_partition['dnsSuffix']}", headers: {"x-amz-account-id"=>["#{bucket_arn['accountId']}"], "x-amz-outpost-id"=>["#{outpost_id}"]}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3-outposts", "disableDoubleEncoding"=>true, "signingRegion"=>"#{bucket_arn['region']}"}]})
                              end
                              raise ArgumentError, "Invalid ARN: Expected an outpost type `bucket`, found `#{outpost_type}`"
                            end
                            raise ArgumentError, "Invalid ARN: expected a bucket name"
                          end
                          raise ArgumentError, "Invalid ARN: Expected a 4-component resource"
                        end
                        raise ArgumentError, "Invalid ARN: The account id may only contain a-z, A-Z, 0-9 and `-`. Found: `#{bucket_arn['accountId']}`"
                      end
                      raise ArgumentError, "Invalid ARN: missing account ID"
                    end
                    raise ArgumentError, "Invalid region in ARN: `#{bucket_arn['region']}` (invalid DNS name)"
                  end
                  raise ArgumentError, "Client was configured for partition `#{partition_result['name']}` but ARN has `#{arn_partition['name']}`"
                end
                raise ArgumentError, "A valid partition could not be determined"
              end
              raise ArgumentError, "Could not load partition for ARN region `#{bucket_arn['region']}`"
            end
            raise ArgumentError, "Invalid ARN: The outpost Id must only contain a-z, A-Z, 0-9 and `-`., found: `#{outpost_id}`"
          end
          raise ArgumentError, "Invalid ARN: The Outpost Id was not set"
        end
      end
      raise ArgumentError, "Invalid ARN: No ARN type specified"
    end
    if (partition_result = Aws::Endpoints::Matchers.aws_partition(region))
      if Aws::Endpoints::Matchers.valid_host_label?(region, true)
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true) && Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(partition_result, "name"), "aws-cn")
          raise ArgumentError, "Partition does not support FIPS"
        end
        if Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.boolean_equals?(, true) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.set?())
          raise ArgumentError, "AccountId is required but not set"
        end
        if Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.valid_host_label?(, false))
          raise ArgumentError, "AccountId must only contain a-z, A-Z, 0-9 and `-`."
        end
        if Aws::Endpoints::Matchers.set?(endpoint) && (url = Aws::Endpoints::Matchers.parse_url(endpoint))
          if Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
            raise ArgumentError, "Invalid Configuration: Dualstack and custom endpoint are not supported"
          end
          if Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.boolean_equals?(, true) && Aws::Endpoints::Matchers.set?()
            return Aws::Endpoints::Endpoint.new(url: "#{url['scheme']}://#{}.#{url['authority']}#{url['path']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
          end
          return Aws::Endpoints::Endpoint.new(url: "#{url['scheme']}://#{url['authority']}#{url['path']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true) && Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.boolean_equals?(, true) && Aws::Endpoints::Matchers.set?()
          return Aws::Endpoints::Endpoint.new(url: "https://#{}.s3-control-fips.dualstack.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
          return Aws::Endpoints::Endpoint.new(url: "https://s3-control-fips.dualstack.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, false) && Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.boolean_equals?(, true) && Aws::Endpoints::Matchers.set?()
          return Aws::Endpoints::Endpoint.new(url: "https://#{}.s3-control-fips.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, true) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, false)
          return Aws::Endpoints::Endpoint.new(url: "https://s3-control-fips.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, false) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true) && Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.boolean_equals?(, true) && Aws::Endpoints::Matchers.set?()
          return Aws::Endpoints::Endpoint.new(url: "https://#{}.s3-control.dualstack.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, false) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, true)
          return Aws::Endpoints::Endpoint.new(url: "https://s3-control.dualstack.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, false) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, false) && Aws::Endpoints::Matchers.set?() && Aws::Endpoints::Matchers.boolean_equals?(, true) && Aws::Endpoints::Matchers.set?()
          return Aws::Endpoints::Endpoint.new(url: "https://#{}.s3-control.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
        if Aws::Endpoints::Matchers.boolean_equals?(use_fips, false) && Aws::Endpoints::Matchers.boolean_equals?(use_dual_stack, false)
          return Aws::Endpoints::Endpoint.new(url: "https://s3-control.#{region}.#{partition_result['dnsSuffix']}", headers: {}, properties: {"authSchemes"=>[{"name"=>"sigv4", "signingName"=>"s3", "disableDoubleEncoding"=>true, "signingRegion"=>"#{region}"}]})
        end
      end
      raise ArgumentError, "Invalid region: region was not a valid DNS name."
    end
    raise ArgumentError, "A valid partition could not be determined"
  end
  raise ArgumentError, "Region must be set"
  raise ArgumentError, 'No endpoint could be resolved'

end