CRUD operations are fundamental concepts in network automation and programmability that define how we interact with REST APIs. CRUD stands for Create, Read, Update, and Delete, which map to specific HTTP methods used when working with network devices and controllers.
GET (Read): This operation ret…CRUD operations are fundamental concepts in network automation and programmability that define how we interact with REST APIs. CRUD stands for Create, Read, Update, and Delete, which map to specific HTTP methods used when working with network devices and controllers.
GET (Read): This operation retrieves data from a network device or controller. When you send a GET request to an API endpoint, you receive information such as device configurations, interface statistics, or network topology data. GET requests do not modify any data on the target system. For example, you might use GET to fetch the running configuration of a router or retrieve a list of VLANs from a switch.
POST (Create): This operation creates new resources or data entries on a network device. When you send a POST request, you include data in the request body that defines the new resource. Examples include creating a new VLAN, adding a new access control list entry, or configuring a new interface. POST requests result in new data being added to the system.
PUT (Update): This operation modifies existing resources on a network device. PUT requests replace the current representation of a resource with the new data provided in the request body. You would use PUT to update interface descriptions, modify routing configurations, or change SNMP community strings. PUT typically requires sending the complete updated resource.
DELETE (Delete): This operation removes resources from a network device. When you send a DELETE request to a specific resource endpoint, that resource is removed from the system. Examples include removing a VLAN, deleting an access list, or removing a static route.
Understanding these CRUD operations is essential for network automation using tools like Python scripts, Ansible playbooks, or working with controllers such as Cisco DNA Center and SD-WAN vManage. These operations form the foundation of programmatic network management.
CRUD Operations (GET, POST, PUT, DELETE) - Complete Guide
Why CRUD Operations Are Important
CRUD operations form the foundation of how applications interact with data and APIs. In modern network automation and programmability, understanding these operations is essential because:
• They enable network engineers to automate configuration changes • They allow integration between network devices and management platforms • They are the standard method for RESTful API communication • Cisco DNA Center, Meraki, and other platforms rely on these operations
What Are CRUD Operations?
CRUD is an acronym that stands for Create, Read, Update, and Delete. These four operations map to HTTP methods used in REST APIs:
CREATE → POST Used to create new resources or data entries. When you want to add a new device, user, or configuration, you use POST.
READ → GET Used to retrieve or read existing data. This is a safe operation that does not modify any data on the server.
UPDATE → PUT (or PATCH) Used to modify existing resources. PUT typically replaces the entire resource, while PATCH modifies only specific fields.
DELETE → DELETE Used to remove resources from the system.
How CRUD Operations Work
When working with REST APIs:
1. GET Request - Retrieves information from the server - Does not change server state - Example: GET /api/devices returns a list of all devices - Considered idempotent (same result each time)
2. POST Request - Sends data to create a new resource - Includes a request body with the data - Example: POST /api/devices with device details creates a new device - Not idempotent (multiple requests create multiple resources)
3. PUT Request - Updates an existing resource by replacing it - Requires the complete resource data - Example: PUT /api/devices/1 replaces device with ID 1 - Considered idempotent
4. DELETE Request - Removes a specified resource - Example: DELETE /api/devices/1 removes device with ID 1 - Considered idempotent
HTTP Response Codes to Know
• 200 OK - Successful GET, PUT, or DELETE • 201 Created - Successful POST (resource created) • 204 No Content - Successful operation with no response body • 400 Bad Request - Invalid request syntax • 401 Unauthorized - Authentication required • 403 Forbidden - Access denied • 404 Not Found - Resource does not exist
Exam Tips: Answering Questions on CRUD Operations
Tip 1: Memorize the Mapping Create = POST, Read = GET, Update = PUT, Delete = DELETE Remember: C-P, R-G, U-P, D-D
Tip 2: Identify the Action in the Question Look for keywords: • 'retrieve,' 'view,' 'display,' 'query' → GET • 'add,' 'create,' 'new,' 'insert' → POST • 'modify,' 'change,' 'update,' 'replace' → PUT • 'remove,' 'delete,' 'erase' → DELETE
Tip 3: Understand Idempotency GET, PUT, and DELETE are idempotent (same result if repeated) POST is NOT idempotent (creates duplicates if repeated)
Tip 4: Know the Request Body Requirements • GET and DELETE typically have no request body • POST and PUT require a request body with data
Tip 5: Response Code Questions If asked about successful creation, the answer is usually 201 If asked about successful retrieval, the answer is usually 200
Tip 6: Context Matters In Cisco DNA Center or other controller contexts, these operations manage network devices, policies, and configurations through northbound APIs.
Common Exam Scenarios
Scenario 1: 'An engineer needs to retrieve a list of network devices from Cisco DNA Center' Answer: GET
Scenario 2: 'Adding a new VLAN to the configuration database' Answer: POST
Scenario 3: 'Changing the hostname of an existing device' Answer: PUT
Scenario 4: 'Removing an outdated policy from the controller' Answer: DELETE