{"id":21636117,"url":"https://github.com/bigevilbeard/interface_up_restconf","last_synced_at":"2025-04-11T15:50:19.838Z","repository":{"id":128721725,"uuid":"263336850","full_name":"bigevilbeard/Interface_Up_Restconf","owner":"bigevilbeard","description":"Using RESTCONF to enable an interface on IOS XE","archived":false,"fork":false,"pushed_at":"2023-05-22T21:39:20.000Z","size":119,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T11:52:24.058Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigevilbeard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2020-05-12T12:57:53.000Z","updated_at":"2023-03-03T14:15:12.000Z","dependencies_parsed_at":"2023-03-12T01:45:58.673Z","dependency_job_id":null,"html_url":"https://github.com/bigevilbeard/Interface_Up_Restconf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2FInterface_Up_Restconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2FInterface_Up_Restconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2FInterface_Up_Restconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2FInterface_Up_Restconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigevilbeard","download_url":"https://codeload.github.com/bigevilbeard/Interface_Up_Restconf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248434409,"owners_count":21102830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-11-25T03:29:59.566Z","updated_at":"2025-04-11T15:50:19.830Z","avatar_url":"https://github.com/bigevilbeard.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using RESTCONF to enable an interface on IOS XE\n\nThis public repo contains python code that can be used to interact with the `Cisco IOS XE API`. The environment is pre-configured to access the [IOS XE on CSR Recommended Code Always On Sandbox](https://devnetsandbox.cisco.com/RM/Diagram/Index/27d9747a-db48-4565-8d44-df318fce37ad?diagramType=Topology) device .You can edit the variables in the environment to point to your own IOS XE device. The code contains REST API calls to authenticate, and bring up an interface.\n\n\n## Python Environment Setup\nIt is recommended that this code be used with Python 3.6. It is highly recommended to leverage Python Virtual Environments (venv).\nFollow these steps to clone the code and create and activate a venv.\n\n```\ngit clone https://github.com/bigevilbeard/Interface_Up_Restconf.git\ncd Interface_Up_Restconf\n```\n\n\n## OS X or Linux\n```\nvirtualenv venv --python=python3.6\nsource venv/bin/activate\n```\n## Install the code requirements\n```\npip install -r requirements.txt\n```\n\n## Python’s Requests Library\n\nThe requests library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data.\n\n## Information About RESTCONF Programmable Interface\n\n### Overview of RESTCONF\nThis section describes the protocols and modelling languages that enable a programmatic way of writing configurations to a network device.\n\n- RESTCONF—Uses structured data (XML or JSON) and YANG to provide a REST-like APIs, enabling you to programmatically access different network devices. RESTCONF APIs use HTTPs methods\n- YANG—A data modelling language that is used to model configuration and operational features . YANG determines the scope and the kind of functions that can be performed by NETCONF and RESTCONF APIs\n\n## PUT Request to Shutdown Interface\n\n- Send PUT request to issue `no shutdown` on GigabitEthernet2\n- Method: PUT\n- Request URL:  `https://{h}:{p}/restconf/data/ietf-interfaces:interfaces`\n- PUT Request Payload:\n\n```\n{\n   \"ietf-interfaces:interface\":{\n      \"name\":\"GigabitEthernet2\",\n      \"description\":\"Configured by RESTCONF\",\n      \"type\":\"iana-if-type:ethernetCsmacd\",\n      \"enabled\":true\n   }\n}\n```\n\nThe payload can also be changed to `\"enabled\": false` to shutdown GigabitEthernet2.\n\n## GET Request to Validate Changes\n\n- Send GET request to issue output on GigabitEthernet2\n- Method: GET\n- Request URL:  `https://{h}:{p}/restconf/data/ietf-interfaces:interfaces`\n- GET Request Payload: N/A\n\nResponce is printed using Python f-strings. Also called “formatted string literals,” f-strings are string literals that have an f at the beginning and curly braces containing expressions that will be replaced with their values. The expressions are evaluated at runtime and then formatted using the __format__ protocol.\n\n```\nfor key, value in jsonResponse.items():\n    print(f'Interface Name: {jsonResponse[\"ietf-interfaces:interface\"][\"name\"]}')\n    print(f'Interface Description: {jsonResponse[\"ietf-interfaces:interface\"][\"description\"]}')\n    print(f'Interface Status: {jsonResponse[\"ietf-interfaces:interface\"][\"enabled\"]}')\n```\n\n## Example Output\n\n![GIF](./images/xe_restconf.gif)\n\n\n## About me\n\nNetwork Automation Developer Advocate for Cisco DevNet.\nI'm like Hugh Hefner... minus the mansion, the exotic cars, the girls, the magazine and the money. So basically, I have a robe.\n\nFind me here: [LinkedIn](https://www.linkedin.com/in/stuarteclark/) / [Twitter](https://twitter.com/bigevilbeard)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigevilbeard%2Finterface_up_restconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigevilbeard%2Finterface_up_restconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigevilbeard%2Finterface_up_restconf/lists"}