Using JSDN API's

This article helps you understand how best you can use Jamcracker REST API's to build a new user interface or integrate JSDN with other applications. This article is intended for developers who are familiar with web development, web services, and the Jamcracker Platform.

An application-programming interface (API) specifies how software components should interact with each other. Jamcracker Cloud Management Platform exposes critical API's to be accessed from outside world. Representational state transfer (REST) style of software architecture is used to perform the operations outside of the platform standard user interface.

Obtaining User Token from JSDN

Below sample call explains how we can obtain the user token from JSDN to make the subsequent api calls using the token.
  • Store URL - The domain name of the store. for example store.jamcracker.com
  • User Name - The email address of the user for whom obtaining the token. @ in email address should be replaced with '.'. For example, if the email address is user@jamcracker.com, the user name will be user.jamcracker.com
  • Password - xxxxxx (user password).
  • Tenant ID - The store acronym of the store the user belongs to.
<?php
 
 $curl = curl_init();
 
curl_setopt_array($curl, array(
                CURLOPT_URL =>
          "https://<<jsdnstoreurl>>/api/v2.0/tokens",
                CURLOPT_RETURNTRANSFER =>
        true,
                CURLOPT_TIMEOUT =>
        500,
                CURLOPT_CUSTOMREQUEST =>
        "POST",
                CURLOPT_POSTFIELDS => "
        
                                {"auth":
        {"passwordCredentials": {"username": "abc.gmail.com","password":                                                       
        "userpassword"},"tenantId": "companyacronym"}}",
                CURLOPT_HTTPHEADER =>
        array(
                               
        "Accept: application/json",
                                 "Content-Type: application/json",
                ),
));
 
$result = curl_exec($curl);
$error = curl_error($curl);
 
curl_close($curl);
 
if ($error) {
                echo "cURL Error
        #:" . $error;
} else {
                echo
        $result;
}

Call Jamcracker API using the Token

Below sample call explains how we can call the JSDN API by passing the user token.
  • API URL
  • User Access Token obtained
