如何使用Python客户端Rancher进行调用

如何使用Python客户端Rancher进行调用,python,docker,curl,kubernetes,rancher,Python,Docker,Curl,Kubernetes,Rancher,我希望你今天做得很好。关于我目前正在开发的Rancher Python客户端,我有一个问题。我试图访问这一个单节点容器并修改所述容器的各个方面,但我真的不知道从哪里开始。我能够应用API键并使用print(client)打印出客户端 问题:是否有人可以对rancher api进行模拟调用,特别是是否有方法更改管理员访问权限,即谁可以从api访问哪个容器 非常感谢你 GitHub链接: 进口牧场主 client=rancher.client(url=)https://localhost:8443/

我希望你今天做得很好。关于我目前正在开发的Rancher Python客户端,我有一个问题。我试图访问这一个单节点容器并修改所述容器的各个方面,但我真的不知道从哪里开始。我能够应用API键并使用print(client)打印出客户端

问题:是否有人可以对rancher api进行模拟调用,特别是是否有方法更改管理员访问权限,即谁可以从api访问哪个容器

非常感谢你

GitHub链接:

进口牧场主
client=rancher.client(url=)https://localhost:8443/v3',
访问密钥=“”,
机密密钥=“”)
#curl-shttps://localhost:8443/v3/users?me=true
client.list\u用户(me='true')
#curl-s-X柱https://localhost:8443/v3/users -H'内容类型:application/json'-d'{“username”:“user1”,“password”:“Password1”}'
创建用户(用户名='user1',密码='Password1')
#curl-s-X-PUThttps://localhost:8443/v3/users/user-xyz123-H'内容类型:application/json'-d'{“description”:“A user”}'
user=client.by_id_user('user-xyz123'))
client.update(user,description='A user')
#curl-s-X删除https://localhost:8443/v3/users/user-xyz123
user=client.by_id_user('user-xyz123'))
client.delete(用户)
#链接
#curl-shttps://localhost:8443/v3/clusterRoleTemplateBindings?userId=user-xyz123
user=client.by_id_user('user-xyz123'))
user.clusterRoleTemplateBindings()

我找到了答案,我一直在使用rancher 1.6,而不是rancher 2.x。API不适用于rancher 1.6。

我找到了答案,我一直在使用rancher 1.6,而不是rancher 2.x。该API不适用于rancher 1.6

import rancher

client = rancher.Client(url='https://localhost:8443/v3',
                        access_key='<some valid access key>',
                        secret_key='<some valid secret key>')

# curl -s https://localhost:8443/v3/users?me=true
client.list_user(me='true')

# curl -s -X POST https://localhost:8443/v3/users -H 'Content-Type: application/json' -d '{ "username" : "user1", "password": "Password1" }'
client.create_user(username='user1', password='Password1')

# curl -s -X PUT https://localhost:8443/v3/users/user-xyz123 -H 'Content-Type: application/json' -d '{ "description" : "A user" }'
user = client.by_id_user('user-xyz123')
client.update(user, description='A user')

# curl -s -X DELETE https://localhost:8443/v3/users/user-xyz123
user = client.by_id_user('user-xyz123')
client.delete(user)

# Links
# curl -s https://localhost:8443/v3/clusterRoleTemplateBindings?userId=user-xyz123
user = client.by_id_user('user-xyz123')
user.clusterRoleTemplateBindings()