nacos-sdk-python 2.0.0b6__tar.gz → 2.0.3__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.
Files changed (109) hide show
  1. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/PKG-INFO +388 -384
  2. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/README.md +387 -383
  3. nacos-sdk-python-2.0.3/nacos/auth.py +26 -0
  4. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/client.py +48 -39
  5. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos_sdk_python.egg-info/PKG-INFO +388 -384
  6. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos_sdk_python.egg-info/SOURCES.txt +2 -0
  7. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/setup.py +1 -1
  8. nacos-sdk-python-2.0.3/v2/nacos/common/auth.py +32 -0
  9. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/common/client_config.py +3 -3
  10. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/common/client_config_builder.py +13 -2
  11. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/remote/config_grpc_client_proxy.py +6 -3
  12. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/remote/naming_grpc_client_proxy.py +6 -3
  13. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/grpc_client.py +14 -6
  14. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/model/internal_request.py +0 -10
  15. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/nacos_server_connector.py +3 -0
  16. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/rpc_client.py +1 -1
  17. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/__init__.py +0 -0
  18. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/commons.py +0 -0
  19. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/exception.py +0 -0
  20. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/files.py +0 -0
  21. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/listener.py +0 -0
  22. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/params.py +0 -0
  23. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/task.py +0 -0
  24. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos/timer.py +0 -0
  25. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos_sdk_python.egg-info/dependency_links.txt +0 -0
  26. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos_sdk_python.egg-info/requires.txt +0 -0
  27. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/nacos_sdk_python.egg-info/top_level.txt +0 -0
  28. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/setup.cfg +0 -0
  29. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/__init__.py +0 -0
  30. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/__init__.py +0 -0
  31. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/common/__init__.py +0 -0
  32. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/common/constants.py +0 -0
  33. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/common/nacos_exception.py +0 -0
  34. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/common/payload_registry.py +0 -0
  35. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/common/preserved_metadata_key.py +0 -0
  36. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/__init__.py +0 -0
  37. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/cache/__init__.py +0 -0
  38. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/cache/config_info_cache.py +0 -0
  39. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/cache/config_subscribe_manager.py +0 -0
  40. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/__init__.py +0 -0
  41. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/kms_client.py +0 -0
  42. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/kms_handler.py +0 -0
  43. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/plugin/__init__.py +0 -0
  44. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/plugin/encryption_plugin.py +0 -0
  45. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/plugin/kms_aes_128_encrytion_plugin.py +0 -0
  46. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/plugin/kms_aes_256_encrytion_plugin.py +0 -0
  47. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/plugin/kms_base_encryption_plugin.py +0 -0
  48. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/encryption/plugin/kms_encrytion_plugin.py +0 -0
  49. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/filter/__init__.py +0 -0
  50. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/filter/config_encryption_filter.py +0 -0
  51. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/filter/config_filter.py +0 -0
  52. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/model/__init__.py +0 -0
  53. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/model/config.py +0 -0
  54. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/model/config_param.py +0 -0
  55. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/model/config_request.py +0 -0
  56. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/model/config_response.py +0 -0
  57. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/nacos_config_service.py +0 -0
  58. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/remote/__init__.py +0 -0
  59. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/remote/config_change_notify_request_handler.py +0 -0
  60. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/remote/config_grpc_connection_event_listener.py +0 -0
  61. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/util/__init__.py +0 -0
  62. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/config/util/config_client_util.py +0 -0
  63. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/nacos_client.py +0 -0
  64. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/__init__.py +0 -0
  65. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/cache/__init__.py +0 -0
  66. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/cache/service_info_cache.py +0 -0
  67. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/cache/subscribe_manager.py +0 -0
  68. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/event/__init__.py +0 -0
  69. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/event/instance_change_notifier.py +0 -0
  70. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/model/__init__.py +0 -0
  71. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/model/instance.py +0 -0
  72. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/model/naming_param.py +0 -0
  73. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/model/naming_request.py +0 -0
  74. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/model/naming_response.py +0 -0
  75. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/model/service.py +0 -0
  76. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/nacos_naming_service.py +0 -0
  77. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/remote/__init__.py +0 -0
  78. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/remote/naming_grpc_connection_event_listener.py +0 -0
  79. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/remote/naming_push_request_handler.py +0 -0
  80. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/util/__init__.py +0 -0
  81. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/util/naming_client_util.py +0 -0
  82. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/naming/util/naming_remote_constants.py +0 -0
  83. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/proto/__init__.py +0 -0
  84. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/__init__.py +0 -0
  85. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/auth_client.py +0 -0
  86. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/connection.py +0 -0
  87. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/connection_event_listener.py +0 -0
  88. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/grpc_connection.py +0 -0
  89. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/grpc_util.py +0 -0
  90. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/grpcauto/__init__.py +0 -0
  91. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/grpcauto/nacos_grpc_service_pb2.py +0 -0
  92. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/grpcauto/nacos_grpc_service_pb2_grpc.py +0 -0
  93. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/http_agent.py +0 -0
  94. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/model/__init__.py +0 -0
  95. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/model/internal_response.py +0 -0
  96. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/model/rpc_request.py +0 -0
  97. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/model/rpc_response.py +0 -0
  98. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/model/server_info.py +0 -0
  99. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/rpc_client_factory.py +0 -0
  100. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/transport/server_request_handler.py +0 -0
  101. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/__init__.py +0 -0
  102. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/aes_util.py +0 -0
  103. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/common_util.py +0 -0
  104. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/content_util.py +0 -0
  105. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/encode_util.py +0 -0
  106. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/file_util.py +0 -0
  107. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/hmac_util.py +0 -0
  108. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/md5_util.py +0 -0
  109. {nacos-sdk-python-2.0.0b6 → nacos-sdk-python-2.0.3}/v2/nacos/utils/net_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nacos-sdk-python
3
- Version: 2.0.0b6
3
+ Version: 2.0.3
4
4
  Summary: Python client for Nacos.
5
5
  Home-page: https://github.com/nacos-group/nacos-sdk-python
6
6
  Author: nacos
@@ -10,151 +10,165 @@ Project-URL: Documentation, https://github.com/nacos-group/nacos-sdk-python
10
10
  Project-URL: Source, https://github.com/nacos-group/nacos-sdk-python
