CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

Code generation service #71

Closed ghost closed 2 years ago

ghost commented 8 years ago

This enables users to handle below use cases as part of YDK app maker (YAM)

class CodeGenerationServiceProvider(object):
    """ Code generation provider"""
   def __init__(self, type):
        '''type is 'xml' or 'json' '''

class CodeGenerationService(object):
    """ Code generation service to generate code from XML/JSON payload """
   def __init__(self):
        pass
    def generate(self, provider, payload):
        '''This will return a python script snippet which can be used in a YDK app'''

It is preferable to continue using the existing service/provider abstraction

ghost commented 7 years ago

There are some code changes made to support the YDK app maker. This is available on a separate branch. To try this, first, clone the ydk-py repo using the below command:

~/ > git clone https://github.com/CiscoDevNet/ydk-py.git -b yam

Then, follow the steps here to install ydk core and bundles.

To run the yam sample:

~/ > cd ydk-py/core/samples
~/ > ./yam_sample.py [-v]