1. Download dependent modules
# pip3 install elasticsearch elasticsearch-xpack
2. Example code
#!/usr/bin/python3#--coding:utf-8--from elasticsearch import Elasticsearchfrom elasticsearch_xpack import LicenseClientes = Elasticsearch(['IP_HOST:9200'],http_auth=('username','password'))xpack = LicenseClient(es)print(xpack.get())
ps: In the process, the online methods are incomplete, and you still need to compile the method by querying the usage of the module and combining the module source code
>>> import elasticsearch>>> print(dir(elasticsearch))['AuthenticationException', 'AuthorizationException', 'ConflictError', 'Connection', 'ConnectionError', 'ConnectionPool', 'ConnectionSelector', 'ConnectionTimeout', 'Elasticsearch', 'ElasticsearchException', 'ImproperlyConfigured', 'JSONSerializer', 'NotFoundError', 'NullHandler', 'RequestError', 'RequestsHttpConnection', 'RoundRobinSelector', 'SSLError', 'SerializationError', 'Transport', 'TransportError', 'Urllib3HttpConnection', 'VERSION', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '__versionstr__', 'absolute_import', 'client', 'compat', 'connection', 'connection_pool', 'exceptions', 'logger', 'logging', 'serializer', 'sys', 'transport']>>> from elasticsearch_xpack import XPackClient>>> print(dir(XPackClient))['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'infect_client', 'info', 'namespace', 'transport', 'usage']>>> import elasticsearch_xpack>>> print(dir(elasticsearch_xpack))['AddonClient', 'DeprecationClient', 'GraphClient', 'LicenseClient', 'MigrationClient', 'MlClient', 'MonitoringClient', 'SecurityClient', 'WatcherClient', 'XPackClient', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'deprecation', 'graph', 'license', 'migration', 'ml', 'monitoring', 'query_params', 'security', 'watcher']>>> print(dir(elasticsearch_xpack.LicenseClient))['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'delete', 'get', 'post', 'transport']