API Use Case: User Activation/Tenant Creation

Overview

Tenant owners can create users within their respective tenants. Each user must be activated before using CloudCenter. You can create and activate a new user using one API or using multiple APIs.

User Configuration Process

The following table identifies the configuration options for this use case using CloudCenter APIs:

API OptionsDescription
Create User without ActivationCreate a user account without activation.
Perform User Actions
(Example 12)
Activate user with pre-built activation profile.
Perform User Actions
(Example 1)
Provide activation details.
Create User with ActivationThis step combines the actions described in the previous 3 rows by issuing just 1 API call.

Sample Configuration Using APIs

This section provides details on the various methods you can use to configure users and tenants using CloudCenter APIs.

Create User without Activation

This example creates a new user without activating the user. 

Request

curl -k -H "Accept:application/json" -H "Content-Type:application/json" 
-u cloudcenteradmin:FAFD1FB17817C4A1 -X POST -d @/tmp/createcloud.json 
"https://m/v1/tenants/1/clouds/"

Request Body

{
    "firstName": "demo",
    "lastName": "user",
    "password": "===redacted===",
    "emailAddr": "demo@company.com",
    "companyName": "demo",
    "phoneNumber": "111-111-1111",
    "externalId": "",
    "tenantId": 1
}

Response

{
    "id": "3",
    "resource": "https://m/v1/users/3",
    "perms": [],
    "username": "demo_3",
    "password": "== red-acted ==",
    "enabled": false,
    "type": "STANDARD",
    "firstName": "demo",
    "lastName": "user",
    "companyName": "demo",
    "tenantId": "1",
    "emailAddr": "demo@demo.com",
    "emailVerified": false,
    "phoneNumber": "111-111-1111",
    "externalId": "",
    "accessKeys": "https://m/v1/users/3/keys",
    "disableReason": null,
    "accountSource": "AdminCreated",
    "status": "NEW",
    "detail": null,
    "activationData": null,
    "created": 1439267074063,
    "lastUpdated": 1439267074040,
    "coAdmin": false
}

Activate User Account

This example activates a user (if the user is already created).

Request

curl -k -H "Accept:application/json"-H "Content-Type:application/json"
-u cloudcenteradmin:FAFD1FB17817C4A1 -X POST -d @/tmp/activateuser.json 
"https://m/v1/users/3"

Request Body

{
    "action": "ACTIVATE",
    "userActivationData": {
        "planId": "1",
        "contractId": "1",
        "activateRegions": [
            {
                "regionId": "1"
            }
        ],
        "agreeToContract": true,
        "sendActivationEmail": false,
        "defaultStorageSize": 0,
        "importApps": []
    }
}

The regionId attribute in the request body corresponds to the Cloud Regions setup for clouds available to the tenant. A price plan and a contract are also required to activate users.  

Response

{
    "operationId": "31170db8-9d24-425a-9ef5-99136f0a701d",
    "status": "RUNNING",
    "msg": "",
    "progress": 0,
    "timestamp": 1439267687135,
    "additionalParameters": null,
    "operationHistory": [],
    "subtaskResults": null,
    "resourceUrl": null
}

The API response contains a reference to a status-tracking object, which can be queried to check the status of the activation operation as follows:

curl -k -H "Accept:application/json" -H "Content-Type:application/json"
-u cloudcenteradmin:FAFD1FB17817C4A1 
"https://m/v1/operationStatus/31170db8-9d24-425a-9ef5-99136f0a701d"
{
    "status": "SUCCESS",
    "msg": "Finished",
    "resource": "https://m",
    "additionalParameters": []
}

Create and Activate User Using One API

This example creates and activates a new user (at the same time)

Request

curl -k -H "Accept:application/json" -H "Content-Type:application/json"
-u cloudcenteradmin:FAFD1FB17817C4A1 -X POST -d @/tmp/createandactivate.json 
"https://m/v1/users"

Request Body

{
    "firstName": "demo2",
    "lastName": "user",
    "password": "===redacted===",
    "emailAddr": "demo2@demo.com",
    "companyName": "demo",
    "phoneNumber": "111-111-1111",
    "externalId": "",
    "tenantId": 1,
    "activationData": {
        "planId": "1",
        "contractId": "1",
        "activateRegions": [
            {
                "regionId": "1"
            }
        ],
        "agreeToContract": true,
        "sendActivationEmail": false,
        "defaultStorageSize": 0,
        "importApps": []
    }
}

Response

{
    "operationId": "ae26c44b-ae6a-4a9d-9c6d-01dada8d7e0e",
    "status": "RUNNING",
    "msg": "",
    "progress": 0,
    "timestamp": 1439271258201,
    "additionalParameters": null,
    "operationHistory": [
        "",
        ""
    ],
    "subtaskResults": {
        "activateUserAccount": null
    },
    "resourceUrl": null
}

Create Sub-Tenant

When you create a new sub-tenant, you are essentially promoting a user to be a tenant admin. As part of this promotion, a sub-tenant is created under the existing tenant. The user being promoted to a tenant owner is moved out of the existing tenant and moved into the newly-created tenant as the admin.

Upload the logo image before creating a service. If you do not upload a logo and provide the existing logo path, then the logo image from the currently-provided path is deleted and this logo image is moved to another location.

 

Request

curl -k -X POST -H "Accept:application/json" -H "Content-Type:application/json"
-u cloudcenteradmin:FAFD1FB17817C4A1 -d @createtenant.json "https://m/v1/tenants/"

Request Body

{
    "name": "Sales Department",
    "shortName": "sales",
    "phone": "",
    "externalId": "",
    "url": "http://sales.mycompany.com",
    "contactEmail": "admin@sales.myconpany.com",
    "enablePurchaseOrder": true,
    "enableEmailNotificationsToUsers": true,
    "loginLogo": "/assets/img/temp/0cc7c98d-9ca0-42e0-9a9d-79e5a330e1dc-wordpress.png",
    "homePageLogo": "/assets/img/temp/c4a64f1d-cf4e-4970-ada3-25273a03320f-wordpress.png",
    "userId": "3",
    "about": "Sales Department",
    "termsOfService": "None",
    "privacyPolicy": "None"
}

The userId attribute in the request is the ID of the user in the current tenant that is promoted to the new sub-tenant.

Response

{
    "id": "2",
    "resource": "https://m/v1/tenants/2",
    "perms": [],
    "name": "Sales Department",
    "url": "http://sales.mycompany.com",
    "about": "Sales Department",
    "contactEmail": "admin@sales.myconpany.com",
    "phone": "",
    "userId": "3",
    "termsOfService": "None",
    "privacyPolicy": "None",
    "revShareRate": 0,
    "ccTransactionFeeRate": 0,
    "minAppFeeRate": 0,
    "enableConsolidatedBilling": false,
    "shortName": "sales",
    "enablePurchaseOrder": true,
    "enableEmailNotificationsToUsers": true,
    "parentTenantId": 1,
    "externalId": "",
    "defaultActivationProfileId": null,
    "enableMonthlyBilling": false,
    "defaultChargeType": null,
    "loginLogo": "/assets/vendors/2/img/logo.png",
    "homePageLogo": "/assets/vendors/2/img/logo-loggedin.png",
    "domainName": null,
    "activationCodes": [],
    "firewallProfiles": [],
    "preferences": [],
    "user": {
        "id": "3",
        "resource": null,
        "perms": [],
        "username": "demo_3",
        "password": "== red-acted ==",
        "enabled": true,
        "type": "TENANT",
        "firstName": "demo",
        "lastName": "user",
        "companyName": "demo",
        "tenantId": "2",
        "emailAddr": "demouser@demo.com",
        "emailVerified": true,
        "phoneNumber": "111-111-1111",
        "externalId": "",
        "accessKeys": "https://m/v1/users/3/keys",
        "disableReason": null,
        "accountSource": "AdminCreated",
        "status": "ENABLED",
        "detail": null
    }
}