Example: Retrieving a list of eligible tenants
Here's a sample GET request that retrieves a list of all the local and remote tenants that are eligible to be included in the erasure coding topology named ex-corp-4. The request writes the list of tenants to a file named eligible-tenants.xml. The request is made using a system-level user account that includes the administrator role.
Request with cURL command line
curl -k -H "Accept: application/xml" -H "Authorization: HCP bGdyZWVu:35dc4c4aa08fe0deab7e292e00eb8e97" "https://admin.hcp-us.example.com:9090/mapi/services/erasureCoding/ ecTopologies/ex-corp-4/tenantCandidates?verbose=true&prettyprint" > eligible-tenants.xml
Request in Python using PycURL
import pycurl filehandle = open("eligible-tenants.xml", 'wb') curl = pycurl.Curl() curl.setopt(pycurl.HTTPHEADER, ["Accept: application/xml", "Authorization: HCP bGdyZWVu:35dc4c4aa08fe0deab7e292e00eb8e97"]) curl.setopt(pycurl.URL, "https://admin.hcp-us.example.com:9090/mapi/services/" + "erasureCoding/ecTopologies/ex-corp-4/tenantCandidates" + "?verbose=true&prettyprint") curl.setopt(pycurl.SSL_VERIFYPEER, 0) curl.setopt(pycurl.SSL_VERIFYHOST, 0) curl.setopt(pycurl.WRITEFUNCTION, filehandle.write) curl.perform() print curl.getinfo(pycurl.RESPONSE_CODE) curl.close() filehandle.close()
Request headers
GET /mapi/services/erasureCoding/ecTopologies/ex-corp-4/tenantCandidates ?verbose=true&prettyprint HTTP/1.1 Host: admin.hcp-us.example.com:9090 Authorization: HCP bGdyZWVu:35dc4c4aa08fe0deab7e292e00eb8e97 Accept: application/xml
Response headers
HTTP/1.1 200 OK Content-Type: application/xml X-HCP-SoftwareVersion: 9.0.0.2 Content-Length: 976
Response body in XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <tenantCandidates> <tenantCandidate> <hcpSystems> <name>hcp-us.example.com</name> </hcpSystems> <name>exec</name> <uuid>26112ed2-bb90-4e34-b450-4bf365a927d9</uuid> </tenantCandidate> <tenantCandidate> <hcpSystems> <name>hcp-us.example.com</name> </hcpSystems> <name>finance</name> <uuid>838cd575-0f94-489a-8f94-f36c1337c446</uuid> </tenantCandidate> <tenantCandidate> <hcpSystems> <name>hcp-eu.example.com</name> </hcpSystems> <name>research-dev</name> <uuid>38e7bc78-c700-4627-af63-a3c19eb77406</uuid> </tenantCandidate> <tenantCandidate> <hcpSystems> <name>hcp-us.example.com</name> </hcpSystems> <name>sales-mktg</name> <uuid>f349387f-18d0-49e2-9bcd-a8ac6f7952c5</uuid> </tenantCandidate> </tenantCandidates>