此内容没有您所选择的语言版本。

Chapter 3. REST API Quick Start Examples


This chapter provides an example to demonstrate the REST API's ability to setup a basic trusted storage pool within the Red Hat Storage environment.
This example uses cURL to demonstrate REST requests with a client application. Find out more about cURL use with the REST API in Appendix B, API Usage with cURL. Note that any application capable of HTTP requests can substitute for cURL.

Important

For simplicity, the HTTP request headers in this example omit the Host: and Authorization: fields. However, these fields are mandatory and require data specific to your installation of Red Hat Storage Console.

Important

All cURL examples include placeholders for authentication details (USER:PASS) and certificate location (CERT). Ensure all requests performed with cURL fulfil certification and authentication requirements. See Chapter 2, Authentication and Security and Appendix B, API Usage with cURL for more information.

Note

Red Hat Storage Console generates a globally unique identifier (GUID) for the id attribute for each resource. Identifier codes in this example might appear different to the identifier codes in your Red Hat Storage Console environment.
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug

3.1. Example: Access API Entry Point

The following request retrieves a representation of the main entry point of the API.

Example 3.1. Access the API entry point

GET /api HTTP/1.1
Accept: application/xml
Copy to Clipboard Toggle word wrap
cURL command:
curl -X GET -H "Accept: application/xml" -u [USER:PASS] --cacert [CERT] https://[RHSC Host]/api
The API returns the following representation:
HTTP/1.1 200 OK
Content-Type: application/xml

<api>
    <link href="/api/capabilities" rel="capabilities"/>
    <link href="/api/clusters" rel="clusters"/>
    <link href="/api/clusters?search={query}" rel="clusters/search"/>
    <link href="/api/events" rel="events"/>
    <link href="/api/events;from={event_id}?search={query}" rel="events/search"/>
    <link href="/api/hosts" rel="hosts"/>
    <link href="/api/hosts?search={query}" rel="hosts/search"/>
    <link href="/api/networks" rel="networks"/>
    <link href="/api/networks?search={query}" rel="networks/search"/>
    <link href="/api/roles" rel="roles"/>
    <link href="/api/tags" rel="tags"/>
    <link href="/api/users" rel="users"/>
    <link href="/api/users?search={query}" rel="users/search"/>
    <link href="/api/groups" rel="groups"/>
    <link href="/api/groups?search={query}" rel="groups/search"/>
    <link href="/api/domains" rel="domains"/>
    <special_objects>
        <link href="/api/tags/00000000-0000-0000-0000-000000000000" rel="tags/root"/>
    </special_objects>
    <product_info>
        <name>Red Hat Storage Console</name>
        <vendor>Red Hat</vendor>
        <version major="3" minor="0" build="0" revision="0"/>
        <full_version>3.0.0-0.10.el6_5</full_version>
    </product_info>
    <summary>
        <hosts>
            <total>0</total>
            <active>0</active>
        </hosts>
        <users>
            <total>1</total>
            <active>1</active>
        </users>
    </summary>
    <time>2014-06-23T06:47:18.567+05:30</time>
</api>
      <total>1</total>
      <active>1</active>
    </users>
  </summary>
</api>
Copy to Clipboard Toggle word wrap
The entry point provides a user with links to the collections in a storage environment. The rel= attribute of each collection link provides a reference point for each link. The next step in this example examines the cluster collection, which is available through the rel="cluster" link.
The entry point also contains other data such as product_info and summary. This data is covered in chapters outside this example.
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat