Example: Creating an HCP tenant

Content Platform Tenant Management Help

Version
9.7.x
File Size
4269 KB
Audience
anonymous
Part Number
MK-95HCPH002-19

Here’s a sample PUT request that creates a tenant named Finance in the HCP system named hcp.example.com. The tenant definition is in an XML file named FinanceTenant.xml. The initial user account for the tenant has a username of lgreen and a password of start123. These are specified by query parameters. The request is made using a system-level user account that includes the administrator role.

This example assumes the existence of a service plan named Short-Term-Activity.

Request body in XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tenant>
    <name>Finance</name>
    <systemVisibleDescription>Created for the Finance department at Example
        Company by P.D. Grey on 2/9/2017.</systemVisibleDescription>
    <hardQuota>100 GB</hardQuota>
    <softQuota>90</softQuota>
    <namespaceQuota>5</namespaceQuota>
    <authenticationTypes>
        <authenticationType>LOCAL</authenticationType>
        <authenticationType>EXTERNAL</authenticationType>
    </authenticationTypes>
    <complianceConfigurationEnabled>true</complianceConfigurationEnabled>
    <versioningConfigurationEnabled>true</versioningConfigurationEnabled>
    <searchConfigurationEnabled>true</searchConfigurationEnabled>
    <replicationConfigurationEnabled>true</replicationConfigurationEnabled>
    <erasureCodingSelectionEnabled>true</erasureCodingSelectionEnabled>
    <tags>
        <tag>Example Company</tag>
        <tag>pdgrey</tag>
    </tags>
    <servicePlanSelectionEnabled>false</servicePlanSelectionEnabled>
    <servicePlan>Short-Term-Activity</servicePlan>
    <dataNetwork>net127</dataNetwork>
    <managementNetwork>net004</managementNetwork>
</tenant>

Request with cURL command line

curl -k -iT FinanceTenant.xml -H "Content-Type: application/xml"
    -H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"
    "https://admin.hcp.example.com:9090/mapi/tenants?username=lgreen
        &password=start123&forcePasswordChange=false"

Request in Python using PycURL

import pycurl
import os
filehandle = open("FinanceTenant.xml", 'rb')
curl = pycurl.Curl()
curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml",
  "Authorization: HCP \
  YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL,
  "https://admin.hcp.example.com:9090/mapi/tenants?" +
  "username=lgreen&password=start123&forcePasswordChange=false")
curl.setopt(pycurl.SSL_VERIFYPEER, 0)
curl.setopt(pycurl.SSL_VERIFYHOST, 0)
curl.setopt(pycurl.UPLOAD, 1)
curl.setopt(pycurl.INFILESIZE, os.path.getsize("FinanceTenant.xml"))
curl.setopt(pycurl.READFUNCTION, filehandle.read)
curl.perform()
print curl.getinfo(pycurl.RESPONSE_CODE)
curl.close()
filehandle.close()

Request headers

PUT /mapi/tenants?username=lgreen&password=start123
    &forcePasswordChange=false HTTP/1.1
Host: admin.hcp.example.com:9090
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Content-Type: application/xml
Content-Length: 1016

Response headers

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