程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python3 operates Elasticsearch to obtain license information of xpack

編輯:Python

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']


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved