API Quickstart
Most APIs (both Rest and SDK) require an authorization token. This topic shows how to generate a token and then add it to APIs.
Note: The token is a large string. For convenience, assign the response to a variable and use the variable as the token, as shown in these examples.
Rest API
-
Get the authorization token.
Rest API
/v1/user/login
Object
{ "username": "USERNAME", "password": "PASSWORD" }
Example
token=`curl --location 'https://webservices.YOUR-DOMAIN/v1/user/login' \ --header 'Content-Type: application/json' \ --data-raw '{"username": "USERNAME","password": "PASSWORD"}' \ | jq -r '.access_token'`
Be sure to replace YOUR-DOMAIN, USERNAME, and PASSWORD with the strings that are relevant to your case.
-
Add the token to the header of an API to verify your connection. This example uses the API to return a list of projects in your stack.
Rest API
/v1/user/projects/search
Example
curl --location 'https://webservices.YOUR_DOMAIN/v1/projects/search' \ --header 'Content-Type: application/json' \ --header "authorization: Bearer $token" \ --data-raw '{"page":1}'
Be sure to replace YOUR-DOMAIN with the strings that are relevant to your case.
The API responds with an object that lists all projects in your stack.
See Rest API documentation for documentation for all Rest APIs.
SDK API
The SDK APIs are python wrappers that call the underlying Rest APIs. You can call them from any python code, including notebooks.
-
Get the authorization token.
from vianops_client import ( AuthV1Api, ) try: token = AuthV1Api().login(username='USERNAME', password='PASSWORD')["access_token"] except: print('Error')
-
Run the
is_authenticated()
method to verify authentication.print(AuthV1Api().is_authenticated())
See Python client SDK for documentation for all SDK APIs.