11
11
  Project-URL: Nacos Open API Guide, https://nacos.io/en-us/docs/open-api.html
12
12
  Description:
13
- # nacos-sdk-python
13
+ # nacos-sdk-python v2
14
14
 
15
15
  A Python implementation of Nacos OpenAPI.
16
16
 
17
- see: https://nacos.io/docs/latest/guide/user/open-api/
17
+ see: https://nacos.io/zh-cn/docs/open-API.html
18
18
 
19
19
  [![Pypi Version](https://badge.fury.io/py/nacos-sdk-python.svg)](https://badge.fury.io/py/nacos-sdk-python)
20
20
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/nacos-group/nacos-sdk-python/blob/master/LICENSE)
21
21
 
22
22
  ### Supported Python version:
23
23
 
24
- Python 2.7
25
- Python 3.6
26
- Python 3.7
24
+ Python 3.7+
27
25
 
28
26
  ### Supported Nacos version
29
27
 
30
- Nacos 0.8.0+
31
- Nacos 1.x
32
- Nacos 2.x with http protocol
28
+ Supported Nacos version over 2.x
33
29
 
34
30
  ## Installation
35
31
 
36
32
  ```shell
37
- pip install nacos-sdk-python
38
- ```
39
-
40
- ## Getting Started
41
-
42
- ```python
43
- import nacos
44
-
45
- # Both HTTP/HTTPS protocols are supported, if not set protocol prefix default is HTTP, and HTTPS with no ssl check(verify=False)
46
- # "192.168.3.4:8848" or "https://192.168.3.4:443" or "http://192.168.3.4:8848,192.168.3.5:8848" or "https://192.168.3.4:443,https://192.168.3.5:443"
47
- SERVER_ADDRESSES = "server addresses split by comma"
48
- NAMESPACE = "namespace id"
49
-
50
- # no auth mode
51
- client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE)
52
- # auth mode
53
- # client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE, ak="{ak}", sk="{sk}")
54
-
55
- # get config
56
- data_id = "config.nacos"
57
- group = "group"
58
- print(client.get_config(data_id, group))
33
+ pip install nacos-sdk-python==2.0.3
59
34
  ```
60
35
 
61
- ## Configuration
36
+ ## Client Configuration
62
37
 
63
38
  ```
64
- client = NacosClient(server_addresses, namespace=your_ns, ak=your_ak, sk=your_sk)
39
+ from v2.nacos import NacosNamingService, ClientConfigBuilder, GRPCConfig, Instance, SubscribeServiceParam, \
40
+ RegisterInstanceParam, DeregisterInstanceParam, BatchRegisterInstanceParam, GetServiceParam, ListServiceParam, \
41
+ ListInstanceParam, NacosConfigService, ConfigParam
42
+
43
+ client_config = (ClientConfigBuilder()
44
+ .access_key(os.getenv('NACOS_ACCESS_KEY'))
45
+ .secret_key(os.getenv('NACOS_SECRET_KEY'))
46
+ .server_address(os.getenv('NACOS_SERVER_ADDR', 'localhost:8848'))
47
+ .log_level('INFO')
48
+ .grpc_config(GRPCConfig(grpc_timeout=5000))
49
+ .build())
65
50
  ```
66
51
 
67
- * *server_addresses* - **required** - Nacos server address, comma separated if more than 1.
68
- * *namespace* - Namespace. | default: `None`
69
- * *ak* - The accessKey to authenticate. | default: null
70
- * *sk* - The secretKey to authentication. | default: null
71
- * *log_level* - Log level. | default: null
72
- * *log_rotation_backup_count* - The number of log files to keep. | default: `7`
73
-
74
- #### Extra Options
52
+ * *server_address* - **required** - Nacos server address
53
+ * *access_key* - The aliyun accessKey to authenticate.
54
+ * *secret_key* - The aliyun secretKey to authenticate.
55
+ * *credentials_provider* - The custom access key manager.
56
+ * *username* - The username to authenticate.
57
+ * *password* - The password to authenticate.
58
+ * *log_level* - Log level | default: `logging.INFO`
59
+ * *cache_dir* - cache dir path. | default: `~/nacos/cache`
60
+ * *log_dir* - log dir path. | default: `~/logs/nacos`
61
+ * *namespace_id* - namespace id. | default: ``
62
+ * *grpc_config* - grpc config.
63
+ * *max_receive_message_length* - max receive message length in grpc. | default: 100 * 1024 * 1024
64
+ * *max_keep_alive_ms* - max keep alive ms in grpc. | default: 60 * 1000
65
+ * *initial_window_size* - initial window size in grpc. | default: 10 * 1024 * 1024
66
+ * *initial_conn_window_size* - initial connection window size in grpc. | default: 10 * 1024 * 1024
67
+ * *grpc_timeout* - grpc timeout in milliseconds. default: 3000
68
+ * *tls_config* - tls config
69
+ * *enabled* - whether enable tls.
70
+ * *ca_file* - ca file path.
71
+ * *cert_file* - cert file path.
72
+ * *key_file* - key file path.
73
+ * *kms_config* - aliyun kms config
74
+ * *enabled* - whether enable aliyun kms.
75
+ * *endpoint* - aliyun kms endpoint.
76
+ * *access_key* - aliyun accessKey.
77
+ * *secret_key* - aliyun secretKey.
78
+ * *password* - aliyun kms password.
75
79
 
76
- Extra option can be set by `set_options`, as following:
80
+ ## Config Client
77
81
 
78
82
  ```
79
- client.set_options({key}={value})
80
- # client.set_options(proxies={"http":"192.168.3.50:809"})
83
+
84
+ config_client = await NacosConfigService.create_config_service(client_config)
85
+
81
86
  ```
82
87
 
83
- Configurable options are:
88
+ ### config client common parameters
84
89
 
85
- * *default_timeout* - Default timeout for get config from server in seconds.
86
- * *pulling_timeout* - Long polling timeout in seconds.
87
- * *pulling_config_size* - Max config items number listened by one polling process.
88
- * *callback_thread_num* - Concurrency for invoking callback.
89
- * *failover_base* - Dir to store failover config files.
90
- * *snapshot_base* - Dir to store snapshot config files.
91
- * *no_snapshot* - To disable default snapshot behavior, this can be overridden by param *no_snapshot* in *get* method.
92
- * *proxies* - Dict proxy mapping, some environments require proxy access, so you can set this parameter, this way http
93
- requests go through the proxy.
90
+ > `param: ConfigParam`
94
91
 
95
- ## API Reference
92
+ * `param` *data_id* Data id.
93
+ * `param` *group* Group, use `DEFAULT_GROUP` if no group specified.
94
+ * `param` *content* Config content.
95
+ * `param` *tag* Config tag.
96
+ * `param` *app_name* Application name.
97
+ * `param` *beta_ips* Beta test ip address.
98
+ * `param` *cas_md5* MD5 check code.
99
+ * `param` *type* Config type.
100
+ * `param` *src_user* Source user.
101
+ * `param` *encrypted_data_key* Encrypted data key.
102
+ * `param` *kms_key_id* Kms encrypted data key id.
103
+ * `param` *usage_type* Usage type.
96
104
 
97
105
  ### Get Config
98
106
 
99
- > `NacosClient.get_config(data_id, group, timeout, no_snapshot)`
107
+ ```
108
+ content = await config_client.get_config(ConfigParam(
109
+ data_id=data_id,
110
+ group=group
111
+ ))
112
+ ```
100
113
 
101
- * `param` *data_id* Data id.
102
- * `param` *group* Group, use `DEFAULT_GROUP` if no group specified.
103
- * `param` *timeout* Timeout for requesting server in seconds.
104
- * `param` *no_snapshot* Whether to use local snapshot while server is unavailable.
105
- * `return`
106
- W
107
- Get value of one config item following priority:
114
+ * `param` *ConfigParam* config client common parameters. When getting configuration, it is necessary to specify the
115
+ required data_id and group in param.
116
+ * `return` Config content if success or an exception will be raised.
108
117
 
118
+ Get value of one config item following priority:
109
119
 
110
- * Step 1 - Get from local failover dir(default: `${cwd}/nacos-data/data`).
111
- * Failover dir can be manually copied from snapshot dir(default: `${cwd}/nacos-data/snapshot`) in advance.
112
- * This helps to suppress the effect of known server failure.
120
+ * Step 1 - Get from local failover dir.
113
121
 
114
122
  * Step 2 - Get from one server until value is got or all servers tried.
115
- * Content will be save to snapshot dir after got from server.
123
+ * Content will be saved to snapshot dir after got from server.
116
124
 
117
125
  * Step 3 - Get from snapshot dir.
118
126
 
119
- ### Add Watchers
127
+ ### Add Listener
120
128
 
121
- > `NacosClient.add_config_watchers(data_id, group, cb_list)`
129
+ ```
130
+ async def config_listener(tenant, data_id, group, content):
131
+ print("listen, tenant:{} data_id:{} group:{} content:{}".format(tenant, data_id, group, content))
122
132
 
123
- * `param` *data_id* Data id.
124
- * `param` *group* Group, use `DEFAULT_GROUP` if no group specified.
125
- * `param` *cb_list* List of callback functions to add.
133
+ await config_client.add_listener(dataID, groupName, config_listener)
134
+ ```
135
+
136
+ * `param` *ConfigParam* config client common parameters.
137
+ * `listener` *listener* Configure listener, defined by the namespace_id、group、data_id、content.
126
138
  * `return`
127
139
 
128
- Add watchers to a specified config item.
140
+ Add Listener to a specified config item.
129
141
 
130
142
  * Once changes or deletion of the item happened, callback functions will be invoked.
131
143
  * If the item is already exists in server, callback functions will be invoked for once.
132
- * Multiple callbacks on one item is allowed and all callback functions are invoked concurrently by `threading.Thread`.
133
144
  * Callback functions are invoked from current process.
134
145
 
135
- ### Remove Watcher
146
+ ### Remove Listener
136
147
 
137
- > `NacosClient.remove_config_watcher(data_id, group, cb, remove_all)`
148
+ ```
149
+ await client.remove_listener(dataID, groupName, config_listener)
150
+ ```
138
151
 
139
- * `param` *data_id* Data id.
140
- * `param` *group* Group, use "DEFAULT_GROUP" if no group specified.
141
- * `param` *cb* Callback function to delete.
142
- * `param` *remove_all* Whether to remove all occurrence of the callback or just once.
143
- * `return`
152
+ * `param` *ConfigParam* config client common parameters.
153
+ * `return` True if success or an exception will be raised.
144
154
 
145
155
  Remove watcher from specified key.
146
156
 
147
157
  ### Publish Config
148
158
 
149
- > `NacosClient.publish_config(data_id, group, content, timeout)`
159
+ ```
160
+ res = await client.publish_config(ConfigParam(
161
+ data_id=dataID,
162
+ group=groupName,
163
+ content="Hello world")
164
+ )
165
+ ```
150
166
 
151
- * `param` *data_id* Data id.
152
- * `param` *group* Group, use "DEFAULT_GROUP" if no group specified.
153
- * `param` *content* Config value.
154
- * `param` *timeout* Timeout for requesting server in seconds.
167
+ * `param` *ConfigParam* config client common parameters. When publishing configuration, it is necessary to specify the
168
+ required data_id, group and content in param.
155
169
  * `return` True if success or an exception will be raised.
156
170
 
157
- Publish one data item to Nacos.
171
+ Publish one congfig data item to Nacos.
158
172
 
159
173
  * If the data key is not exist, create one first.
160
174
  * If the data key is exist, update to the content specified.
@@ -162,286 +176,292 @@ Description:
162
176
 
163
177
  ### Remove Config
164
178
 
165
- > `NacosClient.remove_config(data_id, group, timeout)`
166
-
167
- * `param` *data_id* Data id.
168
- * `param` *group* Group, use "DEFAULT_GROUP" if no group specified.
169
- * `param` *timeout* Timeout for requesting server in seconds.
179
+ ```
180
+ res = await client.remove_config(ConfigParam(
181
+ data_id=dataID,
182
+ group=groupName
183
+ ))
184
+ ```
185
+ * `param` *ConfigParam* config client common parameters.When removing configuration, it is necessary to specify the
186
+ required data_id and group in param.
170
187
  * `return` True if success or an exception will be raised.
171
188
 
172
- Remove one data item from Nacos.
173
-
174
- ### Register Instance
175
-
176
- >
177
- `NacosClient.add_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable, healthy,ephemeral,group_name,heartbeat_interval)`
178
-
179
- * `param` *service_name* **required** Service name to register to.
180
- * `param` *ip* **required** IP of the instance.
181
- * `param` *port* **required** Port of the instance.
182
- * `param` *cluster_name* Cluster to register to.
183
- * `param` *weight* A float number for load balancing weight.
184
- * `param` *metadata* Extra info in JSON string format or dict format
185
- * `param` *enable* A bool value to determine whether instance is enabled or not.
186
- * `param` *healthy* A bool value to determine whether instance is healthy or not.
187
- * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
188
- * `param` *heartbeat_interval* Auto daemon heartbeat interval in seconds.
189
- * `return` True if success or an exception will be raised.
189
+ Remove one config data item from Nacos.
190
190
 
191
- ### Deregister Instance
191
+ ### Stop Config Client
192
192
 
193
- > `NacosClient.remove_naming_instance(service_name, ip, port, cluster_name)`
193
+ ```
194
+ await client.shutdown()
195
+ ```
194
196
 
195
- * `param` *service_name* **required** Service name to deregister from.
196
- * `param` *ip* **required** IP of the instance.
197
- * `param` *port* **required** Port of the instance.
198
- * `param` *cluster_name* Cluster to deregister from.
199
- * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
200
- * `return` True if success or an exception will be raised.
197
+ ## Naming Client
201
198
 
202
- ### Modify Instance
199
+ ```
203
200
 
204
- > `NacosClient.modify_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable)`
201
+ naming_client = await NacosNamingService.create_naming_service(client_config)
205
202
 
206
- * `param` *service_name* **required** Service name.
207
- * `param` *ip* **required** IP of the instance.
208
- * `param` *port* **required** Port of the instance.
209
- * `param` *cluster_name* Cluster name.
210
- * `param` *weight* A float number for load balancing weight.
211
- * `param` *metadata* Extra info in JSON string format or dict format.
212
- * `param` *enable* A bool value to determine whether instance is enabled or not.
213
- * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
214
- * `return` True if success or an exception will be raised.
203
+ ```
215
204
 
