06d90462405e20cb11fa8e5d05d6dc7435b78c22
[govpp.git] / binapigen / vppapi / api.go
1 //  Copyright (c) 2020 Cisco and/or its affiliates.
2 //
3 //  Licensed under the Apache License, Version 2.0 (the "License");
4 //  you may not use this file except in compliance with the License.
5 //  You may obtain a copy of the License at:
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 //  Unless required by applicable law or agreed to in writing, software
10 //  distributed under the License is distributed on an "AS IS" BASIS,
11 //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 //  See the License for the specific language governing permissions and
13 //  limitations under the License.
14
15 package vppapi
16
17 type File struct {
18         Name string
19         Path string
20
21         CRC     string
22         Options map[string]string `json:",omitempty"`
23
24         Imports []string `json:",omitempty"`
25
26         AliasTypes  []AliasType  `json:",omitempty"`
27         EnumTypes   []EnumType   `json:",omitempty"`
28         StructTypes []StructType `json:",omitempty"`
29         UnionTypes  []UnionType  `json:",omitempty"`
30         Messages    []Message    `json:",omitempty"`
31         Service     *Service     `json:",omitempty"`
32 }
33
34 func (x File) Version() string {
35         if x.Options != nil {
36                 return x.Options[fileOptionVersion]
37         }
38         return ""
39 }
40
41 type AliasType struct {
42         Name   string
43         Type   string
44         Length int `json:",omitempty"`
45 }
46
47 type EnumType struct {
48         Name    string
49         Type    string
50         Entries []EnumEntry
51 }
52
53 type EnumEntry struct {
54         Name  string
55         Value uint32
56 }
57
58 type StructType struct {
59         Name   string
60         Fields []Field
61 }
62
63 type UnionType struct {
64         Name   string
65         Fields []Field
66 }
67
68 type Message struct {
69         Name   string
70         Fields []Field
71         CRC    string
72 }
73
74 type Field struct {
75         Name     string
76         Type     string
77         Length   int                    `json:",omitempty"`
78         Array    bool                   `json:",omitempty"`
79         SizeFrom string                 `json:",omitempty"`
80         Meta     map[string]interface{} `json:",omitempty"`
81 }
82
83 type Service struct {
84         RPCs []RPC `json:",omitempty"`
85 }
86
87 type RPC struct {
88         Name       string
89         RequestMsg string
90         ReplyMsg   string
91         Stream     bool     `json:",omitempty"`
92         StreamMsg  string   `json:",omitempty"`
93         Events     []string `json:",omitempty"`
94 }