Kisters液压网络存储服务的客户端库
kisters.water.hydraulic-network.client的Python项目详细描述
液压网络客户端库
此库允许连接到远程液压网络rest服务器。它 支持使用openid connect进行身份验证。
安装
安装时使用pip
:
> python -m pip install kisters.water.hydraulic_network.client
示例用法
创建客户端
fromkisters.water.hydraulic_network.clientimport(OpenIDConnect,# provides authentication tokens for the clientRESTClient,# communicates with a network store service)# Instantiate the authentication class with credentialsauthentication=OpenIDConnect(issuer_url="https://auth.kisters.cloud/auth/realms/external",client_id="jesse-test",client_secret="c4b0f70d-d2e6-497f-b11c-d49fe806c29b",)# Instantiate the client class with the service url and authenticationclient=RESTClient(url="https://jesse-test.hydraulic-network.kisters.cloud/",authentication=authentication)# Verify the client is set up correctly# Note: If you have not created any networks yet, this could be an empty listclient.get(("rest","networks"))# ['my-network', 'my-other-network', ...]
连接到网络
fromkisters.water.hydraulic_network.clientimportNetwork# Instantiate the Network class with the network name and clientnetwork=Network("my-network",client)# You can now access the properties of the networknetwork.get_nodes()# [# FlowBoundary(# created=datetime.datetime(2019, 6, 27, 16, 53, 5),# uid='flow_boundary',# display_name='flow_boundary',# location={'x': 0.0, 'y': 0.0, 'z': 0.0},# schematic_location={'x': 0.0, 'y': 0.0, 'z': 0.0})# ,# ...# ]