{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Firepower Device Manager (FDM) \n", "\n", "Exam Topics Covered:\n", "3.2 Construct API requests to create and delete objects using Firepower device management (FDM)\n", "\n", "There are two management points for Firepower Threat Defense:\n", "1. FMC - Firepower Management Console. Provides centralized management of all Firepower devices. \n", "\n", "2. FDM - Firepower Device Manager. Management dashboard and API for a single Firepower appliance. \n", "\n", "This section will focus on the FDM since that is what is on the blueprint. \n", "\n", "The API documentation is available on the device at the following URL:\n", "https:// If the the JSON payload is incorrect, an HTTP status of 422 'Unprocessable Entity' will be received" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Delete Objects\n", "\n", "A network object can be deleted by issuing a DELETE request with the `object_id` in the API endpoint URL. The `object_id` will first need to be retrieved by querying for the object. Then the ID will be appended to the URL for the delete request. Note that the API will return an HTTP status code 204 to indicate the object has been deleted. There will be no content in the response body. \n", "\n", "```\n", "get_url = f\"https://{hostname}/api/fdm/latest/object/networks\"\n", "\n", "resp = requests.get(get_url, headers=headers, verify=False)\n", "\n", "for item in resp.json()['items']:\n", " if item['name'] == \"TEST_OBJ\":\n", " obj_id = item['id'] \n", " \n", "print(obj_id)\n", "b91e90d7-b97d-11ea-a391-410fe0690874\n", "\n", "delete_url = f\"https://{hostname}/api/fdm/latest/object/networks/{obj_id}\"\n", "\n", "resp = requests.delete(delete_url, headers=headers, verify=False)\n", "\n", "resp.status_code\n", "204\n", "resp.content\n", "b''\n", "\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pagination\n", "\n", "The FDM API has a limit of 10 items that can be returned in a single request. The limit can be modified by setting the `limit` query parameter. The JSON response will include a `paging` dictionary which will indicate the next and previous URLs to retrieve the next or previous data. If previous is blank, it means the current request contained the first set of data. If next is empty, it means the current request contained the last set of data. \n", "\n", "Below is a snippet from a JSON response after configuring > 10 objects on the device.\n", "\n", "```\n", "'paging': {'count': 11,\n", " 'limit': 10,\n", " 'next': ['https://10.10.20.65/api/fdm/latest/object/networks?limit=10&offset=10'],\n", " 'offset': 0,\n", " 'pages': 0,\n", " 'prev': []}}\n", "\n", "```\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" } }, "nbformat": 4, "nbformat_minor": 4 }