Understanding Data Models in Network Automation

CRUD tells an API what to do with a resource. A data model tells the API what that resource looks like: its fields, hierarchy, types and allowed values. This lesson connects the previous CRUD step to the structured data used by network controllers, RESTCONF, NETCONF and automation tools.

Data ModelsJSONYANGNetwork Automation

Data Models and Structures at a Glance

CLI output is shaped for people. Structured data is shaped for software. The visual below follows the path from a client request to a network device, then compares common serialization formats with a YANG model that defines the data structure.

Comparison of traditional CLI text, structured API data formats and YANG data models in network automation
Use the model to understand the shape of the data, then use the format required by the API or automation tool.
Nine-part learning path

Network Automation and Programmability Series

Part 4 explains the structured information that CRUD operations create, read, update and delete. The next lessons apply these ideas to tools, controllers and infrastructure as code.

Part 4 of 9

Data Formats and Data Models Are Different

A format is the syntax used to serialize information. A model is the contract that describes what information exists and how it relates. JSON, XML and YAML can carry data, but a model gives that data meaning and validation rules.

XML

Tag-based and explicit. XML is verbose but common in enterprise systems and NETCONF payloads.

<interface>
  <name>Gi0/1</name>
  <enabled>true</enabled>
</interface>

JSON

Compact key-value syntax widely used by REST APIs and programming languages.

{
  "interface": {
    "name": "Gi0/1",
    "enabled": true
  }
}

YAML

Readable indentation-based syntax often used for automation variables and configuration files.

interface:
  name: Gi0/1
  enabled: true

YANG: The Network Data Model

YANG describes the tree of containers, lists and leaf values that a network service exposes. It can define configuration data, operational state, types, defaults, constraints and relationships. NETCONF and RESTCONF then exchange instances of that model.

module network-device {
  namespace "urn:example:network-device";
  prefix nd;

  container interface {
    leaf name { type string; }
    leaf enabled { type boolean; }
    leaf ip-address { type string; }
  }
}
Useful mental model: YANG is the blueprint; JSON or XML is the serialized instance; NETCONF or RESTCONF is the delivery protocol.

From CRUD Intent to Structured Network Data

  1. Identify the resource. Decide whether the target is a device, interface, VLAN, policy or operational-state object.
  2. Read the model. Check the path, field names, data types, defaults and constraints.
  3. Choose the serialization. Use the format required by the API, such as JSON for REST or XML for NETCONF.
  4. Apply the CRUD action. Send the smallest valid payload for the intended create, read, update or delete operation.
  5. Validate the result. Read the resource back and confirm that the device or controller reports the intended state.

Why Models Matter for Automation

  • They replace guesswork with predictable paths and field names.
  • They let tools validate types and required values before a change reaches a device.
  • They separate the data contract from the script that uses it.
  • They make vendor-neutral interfaces and reusable automation more practical.
  • They help an engineer compare intended state with actual state.

How This Leads to Configuration Tools and Git

You now have the vocabulary for structured network data: CRUD describes the action, formats carry the payload, and models describe the payload's shape. Next, the series moves into configuration management tools and Git so changes can be reviewed, versioned and repeated.

Understanding Data Models Frequently Asked Questions

Why are data models important in network automation?

Data models give automation tools a predictable structure for configuration and operational data, reducing the need to parse human-oriented CLI output.

What is the difference between a data format and a data model?

A format such as JSON, XML or YAML describes how data is serialized. A data model describes fields, hierarchy, types and rules.

What is YANG used for?

YANG defines structured models for network configuration, state and operational data. NETCONF and RESTCONF can exchange data that follows those models.

Does YANG replace JSON or XML?

No. YANG defines structure and rules, while JSON or XML can serialize data that follows the model.

Should network engineers learn JSON, XML and YAML?

Yes. JSON is common in REST APIs, XML appears in NETCONF and other systems, and YAML is widely used for readable automation files.

How do data models connect to CRUD operations?

CRUD describes the action. The data model describes the resource fields, hierarchy and valid values used by that action.