Debian Codegraph @

docs/labs/lab07-aaa/svc_account_misc.py

raw
1 # Copyright (c) 2021 Arista Networks, Inc.
2 # Use of this source code is governed by the Apache License 2.0
3 # that can be found in the COPYING file.
4
5 from cvprac.cvp_client import CvpClient
6 from cvprac.cvp_client_errors import CvpApiError
7 import ssl
8 ssl._create_default_https_context = ssl._create_unverified_context
9 import requests.packages.urllib3
10 requests.packages.urllib3.disable_warnings()
11
12 # Create connection to CloudVision using user/password (on-prem only)
13 clnt = CvpClient()
14 clnt.connect(['cvp1'],'username', 'password')
15
16 # Get all service accounts states
17
18 accounts = clnt.api.svc_account_get_all()
19
20 # Get specific service account state
21
22 account = clnt.api.svc_account_get_one("cvprac2")
23
24 # Get all service account token states
25
26 tokens = clnt.api.svc_account_token_get_all()
27
28 # Get specific token state
29
30 token = clnt.api.svc_account_token_get_one("9bfb39ff892c81d6ac9f25ff95d0389719595feb")
31
32 # Delete a service account token
33
34 clnt.api.svc_account_token_delete("9bfb39ff892c81d6ac9f25ff95d0389719595feb")