Class: Diplomat::RaftOperator

Inherits:
RestClient show all
Defined in:
lib/diplomat/raft.rb

Overview

Methods for interacting with the Consul operator raft API endpoint

Instance Method Summary collapse

Methods inherited from RestClient

access_method?, #concat_url, #configuration, #initialize, method_missing, respond_to?, respond_to_missing?, #use_named_parameter

Constructor Details

This class inherits a constructor from Diplomat::RestClient

Instance Method Details

#get_configuration(options = {}) ⇒ OpenStruct

Get raft configuration

Parameters:

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

    options parameter hash

Returns:

  • (OpenStruct)

    all data associated with the raft configuration



11
12
13
14
15
16
17
# File 'lib/diplomat/raft.rb', line 11

def get_configuration(options = {})
  custom_params = []
  custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]

  ret = send_get_request(@conn, ['/v1/operator/raft/configuration'], options, custom_params)
  JSON.parse(ret.body)
end

#transfer_leader(options = {}) ⇒ OpenStruct

Transfer raft leadership

Parameters:

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

    options parameter hash

Returns:

  • (OpenStruct)

    all data associated with the transfer status with format [“true”|“false”]



23
24
25
26
27
# File 'lib/diplomat/raft.rb', line 23

def transfer_leader(options = {})
  custom_params = options[:id] ? use_named_parameter('id', options[:id]) : nil
  @raw = send_post_request(@conn, ['/v1/operator/raft/transfer-leader'], options, nil, custom_params)
  JSON.parse(@raw.body)
end