216
- ### Query Instances
205
+ ### Register Instance
217
206
 
218
- > `NacosClient.list_naming_instance(service_name, clusters, namespace_id, group_name, healthy_only)`
207
+ ```angular2html
208
+ response = await client.register_instance(
209
+ request=RegisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', ip='1.1.1.1',
210
+ port=7001, weight=1.0, cluster_name='c1', metadata={'a': 'b'},
211
+ enabled=True,
212
+ healthy=True, ephemeral=True))
213
+ ```
219
214
 
220
- * `param` *service_name* **required** Service name to query.
221
- * `param` *clusters* Cluster names separated by comma.
222
- * `param` *namespace_id* Customized group name, default `blank`.
223
- * `param` *group_name* Customized group name , default `DEFAULT_GROUP`.
224
- * `param` *healthy_only* A bool value for querying healthy instances or not.
225
- * `return` Instance info list if success or an exception will be raised.
226
-
227
- ### Query Instance Detail
215
+ ### Batch Register Instance
216
+ ```angular2html
217
+ param1 = RegisterInstanceParam(service_name='nacos.test.1',
218
+ group_name='DEFAULT_GROUP',
219
+ ip='1.1.1.1',
220
+ port=7001,
221
+ weight=1.0,
222
+ cluster_name='c1',
223
+ metadata={'a': 'b'},
224
+ enabled=True,
225
+ healthy=True,
226
+ ephemeral=True
227
+ )
228
+ param2 = RegisterInstanceParam(service_name='nacos.test.1',
229
+ group_name='DEFAULT_GROUP',
230
+ ip='1.1.1.1',
231
+ port=7002,
232
+ weight=1.0,
233
+ cluster_name='c1',
234
+ metadata={'a': 'b'},
235
+ enabled=True,
236
+ healthy=True,
237
+ ephemeral=True
238
+ )
239
+ param3 = RegisterInstanceParam(service_name='nacos.test.1',
240
+ group_name='DEFAULT_GROUP',
241
+ ip='1.1.1.1',
242
+ port=7003,
243
+ weight=1.0,
244
+ cluster_name='c1',
245
+ metadata={'a': 'b'},
246
+ enabled=True,
247
+ healthy=False,
248
+ ephemeral=True
249
+ )
250
+ response = await client.batch_register_instances(
251
+ request=BatchRegisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP',
252
+ instances=[param1, param2, param3]))
253
+ ```
228
254
 
