Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 49146

Re: vRNI API

$
0
0

smitmartijn

 

Yes, here is the code that I wrote for this.

 

 

import requests, os

import json

 

 

def GenrateToken():

   

    BaseUrl = "https://vrniHost.corp/api/ni/auth/token"

    creds = {

    "username": os.environ.get('vrni_user'),

    "password" : os.environ.get('A_PWD'),

    "domain": {

        "domain_type": "LDAP",

        "value":"corp"

        }

    }

    headers = {'Content-Type':'application/json'}

    resp =  requests.post(BaseUrl,headers=headers, data = json.dumps(creds), verify = False,)

    key = resp.json()['token']

    print key

    return key

 

 

 

def GetSwitch(key):

    AuthKey = key

    BaseUrl = "https://vrniHost.corp/api/ni"

    Uri = "/data-sources/cisco-switches"

    headers = {

    "Content-Type":"application/json",

    "Authorization":AuthKey

    }

    CiscoResp = requests.get((BaseUrl+Uri),headers = headers, verify=False)

    print CiscoResp.text

 

 

key = GenrateToken()

 

GetSwitch(key)


Viewing all articles
Browse latest Browse all 49146

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>