python调用nacos账号密码_python-nacos-sdk

nacos-sdk-python

A Python implementation of Nacos OpenAPI.

nacos-sdk-python.svg

license-Apache%202.0-blue.svg

Supported Python version:

Python 2.7

Python 3.6

Python 3.7

Supported Nacos version

Nacos 0.8.0

nacos 1.1.0 后新增了权限控制模块,旧API需要先登陆拿token才能正常调用,该包在原SDK上增加了登陆的逻辑

使用方法

python setup.py install

git clone ....

from nacos.client import NacosClient

方法

ak , sk为账号密码

#初始化

def __init__(self, server_addresses, endpoint=None, namespace=None, ak=None, sk=None)

#开启debug

@staticmethod

def set_debugging():

#获取配置

get_config(self, data_id, group, timeout=None, no_snapshot=None):

#发布配置

publish_config(self, data_id, group, content, timeout=None)

#删除配置

remove_config(self, data_id, group, timeout=None)

#添加监听,cb_list为回调函数列表[call_back,call_back....]

add_config_watchers(self, data_id, group, cb_list)

#删除监听

remove_config_watcher(self, data_id, group, cb, remove_all=False):

#添加实例

add_naming_instance(self, service_name, ip, port, cluster_name="", weight=1.0, metadata="",

enable=True, healthy=True)

#删除实例

remove_naming_instance(self, service_name, ip, port, cluster_name=None)

#修改实例

modify_naming_instance(self, service_name, ip, port, cluster_name=None, weight=None, metadata=None,

enable=None)

#列举实例

list_naming_instance(self, service_name, clusters=None, healthy_only=False)

#获取实例

get_naming_instance(self, service_name, ip, port, cluster_name=None)

#发送心跳

send_heartbeat(self, service_name, ip, port, cluster_name=None, weight=1.0, metadata=None)

#

增加逻辑源码,即每次调用都登陆拿token

...

def _get_common_headers(self, timeout):

server_info = self.get_server()

all_headers = {}

timeout = timeout or self.default_timeout

method = "POST"

if not server_info:

logger.error("

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值