229
- > `NacosClient.get_naming_instance(service_name, ip, port, cluster_name)`
255
+ ### Deregister Instance
230
256
 
231
- * `param` *service_name* **required** Service name.
232
- * `param` *ip* **required** IP of the instance.
233
- * `param` *port* **required** Port of the instance.
234
- * `param` *cluster_name* Cluster name.
235
- * `return` Instance info if success or an exception will be raised.
257
+ ```angular2html
258
+ response = await client.deregister_instance(
259
+ request=DeregisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', ip='1.1.1.1',
260
+ port=7001, cluster_name='c1', ephemeral=True)
261
+ )
262
+ ```
236
263
 
237
- ### Send Instance Beat
264
+ ### Update Instance
265
+ ```angular2html
266
+ response = await client.update_instance(
267
+ request=RegisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', ip='1.1.1.1',
268
+ port=7001, weight=2.0, cluster_name='c1', metadata={'a': 'b'},
269
+ enabled=True,
270
+ healthy=True, ephemeral=True))
271
+ ```
238
272
 
239
- > `NacosClient.send_heartbeat(service_name, ip, port, cluster_name, weight, metadata)`
273
+ ### Get Service
274
+ ```angular2html
275
+ service = await client.get_service(
276
+ GetServiceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', cluster_name='c1'))
277
+ ```
240
278
 
