Commit 0d9840ab authored by Laurent Velez's avatar Laurent Velez
Browse files

Merge branch 'stf644' into 'master'

STF644 - Milestone B - Merge stf644 to Master branch

See merge request !13
parents 07015c2e a0203952
Loading
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+6 −0
Original line number Diff line number Diff line
protoc/
go-stubs/
ruby-stubs/
.proto-gen/
python-stubs/
.vscode/
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
+30 −0
Original line number Diff line number Diff line
.openapi-generator-ignore
README.md
models/address_range.proto
models/app_ext_cp_config.proto
models/app_ext_cp_data.proto
models/cp_protocol_data.proto
models/ext_link_port_data.proto
models/ext_virtual_link_data.proto
models/grant.proto
models/grant_info.proto
models/grant_links.proto
models/grant_request.proto
models/grant_request_links.proto
models/grant_request_operation.proto
models/ip_address.proto
models/ip_address_type.proto
models/ip_over_ethernet_address_data.proto
models/key_value_pair.proto
models/link_type.proto
models/problem_details.proto
models/resource.proto
models/resource_definition.proto
models/resource_definition_type.proto
models/resource_handle.proto
models/vim_assets.proto
models/vim_connection_info.proto
models/vim_software_image.proto
models/zone_group_info.proto
models/zone_info.proto
services/granting_service.proto
+1 −0
Original line number Diff line number Diff line
5.4.0
 No newline at end of file
+115 −0
Original line number Diff line number Diff line
# gPRC for MEC010-2

The ETSI MEC ISG App Grant API described using OpenAPI.

## Overview
These files were generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- API version: 3.1.1
- Package version: 
- Build package: org.openapitools.codegen.languages.ProtobufSchemaCodegen
For more information, please visit [https://forge.etsi.org/rep/mec/gs010-2-app-pkg-lcm-api](https://forge.etsi.org/rep/mec/gs010-2-app-pkg-lcm-api)

## Usage

Below are some usage examples for Go and Ruby. For other languages, please refer to https://grpc.io/docs/quickstart/.

### Python

1. Install the grpcio-tools package
    ```sh
    $ pip install grpcio-tools
    ```

2. Create a directory for generated Python stubs
    ```sh
    $ mkdir python-stubs 
    ```

3. Run the following command from the root of the directory containing this README that you are reading.

   - Models:
  
        ```sh
        $ python -m grpc_tools.protoc -I./AppGrantProto3/proto3 --python_out=./python-stubs ./AppGrantProto3/proto3/models/*
        ```
    
        The above command will generate .py files for all the data models in the ./models directory

   - Services:

        ```sh
        $ python -m grpc_tools.protoc -I./AppGrantProto3/proto3 --python_out=./python-stubs --grpc_python_out=./python-stubs ./AppGrantProto3/proto3/services/*
        ```

        The above command will generate service files for the App Grant API, containing:
        - Python data models used in the App Grant API
        - Classes and functions needed for the supported HTTP methods in the App Grant API

### Go

1. Install protocol buffer compiler
    ```sh
    $ apt install -y protobuf-compiler
    ```
2. Install Go plugins for `protoc`
    ```sh
    $ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
    ```
    ```sh
    $ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
    ```
3. Update `PATH` so `protoc` can find the plugins
    ```sh
    $ export PATH="$PATH:$(go env GOPATH)/bin"
    ```
4. Define a go package by appending `option go_package = "./mec0102.services.appgrantservice";` in .proto files like this:

    ```Go
    syntax = "proto3";

    package mec0102.services.appgrantservice;

    option go_package = "./mec0102.services.appgrantservice";

    import public "models/<xyz>.proto";
    ```

5. Generate Go code for models and services
    ```sh 
    $ mkdir go-stubs

    $ protoc --go_out=./go-stubs ./AppGrantProto3/proto3/models/* -I./AppGrantProto3/proto3
    
    $ protoc --go_out=./go-stubs ./AppGrantProto3/proto3/services/* --go-grpc_out=go-stubs -I./AppGrantProto3/proto3
    ```


    > The generated `<data_model>.pb.go` files will contain all the protocol buffer code to populate, serialize, and retrieve request and response message types defined in the `models` folder.

    > The `<xyz_grpc>.pb.go` file will contain the stubs for the methods defined in the `<xyz_service>.proto` file.

### Ruby

1. Install gRPC Ruby Plugin and required tools
   ```sh
   $ gem install grpc
   $ sudo apt install ruby-grpc-tools
   ```

2. Generate code
    ```sh
    $ mkdir ruby-stubs
    ```
    
    Run the following command to create Ruby modules for all the data models defined in the proto files.

    ```sh
    $ grpc_tools_ruby_protoc -I./AppGrantProto3/proto3 --ruby_out=ruby-stubs ./AppGrantProto3/proto3/models/*
    ```

    Run the following command to generate service file, containing stub and service classes for the endpoints and methods defined in the App Grant API.

    ```sh
    $ grpc_tools_ruby_protoc -I./AppGrantProto3/proto3 --ruby_out=ruby-stubs --grpc_out=ruby-stubs ./AppGrantProto3/proto3/services/*
    ```
 No newline at end of file
Loading