API Guide

Table Of Contents
vCenter authorization
Authorization flow validates the following:
Session token
vCenter user credentials for the required permissions to run the API
Validate session token
OMIVV validates the token that is received from the API client against the following:
Tampering
Session validity
Validate vCenter user credentials
APIs are authorized against the vCenter user credentials, when required. Set an operational context which indicates the
registered vCenter and the associated user credentials.
An operation context is required to ensure the permissions available to the user. You can set an operation context by invoking
the corresponding API.
This context is unique to an OMIVV user session, and only a single context can be active for a session at a time. The different
OMIVV user sessions can invoke APIs using a different vCenter context.
The required vCenter user privileges for all other APIs are verified when you trigger the API.
The following is the sample code to set the operational context:
```json
def setOperationalContext(omivvIP, bearerToken, vcenterId,
vcenterUsername,vCenterDomain, vCenterPassword):
url ="https://" + omivvIP + "/Spectre/api/rest/v1/Services/ConsoleService/
OperationalContext"
postBodyData={"consoleId" : vcenterId, "consoleUserCredential":
{"username":vcenterUsername,"domain" : vCenterDomain,"password" : vCenterPassword}}
head = {'Authorization': 'Bearer ' + bearerToken}
jsonReponse = requests.post(url, json=postBodyData, verify=False,headers=head)
if(jsonReponse.status_code == 204):
return pass;
else:
print("setOperationalContext failed.")
```
The vCenter user privilege is not required to access the following APIs:
/Services/AuthenticationService/login
/Services/AuthenticationService/logoff
/Services/ConsoleService/OperationalContext
/Services/ConsoleService/Consoles
/Services/ConsoleService/Consoles/{id}
12
Security