Example: Creating an HCP namespace

Here’s a sample PUT request that creates an HCP namespace named Accounts-Receivable for the Finance tenant. The namespace definition is in an XML file named AccountsRecNS.xml. The request is made using a tenant-level user account that includes the administrator role.

Request body in XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<namespace>
    <name>Accounts-Receivable</name>
    <description>Created for the Finance department at Example Company by Lee
         Green on 2/9/2012.</description>
    <hashScheme>SHA-256</hashScheme>
    <enterpriseMode>true</enterpriseMode>
    <hardQuota>50 GB</hardQuota>
    <softQuota>75</softQuota>
    <optimizedFor>ALL</optimizedFor>
    <versioningSettings>
         <enabled>true</enabled>
         <prune>true</prune>
         <pruneDays>10</pruneDays>
    </versioningSettings>
    <searchEnabled>true</searchEnabled>
    <indexingEnabled>true</indexingEnabled>
    <customMetadataIndexingEnabled>true</customMetadataIndexingEnabled>
    <replicationEnabled>true</replicationEnabled>    <readFromReplica>true</readFromReplica>
    <serviceRemoteSystemRequests>true</serviceRemoteSystemRequests>
    <tags>
         <tag>Billing</tag>
         <tag>lgreen</tag>
    </tags>
</namespace>

Request with cURL command line

curl -k -iT AccountsRecNS.xml -H "Content-Type: application/xml"
    -H "Authorization: HCP bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6"
    "https://finance.hcp.example.com:9090/mapi/tenants/finance/namespaces"

Request in Python using PycURL

import pycurl
import os
filehandle = open("AccountsRecNS.xml", 'rb')
curl = pycurl.Curl()
curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml",
  "Authorization: HCP \
  bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6"])
curl.setopt(pycurl.URL,
  "https://finance.hcp.example.com:9090/mapi/tenants/finance/" +
"namespaces")
curl.setopt(pycurl.SSL_VERIFYPEER, 0)
curl.setopt(pycurl.SSL_VERIFYHOST, 0)
curl.setopt(pycurl.UPLOAD, 1)
curl.setopt(pycurl.INFILESIZE, os.path.getsize("AccountsRecNS.xml"))
curl.setopt(pycurl.READFUNCTION, filehandle.read)
curl.perform()
print curl.getinfo(pycurl.RESPONSE_CODE)
curl.close()
filehandle.close()

 

Request headers

PUT /mapi/tenants/finance/namespaces HTTP/1.1
Host: finance.hcp.example.com:9090
Authorization: HCP bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6
Content-Type: application/xml
Content-Length: 835

Response headers

HTTP/1.1 200 OK
X-HCP-SoftwareVersion: 7.0.0.16
Content-Length: 0

Trademarks and Legal Disclaimer

© 2016 Hitachi Data Systems Corporation. All rights reserved.