QuestionQ22
Network Element ProgrammabilityWhich Python snippet creates an application policy named OrderProcess containing two application endpoint groups under the SuperEats tenant by making direct calls to the ACI REST API? Assume authentication and library imports are correct.
Drag & Drop
DATA = {
"FVTenant": {"attributes": {"name": "SuperEats"},
"children": [{"FVAP": {"attributes": {"name": "OrderProcess"},
"children": [
{"FVAEPg": {"attributes": {"name": "app"}}},
{"FVAEPg": {"attributes": {"name": "web"}}}
]
}}]
}
}
RESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE)
DATA = {
"fvTenant": {"attributes": {"name": "SuperEats"},
"children": [{"fvAp": {"attributes": {"name": "OrderProcess"},
"children": [
{"fvAEPg": {"attributes": {"name": "app"}}},
{"fvAEPg": {"attributes": {"name": "web"}}}
]
}}]
}
}
RESPONSE = requests.get(APIC+OPERATION, cookies=COOKIE)
DATA = {
"fvTenant": {"attributes": {"rn": "SuperEats"},
"children": [{"fvAp": {"attributes": {"rn": "OrderProcess"},
"children": [
{"fvAEPg": {"attributes": {"rn": "app"}}},
{"fvAEPg": {"attributes": {"rn": "web"}}}
]
}}]
}
}
RESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE)
DATA = {
"fvTenant": {"attributes": {"name": "SuperEats"},
"children": [{"fvAp": {"attributes": {"name": "OrderProcess"},
"children": [
{"fvAEPg": {"attributes": {"name": "app"}}},
{"fvAEPg": {"attributes": {"name": "web"}}}
]
}}]
}
}
RESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE)
import requests USER = "admin" PASS = "password" APIC = 'https://apic.supereats.com' OPERATION = 'api/aaaLogin.json' DATA = {"aaaUser": {"attributes": {"name":USER, "pwd":PASS}}} RESPONSE = requests.post(APIC+OPERATION, json=DATA, verify=False) TOKEN = RESPONSE.json()["imdata"][0]["aaaLogin"]["attributes"]["token"] COOKIE = {'APIC-cookie': TOKEN} OPERATION = 'api/aaaLogout.json' DATA = { "aaaLogout": { "attributes": { "token":TOKEN } } } RESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE, verify=False)
Community Discussion