Skip to content

Instantly share code, notes, and snippets.

@laidbackware
Last active November 15, 2021 13:52
Show Gist options
  • Save laidbackware/ba2bd1b7a17b1e40866348fc8b2ca2c4 to your computer and use it in GitHub Desktop.
Save laidbackware/ba2bd1b7a17b1e40866348fc8b2ca2c4 to your computer and use it in GitHub Desktop.
Python requests session basic auth example - NSX-T update machine cert
import requests, urllib3
from pprint import pprint
urllib3.disable_warnings()
s = requests.Session()
s.auth = ('admin', 'password')
s.verify = False
pprint(s.get('https://192.168.0.193/api/v1/node/services/http').json())
# Search API for NSX-T 3.0 +
pprint(s.get('https://192.168.0.193/api/v1/search/query?query=resource_type:ComputeManager').json())
# Must get this UID of the cert
s.post('https://192.168.0.193/api/v1/node/services/http?action=apply_certificate&certificate_id=c6e7405f-d998-4f2c-92aa-751e13a6411b')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment