opensearchcli 0.1.1__tar.gz → 0.2.0__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.1.1 → opensearchcli-0.2.0}/PKG-INFO +1 -1
- opensearchcli-0.2.0/README.md +165 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/pyproject.toml +1 -1
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/cli.py +5 -9
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/cluster_settings.py +4 -4
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/config.py +4 -1
- opensearchcli-0.2.0/src/opensearchcli/commands/index.py +117 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/index_settings.py +3 -4
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/raw.py +2 -3
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli.egg-info/PKG-INFO +1 -1
- opensearchcli-0.1.1/README.md +0 -74
- opensearchcli-0.1.1/src/opensearchcli/commands/index.py +0 -36
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/setup.cfg +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/__init__.py +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/__init__.py +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/cluster.py +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/commands.py +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/exceptions.py +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/helpers.py +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli/commands/snapshot.py +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli.egg-info/SOURCES.txt +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli.egg-info/dependency_links.txt +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli.egg-info/entry_points.txt +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli.egg-info/requires.txt +0 -0
- {opensearchcli-0.1.1 → opensearchcli-0.2.0}/src/opensearchcli.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# opensearchcli
|
|
2
|
+
|
|
3
|
+
## Getting started
|
|
4
|
+
|
|
5
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
6
|
+
|
|
7
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
8
|
+
|
|
9
|
+
## Add your files
|
|
10
|
+
|
|
11
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
12
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
cd existing_repo
|
|
16
|
+
git remote add origin https://sbp.gitlab.schubergphilis.com/SaaS/opensearchcli.git
|
|
17
|
+
git branch -M main
|
|
18
|
+
git push -uf origin main
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Integrate with your tools
|
|
22
|
+
|
|
23
|
+
- [ ] [Set up project integrations](https://sbp.gitlab.schubergphilis.com/SaaS/opensearchcli/-/settings/integrations)
|
|
24
|
+
|
|
25
|
+
## Collaborate with your team
|
|
26
|
+
|
|
27
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
28
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
29
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
30
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
31
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
32
|
+
|
|
33
|
+
## Test and Deploy
|
|
34
|
+
|
|
35
|
+
Use the built-in continuous integration in GitLab.
|
|
36
|
+
|
|
37
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
|
|
38
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
39
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
40
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
41
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
# Editing this README
|
|
46
|
+
|
|
47
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
48
|
+
|
|
49
|
+
## Suggestions for a good README
|
|
50
|
+
|
|
51
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
52
|
+
|
|
53
|
+
## Name
|
|
54
|
+
Choose a self-explaining name for your project.
|
|
55
|
+
|
|
56
|
+
## Description
|
|
57
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
58
|
+
|
|
59
|
+
## Badges
|
|
60
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
61
|
+
|
|
62
|
+
## Visuals
|
|
63
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
70
|
+
|
|
71
|
+
## Support
|
|
72
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
73
|
+
|
|
74
|
+
## Roadmap
|
|
75
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
79
|
+
|
|
80
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
81
|
+
|
|
82
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
83
|
+
|
|
84
|
+
## Authors and acknowledgment
|
|
85
|
+
Show your appreciation to those who have contributed to the project.
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
For open source projects, say how it is licensed.
|
|
89
|
+
|
|
90
|
+
## Project status
|
|
91
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
92
|
+
=======
|
|
93
|
+
|
|
94
|
+
# OpenSearch CLI
|
|
95
|
+
|
|
96
|
+
OpenSearch CLI is a command-line tool to manage and interact with OpenSearch clusters. It provides commands for cluster management, snapshots, raw API calls, and more, all from your terminal.
|
|
97
|
+
|
|
98
|
+
## Features
|
|
99
|
+
|
|
100
|
+
- Manage OpenSearch clusters (health, settings, allocation, etc.)
|
|
101
|
+
- Run raw OpenSearch API calls
|
|
102
|
+
- Manage snapshots
|
|
103
|
+
- Profile-based configuration
|
|
104
|
+
|
|
105
|
+
## Requirements
|
|
106
|
+
|
|
107
|
+
- Python 3.10+
|
|
108
|
+
|
|
109
|
+
## Installation
|
|
110
|
+
|
|
111
|
+
Clone the repository and install dependencies using [uv](https://github.com/astral-sh/uv):
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
git clone <repo-url>
|
|
115
|
+
cd OpenSearch
|
|
116
|
+
uv sync
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Or, to run commands directly with uv (no manual activation needed):
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
uv run opensearchcli --help
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Usage
|
|
126
|
+
|
|
127
|
+
Run the CLI:
|
|
128
|
+
|
|
129
|
+
```sh
|
|
130
|
+
opensearchcli --help
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Example: Check cluster health
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
opensearchcli cluster health
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Configuration
|
|
140
|
+
|
|
141
|
+
The CLI uses a config file (default: `~/.config/opensearch-cli/config.toml`) to store connection profiles. You can specify a profile with `--profile` or the `OPENSEARCH_PROFILE` environment variable.
|
|
142
|
+
|
|
143
|
+
Example config file:
|
|
144
|
+
|
|
145
|
+
```toml
|
|
146
|
+
[default]
|
|
147
|
+
domain = "localhost"
|
|
148
|
+
username = "admin"
|
|
149
|
+
password = "admin"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Project Structure
|
|
153
|
+
|
|
154
|
+
- `src/opensearchcli/cli.py` — Main CLI entry point
|
|
155
|
+
- `src/opensearchcli/commands/` — Command modules (cluster, snapshot, etc.)
|
|
156
|
+
|
|
157
|
+
## Dependencies
|
|
158
|
+
|
|
159
|
+
- [opensearch-py](https://pypi.org/project/opensearch-py/)
|
|
160
|
+
- [typer](https://pypi.org/project/typer/)
|
|
161
|
+
- [rich](https://pypi.org/project/rich/)
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT (add your license here)
|
|
@@ -14,15 +14,15 @@ console = Console()
|
|
|
14
14
|
app = typer.Typer(rich_markup_mode="rich", no_args_is_help=True)
|
|
15
15
|
app.add_typer(typer_instance=commands.app, name="commands")
|
|
16
16
|
app.add_typer(
|
|
17
|
-
typer_instance=cluster.app, name="cluster", help="OpenSearch cluster
|
|
17
|
+
typer_instance=cluster.app, name="cluster", help="OpenSearch cluster API commands"
|
|
18
18
|
)
|
|
19
19
|
app.add_typer(
|
|
20
|
-
typer_instance=index.app, name="index", help="OpenSearch index
|
|
20
|
+
typer_instance=index.app, name="index", help="OpenSearch index API commands"
|
|
21
21
|
)
|
|
22
22
|
app.add_typer(
|
|
23
23
|
typer_instance=snapshot.app,
|
|
24
24
|
name="snapshot",
|
|
25
|
-
help="OpenSearch snapshot
|
|
25
|
+
help="OpenSearch snapshot API commands",
|
|
26
26
|
)
|
|
27
27
|
app.add_typer(typer_instance=raw.app, name="raw", help="Make raw OpenSearch API calls")
|
|
28
28
|
app.add_typer(
|
|
@@ -49,7 +49,7 @@ class OpenSearchCli:
|
|
|
49
49
|
hosts=[
|
|
50
50
|
{
|
|
51
51
|
"host": self.profile.domain,
|
|
52
|
-
"port":
|
|
52
|
+
"port": self.profile.port,
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
55
|
http_auth=(self.profile.username, self.profile.password),
|
|
@@ -67,12 +67,8 @@ def common(
|
|
|
67
67
|
path=f"{Path.home()}/.config/opensearch-cli/config.toml"
|
|
68
68
|
),
|
|
69
69
|
profile: Annotated[
|
|
70
|
-
str,
|
|
71
|
-
typer.Option(help="OpenSearch profile name", envvar="OPENSEARCH_PROFILE"),
|
|
70
|
+
str, typer.Option(help="OpenSearch profile name", envvar="OPENSEARCH_PROFILE")
|
|
72
71
|
] = "default",
|
|
73
|
-
raw: bool = Annotated[
|
|
74
|
-
bool, typer.Option(help="Display raw JSON output", default=False)
|
|
75
|
-
],
|
|
76
72
|
) -> None:
|
|
77
73
|
"""OpenSearch CLI - Manage your OpenSearch clusters."""
|
|
78
74
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Annotated
|
|
1
|
+
from typing import Annotated
|
|
2
2
|
|
|
3
3
|
import typer
|
|
4
4
|
from opensearchpy import RequestError
|
|
@@ -16,8 +16,8 @@ console = Console()
|
|
|
16
16
|
def get(
|
|
17
17
|
ctx: typer.Context,
|
|
18
18
|
params: Annotated[
|
|
19
|
-
list[str], typer.Option(help="Cluster settings to retrieve")
|
|
20
|
-
]
|
|
19
|
+
list[str], typer.Option(help="Cluster settings to retrieve", default_factory=list)
|
|
20
|
+
],
|
|
21
21
|
):
|
|
22
22
|
"""Retrieve cluster settings."""
|
|
23
23
|
_params = {}
|
|
@@ -32,7 +32,7 @@ def get(
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
@app.command()
|
|
35
|
-
def set(ctx: typer.Context, settings:
|
|
35
|
+
def set(ctx: typer.Context, settings: list[str]):
|
|
36
36
|
"""Update cluster settings."""
|
|
37
37
|
|
|
38
38
|
body = {
|
|
@@ -23,6 +23,9 @@ class ConfigProfile:
|
|
|
23
23
|
def domain(self) -> str:
|
|
24
24
|
return self._data.get("domain", "")
|
|
25
25
|
|
|
26
|
+
def port(self) -> int:
|
|
27
|
+
return self._data.get("port", 9200)
|
|
28
|
+
|
|
26
29
|
@property
|
|
27
30
|
def username(self) -> str:
|
|
28
31
|
return self._data.get("username", "")
|
|
@@ -90,7 +93,7 @@ def _get_profiles_table(profiles: Sequence[ConfigProfile]) -> Table:
|
|
|
90
93
|
f"{profile.profile_name}",
|
|
91
94
|
f"{profile.domain}",
|
|
92
95
|
f"{profile.username}",
|
|
93
|
-
f"{profile.password}",
|
|
96
|
+
f"{'*' * len(profile.password) if profile.password else ''}",
|
|
94
97
|
)
|
|
95
98
|
return table
|
|
96
99
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
|
|
4
|
+
from opensearchcli.commands import index_settings
|
|
5
|
+
|
|
6
|
+
app = typer.Typer(
|
|
7
|
+
rich_markup_mode="rich",
|
|
8
|
+
no_args_is_help=True,
|
|
9
|
+
help="Manage OpenSearch index operations",
|
|
10
|
+
)
|
|
11
|
+
app.add_typer(index_settings.app, name="settings", help="Manage index settings")
|
|
12
|
+
console = Console()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@app.command()
|
|
16
|
+
def list(
|
|
17
|
+
ctx: typer.Context,
|
|
18
|
+
index_pattern: str = typer.Argument(
|
|
19
|
+
..., help="Index name or pattern to list indices"
|
|
20
|
+
),
|
|
21
|
+
):
|
|
22
|
+
"""List indices matching the given pattern."""
|
|
23
|
+
indices = ctx.obj.opensearch.indices.get(index=index_pattern)
|
|
24
|
+
for index_name in indices.keys():
|
|
25
|
+
console.print(index_name)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@app.command()
|
|
29
|
+
def get(
|
|
30
|
+
ctx: typer.Context,
|
|
31
|
+
index: str = typer.Argument(
|
|
32
|
+
help="The name of the index to retrieve information for"
|
|
33
|
+
),
|
|
34
|
+
):
|
|
35
|
+
"""Retrieve information for a specific index."""
|
|
36
|
+
index_info = ctx.obj.opensearch.indices.get(index=index)
|
|
37
|
+
console.print(index_info)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@app.command()
|
|
41
|
+
def ism(
|
|
42
|
+
ctx: typer.Context,
|
|
43
|
+
index: str = typer.Argument(
|
|
44
|
+
help="The name of the index to retrieve the ISM policy information for"
|
|
45
|
+
),
|
|
46
|
+
):
|
|
47
|
+
"""Retrieve ISM information for a specific index."""
|
|
48
|
+
index_info = ctx.obj.opensearch.plugins.index_management.explain_index(index=index)
|
|
49
|
+
console.print(index_info)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@app.command()
|
|
53
|
+
def ism_reset(
|
|
54
|
+
ctx: typer.Context,
|
|
55
|
+
index: str = typer.Argument(help="The name of the index to reset the policy on"),
|
|
56
|
+
policy: str = typer.Argument(
|
|
57
|
+
help="The name of the policy", default="mdr4all_policy"
|
|
58
|
+
),
|
|
59
|
+
):
|
|
60
|
+
"""Reset ism policy on a specific index."""
|
|
61
|
+
res = ctx.obj.opensearch.plugins.index_management.remove_policy_from_index(
|
|
62
|
+
index=index
|
|
63
|
+
)
|
|
64
|
+
console.print("Remove old policies:")
|
|
65
|
+
console.print(res)
|
|
66
|
+
body = {"policy_id": policy}
|
|
67
|
+
res = ctx.obj.opensearch.plugins.index_management.add_policy(index=index, body=body)
|
|
68
|
+
console.print(f"Set new policy '{policy}':")
|
|
69
|
+
console.print(res)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@app.command()
|
|
73
|
+
def ism_unmanaged(
|
|
74
|
+
ctx: typer.Context,
|
|
75
|
+
index: str = typer.Argument(help="Search for unmanaged indices", default=".ds-*"),
|
|
76
|
+
):
|
|
77
|
+
"""List indexes with no ism policy."""
|
|
78
|
+
res = ctx.obj.opensearch.plugins.index_management.explain_index(index=index)
|
|
79
|
+
|
|
80
|
+
unmanaged_indexes = [
|
|
81
|
+
index
|
|
82
|
+
for index, details in res.items()
|
|
83
|
+
if index != "total_managed_indices"
|
|
84
|
+
and details.get("index.plugins.index_state_management.policy_id") is None
|
|
85
|
+
]
|
|
86
|
+
if unmanaged_indexes:
|
|
87
|
+
console.print(f"Found {len(unmanaged_indexes)} unmanaged indexes.")
|
|
88
|
+
for index in unmanaged_indexes:
|
|
89
|
+
console.print(f"Unmanaged index: {index}")
|
|
90
|
+
else:
|
|
91
|
+
console.print("All policies are being managed ok.")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@app.command()
|
|
95
|
+
def ism_failed(
|
|
96
|
+
ctx: typer.Context,
|
|
97
|
+
index: str = typer.Argument(
|
|
98
|
+
help="Search for indices with failed ISM status", default=".ds-*"
|
|
99
|
+
),
|
|
100
|
+
):
|
|
101
|
+
"""List indexes with failed ism policy status."""
|
|
102
|
+
res = ctx.obj.opensearch.plugins.index_management.explain_index(index=index)
|
|
103
|
+
failed_indexes = [
|
|
104
|
+
index
|
|
105
|
+
for index, details in res.items()
|
|
106
|
+
if index != "total_managed_indices"
|
|
107
|
+
and details.get("enabled") is False
|
|
108
|
+
and details.get("action", {}).get("failed") is True
|
|
109
|
+
]
|
|
110
|
+
if failed_indexes:
|
|
111
|
+
console.print(
|
|
112
|
+
f"Found {len(failed_indexes)} indexes have failed during policy management."
|
|
113
|
+
)
|
|
114
|
+
for index in failed_indexes:
|
|
115
|
+
console.print(f"Failed index: {index}")
|
|
116
|
+
else:
|
|
117
|
+
console.print("All indices are in a good state for policy management.")
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from typing import List
|
|
2
1
|
|
|
3
2
|
import typer
|
|
4
3
|
from rich.console import Console
|
|
@@ -17,8 +16,8 @@ console = Console()
|
|
|
17
16
|
def get(
|
|
18
17
|
ctx: typer.Context,
|
|
19
18
|
index: str = typer.Argument(help="The name of the index to retrieve settings for"),
|
|
20
|
-
params:
|
|
21
|
-
|
|
19
|
+
params: list[str] = typer.Option(
|
|
20
|
+
default_factory=list, help="Settings parameters to retrieve"
|
|
22
21
|
),
|
|
23
22
|
):
|
|
24
23
|
"""Retrieve settings for a specific index."""
|
|
@@ -33,7 +32,7 @@ def get(
|
|
|
33
32
|
def set(
|
|
34
33
|
ctx: typer.Context,
|
|
35
34
|
index: str = typer.Argument(help="The name of the index to update settings for"),
|
|
36
|
-
settings:
|
|
35
|
+
settings: list[str] = typer.Argument(
|
|
37
36
|
help="Settings to update in the format key=value"
|
|
38
37
|
),
|
|
39
38
|
):
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from typing import List
|
|
2
1
|
|
|
3
2
|
import typer
|
|
4
3
|
from rich.console import Console
|
|
@@ -18,8 +17,8 @@ def do(
|
|
|
18
17
|
ctx: typer.Context,
|
|
19
18
|
method: str = typer.Argument("GET", help="HTTP method to use"),
|
|
20
19
|
endpoint: str = typer.Argument(help="API endpoint to call"),
|
|
21
|
-
body:
|
|
22
|
-
params:
|
|
20
|
+
body: list[str] = typer.Option(default_factory=dict, help="Request body for POST/PUT requests"),
|
|
21
|
+
params: list[str] = typer.Option(default_factory=dict, help="Query parameters for the request"),
|
|
23
22
|
):
|
|
24
23
|
"""Make a raw API call to the OpenSearch cluster."""
|
|
25
24
|
opensearch = ctx.obj.opensearch
|
opensearchcli-0.1.1/README.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# OpenSearch CLI
|
|
3
|
-
|
|
4
|
-
OpenSearch CLI is a command-line tool to manage and interact with OpenSearch clusters. It provides commands for cluster management, snapshots, raw API calls, and more, all from your terminal.
|
|
5
|
-
|
|
6
|
-
## Features
|
|
7
|
-
|
|
8
|
-
- Manage OpenSearch clusters (health, settings, allocation, etc.)
|
|
9
|
-
- Run raw OpenSearch API calls
|
|
10
|
-
- Manage snapshots
|
|
11
|
-
- Profile-based configuration
|
|
12
|
-
|
|
13
|
-
## Requirements
|
|
14
|
-
|
|
15
|
-
- Python 3.14+
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
Clone the repository and install dependencies using [uv](https://github.com/astral-sh/uv):
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
git clone <repo-url>
|
|
23
|
-
cd OpenSearch
|
|
24
|
-
uv sync
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Or, to run commands directly with uv (no manual activation needed):
|
|
28
|
-
|
|
29
|
-
```sh
|
|
30
|
-
uv run opensearchcli --help
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Usage
|
|
34
|
-
|
|
35
|
-
Run the CLI:
|
|
36
|
-
|
|
37
|
-
```sh
|
|
38
|
-
opensearchcli --help
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Example: Check cluster health
|
|
42
|
-
|
|
43
|
-
```sh
|
|
44
|
-
opensearchcli cluster health
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Configuration
|
|
48
|
-
|
|
49
|
-
The CLI uses a config file (default: `~/.config/opensearch-cli/config.toml`) to store connection profiles. You can specify a profile with `--profile` or the `OPENSEARCH_PROFILE` environment variable.
|
|
50
|
-
|
|
51
|
-
Example config file:
|
|
52
|
-
|
|
53
|
-
```toml
|
|
54
|
-
[default]
|
|
55
|
-
domain = "localhost"
|
|
56
|
-
username = "admin"
|
|
57
|
-
password = "admin"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Project Structure
|
|
61
|
-
|
|
62
|
-
- `src/opensearchcli/cli.py` — Main CLI entry point
|
|
63
|
-
- `src/opensearchcli/commands/` — Command modules (cluster, snapshot, etc.)
|
|
64
|
-
|
|
65
|
-
## Dependencies
|
|
66
|
-
|
|
67
|
-
- [opensearch-py](https://pypi.org/project/opensearch-py/)
|
|
68
|
-
- [typer](https://pypi.org/project/typer/)
|
|
69
|
-
- [rich](https://pypi.org/project/rich/)
|
|
70
|
-
|
|
71
|
-
## License
|
|
72
|
-
|
|
73
|
-
MIT (add your license here)
|
|
74
|
-
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import typer
|
|
2
|
-
from rich.console import Console
|
|
3
|
-
|
|
4
|
-
from opensearchcli.commands import index_settings
|
|
5
|
-
|
|
6
|
-
app = typer.Typer(
|
|
7
|
-
rich_markup_mode="rich",
|
|
8
|
-
no_args_is_help=True,
|
|
9
|
-
help="Manage OpenSearch index operations",
|
|
10
|
-
)
|
|
11
|
-
app.add_typer(index_settings.app, name="settings", help="Manage index settings")
|
|
12
|
-
console = Console()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@app.command()
|
|
16
|
-
def list(
|
|
17
|
-
ctx: typer.Context,
|
|
18
|
-
index_pattern: str = typer.Argument(
|
|
19
|
-
..., help="Index name or pattern to list indices"
|
|
20
|
-
),
|
|
21
|
-
):
|
|
22
|
-
indices = ctx.obj.opensearch.indices.get(index=index_pattern)
|
|
23
|
-
for index_name in indices.keys():
|
|
24
|
-
console.print(index_name)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@app.command()
|
|
28
|
-
def get(
|
|
29
|
-
ctx: typer.Context,
|
|
30
|
-
index: str = typer.Argument(
|
|
31
|
-
help="The name of the index to retrieve information for"
|
|
32
|
-
),
|
|
33
|
-
):
|
|
34
|
-
"""Retrieve information for a specific index."""
|
|
35
|
-
index_info = ctx.obj.opensearch.indices.get(index=index)
|
|
36
|
-
console.print(index_info)
|
|
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
|