Commits (5)
This diff is collapsed.
This diff is collapsed.
......@@ -3,6 +3,15 @@
This repository contains OpenAPIs descriptions for the interfaces specified in ETSI MEC GS 033
## Online resources
* [Specification Document](https://www.etsi.org/deliver/etsi_gs/MEC/001_099/033/03.01.01_60/gs_mec033v030101p.pdf)
## Navigate with Swagger UI
* [IoT API](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/rep/mec/gs033-iot-api/raw/stf644/MEC033_IoT.yaml)
## Navigate with Redocly
* [IoT API](https://redocly.github.io/redoc/?url=https://forge.etsi.org/rep/mec/gs033-iot-api/raw/stf644/MEC033_IoT.yaml)
## License
......
# Protobuf Schema Generation
[OpenAPI Generator](https://openapi-generator.tech) is used to generate protobuf schema (`.proto3`) files from OpenAPI specifications of MEC033 IoT API.
>**NOTE:** At the time of writing, the tool does not support OAS 3.1 version and we have to first convert the [IoT API](./MEC033_IoT.yaml) to OAS 3.0 for generating protobuf schema.
1. Convert OAS for [IoT API](./MEC033_IoT.yaml) from 3.1 to 3.0​
- Change the value of `openapi` field from 3.1.0 to 3.0.0​
- Use this [VS code extension](https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi) to see the errors in the downgraded YAML (v3.0)​
- Manually fix the errors​
- mostly related to `examples` <--> `example` interchange​
- or some 3.1 fields that are not supported in 3.0​ (comment them out)
2. Generate proto files
- Install the `openapi-generator-cli.jar` using the installation procedure mentioned [here](https://openapi-generator.tech/docs/installation#jar).
- Generate the proto files using the following command
```sh
$ java -jar openapi-generator-cli.jar generate -i MEC033_IoT.yaml -g protobuf-schema -o proto3/ --package-name mec033
```
3. Carefully inspect the generated `.proto` files for any inconsistencies. Some of the things to look out for:
- Proto3 generated files for enumerations, structures containing allOf, oneOf, anyOf etc. may need to be touched manually
- Check that all the nested models are being _imported_ correctly in their parent models
- Remove redundant proto files
4. Validate protobuf schema by generating code from proto3 descriptions in different languages. See [this section](#code-generation-from-proto3) for more details.
# Code Generation from proto3
Below are some code generation examples for Python, 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 commands from the root of the directory containing this README that you are reading.
- Models:
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs ./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./proto3 --python_out=./python-stubs --grpc_python_out=./python-stubs ./proto3/services/reg_dev_service.proto
```
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs --grpc_python_out=./python-stubs ./proto3/services/reg_iot_plat_service.proto
```
The above command will generate four files for the IoT service:
- _reg_dev_service_pb2.py_ and _reg_iot_plat_service_pb2.py: containing the python data models used in the IoT service file
- _reg_dev_service_pb2_grpc.py_ and _reg_iot_plat_service_pb2_grpc.py: containing all the classes and functions needed for the supported HTTP methods in the IoT 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 = "./mec033.services.IoTservice";` in all .proto files like this:
```Go
...
syntax = "proto3";
package mec033.services.IoTservice;
option go_package = "./mec033.services.IoTservice";
import public "models/<xyz>.proto";
...
```
5. Generate Go code for models and services
```sh
$ mkdir go-stubs
$ protoc --go_out=./go-stubs ./proto3/models/* -I./proto3
$ protoc --go_out=./go-stubs ./proto3/services/* --go-grpc_out=go-stubs -I./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.
> And the `reg_dev_service_grpc.pb.go` will contain the stubs for the methods defined in the `IoT_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./proto3 --ruby_out=ruby-stubs ./proto3/models/*
```
Run the following command to generate `reg_dev_service_pb.rb` and `reg_dev_service_grpc_pb.rb` files, containing stub and service classes for the endpoints and methods defined in MEC033 IoT service.
```sh
$ grpc_tools_ruby_protoc -I./proto3 --ruby_out=ruby-stubs --grpc_out=ruby-stubs ./proto3/services/*
```
\ No newline at end of file
# 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
README.md
models/addresses.proto
models/device_info.proto
models/device_specific_message_formats.proto
models/downlink_info.proto
models/end_point_info.proto
models/event_msg.proto
models/impl_specific_info.proto
models/interface_descriptor.proto
models/iot_platform_info.proto
models/key_value_pair.proto
models/mb_transport_info.proto
models/o_auth2_info.proto
models/problem_details.proto
models/registereddevices_get200_response.proto
models/registereddevices_post_request.proto
models/registerediotplatforms_by_id_get200_response.proto
models/registerediotplatforms_post_request.proto
models/security_info.proto
models/serializer_type.proto
models/traffic_filter.proto
models/traffic_rule_descriptor.proto
models/transport_info.proto
models/transport_type.proto
models/tunnel_info.proto
models/uplink_msg.proto
services/reg_dev_service.proto
services/reg_iot_plat_service.proto
6.6.0
\ No newline at end of file
# gPRC for mec033
ETSI GS MEC 033 IoT 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/gs033-iot-api](https://forge.etsi.org/rep/mec/gs033-iot-api/)
## Usage
Below are some code generation examples for Python, 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 commands from the root of the directory containing this README that you are reading.
- Models:
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs ./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./proto3 --python_out=./python-stubs --grpc_python_out=./python-stubs ./proto3/services/reg_dev_service.proto
```
```sh
$ python -m grpc_tools.protoc -I./proto3 --python_out=./python-stubs --grpc_python_out=./python-stubs ./proto3/services/reg_iot_plat_service.proto
```
The above command will generate four files for the IoT service:
- _reg_dev_service_pb2.py_ and _reg_iot_plat_service_pb2.py: containing the python data models used in the IoT service file
- _reg_dev_service_pb2_grpc.py_ and _reg_iot_plat_service_pb2_grpc.py: containing all the classes and functions needed for the supported HTTP methods in the IoT 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 = "./mec033.services.IoTservice";` in all .proto files like this:
```Go
...
syntax = "proto3";
package mec033.services.IoTservice;
option go_package = "./mec033.services.IoTservice";
import public "models/<xyz>.proto";
...
```
5. Generate Go code for models and services
```sh
$ mkdir go-stubs
$ protoc --go_out=./go-stubs ./proto3/models/* -I./proto3
$ protoc --go_out=./go-stubs ./proto3/services/* --go-grpc_out=go-stubs -I./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.
> And the `reg_dev_service_grpc.pb.go` will contain the stubs for the methods defined in the `IoT_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./proto3 --ruby_out=ruby-stubs ./proto3/models/*
```
Run the following command to generate `reg_dev_service_pb.rb` and `reg_dev_service_grpc_pb.rb` files, containing stub and service classes for the endpoints and methods defined in MEC033 IoT service.
```sh
$ grpc_tools_ruby_protoc -I./proto3 --ruby_out=ruby-stubs --grpc_out=ruby-stubs ./proto3/services/*
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
message Addresses {
// Host portion of the address.
string host = 3208616;
// Port portion of the address.
int32 port = 3446913;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
import public "models/device_specific_message_formats.proto";
import public "models/downlink_info.proto";
import public "models/key_value_pair.proto";
import public "models/traffic_rule_descriptor.proto";
message DeviceInfo {
// Information needed for secondary authentication of the IoT device to the data network - see ETSI TS 129 561 [i.4] and ETSI TS 129 061 [i.5] for 5G and LTE procedures, respectively. This attribute is implementation dependent and should be logically linked to the identifiers of the IoT device listed hereafter.
string deviceAuthenticationInfo = 231010367;
// Additional information about the IoT device. This attribute is implementation dependent and may be expressed as an array of keyvalue pairs.
repeated KeyValuePair deviceMetadata = 227391580;
// GPSI of the IoT device if 5G-enabled (see note 1).
string gpsi = 3179775;
// PEI of the IoT device if 5G-enabled (see note 1).
string pei = 110868;
// SUPI of the IoT device if 5G-enabled (see note 1).
string supi = 3541979;
// MSISDN of the IoT device if LTE-enabled (see note 1).
string msisdn = 528072231;
// IMEI of the IoT device if LTE-enabled (see note 1).
string imei = 3236040;
// IMSI of the IoT device if LTE-enabled (see note 1).
string imsi = 3236474;
// ICCID of the IoT device (see note 1).
string iccid = 100017508;
// Human-readable identifier of the IoT device.
string deviceId = 35449363;
// MEC traffic rules the IoT device is requested to be associated to (see note 2). The data type definition is as per ETSI GS MEC 010-2 [i.6].
repeated TrafficRuleDescriptor requestedMecTrafficRule = 447629606;
// IoT platform to which the IoT device is requested to be associated to (see note 2).
string requestedIotPlatformId = 382142773;
// User transport to which the IoT device is requested to be associated to (see note 2).
string requestedUserTransportId = 440692748;
DeviceSpecificMessageFormats deviceSpecificMessageFormats = 503076127;
DownlinkInfo downlinkInfo = 457334378;
// Client-side SSL/TLS certificate to be used by the MEC IoTS to interact with the user transport provided by the associated IoT platform in case the MEC IoTS acts on behalf of the IoT device.
string clientCertificate = 55457997;
// Indication whether the IoT device has a valid associated traffic rule (TRUE) or not (FALSE). See note 3.
bool enabled = 535852225;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
import public "models/event_msg.proto";
import public "models/uplink_msg.proto";
message DeviceSpecificMessageFormats {
EventMsg eventMsgFormat = 357883555;
UplinkMsg uplinkMsgFormat = 410143422;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
message DownlinkInfo {
// Topic associated to the IoT device. This topic should be used by an end IoT application to send downlink data to the IoT device.
string downlinkTopic = 228920053;
// UDP port to be used by the MEC IoTS for the outgoing downlink packets towards the IoT device. In case a default value is used, this attribute is optional.
int32 devicePort = 244191224;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
import public "models/addresses.proto";
message EndPointInfo {
// Entry point information of the service as string, formatted according to URI syntax (see IETF RFC 3986 [8]). Shall be used for REST APIs. See note.
repeated string uris = 3598471;
// Fully Qualified Domain Name of the service. See note.
repeated string fqdn = 3150485;
repeated Addresses addresses = 337673123;
// Entry point information of the service in a format defined by an implementation, or in an external specification. See note.
string alternative = 196794451;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
import public "models/serializer_type.proto";
message EventMsg {
// Topic where the message containing application-specific information should be published.
string eventTopic = 437189302;
SerializerType selectedSerializer = 278593909;
// Indication whether to include the IP address of the IoT device (TRUE) or not (FALSE).
bool includeDeviceAddr = 312382002;
// Indication whether to include the metadata about the IoT device (TRUE) or not (FALSE).
bool includeDeviceMetadata = 228401774;
// Indication whether to include the PEI of the IoT device (TRUE) or not (FALSE).
bool includePei = 303285069;
// Indication whether to include the SUPI of the IoT device (TRUE) or not (FALSE).
bool includeSupi = 275136675;
// Indication whether to include the IMEI of the IoT device (TRUE) or not (FALSE).
bool includeImei = 274830736;
// Indication whether to include the IMSI of the IoT device (TRUE) or not (FALSE).
bool includeImsi = 274831170;
// Indication whether to include the ICCID of the IoT device (TRUE) or not (FALSE).
bool includeIccid = 70481508;
// Indication whether to include the human-readable identified of the IoT device (TRUE) or not (FALSE).
bool includeDeviceId = 501908777;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
message ImplSpecificInfo {
// Topics used to publish events related to the established session between the IoT device(s) and the end IoT application(s) on the user transport.
repeated string eventTopics = 131095646;
// Topics used to publish data generated by the IoT device(s) on the user transport, in order to be consumed by the end IoT application(s).
repeated string uplinkTopics = 68167016;
// Topics used to publish data generated by the IoT applications(s) on the user transport, in order to be consumed by the end IoT device(s).
repeated string downlinkTopics = 117199843;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
import public "models/tunnel_info.proto";
message InterfaceDescriptor {
// Type of interface: TUNNEL, MAC, IP, etc.
enum InterfaceTypeEnum {
InterfaceTypeEnum_TUNNEL = 0;
InterfaceTypeEnum_MAC = 1;
InterfaceTypeEnum_IP = 2;
}
InterfaceTypeEnum interfaceType = 516041747;
TunnelInfo tunnelInfo = 458558157;
// If the interface type is MAC, the source address identifies the MAC address of the interface.
string srcMACAddress = 190916442;
// If the interface type is MAC, the destination address identifies the MAC address of the destination. Only used for dstInterface.
string dstMACAddress = 439157945;
// If the interface type is IP, the destination address identifies the IP address of the destination. Only used for dstInterface.
string dstIPAddress = 303696043;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
import public "models/mb_transport_info.proto";
import public "models/transport_info.proto";
message IotPlatformInfo {
// Identifier of the IoT platform.
string iotPlatformId = 298034279;
// Information about the user transport(s) provided by the IoT platform.
repeated MBTransportInfo userTransportInfo = 317790572;
// Transport enabling access to vendor-specific services provided by the IoT platform. The data type definition is as per ETSI GS MEC 011 [i.2].
repeated TransportInfo customServicesTransportInfo = 456179513;
// Indication whether the IoT platform is capable of providing user transports and vendor-specific services (TRUE) or not (FALSE).
bool enabled = 535852225;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
message KeyValuePair {
string key = 106079;
string value = 111972721;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
import public "models/end_point_info.proto";
import public "models/impl_specific_info.proto";
import public "models/security_info.proto";
import public "models/transport_type.proto";
message MBTransportInfo {
// The identifier of this transport as per ETSI GS MEC 011 [i.2].
string id = 3355;
// The name of this transport as per ETSI GS MEC 011 [i.2].
string name = 3373707;
// Human-readable description of this transport as per ETSI GS MEC 011 [i.2].
string description = 113933319;
TransportType type = 3575610;
// The name of the protocol used. Being the transport of MB_TOPIC_BASED type, this attribute should be typically set to \"MQTT\" or \"AMQP.\"
string protocol = 452292969;
// The version of the protocol used as per ETSI GS MEC 011 [i.2].
string version = 351608024;
EndPointInfo endpoint = 130489752;
SecurityInfo security = 412251969;
ImplSpecificInfo implSpecificInfo = 109027520;
}
/*
ETSI GS MEC 033 IoT API
ETSI GS MEC 033 IoT API described using OpenAPI.
The version of the OpenAPI document: 3.1.1
Contact: cti_support@etsi.org
Generated by OpenAPI Generator: https://openapi-generator.tech
*/
syntax = "proto3";
package mec033;
message MBTransportInfoImplSpecificInfo {
// Topics used to publish events related to the established session between the IoT device(s) and the end IoT application(s) on the user transport.
repeated string eventTopics = 131095646;
// Topics used to publish data generated by the IoT device(s) on the user transport, in order to be consumed by the end IoT application(s).
repeated string uplinkTopics = 68167016;
// Topics used to publish data generated by the IoT applications(s) on the user transport, in order to be consumed by the end IoT device(s).
repeated string downlinkTopics = 117199843;
}