JavaScript is required to for searching.
탐색 링크 건너뛰기
인쇄 보기 종료
Oracle® ZFS Storage Appliance RESTful API 설명서, 릴리스 2013.1.3.0
Oracle Technology Network
라이브러리
PDF
인쇄 보기
피드백
search filter icon
search icon

문서 정보

Oracle ZFS Storage Appliance RESTful API 시작하기

RESTful API 작업

RESTful API 경보 서비스

Analytics Services

하드웨어 서비스

로그 명령

네트워크 명령

RESTful API 문제 서비스

RESTful API 역할 서비스

RESTful API SAN 서비스

서비스 명령

RESTful API 스토리지 서비스

시스템 명령

RESTful API 사용자 서비스

워크플로우 명령

RESTful 클라이언트

Curl Rest 클라이언트

리소스 데이터 가져오기

새 리소스 만들기

기존 리소스 수정

기존 리소스 삭제

Python RESTful 클라이언트

리소스 가져오기

리소스 만들기

리소스 수정

기존 리소스 삭제

Curl Rest 클라이언트

두 가지 일반적인 CLI 기반 HTTP 클라이언트는 wget 및 curl입니다. 이 절에는 curl을 사용하여 RESTful API 호출을 수행하는 방법에 대한 여러 가지 예가 나와 있습니다. wget을 사용하면 유사한 기능을 수행할 수 있습니다.

리소스 데이터 가져오기

이 예에서는 간단한 HTTP GET 요청을 사용하여 일부 JSON 데이터를 얻는 방법을 보여 줍니다.

> curl --user ${USER}:${PASSWORD} -k -i https://zfssa.example.com:215/api/nas/v1/pools/gold

 HTTP/1.1 200 OK
 Date: Tue, 23 Jul 2013 12:57:02 GMT
 Server: WSGIServer/0.1 Python/2.6.4
 Content-Length: 284
 Content-Type: application/json
 X-Zfs-Sa-Nas-Api: 1.0

{
   "pool": {
      "profile": "mirror",
      "name": "gold",
      "usage": {
         "available": 895468984832.0,
         "total": 895500681216.0,
         "dedupratio": 100,
         "used": 31696384.0
      },
      "peer": "00000000-0000-0000-0000-000000000000",
      "state": "online",
      "owner": "tanana",
      "asn": "314d252e-c42b-e844-dab1-a3bca680b563"
    }
 }

새 리소스 만들기

이 예에서는 요청의 JSON 데이터를 전송하여 새 리소스를 만드는 방법을 보여 줍니다.

$ curl --user ${USER}:${PASSWORD} -s -k -i -X POST -d @-  \
  -H "Content-Type: application/json" \
  https://zfssa-host.example.com:215/api/user/v1/users <<JSON
> {"logname": "rest_user",
>  "fullname": "REST User",
>  "initial_password": "letmein"}
> JSON

HTTP/1.1 201 Created
Date: Tue, 23 Jul 2013 13:07:37 GMT
Server: WSGIServer/0.1 Python/2.6.4
X-Zfs-Sa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 357

{
   "user": {
      "logname": "rest_user",
      "fullname": "REST User",
      "initial_password": "DummyPassword",
      "require_annotation": false,
      "kiosk_mode": false,
      "kiosk_screen": "status/dashboard",
      "roles": ["basic"],
      "exceptions": {},
      "preferences": {
         "href": "/api/user/v1/users/larry/preferences",
         "locale": "C",
         "login_screen": "status/dashboard",
         "session_timeout": 15,
         "advanced_analytics": false,
         "keys": {}
      }
   }
} 

기존 리소스 수정

이 예에서는 사용자의 세션 시간 초과를 수정합니다.

% curl --user larry:letmein -3 -s -k -i -X PUT \
  -H "Content-Type: application/json" -d @-  \
  https://tanana:215/api/appliance/v1/users/larry/preferences <<JSON
> {"session_timeout":60}
> JSON
HTTP/1.1 202 Accepted
Date: Wed, 24 Jul 2013 05:43:17 GMT
X-Zfs-Sa-Appliance-Api: 1.0
Content-Type: application/json
Content-Length: 0

{
    "preferences": {
        "href": "appliance/v1/users/larry/preferences",
        "locale": "C",
        "login_screen": "status/dashboard",
        "session_timeout": 60,
        "advanced_analytics": false,
        "keys": {}
    }
}

기존 리소스 삭제

이 명령은 시스템에서 사용자를 제거합니다.

curl --user ${USER}:${PASSWORD} -s -k -i -X DELETE  https://tanana:215/api/appliance/v1/users/jschwartz

HTTP/1.1 204 No Content
Date: Tue, 23 Jul 2013 13:21:11 GMT
Server: WSGIServer/0.1 Python/2.6.4
X-Zfs-Sa-Appliance-Api: 1.0
Content-Length: 0