ETExamTower
Q1Network Element Programmability

Which 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. <DragDrop items={["DATA = {\n \"FVTenant\": {\"attributes\": {\"name\": \"SuperEats\"},\n \"children\": [{\"FVAP\": {\"attributes\": {\"name\": \"OrderProcess\"},\n \"children\": [\n {\"FVAEPg\": {\"attributes\": {\"name\": \"app\"}}},\n {\"FVAEPg\": {\"attributes\": {\"name\": \"web\"}}}\n ]\n }}]\n }\n}\nRESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE)","DATA = {\n \"fvTenant\": {\"attributes\": {\"name\": \"SuperEats\"},\n \"children\": [{\"fvAp\": {\"attributes\": {\"name\": \"OrderProcess\"},\n \"children\": [\n {\"fvAEPg\": {\"attributes\": {\"name\": \"app\"}}},\n {\"fvAEPg\": {\"attributes\": {\"name\": \"web\"}}}\n ]\n }}]\n }\n}\nRESPONSE = requests.get(APIC+OPERATION, cookies=COOKIE)","DATA = {\n \"fvTenant\": {\"attributes\": {\"rn\": \"SuperEats\"},\n \"children\": [{\"fvAp\": {\"attributes\": {\"rn\": \"OrderProcess\"},\n \"children\": [\n {\"fvAEPg\": {\"attributes\": {\"rn\": \"app\"}}},\n {\"fvAEPg\": {\"attributes\": {\"rn\": \"web\"}}}\n ]\n }}]\n }\n}\nRESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE)","DATA = {\n \"fvTenant\": {\"attributes\": {\"name\": \"SuperEats\"},\n \"children\": [{\"fvAp\": {\"attributes\": {\"name\": \"OrderProcess\"},\n \"children\": [\n {\"fvAEPg\": {\"attributes\": {\"name\": \"app\"}}},\n {\"fvAEPg\": {\"attributes\": {\"name\": \"web\"}}}\n ]\n }}]\n }\n}\nRESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE)"]} slots={[{"answer":"DATA = {\n \"fvTenant\": {\"attributes\": {\"name\": \"SuperEats\"},\n \"children\": [{\"fvAp\": {\"attributes\": {\"name\": \"OrderProcess\"},\n \"children\": [\n {\"fvAEPg\": {\"attributes\": {\"name\": \"app\"}}},\n {\"fvAEPg\": {\"attributes\": {\"name\": \"web\"}}}\n ]\n }}]\n }\n}\nRESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE)","id":"code"}]} template={"import requests\n\nUSER = \"admin\"\nPASS = \"password\"\nAPIC = 'https://apic.supereats.com'\n\nOPERATION = 'api/aaaLogin.json'\nDATA = {\"aaaUser\": {\"attributes\": {\"name\":USER, \"pwd\":PASS}}}\nRESPONSE = requests.post(APIC+OPERATION, json=DATA, verify=False)\n\nTOKEN = RESPONSE.json()[\"imdata\"][0][\"aaaLogin\"][\"attributes\"][\"token\"]\nCOOKIE = {'APIC-cookie': TOKEN}\n\n{{code}}\n\nOPERATION = 'api/aaaLogout.json'\nDATA = {\n \"aaaLogout\": {\n \"attributes\": {\n \"token\":TOKEN\n }\n }\n}\nRESPONSE = requests.post(APIC+OPERATION, json=DATA, cookies=COOKIE, verify=False)"} explanation={"Creating ACI managed objects through the REST API requires the correct case-sensitive managed-object classes (`fvTenant`, `fvAp`, and `fvAEPg`) and a POST request. The `name` attributes create the SuperEats tenant, the OrderProcess application profile, and the app and web endpoint groups; the APIC authentication cookie authorizes the request."} reuse={false} />

← → navigate · a answer
Discussion · 0
No comments yet. Be the first.