<?php
$($curl = curl_init();
 
$curlConfig = array(
                CURLOPT_URL =>
        $apiurl,
               
        CURLOPT_RETURNTRANSFER => true,
                CURLOPT_TIMEOUT        => 500,
                CURLOPT_HTTPGET        =>
        1
    );
 
curl_setopt(($curl, CURLOPT_HTTPHEADER, array(
                'X-Auth-Token:
        $accessToken',
                'Content-Type:
        application/json',
                'Accept:
        application/json'
                ));
 
curl_setopt_array(($curl, $curlConfig);
 
$result = curl_exec($curl);
$error = curl_error($curl);
 
curl_close($curl);
 
if ($error) {
                echo "cURL Error
        #:" . $error;
} else {
                echo
        $result;
}

Other Sample API's

URL - BASE_URI/api/2.0/{TENANT-ORG-ACRONYM}/organizations

HTTP Method - POST

Body

{ 
  "Organization": {
        "name":"xxxxxx", 
        "languageCode":"xx_XX", 
        "address":{ 
        "address1":"xxxxxx", 
        "address2":"xxxxxx", 
        "phone":"1234567890", 
        "country":"US", 
        "state":"NY",         
        "city":"New York", 
        "zip":"123456" 
        "billingaddress":{ 
            "address1":"xxxxxx", 
            "address2":"xxxxxx", 
            "phone":"1234567890", 
            "country":"US", 
            "state":"NY", 
            "city":"New York", 
            "zip":"123456" 
        } 
        } 
} 

URL - BASE_URI/api/2.0/{TENANT-ORG-ACRONYM}/organizations/{ORG-ACRONYM}

HTTP Method - DELETE

Manage Users

URL - BASE_URI/api/2.0/{TENANT-ORG-ACRONYM}/users

HTTP Method - POST

Body

{
"user":{ 
            "firstname":"xxxxxx",
            "lastname":"xxxxxx",
            "email":"xxxx@xxxx.xxx",
            "phone":"1234567890",
            "rolename":"xxxxx", 
            "custom-info1":"BRN001", 
            "created-date":"2017-03-31T12:12:12", 
            "is-imported":"true"
        }
}

URL - BASE_URI/api/2.0/{TENANT-ORG-ACRONYM}/users/{email}

HTTP Method - PUT

Body

{ 
    "User":{
        "firstname":"xxxxxx",
        "lastname":"xxxxxx",
        "email":"xxxx@xxxx.xxx", 
        "phone":"1234567890",
        "rolename":"xxxxx"
            } 
} 

URL - BASE_URI/api/2.0/{TENANT-ORG-ACRONYM}/users/{email}

HTTP Method - DELETE

Place Order

BASE_URL/v1/{tenant_id}/stacks

Body
{ 
"networkID": "690ded8c-8979-4bbe-89ec-e15eccb9a949", 
"region": "RegionOne", 
"providerID": "privateOpenstack", 
"description": "Pull", 
"languageCode":"en_US", 
"actorID": 4000505, 
"createdBy":4000505, 
"catalogServerId": 1000006, 
"catalogOfferId": 2000009, 
"stack_name": "PChfAPI01", 
"template":
        "{\"heat_template_version\":\"2013-05-23T00:00:00.000Z\",\"description\":\"Heat
        WordPress template to support F18, using only Heat OpenStack-native resource types, and
        without the requirement for heat-cfntools in the image. WordPress is web software you can
        use to create a beautiful website or blog. This template installs a single-instance
        WordPress deployment using a local MySQL database to store the
        data.\",\"parameters\":{\"key_name\":{\"type\":\"string\",\"description\":\"Name
        of a KeyPair to enable SSH access to the
        instance\",\"default\":\"keypair-dab428fe-6186-4a14-b3de-92131f76cd39\"},\"instance_type\":{\"type\":\"string\",\"description\":\"Instance
        type for WordPress
        server\",\"default\":\"m1.tiny\",\"constraints\":[{\"allowed_values\":[\"m1.tiny\",\"m1.medium\",\"m1.large\"],\"description\":\"instance_type
        must be one of m1.tiny, m1.medium or
        m1.large\"}]},\"image_id\":{\"type\":\"string\",\"description\":\"ID of the image
        to use for the WordPress
        server\",\"default\":\"a7605ce6-45d0-4192-a222-3e653b1eae60\",\"constraints\":[{\"allowed_values\":[\"a7605ce6-45d0-4192-a222-3e653b1eae60\",\"a7605ce6-45d0-4192-a222-3e653b1eae60\"],\"description\":\"Image
        ID must be either F18-i386-cfntools or
        F18-x86_64-cfntools\"}]},\"db_name\":{\"type\":\"string\",\"description\":\"WordPress
        database
        name\",\"default\":\"wordpress\",\"constraints\":[{\"length\":{\"min\":1,\"max\":64},\"description\":\"db_name
        must be between 1 and 64
        characters\"},{\"allowed_pattern\":\"[a-zA-Z][a-zA-Z0-9]*\",\"description\":\"db_name
        must begin with a letter and contain only alphanumeric
        characters\"}]},\"db_username\":{\"type\":\"string\",\"description\":\"The
        WordPress database admin account
        username\",\"default\":\"admin\",\"hidden\":true,\"constraints\":[{\"length\":{\"min\":1,\"max\":16},\"description\":\"db_username
        must be between 1 and 64
        characters\"},{\"allowed_pattern\":\"[a-zA-Z][a-zA-Z0-9]*\",\"description\":\"db_username
        must begin with a letter and contain only alphanumeric
        characters\"}]},\"db_password\":{\"type\":\"string\",\"description\":\"The
        WordPress database admin account
        password\",\"default\":\"admin\",\"hidden\":true,\"constraints\":[{\"length\":{\"min\":1,\"max\":41},\"description\":\"db_username
        must be between 1 and 64
        characters\"},{\"allowed_pattern\":\"[a-zA-Z0-9]*\",\"description\":\"db_password
        must contain only alphanumeric
        characters\"}]},\"db_root_password\":{\"type\":\"string\",\"description\":\"Root
        password for
        MySQL\",\"default\":\"admin\",\"hidden\":true,\"constraints\":[{\"length\":{\"min\":1,\"max\":41},\"description\":\"db_username
        must be between 1 and 64
        characters\"},{\"allowed_pattern\":\"[a-zA-Z0-9]*\",\"description\":\"db_password
        must contain only alphanumeric
        characters\"}]}},\"resources\":{\"wordpress_instance\":{\"type\":\"OS::Nova::Server\",\"properties\":{\"image\":{\"get_param\":\"image_id\"},\"flavor\":{\"get_param\":\"instance_type\"},\"user_data\":{\"str_replace\":{\"template\":\"{\\\"CHEF\\\":
        { \\\"client\\\": \\\"nparimi\\\", \\\"validator\\\":
        \\\"jcchef_test2-validator\\\",
        \\\"endpoint\\\":\\\"https://api.opscode.com/organizations/\\\", \\\"organization\\\":
        \\\"jcchef_test2\\\", \\\"validatorPemFile\\\":
        \\\"/d01/jboss-as-7.1.1.Final/pp_config/UserScript/chef-repo/.chef/jcchef_test2-validator.pem\\\",
        \\\"clientPemFile\\\":
        \\\"/d01/jboss-as-7.1.1.Final/pp_config/UserScript/chef-repo/.chef/nparimi.pem\\\",
        \\\"cookbooks\\\": [ \\\"wordpress\\\" ] } }
        \"}}}}},\"outputs\":{\"WebsiteURL\":{\"description\":\"URL for Wordpress
        wiki\",\"value\":{\"str_replace\":{\"template\":\"\",\"params\":{\"host\":{\"get_attr\":[\"wordpress_instance\",\"first_address\"]}}}}}}}",
        
"timeout_mins": "100" 
} 

URL - BASE_URI/api/v2.0/{tenant-org-acronym}/order

HTTP Method - POST

Body
{
    "order": {
    "sales-reference":"88888", 
    "is-imported":"true",
    "creation-date": "2017-04-04T12:10:30", 
    "payment-method": "PAC",
    "products": [
        { 
        "product-code": "ms365offer", 
        "quantity": "1" 
        } 
        ] 
     } 
} 

Body

{
    "order": {
    "sales-reference": "88888", 
    "is-imported": "true",
    "creation-date": "2017-04-04T12:10:30",
    "payment-method": "PAC",
    "products": [
        { 
        "product-code": "ms365offer", 
        "quantity": "1", 
        "provisioning-attributes": { 
        "organization": [ 
        { 
        "name": "msSubDomain", 
        "value": "jamcracker.com" 
        } 
        ],
    "user": [
      { "name":
        "contactPhone", 
        "value": "12121212" 
        } 
        ]
    }
    } 
    ] 
    } 
}        

IaaS Billing Data

Total IaaS Cost by Provider for a selected period

BASE_URI/api/2.0/{tenant-org-acronym}/datafeed/report/provider-usage?cstype=IAAS&provider=All&startdate=20180801&enddate=20180810

IaaS Cost Trend for a Selected Period

BASE_URI/api/2.0/{tenant-org-acronym}/datafeed/report/daily-trend?cstype=IAAS&provider=All&startdate=20180801&enddate=20180810

Cost By Resources

BASE_URI/api/2.0/{tenant-org-acronym}/datafeed/report/top-resources-spend-by-provider?cstype=IAAS&provider=All&startdate=20180801&enddate=20180810&fetchCount=5

Cost Trend By Provider

BASE_URI/api/2.0/{tenant-org-acronym}/datafeed/report/daily-trend-provider?cstype=IAAS&provider=All&startdate=20180801&enddate=20180810

Cost By Services

BASE_URI/api/2.0/{tenant-org-acronym}/datafeed/report/top-products-spend-by-provider?cstype=IAAS&provider=All&startdate=20180801&enddate=20180810&fetchCount=5

Cost By Storage TypeBASE_URI/api/2.0/{tenant-org-acronym}/datafeed/report/storage-spend-by-provider?cstype=IAAS&provider=All&startdate=20180801&enddate=20180810&fetchCount=5

Product Cost Trend: (Current Cost & Estimated Cost)

Get the Products

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/products?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810

Get a Product Cost Trend

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/daily-trend-by-product?cstype=IAAS&provider=All&product=Computing+Instance&startdate=20180801&enddate=20180810

Cost by Platform (VM Cost)

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-platform-spend-by-provider?cstype=IAAS&provider=All&fetchCount=5&startdate=20180801&enddate=20180810

Instance Cost/Count by Type

Instance Count by Type

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-flavor-count-by-provider?cstype=IAAS&provider=All&fetchCount=1000000000000000000&startdate=20180801&enddate=20180810

Instance Cost by Type

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-flavor-spend-by-provider?cstype=IAAS&provider=All&fetchCount=5&startdate=20180801&enddate=20180810

Resource Cost/Count by Region

Resource Count by Region

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-region-count-by-provider?cstype=IAAS&provider=All&fetchCount=1000000000000000000&startdate=20180801&enddate=20180810

Resource Cost by Region

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-region-spend-by-provider?cstype=IAAS&provider=All&fetchCount=5&startdate=20180801&enddate=20180810

VM Cost/Count by Source of Creation

VM Count by Source of Creation

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/vm-count-by-source-of-creation?cstype=IAAS&provider=All&fetchCount=1000000000000000000&startdate=20180801&enddate=20180810

VM Cost by Source of Creation

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/vm-spend-by-source-of-creation?cstype=IAAS&provider=All&fetchCount=5&startdate=20180801&enddate=20180810

Cost by IaaS Usage Type

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-usagetype-spend-by-provider?cstype=IAAS&provider=All&fetchCount=5&startdate=20180801&enddate=20180810

Resource Cost/Count by Tags

Resource Count By Tags

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-vm-count-by-tags?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&fetchCount=1000000000000000000

Resource Cost By Tags

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-tags-spend-by-provider?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&fetchCount=5

Tag Cost Trend

Get the Tag Keys

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/tag-keys?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810

Get the Tag Values

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/tag-values-of-tag-name?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&tagname=owner

Get the Cost Trend by Tag Value

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/daily-trend-by-tag?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&fetchCount=10&tagname=owner&tagvalue=aws123

VM Cost/Count by Tag Key

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-tags-vm-spend-by-provider?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&fetchCount=5&tagname=Owner

Product Cost by Tags

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-tags-spend-by-product?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&fetchCount=5&tagname=aws&tagvalue=EC2ContainerService

Instance Cost Type / Size by Tags

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-flavor-spend-by-tagvalue?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&fetchCount=5&tagname=aws&tagvalue=EC2ContainerService

Cost of Un-Tagged Resources:

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-untagged-resource-by-cost?cstype=IAAS&provider=All&startdate=20180101&enddate=20180810&fetchCount=5

SaaS Billing Data

Cost Trend by Provider

Get Providers

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/providers-saas?cstype=SAAS

Get Cost Trend for All or by provider

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/daily-trend-ytd-saas?cstype=SAAS&provider=All&startdate=20170810&enddate=20180810

Cost by Service Offer

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/top-products-spend-by-provider-saas?cstype=SAAS&provider=All&startdate=20170810&enddate=20180810&fetchCount=5

Cost By Provider

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/provider-usage-saas?cstype=SAAS&provider=All&startdate=20170810&enddate=20180810

Cost Trend by Offer

Get the offers

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/products-saas?cstype=SAAS&provider=All&startdate=20170810&enddate=20180810

Get the Cost Trend for an Offer

BASE_URI/api/2.0/{ORG-ACRONYM}/datafeed/report/daily-trend-ytd-by-product-saas?cstype=SAAS&provider=All&product=Multisubsoffercode&startdate=20180211&enddate=20180810