Skip to content

Commit 8db6c25

Browse files
committed
Removed cloud ID, App Search and ES3 client variants; updated version
1 parent eebd4fb commit 8db6c25

8 files changed

+12
-256
lines changed

README.md

+4-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Escli
22

33
Escli is a tool for interacting with an Elasticsearch service via the command line.
4-
It can also be used with Serverless or Enterprise App Search backends.
54

65
This project began as an experimental side project during November 2021, implementing a limited set of functionality.
76
It is currently considered prototypical, and not suitable for production use.
@@ -30,8 +29,8 @@ The current installed version of `escli` can be shown using the `escli version`
3029
## Quick Search Example
3130

3231
```bash
33-
$ export ESCLI_CLOUD_ID=xxxx:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
34-
$ export ESCLI_PASSWORD=XXXXXXXXXXXXXXXXXXXX
32+
$ export ESCLI_ADDR=https://xxxxxxx.elastic.cloud:443
33+
$ export ESCLI_API_KEY=xxxxxxx
3534
$ escli search kibana_sample_data_flights -i "FlightNum,OriginAirportID,DestAirportID" -n 15
3635
FlightNum DestAirportID OriginAirportID
3736
----------- --------------- -----------------
@@ -53,36 +52,14 @@ DMYXR3E NRT UIO
5352
```
5453

5554

56-
## Operating Modes
57-
58-
By default, `escli` operates in Elasticsearch mode, which expects a regular Elasticsearch service to be available.
59-
60-
To switch to App Search or Serverless mode, instead use the `escli.a` or `escli.s` commands respectively.
61-
62-
```bash
63-
$ escli.s search books
64-
name author release_date page_count
65-
------------------- ----------------- -------------- ------------
66-
Snow Crash Neal Stephenson 1992-06-01 470
67-
Revelation Space Alastair Reynolds 2000-03-15 585
68-
1984 George Orwell 1985-06-01 328
69-
Fahrenheit 451 Ray Bradbury 1953-10-15 227
70-
Brave New World Aldous Huxley 1932-06-01 268
71-
The Handmaid's Tale Margaret Atwood 1985-06-01 311
72-
```
73-
7455
## Connectivity & Authentication
7556

7657
The `escli` tool relies on connection details and credentials supplied through environment variables.
77-
For a default [Elastic Cloud](https://www.elastic.co/cloud/) deployment, only the `ESCLI_CLOUD_ID` and `ESCLI_PASSWORD` variables will generally need to be set.
78-
Other variables are available for use with local, on-prem, and other customised deployments.
58+
Typically, only the `ESCLI_ADDR` and `ESCLI_API_KEY` variables will generally need to be set, although
59+
other variables are available.
7960

8061
The following variables are accepted:
8162

82-
### `ESCLI_CLOUD_ID`
83-
The [Cloud ID](https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html) of an Elastic Cloud deployment.
84-
If using a local or on-prem deployment, this can remain unset.
85-
8663
### `ESCLI_ADDR`
8764
The host names or URLs to which to connect.
8865
This does not need to be set if `ESCLI_CLOUD_ID` is set.

escli/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023.9.dev13
1+
2024.9.dev14

escli/__main__.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,14 @@
2020
from escli.services import SPI
2121

2222

23-
def main(mode=None):
23+
def main():
2424
spi = SPI()
2525
cli = CLI(spi)
2626
spi.init_logging(cli.args.verbose - cli.args.quiet)
27-
spi.init_client(mode)
27+
spi.init_client()
2828
status = cli.process()
2929
exit(status)
3030

3131

32-
def main_app_search():
33-
main(mode="a")
34-
35-
36-
def main_serverless():
37-
main(mode="s")
38-
39-
4032
if __name__ == '__main__':
4133
main()

escli/services/__init__.py

+5-15
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def init_logging(self, verbosity):
7070
else:
7171
basicConfig(format=self.log_format, level=CRITICAL)
7272

73-
def init_client(self, mode=None):
74-
self.__client = Client.create(mode)
73+
def init_client(self):
74+
self.__client = Client.create()
7575

7676

7777
class Client(ABC):
@@ -83,14 +83,11 @@ def get_settings_from_env(cls, default_user="elastic"):
8383
""" Build and return a dictionary of client keyword settings
8484
based on available environment variables.
8585
"""
86-
cloud_id = getenv("ESCLI_CLOUD_ID")
8786
addr = getenv("ESCLI_ADDR")
8887
user = getenv("ESCLI_USER", default_user)
8988
password = getenv("ESCLI_PASSWORD")
9089
api_key = getenv("ESCLI_API_KEY")
9190
settings = {}
92-
if cloud_id:
93-
settings["cloud_id"] = cloud_id
9491
if addr:
9592
settings["hosts"] = addr.split(",")
9693
if password:
@@ -100,16 +97,9 @@ def get_settings_from_env(cls, default_user="elastic"):
10097
return settings
10198

10299
@classmethod
103-
def create(cls, mode=None):
104-
if mode == "s":
105-
from escli.services.serverless import ElasticsearchServerlessClient
106-
return ElasticsearchServerlessClient()
107-
elif mode == "a":
108-
from escli.services.enterprisesearch import AppSearchClient
109-
return AppSearchClient()
110-
else:
111-
from escli.services.elasticsearch import ElasticsearchClient
112-
return ElasticsearchClient()
100+
def create(cls):
101+
from escli.services.elasticsearch import ElasticsearchClient
102+
return ElasticsearchClient()
113103

114104
def info(self):
115105
""" Return backend system information.

escli/services/enterprisesearch.py

-101
This file was deleted.

escli/services/serverless.py

-96
This file was deleted.

requirements.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
elasticsearch
2-
elasticsearch-serverless
3-
elastic_enterprise_search
42
tabulate

setup.cfg

-4
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ long_description_content_type = text/markdown
1111
include_package_data = True
1212
install_requires =
1313
elasticsearch
14-
elasticsearch-serverless
15-
elastic_enterprise_search
1614
tabulate
1715
packages = find:
1816
python_requires = >=3.6
1917

2018
[options.entry_points]
2119
console_scripts =
2220
escli = escli.__main__:main
23-
escli.a = escli.__main__:main_app_search
24-
escli.s = escli.__main__:main_serverless
2521

2622
[bdist_wheel]
2723
universal = 1

0 commit comments

Comments
 (0)