Skip to main content

Client library for Meituan Cloud Platform EC2 API

Project description

Python SDK及客户端
==================

|readthedocs|

我们提供了方便调用MOS API的Python SDK以及基于该SDK实现的客户端。

安装
----

使用pip安装
~~~~~~~~~~~
在命令行下可以直接使用pip进行安装::

sudo pip install mosclient

从源码安装
~~~~~~~~~~
从 `github下载最新版 <https://github.com/meituan/mcsapi_python/archive/master.zip>`_ 代码并解压,或者执行如下命令获取源码::

git clone https://github.com/meituan/mcsapi_python.git

进入mcsapi_python目录执行下述命令安装客户端可执行文件climos以及相应的python SDK::

python setup.py install

访问MOS控制台的 `API页面 <https://mos.meituan.com/console/#api>`_ 获得API入口URL、ACCESS Key和Secret。

使用Python SDK
--------------

通过mosclient.client.Client生成客户端实例,API接口说明实现参见 `SDK API文档 <http://mcsapi-python.readthedocs.org/zh_CN/latest/client.html>`_ 。

示例代码如下:

::

import mosclient.client

version = '1'
key = 'MOS_ACCESS_KEY'
secret = 'MOS_ACCESS_SECRET'
url = 'https://mosapi.meituan.com/mcs/v1'

cli = mosclient.client.Client(version, key, secret, url)

balance = cli.GetBalance()
print balance


使用Python客户端
----------------

安装客户端软件后,执行以下步骤开始使用MOS API Python客户端。

设置环境变量
~~~~~~~~~~~~

在MOS控制台 `API页面 <https://mos.meituan.com/console/#api>`_ 获取个人的MOS ACCESS Key和Secret,以及API入口URL。设置如下环境变量

::

export MOS_ACCESS=4ba303cc17454cc7904e044db2a3c912
export MOS_SECRET=2952f821201341a38978ac4a4a292ce8
export MOS_URL=https://mosapi.meituan.com/mcs/v1

执行climos客户端
~~~~~~~~~~~~~~~~

climos是命令行的客户端工具,用户可以在终端运行,下面的示例是如何使用命令行创建一台机器:

::

# 输出climos命令行工具帮助信息
> climos help

# 获取当前余额
> climos GetBalance

# 列出所有可用的虚拟机镜像模板,选择一个模板,并记下模板ID,如8e76df8f-3476-4eed-8469-ed22daa1334c (templateID)
> climos DescribeTemplates

# 列出所有可用的虚拟机类型,选择一个类型,并记下类型ID,如C1_M1 (instanceTypeID)
> climos DescribeInstanceTypes

# 创建虚拟机,注意需要帐户中有足够余额
> climos CreateInstance 8e76df8f-3476-4eed-8469-ed22daa1334c C1_M1


.. |readthedocs| image:: https://readthedocs.org/projects/mcsapi-python/badge/?version=latest
:target: http://mcsapi-python.readthedocs.org/zh_CN/latest/
:alt: Documentation Status


更新历史
========
v1.0.12 (2017-11-09)
-------------------
1. 增加DeepLearning Docker Image管理接口

v1.0.11 (2017-11-07)
-------------------
1. 增加DeepLearning Project/Job管理接口

v1.0.10 (2016-09-19)
-------------------
1. 增加VPC及其子网的管理接口
2. 创建主机时允许指定所属网络以及IP
3. 浮动IP允许绑定多个(具体机型和配额请提工单咨询)
4. 增加查询主机允许绑定浮动IP数量、已绑定浮动IP数量和剩余可绑定浮动IP数量的接口

v1.0.9 (2016-08-04)
-------------------
1. 添加RDS一主多从相关接口
2. 添加ECS(Memcache)相关接口

v1.0.8 (2016-04-27)
-------------------
1. 增加后计费主机创建接口兼容
2. 增加业务组相关API
3. 支持ip创建备份用户自动开放80端口

v1.0.7 (2016-01-29)
-------------------
1. 增加EBS相关API
2. 增加浮动ip热切换接口
3. 支持浮动ip的操作用具体ip代替原id

v1.0.6 (2015-09-09)
-------------------
1. 增加浮动IP相关API
2. 创建主机时允许指定区域

v1.0.5 (2015-08-10)
-------------------
1. 增加RDS相关api

v1.0.4 (2015-05-13)
-------------------
1. 增加Redis缓存API

v1.0.3 (2014-12-19)
-------------------
1. 修改SDK创建主机以及修改主机配置时数据盘的单位,由10G修改为1G,与RESTful API的单位统一。 (与之前版本不兼容,升级版本时请注意)

v1.0.2 (2014-10-29)
-------------------
1. ChangeInstanceType 支持调整额外的磁盘和带宽
2. 增加保存和删除模板API

v1.0.1 (2014-08-26)
-------------------
1. CreateInstance 支持增加额外的磁盘和带宽


v1.0.0 (2013-10-15)
-------------------
1. MCS API第一个版本,完成基本功能

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mosclient-1.0.12.tar.gz (37.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page