Add mep agent lib and sample app
[ealt-edge.git] / mep / mepagent / pkg / model / instance.go
1 /*
2  *  Copyright 2020 Huawei Technologies Co., Ltd.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17 // define the type information
18 package model
19
20 type AppInstanceInfo struct {
21         AppInstanceId                            string                                    `yaml:"appInstanceId" json:"appInstanceId"`
22         MepServerIP                              string                                    `yaml:"mepServerIP" json:"mepServerIP"`
23         MepServerPORT                            string                                    `yaml:"mepServerPORT" json:"mepServerPORT"`
24         ServiceInfoPosts                         []ServiceInfoPost                         `yaml:"serviceInfoPosts" json:"serviceInfoPosts"`
25         SerAvailabilityNotificationSubscriptions []SerAvailabilityNotificationSubscription `yaml:"serAvailabilityNotificationSubscriptions" json:"serAvailabilityNotificationSubscriptions"`
26 }
27
28 type ServiceInfoPost struct {
29         SerInstanceId     string         `yaml:"serInstanceId" json:"serInstanceId"`
30         SerName           string         `yaml:"serName" json:"serName"`
31         SerCategory       CategoryRef    `yaml:"serCategory" json:"serCategory"`
32         Version           string         `yaml:"version" json:"version"`
33         State             ServiceState   `yaml:"state" json:"state"`
34         TransportId       string         `yaml:"transportId" json:"transportId"`
35         TransportInfo     TransportInfo  `yaml:"transportInfo" json:"transportInfo"`
36         Serializer        SerializerType `yaml:"serializer" json:"serializer"`
37         ScopeOfLocality   LocalityType   `yaml:"scopeOfLocality" json:"scopeOfLocality"`
38         ConsumedLocalOnly bool           `yaml:"consumedLocalOnly" json:"consumedLocalOnly"`
39         IsLocal           bool           `yaml:"isLocal" json:"isLocal"`
40 }
41
42 type CategoryRef struct {
43         Href    string `yaml:"href" json:"href"`
44         Id      string `yaml:"id" json:"id"`
45         Name    string `yaml:"name" json:"name"`
46         Version string `yaml:"version" json:"version"`
47 }
48
49 type ServiceState string
50
51 const (
52         ACTIVE   ServiceState = "ACTIVE"
53         INACTIVE ServiceState = "INACTIVE"
54 )
55
56 type TransportInfo struct {
57         Id               string           `yaml:"id" json:"id"`
58         Name             string           `yaml:"name" json:"name"`
59         Description      string           `yaml:"description" json:"description"`
60         TransportType    TransportType    `yaml:"type" json:"type"`
61         Protocol         string           `yaml:"protocol" json:"protocol"`
62         Version          string           `yaml:"version" json:"version"`
63         Endpoint         EndPointInfoUris `yaml:"endpoint" json:"endpoint"`
64         Security         SecurityInfo     `yaml:"security" json:"security"`
65         ImplSpecificInfo ImplSpecificInfo `yaml:"implSpecificInfo" json:"implSpecificInfo"`
66 }
67
68 type TransportType string
69
70 const (
71         REST_HTTP      TransportType = "REST_HTTP"
72         MB_TOPIC_BASED TransportType = "MB_TOPIC_BASED"
73         MB_ROUTING     TransportType = "MB_ROUTING"
74         MB_PUBSUB      TransportType = "MB_PUBSUB"
75         RPC            TransportType = "RPC"
76         RPC_STREAMING  TransportType = "RPC_STREAMING"
77         WEBSOCKET      TransportType = "WEBSOCKET"
78 )
79
80 type EndPointInfoUris struct {
81         Uris []string `yaml:"uris" json:"uris"`
82 }
83
84 type SecurityInfo struct {
85         OAuth2Info SecurityInfoOAuth2Info `yaml:"oAuth2Info" json:"oAuth2Info"`
86 }
87
88 type SecurityInfoOAuth2Info struct {
89         GrantTypes    []SecurityInfoOAuth2InfoGrantType `yaml:"grantTypes" json:"grantTypes"`
90         TokenEndpoint string                            `yaml:"tokenEndpoint" json:"tokenEndpoint"`
91 }
92
93 type SecurityInfoOAuth2InfoGrantType string
94
95 const (
96         AUTHORIZATION_CODE SecurityInfoOAuth2InfoGrantType = "OAUTH2_AUTHORIZATION_CODE"
97         IMPLICIT_GRANT     SecurityInfoOAuth2InfoGrantType = "OAUTH2_IMPLICIT_GRANT"
98         RESOURCE_OWNER     SecurityInfoOAuth2InfoGrantType = "OAUTH2_RESOURCE_OWNER"
99         CLIENT_CREDENTIALS SecurityInfoOAuth2InfoGrantType = "OAUTH2_CLIENT_CREDENTIALS"
100 )
101
102 type ImplSpecificInfo struct {
103 }
104
105 type SerializerType string
106
107 const (
108         JSON      SerializerType = "JSON"
109         XML       SerializerType = "XML"
110         PROTOBUF3 SerializerType = "PROTOBUF3"
111 )
112
113 type LocalityType string
114
115 const (
116         MEC_SYSTEM LocalityType = "MEC_SYSTEM"
117         MEC_HOST   LocalityType = "MEC_HOST"
118         NFVI_POP   LocalityType = "NFVI_POP"
119         ZONE       LocalityType = "ZONE"
120         ZONE_GROUP LocalityType = "ZONE_GROUP"
121         NFVI_NODE  LocalityType = "NFVI_NODE"
122 )
123
124 type SerAvailabilityNotificationSubscription struct {
125         SubscriptionType  string                                                   `yaml:"subscriptionType" json:"subscriptionType"`
126         CallbackReference string                                                   `yaml:"callbackReference" json:"callbackReference"`
127         Links             Self                                                     `yaml:"links" json:"links"`
128         FilteringCriteria SerAvailabilityNotificationSubscriptionFilteringCriteria `yaml:"filteringCriteria" json:"filteringCriteria"`
129 }
130
131 type Self struct {
132         Self LinkType `yaml:"self" json:"self"`
133 }
134
135 type LinkType struct {
136         Href string `yaml:"href" json:"href"`
137 }
138
139 type SerAvailabilityNotificationSubscriptionFilteringCriteria struct {
140         SerInstanceIds []string       `yaml:"serInstanceIds" json:"serInstanceIds"`
141         SerNames       []string       `yaml:"serNames" json:"serNames"`
142         SerCategories  []CategoryRef  `yaml:"serCategories" json:"serCategories"`
143         States         []ServiceState `yaml:"states" json:"states"`
144         IsLocal        bool           `yaml:"isLocal" json:"isLocal"`
145 }