opensearchcli 0.2.4__tar.gz → 0.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/PKG-INFO +1 -1
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/pyproject.toml +1 -1
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/cli.py +14 -1
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/cluster_settings.py +9 -8
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/index.py +20 -6
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/raw.py +17 -3
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli.egg-info/PKG-INFO +1 -1
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/README.md +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/setup.cfg +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/__init__.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/__init__.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/cluster.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/commands.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/config.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/exceptions.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/helpers.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/index_settings.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli/commands/snapshot.py +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli.egg-info/SOURCES.txt +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli.egg-info/dependency_links.txt +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli.egg-info/entry_points.txt +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli.egg-info/requires.txt +0 -0
- {opensearchcli-0.2.4 → opensearchcli-0.2.7}/src/opensearchcli.egg-info/top_level.txt +0 -0
|
@@ -58,11 +58,15 @@ class OpenSearchCli:
|
|
|
58
58
|
config: config.Config,
|
|
59
59
|
profile: config.ConfigProfile,
|
|
60
60
|
config_file_path: str,
|
|
61
|
+
json_output: bool = False,
|
|
62
|
+
timeout: int = 30,
|
|
61
63
|
) -> None:
|
|
62
64
|
self._opensearch: OpenSearch | None = None
|
|
63
65
|
self.config = config
|
|
64
66
|
self.profile = profile
|
|
65
67
|
self.config_file_path = config_file_path
|
|
68
|
+
self.timeout = timeout
|
|
69
|
+
self.json_output = json_output
|
|
66
70
|
|
|
67
71
|
@property
|
|
68
72
|
def opensearch(self) -> OpenSearch:
|
|
@@ -78,6 +82,8 @@ class OpenSearchCli:
|
|
|
78
82
|
use_ssl=True,
|
|
79
83
|
verify_certs=False,
|
|
80
84
|
ssl_show_warn=False,
|
|
85
|
+
timeout=self.timeout,
|
|
86
|
+
headers={"Accept": "application/json"} if self.json_output else {},
|
|
81
87
|
)
|
|
82
88
|
return self._opensearch
|
|
83
89
|
|
|
@@ -91,7 +97,12 @@ def common(
|
|
|
91
97
|
profile: Annotated[
|
|
92
98
|
str, typer.Option(help="OpenSearch profile name", envvar="OPENSEARCH_PROFILE")
|
|
93
99
|
] = "default",
|
|
94
|
-
json_output: Annotated[
|
|
100
|
+
json_output: Annotated[
|
|
101
|
+
bool, typer.Option("--json", help="Output results as JSON")
|
|
102
|
+
] = False,
|
|
103
|
+
timeout: Annotated[
|
|
104
|
+
int, typer.Option("--timeout", help="Request timeout in seconds")
|
|
105
|
+
] = 30,
|
|
95
106
|
) -> None:
|
|
96
107
|
"""OpenSearch CLI - Manage your OpenSearch clusters."""
|
|
97
108
|
|
|
@@ -106,6 +117,8 @@ def common(
|
|
|
106
117
|
config=_config,
|
|
107
118
|
profile=_profile,
|
|
108
119
|
config_file_path=config_file,
|
|
120
|
+
json_output=json_output,
|
|
121
|
+
timeout=timeout,
|
|
109
122
|
)
|
|
110
123
|
ctx.meta["json_output"] = json_output
|
|
111
124
|
|
|
@@ -4,6 +4,8 @@ import typer
|
|
|
4
4
|
from opensearchpy import RequestError
|
|
5
5
|
from rich.console import Console
|
|
6
6
|
|
|
7
|
+
from opensearchcli.commands.exceptions import catch_exception
|
|
8
|
+
|
|
7
9
|
app = typer.Typer(
|
|
8
10
|
rich_markup_mode="rich",
|
|
9
11
|
no_args_is_help=True,
|
|
@@ -16,7 +18,8 @@ console = Console()
|
|
|
16
18
|
def get(
|
|
17
19
|
ctx: typer.Context,
|
|
18
20
|
params: Annotated[
|
|
19
|
-
list[str],
|
|
21
|
+
list[str],
|
|
22
|
+
typer.Option(help="Cluster settings to retrieve", default_factory=list),
|
|
20
23
|
],
|
|
21
24
|
):
|
|
22
25
|
"""Retrieve cluster settings."""
|
|
@@ -32,6 +35,7 @@ def get(
|
|
|
32
35
|
|
|
33
36
|
|
|
34
37
|
@app.command()
|
|
38
|
+
@catch_exception(RequestError, exit_code=1)
|
|
35
39
|
def set(ctx: typer.Context, settings: list[str]):
|
|
36
40
|
"""Update cluster settings."""
|
|
37
41
|
|
|
@@ -42,10 +46,7 @@ def set(ctx: typer.Context, settings: list[str]):
|
|
|
42
46
|
name, value = s.split("=", 1)
|
|
43
47
|
body["persistent"][name] = value
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
except RequestError as e:
|
|
51
|
-
console.print(f"[red]Error updating settings:[/red] {e.info}")
|
|
49
|
+
ctx.obj.opensearch.cluster.put_settings(body=body)
|
|
50
|
+
console.print(
|
|
51
|
+
f"[green]Successfully updated settings:[/green] {body['persistent']}"
|
|
52
|
+
)
|
|
@@ -13,16 +13,30 @@ app.add_typer(index_settings.app, name="settings", help="Manage index settings")
|
|
|
13
13
|
console = Console()
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
@app.command()
|
|
17
|
-
def
|
|
16
|
+
@app.command(name="list")
|
|
17
|
+
def list_indices(
|
|
18
18
|
ctx: typer.Context,
|
|
19
19
|
index_pattern: str = typer.Argument(
|
|
20
|
-
|
|
20
|
+
"*",
|
|
21
|
+
help="Index name or pattern to list indices. Quote patterns to stop the "
|
|
22
|
+
"shell expanding them, e.g. '*' or '.ds-*'.",
|
|
23
|
+
),
|
|
24
|
+
expand_wildcards: str = typer.Option(
|
|
25
|
+
"all",
|
|
26
|
+
help=(
|
|
27
|
+
"Which index states to include: open, closed, hidden, none, all. "
|
|
28
|
+
"'all' includes hidden data stream backing indices (.ds-*)."
|
|
29
|
+
),
|
|
21
30
|
),
|
|
22
31
|
):
|
|
23
|
-
"""List indices matching the given pattern.
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
"""List indices matching the given pattern.
|
|
33
|
+
|
|
34
|
+
Defaults to all indices, including data stream backing indices.
|
|
35
|
+
"""
|
|
36
|
+
indices = ctx.obj.opensearch.indices.get(
|
|
37
|
+
index=index_pattern, expand_wildcards=expand_wildcards
|
|
38
|
+
)
|
|
39
|
+
typer.echo(json.dumps(sorted(indices.keys()), indent=2))
|
|
26
40
|
|
|
27
41
|
|
|
28
42
|
@app.command()
|
|
@@ -15,14 +15,28 @@ console = Console()
|
|
|
15
15
|
@app.command()
|
|
16
16
|
def do(
|
|
17
17
|
ctx: typer.Context,
|
|
18
|
-
method: str = typer.Argument("GET", help="HTTP method to use"),
|
|
19
18
|
endpoint: str = typer.Argument(help="API endpoint to call"),
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
method: str = typer.Option("GET", "--method", "-X", help="HTTP method to use"),
|
|
20
|
+
body: list[str] = typer.Option(
|
|
21
|
+
default_factory=list,
|
|
22
|
+
show_default=False,
|
|
23
|
+
help="Request body field as key=value (dotted keys nest), repeatable. "
|
|
24
|
+
"E.g. --body query.match.title=hello",
|
|
25
|
+
),
|
|
26
|
+
params: list[str] = typer.Option(
|
|
27
|
+
default_factory=list,
|
|
28
|
+
show_default=False,
|
|
29
|
+
help="Query parameter as key=value, repeatable. "
|
|
30
|
+
"E.g. --params flat_settings=true",
|
|
31
|
+
),
|
|
22
32
|
):
|
|
23
33
|
"""Make a raw API call to the OpenSearch cluster."""
|
|
24
34
|
opensearch = ctx.obj.opensearch
|
|
25
35
|
|
|
36
|
+
# Normalize the endpoint so it works with or without a leading slash.
|
|
37
|
+
if not endpoint.startswith("/"):
|
|
38
|
+
endpoint = f"/{endpoint}"
|
|
39
|
+
|
|
26
40
|
payload = body_dict_from_flags(body)
|
|
27
41
|
query_params = parse_params(params)
|
|
28
42
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|