Module: Elasticsearch::API::IndexLifecycleManagement::Actions
- Defined in:
- lib/elasticsearch/api/actions/index_lifecycle_management/stop.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/retry.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/start.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/get_status.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/get_lifecycle.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/remove_policy.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/delete_lifecycle.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/explain_lifecycle.rb,
lib/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers.rb
Instance Method Summary collapse
-
#delete_lifecycle(arguments = {}) ⇒ Object
Delete a lifecycle policy.
-
#explain_lifecycle(arguments = {}) ⇒ Object
Explain the lifecycle state.
-
#get_lifecycle(arguments = {}) ⇒ Object
Get lifecycle policies.
-
#get_status(arguments = {}) ⇒ Object
Get the ILM status.
-
#migrate_to_data_tiers(arguments = {}) ⇒ Object
Migrate to data tiers routing.
-
#move_to_step(arguments = {}) ⇒ Object
Move to a lifecycle step.
-
#put_lifecycle(arguments = {}) ⇒ Object
Create or update a lifecycle policy.
-
#remove_policy(arguments = {}) ⇒ Object
Remove policies from an index.
-
#retry(arguments = {}) ⇒ Object
Retry a policy.
-
#start(arguments = {}) ⇒ Object
Start the ILM plugin.
-
#stop(arguments = {}) ⇒ Object
Stop the ILM plugin.
Instance Method Details
#delete_lifecycle(arguments = {}) ⇒ Object
Delete a lifecycle policy. You cannot delete policies that are currently in use. If the policy is being used to manage any indices, the request fails and returns an error.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/delete_lifecycle.rb', line 35 def delete_lifecycle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.delete_lifecycle' } defined_params = [:policy].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'policy' missing" unless arguments[:policy] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _policy = arguments.delete(:policy) method = Elasticsearch::API::HTTP_DELETE path = "_ilm/policy/#{Utils.listify(_policy)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#explain_lifecycle(arguments = {}) ⇒ Object
Explain the lifecycle state. Get the current lifecycle status for one or more indices. For data streams, the API retrieves the current lifecycle status for the stream’s backing indices. The response indicates when the index entered each lifecycle state, provides the definition of the running phase, and information about any failures.
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 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/explain_lifecycle.rb', line 39 def explain_lifecycle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.explain_lifecycle' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = "#{Utils.listify(_index)}/_ilm/explain" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_lifecycle(arguments = {}) ⇒ Object
Get lifecycle policies.
34 35 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 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/get_lifecycle.rb', line 34 def get_lifecycle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.get_lifecycle' } defined_params = [:policy].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _policy = arguments.delete(:policy) method = Elasticsearch::API::HTTP_GET path = if _policy "_ilm/policy/#{Utils.listify(_policy)}" else '_ilm/policy' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#get_status(arguments = {}) ⇒ Object
Get the ILM status. Get the current index lifecycle management status.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/get_status.rb', line 32 def get_status(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.get_status' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_ilm/status' params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#migrate_to_data_tiers(arguments = {}) ⇒ Object
Migrate to data tiers routing. Switch the indices, ILM policies, and legacy, composable, and component templates from using custom node attributes and attribute-based allocation filters to using data tiers. Optionally, delete one legacy index template. Using node roles enables ILM to automatically move the indices between data tiers. Migrating away from custom node attributes routing can be manually performed. This API provides an automated way of performing three out of the four manual steps listed in the migration guide:
-
Stop setting the custom hot attribute on new indices.
-
Remove custom allocation settings from existing ILM policies.
-
Replace custom allocation settings from existing indices with the corresponding tier preference.
ILM must be stopped before performing the migration. Use the stop ILM and get ILM status APIs to wait until the reported operation mode is STOPPED
.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers.rb', line 47 def migrate_to_data_tiers(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.migrate_to_data_tiers' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST path = '_ilm/migrate_to_data_tiers' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#move_to_step(arguments = {}) ⇒ Object
Move to a lifecycle step. Manually move an index into a specific step in the lifecycle policy and run that step. WARNING: This operation can result in the loss of data. Manually moving an index into a specific step runs that step even if it has already been performed. This is a potentially destructive action and this should be considered an expert level API. You must specify both the current step and the step to be executed in the body of the request. The request will fail if the current step does not match the step currently running for the index This is to prevent the index from being moved from an unexpected step into the next step. When specifying the target (next_step
) to which the index will be moved, either the name or both the action and name fields are optional. If only the phase is specified, the index will move to the first step of the first action in the target phase. If the phase and action are specified, the index will move to the first step of the specified action in the specified phase. Only actions specified in the ILM policy are considered valid. An index cannot move to a step that is not part of its policy.
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 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb', line 43 def move_to_step(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.move_to_step' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "_ilm/move/#{Utils.listify(_index)}" params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#put_lifecycle(arguments = {}) ⇒ Object
Create or update a lifecycle policy. If the specified policy exists, it is replaced and the policy version is incremented. NOTE: Only the latest version of the policy is stored, you cannot revert to previous versions.
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 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb', line 37 def put_lifecycle(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.put_lifecycle' } defined_params = [:policy].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'policy' missing" unless arguments[:policy] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _policy = arguments.delete(:policy) method = Elasticsearch::API::HTTP_PUT path = "_ilm/policy/#{Utils.listify(_policy)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#remove_policy(arguments = {}) ⇒ Object
Remove policies from an index. Remove the assigned lifecycle policies from an index or a data stream’s backing indices. It also stops managing the indices.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/remove_policy.rb', line 34 def remove_policy(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.remove_policy' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.listify(_index)}/_ilm/remove" params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#retry(arguments = {}) ⇒ Object
Retry a policy. Retry running the lifecycle policy for an index that is in the ERROR step. The API sets the policy back to the step where the error occurred and runs the step. Use the explain lifecycle state API to determine whether an index is in the ERROR step.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/retry.rb', line 35 def retry(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.retry' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = "#{Utils.listify(_index)}/_ilm/retry" params = {} Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#start(arguments = {}) ⇒ Object
Start the ILM plugin. Start the index lifecycle management plugin if it is currently stopped. ILM is started automatically when the cluster is formed. Restarting ILM is necessary only when it has been stopped using the stop ILM API.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/start.rb', line 36 def start(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.start' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_POST path = '_ilm/start' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |
#stop(arguments = {}) ⇒ Object
Stop the ILM plugin. Halt all lifecycle management operations and stop the index lifecycle management plugin. This is useful when you are performing maintenance on the cluster and need to prevent ILM from performing any actions on your indices. The API returns as soon as the stop request has been acknowledged, but the plugin might continue to run until in-progress operations complete and the plugin can be safely stopped. Use the get ILM status API to check whether ILM is running.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/elasticsearch/api/actions/index_lifecycle_management/stop.rb', line 37 def stop(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'ilm.stop' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_POST path = '_ilm/stop' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |