Esempio n. 1
0
def get_access_policy(token=False):

    url = "https://fmcrestapisandbox.cisco.com/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/policy/accesspolicies?limit=400"
    session = requests.session()
    session.headers = get_access_token(token)

    response = session.get(url, verify=False).json()
    policies = response['items']

    for policy in policies:
        p_name = policy['name']
        p_id = policy['id']
        p_type = policy['type']
        p_link = policy['links']['self']

        if p_name == 'James Policy Demo':

            response = session.get(p_link, verify=False).json()
            policyrules = response['rules']

            print(f"Name: {p_name}")
            print(f"Id: {p_id}")
            print(f"Type: {p_type}")
            print(f"Rules")

            if type(policyrules) == list:
                for rule in policyrules:
                    r_type = rule['type']
                    r_link = rule['links']['self']

                    print(f"{r_link}")
                    print('*' * 50)

            else:
                print(f"Type: {policyrules['type']}")
                print(f"{policyrules['links']['self']}")

            return p_id

    return None
Esempio n. 2
0
import requests
import json
from FirepowerFMC.Get_Token import get_access_token

url = "https://fmcrestapisandbox.cisco.com/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/applications"
session = requests.session()
session.headers = get_access_token()

response = session.get(url, verify=False).json()
apps = response['items']

for app in apps:
    print('*' * 50)
    app_name = app['name']
    app_id = app['id']
    app_type = app['type']
    app_link = app['links']['self']

    print(f"Name: {app_name}")
    print(f"Id: {app_id}")
    print(f"Type: {app_type}")
    print(f"Link: {app_link}")
    print('*' * 50)
Esempio n. 3
0
import requests
import json
from FirepowerFMC.Get_Application_Policy import get_access_policy
from FirepowerFMC.Get_Token import get_access_token
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

headers = get_access_token()
policy_id = get_access_policy(headers['X-auth-access-token'])

url = f"https://fmcrestapisandbox.cisco.com/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/policy/accesspolicies/{policy_id}"
response = requests.delete(url, headers=headers, verify=False).json()
print(response)