241
- * `param` *service_name* **required** Service name.
242
- * `param` *ip* **required** IP of the instance.
243
- * `param` *port* **required** Port of the instance.
244
- * `param` *cluster_name* Cluster to register to.
245
- * `param` *weight* A float number for load balancing weight.
246
- * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
247
- * `param` *metadata* Extra info in JSON string format or dict format.
248
- * `return` A JSON object include server recommended beat interval if success or an exception will be raised.
279
+ ### List Service
280
+ ```angular2html
249
281
 
250
- ### Subscribe Service Instances Changed
282
+ service_list = await client.list_services(ListServiceParam())
251
283
 
252
- > `NacosClient.subscribe(listener_fn, listener_interval=7, *args, **kwargs)`
284
+ ```
253
285
 
254
- * `param` *listener_fn* **required** Customized listener function.
255
- * `param` *listener_interval* Listen interval , default 7 second.
256
- * `param` *service_name* **required** Service name which subscribes.
257
- * `param` *clusters* Cluster names separated by comma.
258
- * `param` *namespace_id* Customized group name, default `blank`.
259
- * `param` *group_name* Customized group name , default `DEFAULT_GROUP`.
260
- * `param` *healthy_only* A bool value for querying healthy instances or not.
261
- * `return`
286
+ ### List Instance
262
287
 
263
- ### Unsubscribe Service Instances Changed
288
+ ```angular2html
264
289
 
265
- > `NacosClient.unsubscribe(service_name, listener_name)`
290
+ instance_list = await client.list_instances(ListInstanceParam(service_name='nacos.test.1', healthy_only=True))
291
+ instance_list = await client.list_instances(ListInstanceParam(service_name='nacos.test.1', healthy_only=False))
292
+ instance_list = await client.list_instances(ListInstanceParam(service_name='nacos.test.1', healthy_only=None))
266
293
 
267
- * `param` *service_name* **required** Service name to subscribed.
268
- * `param` *listener_name* listener_name which is customized.
269
- * `return`
294
+ ```
270
295
 
271
- ### Stop All Service Subscribe
296
+ ### Subscribe
272
297
 
273
- > `NacosClient.stop_subscribe()`
298
+ ```angular2html
299
+ async def cb(instance_list: list[Instance]):
300
+ print('received subscribe callback', str(instance_list))
274
301
 
275
- * `return`
302
+ await client.subscribe(
303
+ SubscribeServiceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', subscribe_callback=cb))
304
+ ```
276
305
 
277
- ## Debugging Mode
278
306
 
279
- Debugging mode if useful for getting more detailed log on console.
307
+ ### Unsubscribe
280
308
 
281
- Debugging mode can be set by:
309
+ ```angular2html
310
+ async def cb(instance_list: list[Instance]):
311
+ print('received subscribe callback', str(instance_list))
282
312
 
283
- ```
284
- client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE, username=USERNAME, password=PASSWORD,log_level="DEBUG")
313
+ await client.unsubscribe(
314
+ SubscribeServiceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', subscribe_callback=cb))
285
315
  ```
286
316
 
287
- # nacos-sdk-python v2
317
+
318
+ # nacos-sdk-python 1.0
288
319
 
289
320
  A Python implementation of Nacos OpenAPI.
290
321
 
291
- see: https://nacos.io/zh-cn/docs/open-API.html
322
+ see: https://nacos.io/docs/latest/guide/user/open-api/
292
323
 
293
324
  [![Pypi Version](https://badge.fury.io/py/nacos-sdk-python.svg)](https://badge.fury.io/py/nacos-sdk-python)
294
325
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/nacos-group/nacos-sdk-python/blob/master/LICENSE)
295
326
 
296
327
  ### Supported Python version:
297
328
 
298
- Python 3.7+
329
+ Python 2.7
330
+ Python 3.6
331
+ Python 3.7
299
332
 
300
333
  ### Supported Nacos version
301
334
 
302
- Supported Nacos version over 2.x
335
+ Nacos 0.8.0+
336
+ Nacos 1.x
337
+ Nacos 2.x with http protocol
303
338
 
304
339
  ## Installation
305
340
 
306
341
  ```shell
307
- pip install nacos-sdk-python==2.0.0b5
342
+ pip install nacos-sdk-python
308
343
  ```
309
344
 
310
- ## Client Configuration
311
345
 
312
- ```
313
- from v2.nacos import NacosNamingService, ClientConfigBuilder, GRPCConfig, Instance, SubscribeServiceParam, \
314
- RegisterInstanceParam, DeregisterInstanceParam, BatchRegisterInstanceParam, GetServiceParam, ListServiceParam, \
315
- ListInstanceParam, NacosConfigService, ConfigParam
316
-
317
- client_config = (ClientConfigBuilder()
318
- .access_key(os.getenv('NACOS_ACCESS_KEY'))
319
- .secret_key(os.getenv('NACOS_SECRET_KEY'))
320
- .server_address(os.getenv('NACOS_SERVER_ADDR', 'localhost:8848'))
321
- .log_level('INFO')
322
- .grpc_config(GRPCConfig(grpc_timeout=5000))
323
- .build())
324
- ```
346
+ ## Getting Started
325
347
 
326
- * *server_address* - **required** - Nacos server address
327
- * *access_key* - The aliyun accessKey to authenticate.
328
- * *secret_key* - The aliyun secretKey to authenticate.
329
- * *username* - The username to authenticate.
330
- * *password* - The password to authenticate.
331
- * *log_level* - Log level | default: `logging.INFO`
332
- * *cache_dir* - cache dir path. | default: `~/nacos/cache`
333
- * *log_dir* - log dir path. | default: `~/logs/nacos`
334
- * *namespace_id* - namespace id. | default: ``
335
- * *grpc_config* - grpc config.
336
- * *max_receive_message_length* - max receive message length in grpc. | default: 100 * 1024 * 1024
337
- * *max_keep_alive_ms* - max keep alive ms in grpc. | default: 60 * 1000
338
- * *initial_window_size* - initial window size in grpc. | default: 10 * 1024 * 1024
339
- * *initial_conn_window_size* - initial connection window size in grpc. | default: 10 * 1024 * 1024
340
- * *grpc_timeout* - grpc timeout in milliseconds. default: 3000
341
- * *tls_config* - tls config
342
- * *enabled* - whether enable tls.
343
- * *ca_file* - ca file path.
344
- * *cert_file* - cert file path.
345
- * *key_file* - key file path.
346
- * *kms_config* - aliyun kms config
347
- * *enabled* - whether enable aliyun kms.
348
- * *endpoint* - aliyun kms endpoint.
349
- * *access_key* - aliyun accessKey.
350
- * *secret_key* - aliyun secretKey.
351
- * *password* - aliyun kms password.
348
+ ```python
349
+ import nacos
352
350
 
353
- ## Config Client
351
+ # Both HTTP/HTTPS protocols are supported, if not set protocol prefix default is HTTP, and HTTPS with no ssl check(verify=False)
352
+ # "192.168.3.4:8848" or "https://192.168.3.4:443" or "http://192.168.3.4:8848,192.168.3.5:8848" or "https://192.168.3.4:443,https://192.168.3.5:443"
353
+ SERVER_ADDRESSES = "server addresses split by comma"
354
+ NAMESPACE = "namespace id"
355
+
356
+ # no auth mode
357
+ client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE)
358
+ # auth mode
359
+ # client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE, ak="{ak}", sk="{sk}")
354
360
 
