이 콘텐츠는 선택한 언어로 제공되지 않습니다.

A.4. Examples


A.4.1. GET Request with cURL

Example A.1. GET request

The following GET request lists the virtual machines in the vms collection. Note that a GET request does not contain a body.
GET /ovirt-engine/api/vms HTTP/1.1
Accept: application/xml
Adapt the method (GET), header (Accept: application/xml) and URI (https://[RHEVM-Host]:443/ovirt-engine/api/vms) into the following cURL command:
$ curl -X GET -H "Accept: application/xml" -u [USER:PASS] --cacert [CERT] https://[RHEVM-Host]:443/ovirt-engine/api/vms
An XML representation of the vms collection displays.

A.4.2. POST Request with cURL

Example A.2. POST request

The following POST request creates a virtual machine in the vms collection. Note that a POST request requires a body.
POST /ovirt-engine/api/vms HTTP/1.1
Accept: application/xml
Content-type: application/xml

<vm>
  <name>vm1</name>
  <cluster>
    <name>default</name>
  </cluster>
  <template>
    <name>Blank</name>
  </template>
  <memory>536870912</memory> 
  <os>
    <boot dev="hd"/>
  </os>
</vm>
Adapt the method (POST), headers (Accept: application/xml and Content-type: application/xml), URI (https://[RHEVM-Host]:443/ovirt-engine/api/vms) and request body into the following cURL command:
$ curl -X POST -H "Accept: application/xml" -H "Content-type: application/xml" -u [USER:PASS] --cacert [CERT] -d "<vm><name>vm1</name><cluster><name>default</name></cluster><template><name>Blank</name></template><memory>536870912</memory><os><boot dev='hd'/></os></vm>" https://[RHEVM-Host]:443/ovirt-engine/api/vms
The REST API creates a new virtual machine and displays an XML representation of the resource.

A.4.3. PUT Request with cURL

Example A.3. PUT request

The following PUT request updates the memory of a virtual machine resource. Note that a PUT request requires a body.
PUT /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<vm>
    <memory>1073741824</memory>
</vm>
Adapt the method (PUT), headers (Accept: application/xml and Content-type: application/xml), URI (https://[RHEVM-Host]:443/ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399) and request body into the following cURL command:
$ curl -X PUT -H "Accept: application/xml" -H "Content-type: application/xml" -u [USER:PASS] --cacert [CERT] -d "<vm><memory>1073741824</memory></vm>" https://[RHEVM-Host]:443//ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c039
The REST API updates the virtual machine with a new memory configuration.

A.4.4. DELETE Request with cURL

Example A.4. DELETE request

The following DELETE request removes a virtual machine resource.
DELETE /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Adapt the method (DELETE) and URI (https://[RHEVM-Host]:443/ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399) into the following cURL command:
$ curl -X DELETE -u [USER:PASS] --cacert [CERT] https://[RHEVM-Host]:443//ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c039
The REST API removes the virtual machine. Note the Accept: application/xml request header is optional due to the empty result of DELETE requests.

A.4.5. DELETE Request Including Body with cURL

Example A.5. DELETE request with body

The following DELETE request force removes a virtual machine resource as indicated with the optional body.
DELETE /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<action>
  <force>true</force>
</action>
Adapt the method (DELETE), headers (Accept: application/xml and Content-type: application/xml), URI (https://[RHEVM-Host]:443/ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399) and request body into the following cURL command:
$ curl -X DELETE -H "Accept: application/xml" -H "Content-type: application/xml" -u [USER:PASS] --cacert [CERT] -d "<action><force>true</force></action>" https://[RHEVM-Host]:443//ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c039
The REST API force removes the virtual machine.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.