@@ -37,8 +37,9 @@ class Client
37
37
#
38
38
# @param [Hash] arguments - initializer arguments
39
39
# @option arguments [String] :cloud_id - The Cloud ID to connect to Elastic Cloud
40
- # @option arguments [String, Hash] :api_key Use API Key Authentication, either the base64 encoding of `id` and `api_key`
41
- # joined by a colon as a String, or a hash with the `id` and `api_key` values.
40
+ # @option arguments [String, Hash] :api_key Use API Key Authentication, either the base64 encoding of `id` and
41
+ # `api_key` joined by a colon as a String, or a hash with the `id` and
42
+ # `api_key` values.
42
43
# @option arguments [String] :opaque_id_prefix set a prefix for X-Opaque-Id when initializing the client.
43
44
# This will be prepended to the id you set before each request
44
45
# if you're using X-Opaque-Id
@@ -65,10 +66,10 @@ def method_missing(name, *args, &block)
65
66
opaque_id = @opaque_id_prefix ? "#{ @opaque_id_prefix } #{ opaque_id } " : opaque_id
66
67
args [ 4 ] = headers . merge ( 'X-Opaque-Id' => opaque_id )
67
68
end
68
- unless @verified
69
- verify_elasticsearch ( *args , &block )
70
- else
69
+ if @verified
71
70
@transport . perform_request ( *args , &block )
71
+ else
72
+ verify_elasticsearch ( *args , &block )
72
73
end
73
74
else
74
75
@transport . send ( name , *args , &block )
@@ -101,6 +102,7 @@ def verify_elasticsearch(*args, &block)
101
102
raise e
102
103
end
103
104
raise Elasticsearch ::UnsupportedProductError unless response . headers [ 'x-elastic-product' ] == 'Elasticsearch'
105
+
104
106
@verified = true
105
107
response
106
108
end
@@ -175,7 +177,7 @@ def set_user_agent!(arguments)
175
177
end
176
178
arguments [ :transport_options ] ||= { }
177
179
arguments [ :transport_options ] [ :headers ] ||= { }
178
- arguments [ :transport_options ] [ :headers ] . merge! ( { user_agent : user_agent . join ( '; ' ) } )
180
+ arguments [ :transport_options ] [ :headers ] . merge! ( { user_agent : user_agent . join ( '; ' ) } )
179
181
end
180
182
end
181
183
0 commit comments