{ "info": { "author": "nacos", "author_email": "755063194@qq.com", "bugtrack_url": null, "classifiers": [], "description": "# nacos-sdk-python\nA Python implementation of Nacos OpenAPI.\n\nsee: https://nacos.io/zh-cn/docs/open-API.html\n\n[![Pypi Version](https://badge.fury.io/py/nacos-sdk-python.svg)](https://badge.fury.io/py/nacos-sdk-python)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/nacos-group/nacos-sdk-python/blob/master/LICENSE)\n\n\n### Supported Python version\uff1a\n\nPython 2.7\nPython 3.6\nPython 3.7\n\n### Supported Nacos version\nNacos 0.8.0\n\n\n## Installation\n```shell\npip install nacos-sdk-python\n```\n\n## Getting Started\n```python\nimport nacos\n\nSERVER_ADDRESSES = \"server addresses split by comma\"\nNAMESPACE = \"***\"\n\nclient = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE)\n\n# get config\ndata_id = \"config.nacos\"\ngroup = \"group\"\nprint(client.get_config(data_id, group))\n```\n\n## Configuration\n```\nclient = NacosClient(server_addresses, namespace=your_ns)\n```\n\n* *server_addresses* - **required** - Nacos server address, comma separated if more than 1.\n* *namespace* - Namespace. | default: `None`\n\n#### Extra Options\nExtra option can be set by `set_options`, as following:\n\n```\nclient.set_options({key}={value})\n```\n\nConfigurable options are:\n\n* *default_timeout* - Default timeout for get config from server in seconds.\n* *pulling_timeout* - Long polling timeout in seconds.\n* *pulling_config_size* - Max config items number listened by one polling process.\n* *callback_thread_num* - Concurrency for invoking callback.\n* *failover_base* - Dir to store failover config files.\n* *snapshot_base* - Dir to store snapshot config files.\n* *no_snapshot* - To disable default snapshot behavior, this can be overridden by param *no_snapshot* in *get* method.\n\n## API Reference\n\n### Get Config\n>`NacosClient.get_config(data_id, group, timeout, no_snapshot)`\n\n* `param` *data_id* Data id.\n* `param` *group* Group, use `DEFAULT_GROUP` if no group specified.\n* `param` *timeout* Timeout for requesting server in seconds.\n* `param` *no_snapshot* Whether to use local snapshot while server is unavailable.\n* `return` \nW\nGet value of one config item following priority:\n\n* Step 1 - Get from local failover dir(default: `${cwd}/nacos-data/data`).\n * Failover dir can be manually copied from snapshot dir(default: `${cwd}/nacos-data/snapshot`) in advance.\n * This helps to suppress the effect of known server failure.\n\n* Step 2 - Get from one server until value is got or all servers tried.\n * Content will be save to snapshot dir after got from server.\n\n* Step 3 - Get from snapshot dir.\n\n### Add Watchers\n>`NacosClient.add_config_watchers(data_id, group, cb_list)`\n\n* `param` *data_id* Data id.\n* `param` *group* Group, use `DEFAULT_GROUP` if no group specified.\n* `param` *cb_list* List of callback functions to add.\n* `return`\n\nAdd watchers to a specified config item.\n* Once changes or deletion of the item happened, callback functions will be invoked.\n* If the item is already exists in server, callback functions will be invoked for once.\n* Multiple callbacks on one item is allowed and all callback functions are invoked concurrently by `threading.Thread`.\n* Callback functions are invoked from current process.\n\n### Remove Watcher\n>`NacosClient.remove_config_watcher(data_id, group, cb, remove_all)`\n\n* `param` *data_id* Data id.\n* `param` *group* Group, use \"DEFAULT_GROUP\" if no group specified.\n* `param` *cb* Callback function to delete.\n* `param` *remove_all* Whether to remove all occurrence of the callback or just once.\n* `return`\n\nRemove watcher from specified key.\n\n### Publish Config\n>`NacosClient.publish_config(data_id, group, content, timeout)`\n\n* `param` *data_id* Data id.\n* `param` *group* Group, use \"DEFAULT_GROUP\" if no group specified.\n* `param` *content* Config value.\n* `param` *timeout* Timeout for requesting server in seconds.\n* `return` True if success or an exception will be raised.\n\nPublish one data item to Nacos.\n* If the data key is not exist, create one first.\n* If the data key is exist, update to the content specified.\n* Content can not be set to None, if there is need to delete config item, use function **remove** instead.\n\n### Remove Config\n>`NacosClient.remove_config(data_id, group, timeout)`\n* `param` *data_id* Data id.\n* `param` *group* Group, use \"DEFAULT_GROUP\" if no group specified.\n* `param` *timeout* Timeout for requesting server in seconds.\n* `return` True if success or an exception will be raised.\n\nRemove one data item from Nacos.\n\n### Register Instance\n>`NacosClient.add_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable, healthy)`\n* `param` *service_name* **required** Service name to register to.\n* `param` *ip* **required** IP of the instance.\n* `param` *port* **required** Port of the instance.\n* `param` *cluster_name* Cluster to register to.\n* `param` *weight* A float number for load balancing weight.\n* `param` *metadata* Extra info in JSON string format.\n* `param` *enable* A bool value to determine whether instance is enabled or not.\n* `param` *healthy* A bool value to determine whether instance is healthy or not.\n* `return` True if success or an exception will be raised.\n\n### Deregister Instance\n>`NacosClient.remove_naming_instance(service_name, ip, port, cluster_name)`\n* `param` *service_name* **required** Service name to deregister from.\n* `param` *ip* **required** IP of the instance.\n* `param` *port* **required** Port of the instance.\n* `param` *cluster_name* Cluster to deregister from.\n* `return` True if success or an exception will be raised.\n\n### Modify Instance\n>`NacosClient.modify_naming_instance(service_name, ip, port, cluster_name, weight, metadata, enable)`\n* `param` *service_name* **required** Service name.\n* `param` *ip* **required** IP of the instance.\n* `param` *port* **required** Port of the instance.\n* `param` *cluster_name* Cluster name.\n* `param` *weight* A float number for load balancing weight.\n* `param` *metadata* Extra info in JSON string format.\n* `param` *enable* A bool value to determine whether instance is enabled or not.\n* `return` True if success or an exception will be raised.\n\n### Query Instances\n>`NacosClient.list_naming_instance(service_name, clusters, healthy_only)`\n* `param` *service_name* **required** Service name to query.\n* `param` *clusters* Cluster names separated by comma.\n* `param` *healthy_only* A bool value for querying healthy instances or not.\n* `return` Instance info list if success or an exception will be raised.\n\n### Query Instance Detail\n>`NacosClient.get_naming_instance(service_name, ip, port, cluster_name)`\n* `param` *service_name* **required** Service name.\n* `param` *ip* **required** IP of the instance.\n* `param` *port* **required** Port of the instance.\n* `param` *cluster_name* Cluster name.\n* `return` Instance info if success or an exception will be raised.\n\n### Send Instance Beat\n>`NacosClient.send_heartbeat(service_name, ip, port, cluster_name, weight, metadata)`\n* `param` *service_name* **required** Service name.\n* `param` *ip* **required** IP of the instance.\n* `param` *port* **required** Port of the instance.\n* `param` *cluster_name* Cluster to register to.\n* `param` *weight* A float number for load balancing weight.\n* `param` *metadata* Extra info in JSON string format.\n* `return` A JSON object include server recommended beat interval if success or an exception will be raised.\n\n## Debugging Mode\nDebugging mode if useful for getting more detailed log on console.\n\nDebugging mode can be set by:\n```\nNacosClient.set_debugging()\n# only effective within the current process\n```\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nacos-group/nacos-sdk-python", "keywords": "", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "nacos-sdk-python", "package_url": "https://pypi.org/project/nacos-sdk-python/", "platform": "", "project_url": "https://pypi.org/project/nacos-sdk-python/", "project_urls": { "Homepage": "https://github.com/nacos-group/nacos-sdk-python" }, "release_url": "https://pypi.org/project/nacos-sdk-python/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Python client for Nacos.", "version": "0.1.1" }, "last_serial": 4909632, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "cd4e2978a5928579df53d0c47e18d9fb", "sha256": "7df88eaf844ae3622e4c9d0c02f5f9a5223dec9ebeb07f435b0492077296c480" }, "downloads": -1, "filename": "nacos_sdk_python-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "cd4e2978a5928579df53d0c47e18d9fb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11381, "upload_time": "2019-02-15T05:40:42", "url": "https://files.pythonhosted.org/packages/1b/55/098c9b44e2808a621bd3b77d6f3413dcb6276809a6607b05cb9a6a019ba9/nacos_sdk_python-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0b6231a25f45a164aacdaa94fb92ccd3", "sha256": "4be56e216ed56fd41a6eb5c2a02d0171749d7ea208e8c219818f5df29c2f05b4" }, "downloads": -1, "filename": "nacos-sdk-python-0.1.0.tar.gz", "has_sig": false, "md5_digest": "0b6231a25f45a164aacdaa94fb92ccd3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12428, "upload_time": "2019-02-15T05:40:45", "url": "https://files.pythonhosted.org/packages/ef/b5/9ab94854d942d42b0f4280b8c80b19bf69b16f3add178734bd98a99a6620/nacos-sdk-python-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "cbe6a0c3964a0a0c388c90f942524a1e", "sha256": "81544c2034f45f6bbd5359b2fa71f0fbca6b43400062f179848dc591fa10d55b" }, "downloads": -1, "filename": "nacos_sdk_python-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "cbe6a0c3964a0a0c388c90f942524a1e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11415, "upload_time": "2019-03-07T11:07:04", "url": "https://files.pythonhosted.org/packages/d3/43/ad53207c5a9f98058d409331e4f7001aab33728b3ac6079a565a560a6aed/nacos_sdk_python-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6cfddb93b3e7774997dca47c76de2b35", "sha256": "24d5ce83b6b10cf523bf0a2956dd533f8777a1dfc205a80e4105ce4b657c67b5" }, "downloads": -1, "filename": "nacos-sdk-python-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6cfddb93b3e7774997dca47c76de2b35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12468, "upload_time": "2019-03-07T11:07:06", "url": "https://files.pythonhosted.org/packages/7f/0d/93774753da447f8cae1e722a5ad9e3addd988f89371b7d1853710f3db22c/nacos-sdk-python-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cbe6a0c3964a0a0c388c90f942524a1e", "sha256": "81544c2034f45f6bbd5359b2fa71f0fbca6b43400062f179848dc591fa10d55b" }, "downloads": -1, "filename": "nacos_sdk_python-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "cbe6a0c3964a0a0c388c90f942524a1e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11415, "upload_time": "2019-03-07T11:07:04", "url": "https://files.pythonhosted.org/packages/d3/43/ad53207c5a9f98058d409331e4f7001aab33728b3ac6079a565a560a6aed/nacos_sdk_python-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6cfddb93b3e7774997dca47c76de2b35", "sha256": "24d5ce83b6b10cf523bf0a2956dd533f8777a1dfc205a80e4105ce4b657c67b5" }, "downloads": -1, "filename": "nacos-sdk-python-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6cfddb93b3e7774997dca47c76de2b35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12468, "upload_time": "2019-03-07T11:07:06", "url": "https://files.pythonhosted.org/packages/7f/0d/93774753da447f8cae1e722a5ad9e3addd988f89371b7d1853710f3db22c/nacos-sdk-python-0.1.1.tar.gz" } ] }