361
+ # get config
362
+ data_id = "config.nacos"
363
+ group = "group"
364
+ print(client.get_config(data_id, group))
355
365
  ```
356
366
 
357
- config_client = await NacosConfigService.create_config_service(client_config)
367
+ ## Configuration
358
368
 
369
+ ```
370
+ client = NacosClient(server_addresses, namespace=your_ns, ak=your_ak, sk=your_sk)
359
371
  ```
360
372
 
361
- ### config client common parameters
362
-
363
- > `param: ConfigParam`
373
+ * *server_addresses* - **required** - Nacos server address, comma separated if more than 1.
374
+ * *namespace* - Namespace. | default: `None`
375
+ * *ak* - The accessKey to authenticate. | default: null
376
+ * *sk* - The secretKey to authentication. | default: null
377
+ * *credentials_provider* - The custom access key manager | default: null
378
+ * *log_level* - Log level. | default: null
379
+ * *log_rotation_backup_count* - The number of log files to keep. | default: `7`
364
380
 
365
- * `param` *data_id* Data id.
366
- * `param` *group* Group, use `DEFAULT_GROUP` if no group specified.
367
- * `param` *content* Config content.
368
- * `param` *tag* Config tag.
369
- * `param` *app_name* Application name.
370
- * `param` *beta_ips* Beta test ip address.
371
- * `param` *cas_md5* MD5 check code.
372
- * `param` *type* Config type.
373
- * `param` *src_user* Source user.
374
- * `param` *encrypted_data_key* Encrypted data key.
375
- * `param` *kms_key_id* Kms encrypted data key id.
376
- * `param` *usage_type* Usage type.
381
+ #### Extra Options
377
382
 
378
- ### Get Config
383
+ Extra option can be set by `set_options`, as following:
379
384
 
380
385
  ```
381
- content = await config_client.get_config(ConfigParam(
382
- data_id=data_id,
383
- group=group
384
- ))
386
+ client.set_options({key}={value})
387
+ # client.set_options(proxies={"http":"192.168.3.50:809"})
385
388
  ```
386
389
 
387
- * `param` *ConfigParam* config client common parameters. When getting configuration, it is necessary to specify the
388
- required data_id and group in param.
389
- * `return` Config content if success or an exception will be raised.
390
+ Configurable options are:
390
391
 
391
- Get value of one config item following priority:
392
+ * *default_timeout* - Default timeout for get config from server in seconds.
393
+ * *pulling_timeout* - Long polling timeout in seconds.
394
+ * *pulling_config_size* - Max config items number listened by one polling process.
395
+ * *callback_thread_num* - Concurrency for invoking callback.
396
+ * *failover_base* - Dir to store failover config files.
397
+ * *snapshot_base* - Dir to store snapshot config files.
398
+ * *no_snapshot* - To disable default snapshot behavior, this can be overridden by param *no_snapshot* in *get* method.
399
+ * *proxies* - Dict proxy mapping, some environments require proxy access, so you can set this parameter, this way http
400
+ requests go through the proxy.
392
401
 
393
- * Step 1 - Get from local failover dir.
402
+ ## API Reference
403
+
404
+ ### Get Config
405
+
406
+ > `NacosClient.get_config(data_id, group, timeout, no_snapshot)`
407
+
408
+ * `param` *data_id* Data id.
409
+ * `param` *group* Group, use `DEFAULT_GROUP` if no group specified.
410
+ * `param` *timeout* Timeout for requesting server in seconds.
411
+ * `param` *no_snapshot* Whether to use local snapshot while server is unavailable.
412
+ * `return`
413
+ W
414
+ Get value of one config item following priority:
415
+
416
+
417
+ * Step 1 - Get from local failover dir(default: `${cwd}/nacos-data/data`).
418
+ * Failover dir can be manually copied from snapshot dir(default: `${cwd}/nacos-data/snapshot`) in advance.
419
+ * This helps to suppress the effect of known server failure.
394
420
 
395
421
  * Step 2 - Get from one server until value is got or all servers tried.
396
- * Content will be saved to snapshot dir after got from server.
422
+ * Content will be save to snapshot dir after got from server.
397
423
 
398
424
  * Step 3 - Get from snapshot dir.
399
425
 
400
- ### Add Listener
401
-
402
- ```
403
- async def config_listener(tenant, data_id, group, content):
404
- print("listen, tenant:{} data_id:{} group:{} content:{}".format(tenant, data_id, group, content))
426
+ ### Add Watchers
405
427
 
