@@ -36,6 +36,60 @@ def follow(follower_index, body, params = {})
3636 response = client . put "/#{ follower_index } /_ccr/follow" , params . merge ( body :, action : "follow" , rest_api : "ccr" )
3737 response . body
3838 end
39+
40+ # Creates a new auto-follow pattern for the provided remote cluster.
41+ #
42+ # pattern_name - String name of the auto-follow pattern to create
43+ # body - Hash of the request body
44+ # :remote_cluster - String name of the remote cluster. Required.
45+ # :leader_index_patterns - An array of simple index patterns to match against indices in the remote cluster
46+ # :leader_index_exclusion_patterns - An array of simple index patterns that can be used to exclude indices from being auto-followed.
47+ # :follow_index_pattern - The name of follower index. The template {{leader_index}} can be used to derive
48+ # the name of the follower index from the name of the leader index.
49+ # params - Hash of query parameters
50+
51+ # Examples
52+
53+ # ccr.auto_follow("follower_pattern", { remote_cluster: "leader", leader_index_patterns: ["leader_index*"],
54+ # follow_index_pattern: "{{leader_index}}-follower" })
55+
56+ # See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html
57+
58+ def auto_follow ( pattern_name , body , params = { } )
59+ response = client . put "/_ccr/auto_follow/#{ pattern_name } " , params . merge ( body :, action : "create_auto_follow_pattern" , rest_api : "ccr" )
60+ response . body
61+ end
62+
63+ # Deletes the auto-follow pattern for the provided remote cluster.
64+ #
65+ # pattern_name - String name of the auto-follow pattern to delete
66+ # params - Hash of query parameters
67+ #
68+ # Examples
69+ #
70+ # ccr.delete_auto_follow("follower_pattern")
71+ #
72+ # See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html
73+
74+ def delete_auto_follow ( pattern_name , params = { } )
75+ response = client . delete "/_ccr/auto_follow/#{ pattern_name } " , params . merge ( action : "delete_auto_follow_pattern" , rest_api : "ccr" )
76+ response . body
77+ end
78+
79+ # Gets cross-cluster replication auto-follow patterns
80+ #
81+ # params - Hash of query parameters
82+ # :pattern_name - (Optional) String name of the auto-follow pattern. Returns all patterns if not specified
83+ # Examples
84+ #
85+ # ccr.get_auto_follow
86+ #
87+ # See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html
88+
89+ def get_auto_follow ( params = { } )
90+ response = client . get "/_ccr/auto_follow{/pattern_name}" , params . merge ( action : "get_auto_follow_pattern" , rest_api : "ccr" )
91+ response . body
92+ end
3993 end
4094 end
4195end
0 commit comments