开发者社区> 问答> 正文

Using AliCloud API to interact with your OSS

[Reprint from ken's post]



1.       AliCloud API overview
AliCloud API is a powerful abstraction of interacting the entire cloud infrastructure in a programmable fashion. 90% of the tasks that we can perform through the web console can also be achieved through API calls. This allows system administrators and developers to raise their productivity and embed automation in their day-to-day operation activities.
In order to connect to AliCloud API endpoints, we first need to obtain a pair of Access Key Secret, which is described next below.


2.   Access Key Pair Generation
a. Login to the Web Console GUI:
- Click on the Console link on the top panel from the main website (www.alicloud.com)

- Login with your account username and password:



b. Once you are in the Web Console GUI, click on the ‘AccessKeys’ from the top panel


c. On the newly launched page, click “Create AccessKey” on the top right corner


d. Follow the prompted steps, including a step where you may have to click a link in the pop-out window to send a SMS to your registered mobile number with the confirmation 6-digit code.


e. After creation, we should see the key pair as below, with the Access Key Secret hidden


f. Click “Show” to obtain the key secret



g. Make a copy of the Access Key ID and Access Key Secret. We will need them in the next steps of setting up the environment. Please don’t share with anyone else as this would allow API calls across your cloud infrastructure (as we will see later).


3.   Python SDK
AliCloud has integrated with various popular SDK: Java, Python, PHP, while many are being actively developed.
For this tutorial, we will use the Python SDK, and we are going to install the SDK for AliCloud OSS
  
a. Prerequisite: Python 2.7+
b. Install ‘pip’ for managing Python package dependencies management.
c. Use ‘pip’ to install the following AliCloud core packages:
>> pip install aliyun-python-sdk-core
>> pip install aliyun-python-sdk-oss


Please note that the above environment can be configured on ANY machines , it doesn’t have to be on any ECS instance running on the AliCloud.
  
4.   Aliyuncli
Aliyuncli is built on top of the above core Python AliCloud packages, which provides a simple command line interface to interact with AliCloud infrastructure resources. Instead of writing your own programs from scratch, aliyuncli delivers a ready-to-use toolkit that wraps around most of the essential functions.


a. Use pip to install package ‘aliyuncli’
>> pip install aliyuncli
b. Configure ‘aliyuncli’ with the pair of Access Key obtained above by running the command, to setup the authentication parameters
>> aliyuncli oss Config --host oss.aliyuncs.com --accessid ***********Em --accesskey ***********0Dr



展开
收起
winson.zhang 2016-03-02 11:49:41 7224 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
OSS运维进阶实战手册 立即下载
《OSS运维基础实战手册》 立即下载
OSS运维基础实战手册 立即下载