Openstack Object Storage developer Guide/official swift API documentation-translation (1)

Source: Internet
Author: User
Tags how to use curl representational state transfer

AboutSource codeOnly the XMPP server is used to implement openfire and swift. Think about the stagnation of swift learning during this period, and feel that "if you want to learn the principle of something, you must first use it ", this will increase the understanding of the function processing process to a certain extent and resonate with the source code reading.

For Swift API learning, because you have not found any reference system, there is no link on the official document homepage, therefore, the curl commands of swift-Python-client are all compared. These days, we suddenly found that the SWIFT's API docs link has been added to the official swift document homepage! The content is very comprehensive. I have never seen it before. It may be too deep. Please click here to download the PDF.

In document change history in section 1.2, you can see that this document is a branch of rackspace cloud files developer guide. I read it all over and found that many details were previously unknown, such as multipart return information and uploading of large files larger than 5 Gb. In order to prepare for subsequent API development in the lab, so I decided to try to translate it and share it as a group.

The content of this document is divided into four parts:

 
1. overview2. General API information3. API operations for storage services4. troubleshooting and Examples

Part 1 briefly introduces swift, specifying the target readers of this document, providing document change records, and other resource links; part 1 mainly describes how to use curl to interact with SWIFT to bypassCodeLayer interaction, and return the request/corresponding details. In fact, after reading the first three parts, you can simply tap the curl command on the command line. I am still very lazy,So Part 3 and part 3 are not going to translate = d

Now, let's have a pleasant start!

========================================================== ============================================

2. Basic API Information

2.1. Authentication
2.2 API Operation overview

API operation reference summary

Accounts Storage
Verb Uri Description
Get /Account Obtains the containers list under the current account.
Head Account Get account metadata

 

 

 

 

Container storage
Verb Uri Description
Get /Account/Container Obtains the list of objects in the current iner.
Put /Account/Container Create a container
Delete /Account/Container Delete container
Head /Account/Container Obtain container metadata

 

 

 

 

Object Storage
Verb Uri Description
Get /Account/container/Object Get object
Put /Account/container/Object Create/update an object
Put /Account/container/Object Multipart Transfer Encoding
Delete /Account/container/Object Delete an object (an error occurred in the original document)
Head /Account/container/Object Get object metadata
Post /Account/container/Object Update object metadata

 

 

 

 

 

2.1. Authentication) 

Client Authentication is provided by the get method of the rest interface and is usedV1.0As the path. In addition, there are two headers that must provide:X-auth-userAndX-auth-KeyAnd their values are the user name and API access key respectively.

Each rest request accessing the openstack Object Storage System must contain a specific header in the HTTP header:X-auth-tokenThe value of this header is the user's access authentication token. The client needs to maintain the token and the api uri of the corresponding cloud server, these two values are returned when the client first uses the user name and API to access the key for authentication service.

Request

To perform authentication, you must provide your username and API access key, and use these two values to set the X-headers of the HTTP request header:

    • Use your openstack Object Storage Service (swfit) user name as the user name for API access.Store the user name in the Request HeaderX-auth-user.
    • Obtain your API access key from the authentication service you selected during installation. You can have several options for authentication, including tempauth (self-contained in SWIFT) and swauth (this is a method that uses Swift's authentication service as wsgi middleware, it uses swift as the backend storage, and swauth can be downloaded through GitHub), openstack Authentication Service (keystone), or you can use your own authentication system.Store the API access key in the Request HeaderX-auth-Key.

Example 2.1. authentication request

 
GET/V1.0 HTTP/1.1 HOST: Auth. API. yourcloud. comx-auth-user: jdoex-auth-key: a86850deb2742ec3cb1_18e26aa2d89

Response

When the authentication succeeds, a status code is 204 (NO content) and contains header information.X-storage-URLAndX-auth-tokenWill be returned. Any response whose status code is 2XX is a good response. For example, a 202 response means that the request has been accepted. Of course, an extra X-headers may also be returned. These additional header information can also be ignored when it is related to other rackspace services. When authentication fails, a 401 (unauthorized) response is returned.All openstack Object Storage operations with sub-paths container/object should useX-storage-URLAnd must containX-auth-tokenHeader.

Case 2.2. authentication response

 
HTTP/1.1 204 no contentdate: Mon, 12 Nov 2010 15:32:21 gmtserver: apachex-storage-URL: Plain eaaafd18-0fed-4b3a-81b4-663c99ec1cbbContent-Length: 0content-type: text/plain; charset = UTF-8

X-storage-URLIt must be parsed and used as a base URI in subsequent connections and all Object Storage requests. In Example 2.2, when you connect to openstack Object Storage for iner/Object Requests, storage.swiftdrive.com is used as the host header and/V1/cf_xer7_34 is used as the request version and account in most cases. Note that,In many authentication configurations, the token validity period is only 24 hours..

2.2 API Operation overview 

Openstack APIs are implemented as a set of restful (representational state transfer) Web services. All authentication and container/object operations can be implemented through standard HTTP calls. You can view Wikipedia for more rest information.

The following are some restrictions on HTTP requests of rest APIs:

    • Each request has a maximum of 90 HTTP headers;
    • The maximum length of all HTTP headers is 4096 bytes;
    • The maximum length of each HTTP request line is 8192 bytes;
    • The maximum length of each HTTP request is 5 GB;
    • The maximum length of a container name is 256 bytes;
    • The maximum Object Name Length is 1024 bytes.

The name of the container and object must be properly URL encoded before interacting with the rest interface, and the name of the container and object must also be UTF-8 encoded. Check the length constraints on the string after URL encoding.

Each rest request for the openstack Object Storage System must contain an HTTP header specified for the authentication token --X-auth-token. The client obtains the token for the first authentication using the user name and API access key, and also obtains the URLs of openstack object storage.

UseX-storage-URLRecognized rest service terms manage data stored in the system. For example, create a iner and upload an object.

In the next section, we will introduce the relationship between each HTTP method call and the service. For exampleX-storage-URLThe put request may be used to create a iner or upload an object.

APIS for a specific languageProgramStaff and system implementation details are separated. Programmers can create a iner, mark it as public, and assign it to the appropriate backend service by handling calls.

Note:

 
All authentication requests and operations on the openstack Object Storage Service are performed over SSL over HTTP (https) and use TCP port 443.

 

Ah, I can't stand it anymore. t ^ t

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.