Accessing the public APIs

A TrueSight Capacity Optimization administrator must grant the required read or write permission to users for accessing the public APIs. The permission is based on the API read or write activity that the administrator assigns to user roles. For information about granting access, see Adding and managing roles.

Support for granting access to the public APIs is available only when you apply Service Pack 1 (11.5.01) of TrueSight Capacity Optimization 11.5.


When a user with the required access makes RESTful web service requests from a REST client, these requests are authenticated. TrueSight Capacity Optimization supports the following methods of authentication:

Basic authentication

This authentication requires user credentials in the Base64 encoded format. These credentials are authenticated during API calls. Access to the public API is granted to only those clients that have the correct credentials.

The process of using this authentication:

  1. Create a concatenated string of user name and password separated by a colon (:) in the Base64 encoded format. For example, if the user name is admin and password is admin, the concatenated string is admin:admin. The Base64 encoded string of admin:admin is YWRtaW46YWRtaW4=.
  2. Use this encoded string as user credentials in the HTTP header of each Restful web service request. For example, the HTTP header containing encoded string is as follows:
    Authorization: Basic YWRtaW46YWRtaW4=
  3. Make the API call.
 Sample request to fetch data from the Reservation API

To authenticate (with admin as the username and password) and retrieve data for an existing reservation along with alert status information, add the following details in the request:

Method

GET

URI

/dh-services/rsv/reservations/{reservation-id}

HOST

hostname:8280

Request headers

Authorization: Basic YWRtaW46YWRtaW4=

The following image shows an example of a Reservation API request in a REST client.

 Sample response from the Reservation API
{
  "href": "hostname:8000/dh-services/rsv/reservations/31279",
  "id": 31279,
  "name": "testReservation_PUT_mergeResourceSpecs",
  "startDate": "08/02/2017",
  "description": "generated as part of JUNIT test, should be automatically deleted",
  "status": "ACCEPTED",
  "priority": "MEDIUM",
  "probability": 100,
  "realizationMode": "MANUAL",
  "highAvailability": "NO",
  "alertstatus": [],
  "resourceRequirementSummary": {
    "numItems": 2,
    "cpuTotalMHz": 8000,
    "memTotal": 4294967296,
    "storageTotal": 107374182400,
    "cpuTotalMHzUsed": 5280,
    "memTotalUsed": 3908420239.36,
    "storageTotalUsed": 35433480192
  },
  "resources": {
    "resourceSpecs": [
      {
        "id": 1932051,
        "name": "item-1",
        "numItems": 1,
        "enttypenm": "gm:vmw",
        "cpuCores": 4,
        "cpuTotalMHz": 4000,
        "memTotal": 2147483648,
        "storageTotal": 53687091200,
        "os": "LINUX",
        "cpuUtilization": 0.66,
        "memUtilization": 0.91,
        "storageUtilization": 0.33
      },
      {
        "id": 1932052,
        "name": "item-2",
        "numItems": 1,
        "enttypenm": "gm:vmw",
        "cpuCores": 4,
        "cpuTotalMHz": 4000,
        "memTotal": 2147483648,
        "storageTotal": 53687091200,
        "os": "LINUX",
        "cpuUtilization": 0.66,
        "memUtilization": 0.91,
        "storageUtilization": 0.33
      }
    ]
  },
  "items": [
    {
      "href": "http://hostname:8000/dh-services/rsv/reservations/31279/items/50748",
      "id": 50748,
      "name": "item-1",
      "resourceSpec": {
        "id": 1932051,
        "name": "item-1",
        "enttypenm": "gm:vmw",
        "cpuCores": 4,
        "cpuTotalMHz": 4000,
        "memTotal": 2147483648,
        "storageTotal": 53687091200,
        "os": "LINUX",
        "cpuUtilization": 0.66,
        "memUtilization": 0.91,
        "storageUtilization": 0.33
      }
    },
    {
      "href": "http://hostname:8000/dh-services/rsv/reservations/31279/items/50749",
      "id": 50749,
      "name": "item-2",
      "resourceSpec": {
        "id": 1932052,
        "name": "item-2",
        "enttypenm": "gm:vmw",
        "cpuCores": 4,
        "cpuTotalMHz": 4000,
        "memTotal": 2147483648,
        "storageTotal": 53687091200,
        "os": "LINUX",
        "cpuUtilization": 0.66,
        "memUtilization": 0.91,
        "storageUtilization": 0.33
      }
    }
  ]
} 

Bearer authentication

This authentication requires a token key. You can generate this key from the TrueSight Capacity Optimization console and use it in your RESTful web request calls. These API calls are authenticated by validating the token.

The process of using this authentication:

  1. Generate the API key. For more information, see Generating an API key for programmatic access.
  2. In a text editor, open the credentials.key file and copy the token.
  3. In your REST API call request, paste the copied token to the header statement.

  4. Make the API call.

 

Was this page helpful? Yes No Submitting... Thank you

Comments