GithubHelp home page GithubHelp logo

cao527121128 / qingcloud-sdk-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yunify/qingcloud-sdk-python

0.0 1.0 0.0 873 KB

QingCloud SDK for Python

License: Apache License 2.0

Python 100.00%

qingcloud-sdk-python's Introduction

QingCloud Python SDK

This repository allows you to access QingCloud and control your resources from your applications.

This SDK is licensed under Apache Licence, Version 2.0.

Note

Requires Python 2.6 or higher, compatible with Python 3, for more information please see QingCloud SDK Documentation

Installation

Install via pip

$ pip install qingcloud-sdk

Upgrade to the latest version

$ pip install --upgrade qingcloud-sdk

Install from source

git clone https://github.com/yunify/qingcloud-sdk-python.git
cd qingcloud-sdk-python
python setup.py install

Getting Started

In order to operate QingCloud IaaS or QingStor (QingCloud Object Storage), you need apply access key on qingcloud console first.

QingCloud IaaS API

Pass access key id and secret key into method connect_to_zone to create connection

>>> import qingcloud.iaas
>>> conn = qingcloud.iaas.connect_to_zone(
        'zone id',
        'access key id',
        'secret access key'
    )

The variable conn is the instance of qingcloud.iaas.connection.APIConnection, we can use it to call resource related methods.

Example:

# launch instances
>>> ret = conn.run_instances(
        image_id='img-xxxxxxxx',
        cpu=1,
        memory=1024,
        vxnets=['vxnet-0'],
        login_mode='passwd',
        login_passwd='Passw0rd@()'
    )

# stop instances
>>> ret = conn.stop_instances(
        instances=['i-xxxxxxxx'],
        force=True
      )

# describe instances
>>> ret = conn.describe_instances(
        status=['running', 'stopped']
      )

QingCloud QingStor API

Pass access key id and secret key into method connect to create connection

>>> import qingcloud.qingstor
>>> conn = qingcloud.qingstor.connect(
        'pek3a.qingstor.com',
        'access key id',
        'secret access key'
    )

The variable conn is the instance of qingcloud.qingstor.connection.QSConnection, we can use it to create Bucket which is used for generating Key and MultiPartUpload.

Example:

# Create a bucket
>>> bucket = conn.create_bucket('mybucket')

# Create a key
>>> key = bucket.new_key('myobject')
>>> with open('/tmp/myfile') as f:
>>>     key.send_file(f)

# Delete the key
>>> bucket.delete_key('myobject')

qingcloud-sdk-python's People

Contributors

9nix00 avatar bingwen avatar chenhaiq avatar cygnus-yunify avatar ethan-black avatar fondazhu avatar markduan avatar nashuiliang avatar pengsrc avatar simonluo avatar sunight avatar wangyuwill avatar wangzw avatar xuanwo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.