{"id":22513381,"url":"https://github.com/bitvantage/cisco.configurationsection","last_synced_at":"2026-02-28T03:41:24.612Z","repository":{"id":246670501,"uuid":"820194063","full_name":"Bitvantage/Cisco.ConfigurationSection","owner":"Bitvantage","description":"Facilitate parsing configuration files from Cisco routers and switches into a document object model (DOM) enabling network administrators and developers to easily read, query, and modify the structured data from Cisco device configurations.","archived":false,"fork":false,"pushed_at":"2025-05-03T23:04:44.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T16:45:05.097Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bitvantage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-26T01:59:10.000Z","updated_at":"2025-05-03T23:04:47.000Z","dependencies_parsed_at":"2024-06-29T15:14:47.940Z","dependency_job_id":null,"html_url":"https://github.com/Bitvantage/Cisco.ConfigurationSection","commit_stats":null,"previous_names":["bitvantage/cisco.configurationsection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Bitvantage/Cisco.ConfigurationSection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitvantage%2FCisco.ConfigurationSection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitvantage%2FCisco.ConfigurationSection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitvantage%2FCisco.ConfigurationSection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitvantage%2FCisco.ConfigurationSection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bitvantage","download_url":"https://codeload.github.com/Bitvantage/Cisco.ConfigurationSection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitvantage%2FCisco.ConfigurationSection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29924379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T03:12:00.218Z","updated_at":"2026-02-28T03:41:24.585Z","avatar_url":"https://github.com/Bitvantage.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Bitvantage.Cisco.ConfigurationSection\nFacilitate parsing configuration files from Cisco routers and switches into a document object model (DOM) enabling network administrators and developers to easily read, query, and modify the structured data from Cisco device configurations.\n## Installing via NuGet Package Manager\n```\nPM\u003e NuGet\\Install-Package Bitvantage.Cisco.ConfigurationSection\n```\n\n## Quick Start\n```csharp\n var configuration =\u003e \"\"\"\n        !\n        ! Last configuration change at 01:15:54 UTC Thu Jun 13 2024 by admin\n        !\n        version 15.2\n        service timestamps debug datetime msec\n        service timestamps log datetime msec\n        service password-encryption\n        service compress-config\n        \"\"\";\n\nvar configurationSection = ConfigurationSection.Parse(configuration);\n\nconfigurationSection\n    .Add(\"class-map type control subscriber match-all DOT1X\")\n    .Add(\"match method dot1x\");\n\nconfigurationSection.Remove(\"service compress-config\");\n\nvar updatedConfiguration = configurationSection.ToString();\n```\n\n## Working with Nodes\nEach configuration command is represented by a node in a tree with sub-commands represented as child nodes. For example:\n```\nconfiguration\n├── interface GigabitEthernet0/1\n│   ├── description Uplink to Core Switch\n│   ├── ip address 192.168.1.1 255.255.255.0\n│   ├── speed 1000\n│   └── duplex full\n├── interface GigabitEthernet0/2\n│   ├── description Connection to Server\n│   ├── ip address 192.168.1.2 255.255.255.0\n│   ├── speed 1000\n│   └── duplex full\n├── vlan10\n│   └── name Sales\n├── vlan20\n│   └── name Engineering\n└── ip route 100.0.0.0 255.255.255.0 gigabitEthernet 0/1\n```\n\n### Programicly Building a Configuration\nA ConfigurationSection section, more or less, acts as a list that contains children, when you add a child node to a node, the added node is returned.\n```csharp\nvar configuration = new ConfigurationSection()\n    .Add(\"interface GigabitEthernet0/1\")\n    .Add(\"ip address 192.168.1.1 255.255.255.0\").Parent\n    .Add(\"speed 1000\").Parent\n    .Add(\"duplex full\").Root\n    .Add(\"interface GigabitEthernet0/2\")\n    .Add(\"ip address 192.168.1.2 255.255.255.0\").Parent\n    .Add(\"speed 1000\").Parent\n    .Add(\"duplex full\")  \n```\n\n### Updating a Node\nNodes are immutable; however an existing node can be replaced by another node\n```csharp\nvar configuration = ConfigurationSection.Parse(\"\"\"\n    interface GigabitEthernet0/1\n     ip address 192.168.1.1 255.255.255.0\n     speed 1000\n     duplex full\n    !\n    interface GigabitEthernet0/2\n     ip address 192.168.1.2 255.255.255.0\n     speed 1000\n     duplex full\n    !\n    \"\"\");\n\nconfiguration[\"interface GigabitEthernet0/2\"][\"ip address 192.168.1.2 255.255.255.0\"].Replace(\"ip address 192.168.100.2 255.255.255.0\");\n```\n\n## Adding a Node\n```csharp\nvar configuration = ConfigurationSection.Parse(\"\"\"\n    interface GigabitEthernet0/1\n        ip address 192.168.1.1 255.255.255.0\n        speed 1000\n        duplex full\n    !\n    interface GigabitEthernet0/2\n        ip address 192.168.1.2 255.255.255.0\n        speed 1000\n        duplex full\n    !\n    \"\"\");\n\nforeach (var configurationSection in configuration.Search(\"^interface GigabitEthernet\")) \n    configurationSection.AddFirst(\"description Ethernet port\");\n```\n\n### Getting a Child Node By Exact Name\n```csharp\n// gets the first matching child node; throws an exception if the node does not exist\nvar childNode1 = configurationSection[\"spanning-tree mode rapid-pvst\"]\n\n// tries to get the first matching child node\nvar success = configurationSection.TryGet(\"spanning-tree mode rapid-pvst\", out var childNode2);\n```\n\n### Finding Child Nodes by Exact Name\nTo find nodes by exact match use the Find() method. Multiple names can be specified, which correspond to the node path.\n\n```csharp\nvar matchingNodes = configurationSection.Find(\"interface GigabitEtherne1/0\",\"ip address 10.255.0.4 255.255.255.254\");\n```\n\n### Searching Child Nodes by Regular Expression\nTo search for nodes by a regular expression use the Search() method. Multiple regular expressions can be specified, which correspond to the path of the node.\n\nFor example to find GigabitEthernet interfaces that have an IPv4 address set:\n```csharp\nvar matchingNodes = configurationSection.Search(@\"^interface GigabitEthernet\\d+/\\d+\",\"^ip address \\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3} \\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$\");\n```\n\n### Matching Child Nodes by Regular Expression\nTo find nodes by regular expression and retain the matched groups for future use, use the Match() method. Multiple regular expressions can be specified, which correspond to the path of the node.\n```csharp\nvar sectionMatches = configurationSection.Match(@\"^interface (?\u003cinterface\u003eGigabitEthernet\\d+/\\d+)$\", @\"^ip address (?\u003cnetwork\u003e(?\u003caddress\u003e\\d+\\.\\d+\\.\\d+\\.\\d+) (?\u003cmask\u003e\\d+\\.\\d+\\.\\d+\\.\\d+))$\");\n\nvar interfaces = sectionMatches\n    .Select(item =\u003e new\n    {\n        Interface = IosInterface.Parse(item.Path[0].Match.Groups[\"interface\"].Value),\n        Address = IPAddress.Parse(item.Match.Groups[\"address\"].Value),\n        Network = Network.Parse(item.Match.Groups[\"network\"].Value)\n    }).ToList();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitvantage%2Fcisco.configurationsection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitvantage%2Fcisco.configurationsection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitvantage%2Fcisco.configurationsection/lists"}