aws-sdk-arcregionswitch 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,67 @@
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::ARCRegionswitch
11
+ # Endpoint parameters used to influence endpoints per request.
12
+ #
13
+ # @!attribute use_fips
14
+ # 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.
15
+ #
16
+ # @return [Boolean]
17
+ #
18
+ # @!attribute endpoint
19
+ # Override the endpoint used to send this request
20
+ #
21
+ # @return [String]
22
+ #
23
+ # @!attribute region
24
+ # The AWS region used to dispatch the request.
25
+ #
26
+ # @return [String]
27
+ #
28
+ # @!attribute use_control_plane_endpoint
29
+ # Whether the operation is a control plane operation. Control plane operations are routed to a centralized endpoint in the partition leader.
30
+ #
31
+ # @return [Boolean]
32
+ #
33
+ EndpointParameters = Struct.new(
34
+ :use_fips,
35
+ :endpoint,
36
+ :region,
37
+ :use_control_plane_endpoint,
38
+ ) do
39
+ include Aws::Structure
40
+
41
+ # @api private
42
+ class << self
43
+ PARAM_MAP = {
44
+ 'UseFIPS' => :use_fips,
45
+ 'Endpoint' => :endpoint,
46
+ 'Region' => :region,
47
+ 'UseControlPlaneEndpoint' => :use_control_plane_endpoint,
48
+ }.freeze
49
+ end
50
+
51
+ def initialize(options = {})
52
+ self[:use_fips] = options[:use_fips]
53
+ self[:use_fips] = false if self[:use_fips].nil?
54
+ self[:endpoint] = options[:endpoint]
55
+ self[:region] = options[:region]
56
+ self[:use_control_plane_endpoint] = options[:use_control_plane_endpoint]
57
+ end
58
+
59
+ def self.create(config, options={})
60
+ new({
61
+ use_fips: config.use_fips_endpoint,
62
+ endpoint: (config.endpoint.to_s unless config.regional_endpoint),
63
+ region: config.region,
64
+ }.merge(options))
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,44 @@
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::ARCRegionswitch
11
+ class EndpointProvider
12
+ def resolve_endpoint(parameters)
13
+ if Aws::Endpoints::Matchers.set?(parameters.use_control_plane_endpoint) && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_control_plane_endpoint, true) && Aws::Endpoints::Matchers.set?(parameters.region) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.set?(parameters.endpoint)) && (partition_result = Aws::Endpoints::Matchers.aws_partition(parameters.region)) && Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(partition_result, "name"), "aws-cn")
14
+ return Aws::Endpoints::Endpoint.new(url: "https://arc-region-switch-control-plane.cn-north-1.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4", "signingName" => "arc-region-switch", "signingRegion" => "cn-north-1"}]})
15
+ end
16
+ if Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.set?(parameters.endpoint)) && Aws::Endpoints::Matchers.set?(parameters.use_control_plane_endpoint) && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_control_plane_endpoint, true) && Aws::Endpoints::Matchers.set?(parameters.region) && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true) && (partition_result = Aws::Endpoints::Matchers.aws_partition(parameters.region))
17
+ if Aws::Endpoints::Matchers.string_equals?(Aws::Endpoints::Matchers.attr(partition_result, "name"), "aws-cn")
18
+ raise ArgumentError, "Invalid Configuration: FIPS is not supported in this partition"
19
+ end
20
+ return Aws::Endpoints::Endpoint.new(url: "https://arc-region-switch-control-plane-fips.#{partition_result['implicitGlobalRegion']}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4", "signingName" => "arc-region-switch", "signingRegion" => "#{partition_result['implicitGlobalRegion']}"}]})
21
+ end
22
+ if Aws::Endpoints::Matchers.set?(parameters.use_control_plane_endpoint) && Aws::Endpoints::Matchers.boolean_equals?(parameters.use_control_plane_endpoint, true) && Aws::Endpoints::Matchers.set?(parameters.region) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)) && Aws::Endpoints::Matchers.not(Aws::Endpoints::Matchers.set?(parameters.endpoint)) && (partition_result = Aws::Endpoints::Matchers.aws_partition(parameters.region))
23
+ return Aws::Endpoints::Endpoint.new(url: "https://arc-region-switch-control-plane.#{partition_result['implicitGlobalRegion']}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {"authSchemes" => [{"name" => "sigv4", "signingName" => "arc-region-switch", "signingRegion" => "#{partition_result['implicitGlobalRegion']}"}]})
24
+ end
25
+ if Aws::Endpoints::Matchers.set?(parameters.endpoint)
26
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
27
+ raise ArgumentError, "Invalid Configuration: FIPS and custom endpoint are not supported"
28
+ end
29
+ return Aws::Endpoints::Endpoint.new(url: parameters.endpoint, headers: {}, properties: {})
30
+ end
31
+ if Aws::Endpoints::Matchers.set?(parameters.region)
32
+ if (partition_result = Aws::Endpoints::Matchers.aws_partition(parameters.region))
33
+ if Aws::Endpoints::Matchers.boolean_equals?(parameters.use_fips, true)
34
+ return Aws::Endpoints::Endpoint.new(url: "https://arc-region-switch-fips.#{parameters.region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
35
+ end
36
+ return Aws::Endpoints::Endpoint.new(url: "https://arc-region-switch.#{parameters.region}.#{partition_result['dualStackDnsSuffix']}", headers: {}, properties: {})
37
+ end
38
+ end
39
+ raise ArgumentError, "Invalid Configuration: Missing Region"
40
+ raise ArgumentError, 'No endpoint could be resolved'
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,122 @@
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::ARCRegionswitch
12
+ # @api private
13
+ module Endpoints
14
+
15
+ class CreatePlan
16
+ def self.build(context)
17
+ Aws::ARCRegionswitch::EndpointParameters.create(
18
+ context.config,
19
+ use_control_plane_endpoint: true,
20
+ )
21
+ end
22
+ end
23
+
24
+ class DeletePlan
25
+ def self.build(context)
26
+ Aws::ARCRegionswitch::EndpointParameters.create(
27
+ context.config,
28
+ use_control_plane_endpoint: true,
29
+ )
30
+ end
31
+ end
32
+
33
+ class GetPlan
34
+ def self.build(context)
35
+ Aws::ARCRegionswitch::EndpointParameters.create(
36
+ context.config,
37
+ use_control_plane_endpoint: true,
38
+ )
39
+ end
40
+ end
41
+
42
+ class ListPlans
43
+ def self.build(context)
44
+ Aws::ARCRegionswitch::EndpointParameters.create(
45
+ context.config,
46
+ use_control_plane_endpoint: true,
47
+ )
48
+ end
49
+ end
50
+
51
+ class ListRoute53HealthChecks
52
+ def self.build(context)
53
+ Aws::ARCRegionswitch::EndpointParameters.create(
54
+ context.config,
55
+ use_control_plane_endpoint: true,
56
+ )
57
+ end
58
+ end
59
+
60
+ class ListTagsForResource
61
+ def self.build(context)
62
+ Aws::ARCRegionswitch::EndpointParameters.create(
63
+ context.config,
64
+ use_control_plane_endpoint: true,
65
+ )
66
+ end
67
+ end
68
+
69
+ class TagResource
70
+ def self.build(context)
71
+ Aws::ARCRegionswitch::EndpointParameters.create(
72
+ context.config,
73
+ use_control_plane_endpoint: true,
74
+ )
75
+ end
76
+ end
77
+
78
+ class UntagResource
79
+ def self.build(context)
80
+ Aws::ARCRegionswitch::EndpointParameters.create(
81
+ context.config,
82
+ use_control_plane_endpoint: true,
83
+ )
84
+ end
85
+ end
86
+
87
+ class UpdatePlan
88
+ def self.build(context)
89
+ Aws::ARCRegionswitch::EndpointParameters.create(
90
+ context.config,
91
+ use_control_plane_endpoint: true,
92
+ )
93
+ end
94
+ end
95
+
96
+
97
+ def self.parameters_for_operation(context)
98
+ case context.operation_name
99
+ when :create_plan
100
+ CreatePlan.build(context)
101
+ when :delete_plan
102
+ DeletePlan.build(context)
103
+ when :get_plan
104
+ GetPlan.build(context)
105
+ when :list_plans
106
+ ListPlans.build(context)
107
+ when :list_route_53_health_checks
108
+ ListRoute53HealthChecks.build(context)
109
+ when :list_tags_for_resource
110
+ ListTagsForResource.build(context)
111
+ when :tag_resource
112
+ TagResource.build(context)
113
+ when :untag_resource
114
+ UntagResource.build(context)
115
+ when :update_plan
116
+ UpdatePlan.build(context)
117
+ else
118
+ Aws::ARCRegionswitch::EndpointParameters.create(context.config)
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,118 @@
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::ARCRegionswitch
11
+
12
+ # When ARCRegionswitch returns an error response, the Ruby SDK constructs and raises an error.
13
+ # These errors all extend Aws::ARCRegionswitch::Errors::ServiceError < {Aws::Errors::ServiceError}
14
+ #
15
+ # You can rescue all ARCRegionswitch errors using ServiceError:
16
+ #
17
+ # begin
18
+ # # do stuff
19
+ # rescue Aws::ARCRegionswitch::Errors::ServiceError
20
+ # # rescues all ARCRegionswitch 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
+ # * {IllegalArgumentException}
32
+ # * {IllegalStateException}
33
+ # * {InternalServerException}
34
+ # * {ResourceNotFoundException}
35
+ #
36
+ # Additionally, error classes are dynamically generated for service errors based on the error code
37
+ # if they are not defined above.
38
+ module Errors
39
+
40
+ extend Aws::Errors::DynamicErrors
41
+
42
+ class AccessDeniedException < ServiceError
43
+
44
+ # @param [Seahorse::Client::RequestContext] context
45
+ # @param [String] message
46
+ # @param [Aws::ARCRegionswitch::Types::AccessDeniedException] data
47
+ def initialize(context, message, data = Aws::EmptyStructure.new)
48
+ super(context, message, data)
49
+ end
50
+
51
+ # @return [String]
52
+ def message
53
+ @message || @data[:message]
54
+ end
55
+ end
56
+
57
+ class IllegalArgumentException < ServiceError
58
+
59
+ # @param [Seahorse::Client::RequestContext] context
60
+ # @param [String] message
61
+ # @param [Aws::ARCRegionswitch::Types::IllegalArgumentException] data
62
+ def initialize(context, message, data = Aws::EmptyStructure.new)
63
+ super(context, message, data)
64
+ end
65
+
66
+ # @return [String]
67
+ def message
68
+ @message || @data[:message]
69
+ end
70
+ end
71
+
72
+ class IllegalStateException < ServiceError
73
+
74
+ # @param [Seahorse::Client::RequestContext] context
75
+ # @param [String] message
76
+ # @param [Aws::ARCRegionswitch::Types::IllegalStateException] data
77
+ def initialize(context, message, data = Aws::EmptyStructure.new)
78
+ super(context, message, data)
79
+ end
80
+
81
+ # @return [String]
82
+ def message
83
+ @message || @data[:message]
84
+ end
85
+ end
86
+
87
+ class InternalServerException < ServiceError
88
+
89
+ # @param [Seahorse::Client::RequestContext] context
90
+ # @param [String] message
91
+ # @param [Aws::ARCRegionswitch::Types::InternalServerException] data
92
+ def initialize(context, message, data = Aws::EmptyStructure.new)
93
+ super(context, message, data)
94
+ end
95
+
96
+ # @return [String]
97
+ def message
98
+ @message || @data[:message]
99
+ end
100
+ end
101
+
102
+ class ResourceNotFoundException < ServiceError
103
+
104
+ # @param [Seahorse::Client::RequestContext] context
105
+ # @param [String] message
106
+ # @param [Aws::ARCRegionswitch::Types::ResourceNotFoundException] data
107
+ def initialize(context, message, data = Aws::EmptyStructure.new)
108
+ super(context, message, data)
109
+ end
110
+
111
+ # @return [String]
112
+ def message
113
+ @message || @data[:message]
114
+ end
115
+ end
116
+
117
+ end
118
+ end
@@ -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::ARCRegionswitch
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::ARCRegionswitch::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::ARCRegionswitch::EndpointParameters`.
22
+ DOCS
23
+ Aws::ARCRegionswitch::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::ARCRegionswitch::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::ARCRegionswitch
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