406
- await config_client.add_listener(dataID, groupName, config_listener)
407
- ```
428
+ > `NacosClient.add_config_watchers(data_id, group, cb_list)`
408
429
 
409
- * `param` *ConfigParam* config client common parameters.
410
- * `listener` *listener* Configure listener, defined by the namespace_id、group、data_id、content.
430
+ * `param` *data_id* Data id.
431
+ * `param` *group* Group, use `DEFAULT_GROUP` if no group specified.
432
+ * `param` *cb_list* List of callback functions to add.
411
433
  * `return`
412
434
 
413
- Add Listener to a specified config item.
435
+ Add watchers to a specified config item.
414
436
 
415
437
  * Once changes or deletion of the item happened, callback functions will be invoked.
416
438
  * If the item is already exists in server, callback functions will be invoked for once.
439
+ * Multiple callbacks on one item is allowed and all callback functions are invoked concurrently by `threading.Thread`.
417
440
  * Callback functions are invoked from current process.
418
441
 
419
- ### Remove Listener
442
+ ### Remove Watcher
420
443
 
421
- ```
422
- await client.remove_listener(dataID, groupName, config_listener)
423
- ```
444
+ > `NacosClient.remove_config_watcher(data_id, group, cb, remove_all)`
424
445
 
425
- * `param` *ConfigParam* config client common parameters.
426
- * `return` True if success or an exception will be raised.
446
+ * `param` *data_id* Data id.
447
+ * `param` *group* Group, use "DEFAULT_GROUP" if no group specified.
448
+ * `param` *cb* Callback function to delete.
449
+ * `param` *remove_all* Whether to remove all occurrence of the callback or just once.
450
+ * `return`
427
451
 
428
452
  Remove watcher from specified key.
429
453
 
430
454
  ### Publish Config
431
455
 
432
- ```
433
- res = await client.publish_config(ConfigParam(
434
- data_id=dataID,
435
- group=groupName,
436
- content="Hello world")
437
- )
438
- ```
456
+ > `NacosClient.publish_config(data_id, group, content, timeout)`
439
457
 
440
- * `param` *ConfigParam* config client common parameters. When publishing configuration, it is necessary to specify the
441
- required data_id, group and content in param.
458
+ * `param` *data_id* Data id.
459
+ * `param` *group* Group, use "DEFAULT_GROUP" if no group specified.
460
+ * `param` *content* Config value.
461
+ * `param` *timeout* Timeout for requesting server in seconds.
442
462
  * `return` True if success or an exception will be raised.
443
463
 
444
- Publish one congfig data item to Nacos.
464
+ Publish one data item to Nacos.
445
465
 
446
466
  * If the data key is not exist, create one first.
447
467
  * If the data key is exist, update to the content specified.
@@ -449,142 +469,126 @@ Description:
449
469
 
450
470
  ### Remove Config
451
471
 
452
- ```
453
- res = await client.remove_config(ConfigParam(
454
- data_id=dataID,
455
- group=groupName
456
- ))
457
- ```
458
- * `param` *ConfigParam* config client common parameters.When removing configuration, it is necessary to specify the
459
- required data_id and group in param.
472
+ > `NacosClient.remove_config(data_id, group, timeout)`
473
+
474
+ * `param` *data_id* Data id.
475
+ * `param` *group* Group, use "DEFAULT_GROUP" if no group specified.
476
+ * `param` *timeout* Timeout for requesting server in seconds.
460
477
  * `return` True if success or an exception will be raised.
461
478
 
462
- Remove one config data item from Nacos.
479
+ Remove one data item from Nacos.
463
480
 
464
- ### Stop Config Client
481
+ ### Register Instance
465
482
 
466
- ```
467
- await client.shutdown()
468
- ```
483
+ >
484
+ `NacosClient.add_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable, healthy,ephemeral,group_name,heartbeat_interval)`
469
485
 
470
- ## Naming Client
486
+ * `param` *service_name* **required** Service name to register to.
487
+ * `param` *ip* **required** IP of the instance.
488
+ * `param` *port* **required** Port of the instance.
489
+ * `param` *cluster_name* Cluster to register to.
490
+ * `param` *weight* A float number for load balancing weight.
491
+ * `param` *metadata* Extra info in JSON string format or dict format
492
+ * `param` *enable* A bool value to determine whether instance is enabled or not.
493
+ * `param` *healthy* A bool value to determine whether instance is healthy or not.
494
+ * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
495
+ * `param` *heartbeat_interval* Auto daemon heartbeat interval in seconds.
496
+ * `return` True if success or an exception will be raised.
471
497
 
472
- ```
498
+ ### Deregister Instance
473
499
 
474
- naming_client = await NacosNamingService.create_naming_service(client_config)
500
+ > `NacosClient.remove_naming_instance(service_name, ip, port, cluster_name)`
475
501
 
