Method: Elasticsearch::API::Snapshot::Actions#clone

Defined in:
lib/elasticsearch/api/actions/snapshot/clone.rb

#clone(arguments = {}) ⇒ Object

Clones indices from one snapshot into another snapshot in the same repository.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    A repository name

  • :snapshot (String)

    The name of the snapshot to clone from

  • :target_snapshot (String)

    The name of the cloned snapshot to create

  • :master_timeout (Time)

    Explicit operation timeout for connection to master node

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The snapshot clone definition (Required)

Raises:

  • (ArgumentError)

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/elasticsearch/api/actions/snapshot/clone.rb', line 36

def clone(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || "snapshot.clone" }

  defined_params = [:repository, :snapshot, :target_snapshot].inject({}) do |set_variables, variable|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
    set_variables
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
  raise ArgumentError, "Required argument 'target_snapshot' missing" unless arguments[:target_snapshot]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _repository = arguments.delete(:repository)

  _snapshot = arguments.delete(:snapshot)

  _target_snapshot = arguments.delete(:target_snapshot)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_clone/#{Utils.__listify(_target_snapshot)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end