{"id":21228491,"url":"https://github.com/polycube-network/polycube-codegen","last_synced_at":"2025-07-10T15:31:15.899Z","repository":{"id":37923382,"uuid":"179567894","full_name":"polycube-network/polycube-codegen","owner":"polycube-network","description":"Polycube Codegen","archived":false,"fork":false,"pushed_at":"2023-03-30T05:49:46.000Z","size":28,"stargazers_count":2,"open_issues_count":3,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-09-21T12:52:49.684Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polycube-network.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-04T19:57:30.000Z","updated_at":"2024-05-06T08:59:42.000Z","dependencies_parsed_at":"2022-08-26T13:31:01.480Z","dependency_job_id":null,"html_url":"https://github.com/polycube-network/polycube-codegen","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/polycube-network%2Fpolycube-codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polycube-network%2Fpolycube-codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polycube-network%2Fpolycube-codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polycube-network%2Fpolycube-codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polycube-network","download_url":"https://codeload.github.com/polycube-network/polycube-codegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225643678,"owners_count":17501419,"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-20T23:19:17.587Z","updated_at":"2024-11-20T23:19:18.078Z","avatar_url":"https://github.com/polycube-network.png","language":"Shell","readme":"polycube code generation tools\n******************************\n\nThis repository keeps in the same place the two tools `pyang-swagger \u003chttps://github.com/polycube-network/pyang-swagger\u003e`_ and `swagger-codegen \u003chttps://github.com/polycube-network/swagger-codegen\u003e`_, which are used to generate a polycube stub from a YANG datamodel.\n\nThe preferred way to generate a stub from a yang datamodel is through its corresponding `docker`_.\n\nDocker\n======\n\nA ready-to-go Docker image is at `polycubenetwork/polycube-codegen \u003chttps://hub.docker.com/r/polycubenetwork/polycube-codegen\u003e`_.\nThe entry point of the image is ``polycube-codegen`` and the `usage`_ provided in this document.\nIn this case you should provide a volume in ``/polycube-base-datamodel`` with the polycube base datamodel you want to handle.\n\nThe following is a full command line example, where the ``--user `id -u``` guarantees that the generated files have the permissions set to the current user:\n\n::\n\n    export POLYCUBE_BASEMODELS=\u003cpath to base models usually /usr/local/include/polycube/datamodel-common/\u003e\n    docker pull polycubenetwork/polycube-codegen\n    docker run -it --user `id -u` \\\n      -v $POLYCUBE_BASEMODELS:/polycube-base-datamodels \\\n      -v \u003cinput yang\u003e:/input \\\n      -v \u003coutput folder in host\u003e:/output \\\n      polycubenetwork/polycube-codegen \\\n      -i /input/\u003cyang datamodel\u003e \\\n      -o /output/\u003coutput folder\u003e\n\n\nUsage\n=====\n\n``polycube-codegen`` expects the ``POLYCUBE_BASE_DATAMODELS_FOLDER`` to be set to the folder were the base datamodels of polycube are located.\nIf you have installed polycube in the standard location and everything is ok you could omit that parameter that defaults to ``/usr/local/include/polycube/datamodel-common/``.\n\n::\n\n    $ docker run -it --user `id -u` [folder-options] [polycube-codegen-options]\n\n    where [folder-options] are required to tell the Docker the location of input/output files \n    and the exact datamodel we are interested in:\n        -v $POLYCUBE_BASEMODELS:/polycube-base-datamodels \\\n        -v \u003cinput yang file\u003e:/input \\\n        -v \u003coutput folder in host\u003e:/output\n    \n    and where [polycube-codegen-options] can be:\n        -h  show this help text\n        -i  path to the input YANG file\n        -o  path to the destination folder where the service stub will be placed\n        -s  path to the destination swagger file (optional)\n        -l  language used to generate service's client library (optional)\"\n\n\nClient stub for Polycube services\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nEach Polycube service uses a specific convention for generate the REST APIs that are used by external players to interact with the service itself. \nIn order to interact with those service, users can use the ``polycubectl`` CLI tool or creates their own client programs that communicates with a given service.\nTo simplify the creation of those programs, ``polycube-codegen`` supports the generation of client stubs in different programming languages such as ``golang``, ``java``, ``python`` (full list available `here \u003chttps://github.com/swagger-api/swagger-codegen#overview\u003e`_ under the ``swagger-codegen`` project).\n\nTo do this, we can directly use the provided ``polycube-codegen`` script adding the ``-l`` option with the name of the language you want to use.\nFor instance, in order to generate the client stub for the ``pcn-simplebridge`` service in the GO language, you can use the following command line options:\n\n::\n\n    -i pcn-simplebridge.yang\n    -o output_folder\n    -l go\n\nIn its final processing step, ``polycube-codegen`` relies on the online service https://generator.swagger.io/api/gen/clients generator to create the code stub; hence this requires Internet connectivity.\n\n\n\nFull installation (from sources)\n================================\n\nIf you don't want to use the `docker`_, the easiest way to install this package (including all dependencies) is to use the ``install.sh`` script.\nIf you want to install those by hands please refer to each repository to get further details.\n\n::\n\n    cd polycube-codegen\n    git submodule update --init\n    ./install.sh\n\nThe command line is similar to the `docker`_, such as:\n\n::\n\n    $ polycube-codegen [-h] [-i input_yang] [-o output_folder] [-s output_swagger_file] [-l client_language]\n    Polycube code generator that translates a YANG file into an polycube C++ service stub\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolycube-network%2Fpolycube-codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolycube-network%2Fpolycube-codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolycube-network%2Fpolycube-codegen/lists"}