Skip to content

Instantly share code, notes, and snippets.

@afaqk9394
Created November 3, 2019 07:00
Show Gist options
  • Select an option

  • Save afaqk9394/88ca9b598a3e8982ea6e4b9ab8796e50 to your computer and use it in GitHub Desktop.

Select an option

Save afaqk9394/88ca9b598a3e8982ea6e4b9ab8796e50 to your computer and use it in GitHub Desktop.
capabilities of Cisco security platforms and APIs
import json
import sys
import requests
server = "https://fmcrestapisandbox.cisco.com"
username = "ccnain4wee"
password = "Fq3L8GVG"
r = None
headers = {'Content-Type': 'application/json'}
api_auth_path = "/api/fmc_platform/v1/auth/generatetoken"
auth_url = server + api_auth_path
r = requests.post(auth_url, headers=headers, auth=requests.auth.HTTPBasicAuth(username,password), verify=False)
auth_headers = r.headers
auth_token = auth_headers.get('X-auth-access-token', default=None)
headers['X-auth-access-token']=auth_token
api_path = "/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/devices/devicerecords" # param
url = server + api_path
if (url[-1] == '/'):
url = url[:-1]
# GET OPERATION
r = requests.get(url, headers=headers, verify=False)
status_code = r.status_code
resp = r.text
json_resp = json.loads(resp)
print(json.dumps(json_resp,sort_keys=True,indent=4, separators=(',', ': ')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment