# Python SDK for CloudCIX API #
An Python SDK implementation to make the work with CloudCIX API fun.
API Docs: http://docs.cloudcix.com
CloudCIX is developed by CIX: http://www.cix.ie
# Installation #
pip install cloudcix
# Required settings #
When you run your project you should set the settings variable
`CLOUDCIX_SETTINGS_MODULE` to point to the module that contains the settings
object.
Example django lazy settings object (object should be specified after ":"):
import os
os.environ.setdefault("CLOUDCIX_SETTINGS_MODULE", "django.conf:settings")
Example for a module based settings:
import os
os.environ.setdefault("CLOUDCIX_SETTINGS_MODULE", "my.project.my_settings")
Required `CLOUDCIX` and `OPENSTACK` settings
CLOUDCIX_SERVER_URL = 'https://api.cloudcix.com'
CLOUDCIX_API_USERNAME = 'user@cloudcix.com'
CLOUDCIX_API_PASSWORD = 'super53cr3t3'
CLOUDCIX_API_ID_MEMBER = '2243'
OPENSTACK_KEYSTONE_URL = 'http://keystone.cloudcix.com:5000/v3'
As an alternative when used from console the settings can be set as environment
variables
os.environ['CLOUDCIX_SERVER_URL'] = 'https://api.cloudcix.com/'
utils method get_admin_token and get_admin_session, will require you to set
following environment variables as well
os.environ['CLOUDCIX_API_USERNAME'] = 'user@cloudcix.com'
os.environ['CLOUDCIX_API_PASSWORD'] = 'super53cr3t3'
os.environ['CLOUDCIX_API_ID_MEMBER'] = '2243'
os.environ['OPENSTACK_KEYSTONE_URL'] = 'http://keystone.cloudcix.com:5000/v3'
# Sample usage #
## Use the language service ##
from cloudcix import api
from cloudcix.utils import get_admin_session
# get an admin token
token = get_admin_session().get_token()
# call a sample membership service
api.membership.language.list()
## Create token for a User, and read the User Address ##
from cloudcix import api
from cloudcix.cloudcixauth import CloudCIXAuth
from cloudcix.utils import KeystoneSession, KeystoneClient, \
get_admin_client
from keystoneclient.exceptions import NotFound
# create auth payload
auth = CloudCIXAuth(
auth_url=settings.OPENSTACK_KEYSTONE_URL,
username='john@doe.com',
password='ubersecret',
idMember='2243')
auth_session = KeystoneSession(auth=auth)
user_token = auth_session.get_token()
token_data = auth_session.auth.auth_ref
# for the sake of example check that the token is valid
# you should use your admin credentials to check user's token
admin_cli = get_admin_client()
try:
admin_cli.tokens.validate(user_token)
except NotFound as e:
# Token is invalid, re-raise the exception
raise e
# token is valid, continue
# Finally, read the address
response = api.membership.address.read(
pk=token_data['user']['address']['idAddress'],
token=user_token)
# check the response status to ensure we've been able to read the address
if response.status_code != 200:
# we couldn't read the address
return response.content
address = response.json()['content']
# Finally delete the token
admin_cli.tokens.revoke_token(user_token)
# And make sure it's not longer valid
try:
admin_cli.tokens.validate(user_token)
except NotFound as e:
# Token is not longer valid
pass
## Given an expiring token, get a new token for further calls ##
from cloudcix.utils import KeystoneTokenAuth, KeystoneSession
expiring_token = 'xyz123'
auth = KeystoneTokenAuth(
auth_url=settings.OPENSTACK_KEYSTONE_URL,
token=expiring_token)
new_token = KeystoneSession(auth=auth).get_token()
没有合适的资源?快使用搜索试试~ 我知道了~
Python库 | cloudcix-0.1.4.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 104 浏览量
2022-04-07
09:27:05
上传
评论
收藏 8KB GZ 举报
温馨提示
资源分类:Python库 所属语言:Python 资源全名:cloudcix-0.1.4.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
cloudcix-0.1.4.tar.gz (19个子文件)
cloudcix-0.1.4
MANIFEST.in 120B
PKG-INFO 6KB
README.txt 4KB
cloudcix
utils.py 3KB
cloudcixauth.py 4KB
__init__.py 138B
api.py 4KB
base.py 14KB
LICENSE 576B
setup.cfg 82B
cloudcix.egg-info
PKG-INFO 6KB
requires.txt 54B
SOURCES.txt 359B
top_level.txt 9B
dependency_links.txt 1B
pbr.json 47B
requirements.txt 55B
setup.py 1KB
README.md 4KB
共 19 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- java制造业MES生产管理系统源码 MES源码数据库 MySQL源码类型 WebForm
- 基于无人机航拍数据实现的三维场景重建python源代码+文档说明+数据集(高分项目)
- 【重磅,更新!】全国2000-2022年植被指数数据(分辨率30m)
- 包含Qt5Core.dll Qt5Gui.dll Qt5Network.dll Qt5Svg.dll Qt5Widgets.dl
- python3.6 get-pip.py
- python期末大作业基于ResNet的人脸表情识别项目源码+数据集+模型文件(高分项目)
- C#大型多门店4S连锁汽车维修保养管理系统源码(带文档)数据库 SQL2008源码类型 WebForm
- 【安卓毕业设计】基于Android健康检测系统的设计与实现源码(完整前后端+mysql+说明文档).zip
- 【重磅,更新!】中国分省农户创业活动农户创业活跃度(2011-2021年)
- YOLOv5 PyTorch 格式注释番茄叶病检测数据集下载
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功