476
- ```
502
+ * `param` *service_name* **required** Service name to deregister from.
503
+ * `param` *ip* **required** IP of the instance.
504
+ * `param` *port* **required** Port of the instance.
505
+ * `param` *cluster_name* Cluster to deregister from.
506
+ * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
507
+ * `return` True if success or an exception will be raised.
477
508
 
478
- ### Register Instance
509
+ ### Modify Instance
479
510
 
480
- ```angular2html
481
- response = await client.register_instance(
482
- request=RegisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', ip='1.1.1.1',
483
- port=7001, weight=1.0, cluster_name='c1', metadata={'a': 'b'},
484
- enabled=True,
485
- healthy=True, ephemeral=True))
486
- ```
511
+ > `NacosClient.modify_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable)`
487
512
 
488
- ### Batch Register Instance
489
- ```angular2html
490
- param1 = RegisterInstanceParam(service_name='nacos.test.1',
491
- group_name='DEFAULT_GROUP',
492
- ip='1.1.1.1',
493
- port=7001,
494
- weight=1.0,
495
- cluster_name='c1',
496
- metadata={'a': 'b'},
497
- enabled=True,
498
- healthy=True,
499
- ephemeral=True
500
- )
501
- param2 = RegisterInstanceParam(service_name='nacos.test.1',
502
- group_name='DEFAULT_GROUP',
503
- ip='1.1.1.1',
504
- port=7002,
505
- weight=1.0,
506
- cluster_name='c1',
507
- metadata={'a': 'b'},
508
- enabled=True,
509
- healthy=True,
510
- ephemeral=True
511
- )
512
- param3 = RegisterInstanceParam(service_name='nacos.test.1',
513
- group_name='DEFAULT_GROUP',
514
- ip='1.1.1.1',
515
- port=7003,
516
- weight=1.0,
517
- cluster_name='c1',
518
- metadata={'a': 'b'},
519
- enabled=True,
520
- healthy=False,
521
- ephemeral=True
522
- )
523
- response = await client.batch_register_instances(
524
- request=BatchRegisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP',
525
- instances=[param1, param2, param3]))
526
- ```
513
+ * `param` *service_name* **required** Service name.
514
+ * `param` *ip* **required** IP of the instance.
515
+ * `param` *port* **required** Port of the instance.
516
+ * `param` *cluster_name* Cluster name.
517
+ * `param` *weight* A float number for load balancing weight.
518
+ * `param` *metadata* Extra info in JSON string format or dict format.
519
+ * `param` *enable* A bool value to determine whether instance is enabled or not.
520
+ * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
521
+ * `return` True if success or an exception will be raised.
527
522
 
528
- ### Deregister Instance
523
+ ### Query Instances
529
524
 
530
- ```angular2html
531
- response = await client.deregister_instance(
532
- request=DeregisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', ip='1.1.1.1',
533
- port=7001, cluster_name='c1', ephemeral=True)
534
- )
535
- ```
525
+ > `NacosClient.list_naming_instance(service_name, clusters, namespace_id, group_name, healthy_only)`
536
526
 
537
- ### Update Instance
538
- ```angular2html
539
- response = await client.update_instance(
540
- request=RegisterInstanceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', ip='1.1.1.1',
541
- port=7001, weight=2.0, cluster_name='c1', metadata={'a': 'b'},
542
- enabled=True,
543
- healthy=True, ephemeral=True))
544
- ```
527
+ * `param` *service_name* **required** Service name to query.
528
+ * `param` *clusters* Cluster names separated by comma.
529
+ * `param` *namespace_id* Customized group name, default `blank`.
530
+ * `param` *group_name* Customized group name , default `DEFAULT_GROUP`.
531
+ * `param` *healthy_only* A bool value for querying healthy instances or not.
532
+ * `return` Instance info list if success or an exception will be raised.
545
533
 
546
- ### Get Service
547
- ```angular2html
548
- service = await client.get_service(
549
- GetServiceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', cluster_name='c1'))
550
- ```
534
+ ### Query Instance Detail
551
535
 
552
- ### List Service
553
- ```angular2html
536
+ > `NacosClient.get_naming_instance(service_name, ip, port, cluster_name)`
554
537
 
555
- service_list = await client.list_services(ListServiceParam())
538
+ * `param` *service_name* **required** Service name.
539
+ * `param` *ip* **required** IP of the instance.
540
+ * `param` *port* **required** Port of the instance.
541
+ * `param` *cluster_name* Cluster name.
542
+ * `return` Instance info if success or an exception will be raised.
556
543
 
557
- ```
544
+ ### Send Instance Beat
558
545
 
559
- ### List Instance
546
+ > `NacosClient.send_heartbeat(service_name, ip, port, cluster_name, weight, metadata)`
560
547
 
561
- ```angular2html
548
+ * `param` *service_name* **required** Service name.
549
+ * `param` *ip* **required** IP of the instance.
550
+ * `param` *port* **required** Port of the instance.
551
+ * `param` *cluster_name* Cluster to register to.
552
+ * `param` *weight* A float number for load balancing weight.
553
+ * `param` *ephemeral* A bool value to determine whether instance is ephemeral or not.
554
+ * `param` *metadata* Extra info in JSON string format or dict format.
555
+ * `return` A JSON object include server recommended beat interval if success or an exception will be raised.
562
556
 
563
- instance_list = await client.list_instances(ListInstanceParam(service_name='nacos.test.1', healthy_only=True))
564
- instance_list = await client.list_instances(ListInstanceParam(service_name='nacos.test.1', healthy_only=False))
565
- instance_list = await client.list_instances(ListInstanceParam(service_name='nacos.test.1', healthy_only=None))
557
+ ### Subscribe Service Instances Changed
566
558
 
567
- ```
559
+ >`NacosClient.subscribe(listener_fn, listener_interval=7, *args, **kwargs)`
568
560
 
569
- ### Subscribe
561
+ * `param` *listener_fn* **required** Customized listener function. with signature `fn_listener1(event, instance)->None`
562
+ * `param` *listener_interval* Listen interval , default 7 second.
563
+ * `param` *service_name* **required** Service name which subscribes.
564
+ * `param` *clusters* Cluster names separated by comma.
565
+ * `param` *namespace_id* Customized group name, default `blank`.
566
+ * `param` *group_name* Customized group name , default `DEFAULT_GROUP`.
567
+ * `param` *healthy_only* A bool value for querying healthy instances or not.
568
+ * `return`
570
569
 
571
- ```angular2html
572
- async def cb(instance_list: list[Instance]):
573
- print('received subscribe callback', str(instance_list))
570
+ ### Unsubscribe Service Instances Changed
574
571
 
575
- await client.subscribe(
576
- SubscribeServiceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', subscribe_callback=cb))
577
- ```
572
+ > `NacosClient.unsubscribe(service_name, listener_name)`
578
573
 
574
+ * `param` *service_name* **required** Service name to subscribed.
575
+ * `param` *listener_name* listener_name which is customized.
576
+ * `return`
579
577
 
580
- ### Unsubscribe
578
+ ### Stop All Service Subscribe
581
579
 
582
- ```angular2html
583
- async def cb(instance_list: list[Instance]):
584
- print('received subscribe callback', str(instance_list))
580
+ > `NacosClient.stop_subscribe()`
585
581
 
586
- await client.unsubscribe(
587
- SubscribeServiceParam(service_name='nacos.test.1', group_name='DEFAULT_GROUP', subscribe_callback=cb))
582
+ * `return`
583
+
584
+ ## Debugging Mode
585
+
586
+ Debugging mode if useful for getting more detailed log on console.
587
+
588
+ Debugging mode can be set by:
589
+
590
+ ```
591
+ client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE, username=USERNAME, password=PASSWORD,log_level="DEBUG")
588
592
  ```
589
593
  Keywords: nacos,nacos-sdk-python
590
594
  Platform: UNKNOWN