|
| 1 | +from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH |
| 2 | + |
| 3 | + |
| 4 | +class CcrClient(NamespacedClient): |
| 5 | + @query_params() |
| 6 | + def delete_auto_follow_pattern(self, name, params=None): |
| 7 | + """ |
| 8 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html>`_ |
| 9 | +
|
| 10 | + :arg name: The name of the auto follow pattern. |
| 11 | + """ |
| 12 | + if name in SKIP_IN_PATH: |
| 13 | + raise ValueError("Empty value passed for a required argument 'name'.") |
| 14 | + return self.transport.perform_request( |
| 15 | + "DELETE", _make_path("_ccr", "auto_follow", name), params=params |
| 16 | + ) |
| 17 | + |
| 18 | + @query_params("wait_for_active_shards") |
| 19 | + def follow(self, index, body, params=None): |
| 20 | + """ |
| 21 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html>`_ |
| 22 | +
|
| 23 | + :arg index: The name of the follower index |
| 24 | + :arg body: The name of the leader index and other optional ccr related |
| 25 | + parameters |
| 26 | + :arg wait_for_active_shards: Sets the number of shard copies that must |
| 27 | + be active before returning. Defaults to 0. Set to `all` for all |
| 28 | + shard copies, otherwise set to any non-negative value less than or |
| 29 | + equal to the total number of copies for the shard (number of |
| 30 | + replicas + 1), default '0' |
| 31 | + """ |
| 32 | + for param in (index, body): |
| 33 | + if param in SKIP_IN_PATH: |
| 34 | + raise ValueError("Empty value passed for a required argument.") |
| 35 | + return self.transport.perform_request( |
| 36 | + "PUT", _make_path(index, "_ccr", "follow"), params=params, body=body |
| 37 | + ) |
| 38 | + |
| 39 | + @query_params() |
| 40 | + def follow_info(self, index=None, params=None): |
| 41 | + """ |
| 42 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html>`_ |
| 43 | +
|
| 44 | + :arg index: A comma-separated list of index patterns; use `_all` to |
| 45 | + perform the operation on all indices |
| 46 | + """ |
| 47 | + return self.transport.perform_request( |
| 48 | + "GET", _make_path(index, "_ccr", "info"), params=params |
| 49 | + ) |
| 50 | + |
| 51 | + @query_params() |
| 52 | + def follow_stats(self, index=None, params=None): |
| 53 | + """ |
| 54 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html>`_ |
| 55 | +
|
| 56 | + :arg index: A comma-separated list of index patterns; use `_all` to |
| 57 | + perform the operation on all indices |
| 58 | + """ |
| 59 | + return self.transport.perform_request( |
| 60 | + "GET", _make_path(index, "_ccr", "stats"), params=params |
| 61 | + ) |
| 62 | + |
| 63 | + @query_params() |
| 64 | + def forget_follower(self, index, body, params=None): |
| 65 | + """ |
| 66 | + `<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_ |
| 67 | +
|
| 68 | + :arg index: the name of the leader index for which specified follower |
| 69 | + retention leases should be removed |
| 70 | + :arg body: the name and UUID of the follower index, the name of the |
| 71 | + cluster containing the follower index, and the alias from the |
| 72 | + perspective of that cluster for the remote cluster containing the |
| 73 | + leader index |
| 74 | + """ |
| 75 | + for param in (index, body): |
| 76 | + if param in SKIP_IN_PATH: |
| 77 | + raise ValueError("Empty value passed for a required argument.") |
| 78 | + return self.transport.perform_request( |
| 79 | + "POST", |
| 80 | + _make_path(index, "_ccr", "forget_follower"), |
| 81 | + params=params, |
| 82 | + body=body, |
| 83 | + ) |
| 84 | + |
| 85 | + @query_params() |
| 86 | + def get_auto_follow_pattern(self, name=None, params=None): |
| 87 | + """ |
| 88 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html>`_ |
| 89 | +
|
| 90 | + :arg name: The name of the auto follow pattern. |
| 91 | + """ |
| 92 | + return self.transport.perform_request( |
| 93 | + "GET", _make_path("_ccr", "auto_follow", name), params=params |
| 94 | + ) |
| 95 | + |
| 96 | + @query_params() |
| 97 | + def pause_follow(self, index, params=None): |
| 98 | + """ |
| 99 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html>`_ |
| 100 | +
|
| 101 | + :arg index: The name of the follower index that should pause following |
| 102 | + its leader index. |
| 103 | + """ |
| 104 | + if index in SKIP_IN_PATH: |
| 105 | + raise ValueError("Empty value passed for a required argument 'index'.") |
| 106 | + return self.transport.perform_request( |
| 107 | + "POST", _make_path(index, "_ccr", "pause_follow"), params=params |
| 108 | + ) |
| 109 | + |
| 110 | + @query_params() |
| 111 | + def put_auto_follow_pattern(self, name, body, params=None): |
| 112 | + """ |
| 113 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html>`_ |
| 114 | +
|
| 115 | + :arg name: The name of the auto follow pattern. |
| 116 | + :arg body: The specification of the auto follow pattern |
| 117 | + """ |
| 118 | + for param in (name, body): |
| 119 | + if param in SKIP_IN_PATH: |
| 120 | + raise ValueError("Empty value passed for a required argument.") |
| 121 | + return self.transport.perform_request( |
| 122 | + "PUT", _make_path("_ccr", "auto_follow", name), params=params, body=body |
| 123 | + ) |
| 124 | + |
| 125 | + @query_params() |
| 126 | + def resume_follow(self, index, body=None, params=None): |
| 127 | + """ |
| 128 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html>`_ |
| 129 | +
|
| 130 | + :arg index: The name of the follow index to resume following. |
| 131 | + :arg body: The name of the leader index and other optional ccr related |
| 132 | + parameters |
| 133 | + """ |
| 134 | + if index in SKIP_IN_PATH: |
| 135 | + raise ValueError("Empty value passed for a required argument 'index'.") |
| 136 | + return self.transport.perform_request( |
| 137 | + "POST", _make_path(index, "_ccr", "resume_follow"), params=params, body=body |
| 138 | + ) |
| 139 | + |
| 140 | + @query_params() |
| 141 | + def stats(self, params=None): |
| 142 | + """ |
| 143 | + `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html>`_ |
| 144 | + """ |
| 145 | + return self.transport.perform_request("GET", "/_ccr/stats", params=params) |
| 146 | + |
| 147 | + @query_params() |
| 148 | + def unfollow(self, index, params=None): |
| 149 | + """ |
| 150 | + `<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_ |
| 151 | +
|
| 152 | + :arg index: The name of the follower index that should be turned into a |
| 153 | + regular index. |
| 154 | + """ |
| 155 | + if index in SKIP_IN_PATH: |
| 156 | + raise ValueError("Empty value passed for a required argument 'index'.") |
| 157 | + return self.transport.perform_request( |
| 158 | + "POST", _make_path(index, "_ccr", "unfollow"), params=params |
| 159 | + ) |
0 commit comments