Skip to main content

An open source Python package that helps developers to translate YANG (RFC6020/RFC7950) data models to Python.

Project description

Yet Another PYANG

GitHub Actions Workflow Status Codecov
PyPI - Python Version PyPI - Downloads GitHub License

An open source Python package that helps developers to translate YANG (RFC6020/RFC7950) data models to Python. YAPYANG mimics the functionality of YANG data structures, enforces types through annotations, and supports JSON/XML ser/des. YAPYANG is authored by Antonio Faria, governed as a benevolent dictatorship, and distributed under license

[!WARNING] YAPYANG is in construction, during this time no effort shall be afforded to migrations and backwards compatibility. See versioning.

Quick Start

For convenience we've included a basic quick start below. Ensure that a supported version of Python and the latest version of YAPYANG is installed.

Start by choosing the YANG model to translate. We've simplified OpenConfig interfaces.

module openconfig-interfaces {
    namespace "http://openconfig.net/yang/interfaces";
    container interfaces {
        list interface {
            key "name";
            leaf name {
                type string;
            }
        }
    }
}

For each YANG node (module, container, list, and leaf) in the YANG model translate it into Python with YAPYANG through subclasses of the provided node types.

from yapyang import *

class Name(LeafNode):
    __identifier__ = "name"

    value: str

class Interface(ListNode):
    __identifier__ = "interface"
    __key__ = "name"

    name: Name

class Interfaces(ContainerNode):
    __identifier__ = "interfaces"

    interface: Interface

class OpenConfigInterfaces(ModuleNode):
    __identifier__ = "openconfig-interfaces"
    __namespace__ = "http://openconfig.net/yang/interfaces"

    interfaces: Interfaces

Create instances of the translated YANG model nodes, add interface entries, and serialize to XML. Read the full docs.

module = OpenConfigInterfaces(Interfaces(Interface()))
module.interfaces.interface.append(Name("xe-0/0/0"))
print(module.to_xml())
...

<interfaces xmlns="http://openconfig.net/yang/interfaces"><interface><name>xe-0/0/0</name></interface></interfaces>

Versioning

Releases will follow semantic versioning (major.minor.patch). Before 1.0.0 breaking changes can be included in a minor release, therefore we highly recommend pinning this package.

Contributing

Suggest a feature or report a bug. Read our developer guide.

License

YAPYANG is distributed under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yapyang-0.2.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file yapyang-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: yapyang-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for yapyang-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb57df5a57f0774dfb2a74aa43529272163eb15c8eea05eda3b0f25d22c8ae41
MD5 8a3eec2ed618fc59f75b287fbc4b590f
BLAKE2b-256 69ab58de06782ef9de1f11624f734b72204c6a47596386e36ad5855367e3c0c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page