Module: Aws::Endpoints::Matchers Private
- Defined in:
- lib/aws-sdk-core/endpoints/matchers.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
generic matcher functions for service endpoints
Constant Summary collapse
- BRACKET_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regex that extracts anything in square brackets
/\[(.*?)\]/.freeze
Class Method Summary collapse
-
.attr(value, path) ⇒ Object
private
getAttr(value: Object | Array, path: string) Document.
-
.aws_parse_arn(value) ⇒ Object
private
aws.parseArn(value: string) Option<ARN>.
-
.aws_partition(value) ⇒ Object
private
aws.partition(value: string) Option<Partition>.
-
.aws_virtual_hostable_s3_bucket?(value, allow_sub_domains = false) ⇒ Boolean
private
aws.isVirtualHostableS3Bucket(value: string, allowSubDomains: bool) bool.
-
.boolean_equals?(value1, value2) ⇒ Boolean
private
booleanEquals(value1: bool, value2: bool) bool.
-
.not(bool) ⇒ Object
private
not(value: bool) bool.
-
.parse_url(value) ⇒ Object
private
parseUrl(value: string) Option<URL>.
-
.set?(value) ⇒ Boolean
private
isSet(value: Option<T>) bool.
-
.string_equals?(value1, value2) ⇒ Boolean
private
stringEquals(value1: string, value2: string) bool.
- .substring(input, start, stop, reverse) ⇒ Object private
-
.uri_encode(value) ⇒ Object
private
uriEncode(value: string) string.
-
.valid_host_label?(value, allow_sub_domains = false) ⇒ Boolean
private
isValidHostLabel(value: string, allowSubDomains: bool) bool.
Class Method Details
.attr(value, path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
getAttr(value: Object | Array, path: string) Document
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 27 def self.attr(value, path) parts = path.split('.') val = if (index = parts.first[BRACKET_REGEX, 1]) # remove brackets and index from part before indexing if (base = parts.first.gsub(BRACKET_REGEX, '')) && !base.empty? value[base][index.to_i] else value[index.to_i] end else value[parts.first] end if parts.size == 1 val else attr(val, parts.slice(1..-1).join('.')) end end |
.aws_parse_arn(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
aws.parseArn(value: string) Option<ARN>
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 102 def self.aws_parse_arn(value) arn = Aws::ARNParser.parse(value) json = arn.as_json # HACK: because of poor naming and also requirement of splitting resource = json.delete('resource') json['resourceId'] = resource.split(%r{[:\/]}, -1) json rescue Aws::Errors::InvalidARNError nil end |
.aws_partition(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
aws.partition(value: string) Option<Partition>
97 98 99 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 97 def self.aws_partition(value) Aws::Partitions::Metadata.partition(value) end |
.aws_virtual_hostable_s3_bucket?(value, allow_sub_domains = false) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
aws.isVirtualHostableS3Bucket(value: string, allowSubDomains: bool) bool
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 114 def self.aws_virtual_hostable_s3_bucket?(value, allow_sub_domains = false) return false if value.empty? if allow_sub_domains labels = value.split('.', -1) return labels.all? { |l| aws_virtual_hostable_s3_bucket?(l) } end # must be between 3 and 63 characters long, no uppercase value =~ /\A(?!-)[a-z0-9-]{3,63}(?<!-)\z/ && # not an IP address value !~ /(\d+\.){3}\d+/ end |
.boolean_equals?(value1, value2) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
booleanEquals(value1: bool, value2: bool) bool
66 67 68 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 66 def self.boolean_equals?(value1, value2) value1 == value2 end |
.not(bool) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
not(value: bool) bool
22 23 24 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 22 def self.not(bool) !bool end |
.parse_url(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
parseUrl(value: string) Option<URL>
76 77 78 79 80 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 76 def self.parse_url(value) URL.new(value).as_json rescue ArgumentError, URI::InvalidURIError nil end |
.set?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
isSet(value: Option<T>) bool
17 18 19 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 17 def self.set?(value) !value.nil? end |
.string_equals?(value1, value2) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
stringEquals(value1: string, value2: string) bool
61 62 63 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 61 def self.string_equals?(value1, value2) value1 == value2 end |
.substring(input, start, stop, reverse) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 48 def self.substring(input, start, stop, reverse) return nil if start >= stop || input.size < stop return nil if input.chars.any? { |c| c.ord > 127 } return input[start...stop] unless reverse r_start = input.size - stop r_stop = input.size - start input[r_start...r_stop] end |
.uri_encode(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
uriEncode(value: string) string
71 72 73 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 71 def self.uri_encode(value) CGI.escape(value.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~') end |
.valid_host_label?(value, allow_sub_domains = false) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
isValidHostLabel(value: string, allowSubDomains: bool) bool
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/aws-sdk-core/endpoints/matchers.rb', line 83 def self.valid_host_label?(value, allow_sub_domains = false) return false if value.empty? if allow_sub_domains labels = value.split('.', -1) return labels.all? { |l| valid_host_label?(l) } end !!(value =~ /\A(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\z/) end |