Method: Diplomat::Query#create

Defined in:
lib/diplomat/query.rb

#create(definition, options = {}) ⇒ String

Create a prepared query or prepared query template

Parameters:

  • definition (Hash)

    Hash containing definition of prepared query

  • options (Hash) (defaults to: {})

    :dc Consul datacenter to query

Returns:

  • (String)

    the ID of the prepared query created



31
32
33
34
35
36
37
# File 'lib/diplomat/query.rb', line 31

def create(definition, options = {})
  custom_params = options[:dc] ? use_named_parameter('dc', options[:dc]) : nil
  @raw = send_post_request(@conn, ['/v1/query'], options, definition, custom_params)
  parse_body
rescue Faraday::ClientError
  raise Diplomat::QueryAlreadyExists
end