2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
23 "github.com/gorilla/mux"
24 cmap "github.com/orcaman/concurrent-map"
28 type CmdOptions struct {
34 type Resource struct {
37 HandlerFunc http.HandlerFunc
41 Name string `json:"name"`
42 Status string `json:"status"`
43 Version string `json:"version"`
44 Instances []XappInstance `json:"instances"`
47 type XappInstance struct {
48 Name string `json:"name"`
49 Status string `json:"status"`
51 Port int `json:"port"`
52 TxMessages []string `json:"txMessages"`
53 RxMessages []string `json:"rxMessages"`
56 type XappDeploy struct {
57 Name string `json:"name"`
58 ConfigName string `json:"configName, omitempty"`
59 Namespace string `json:"namespace, omitempty"`
60 ServiceName string `json:"serviceName, omitempty"`
61 ImageRepo string `json:"imageRepo, omitempty"`
62 Hostname string `json:"hostname, omitempty"`
65 type XappManager struct {
69 sd SubscriptionDispatcher
74 type ConfigMapper interface {
75 UploadConfig() (cfg []XAppConfig)
76 CreateConfigMap(r XAppConfig) (errList []CMError, err error)
77 UpdateConfigMap(r XAppConfig) (errList []CMError, err error)
78 DeleteConfigMap(r XAppConfig) (cm interface{}, err error)
79 PurgeConfigMap(m XappDeploy) (cm interface{}, err error)
80 RestoreConfigMap(m XappDeploy, cm interface{}) (err error)
81 ReadConfigMap(name string, ns string, c *interface{}) (err error)
82 ApplyConfigMap(r XAppConfig, action string) (err error)
83 GetMessages(name string) (msgs MessageTypes)
86 type Helmer interface {
89 Install(m XappDeploy) (xapp Xapp, err error)
90 Status(name string) (xapp Xapp, err error)
91 StatusAll() (xapps []Xapp, err error)
92 List() (xapps []string, err error)
93 Delete(name string) (xapp Xapp, err error)
103 type SubscriptionReq struct {
104 Id string `json:"id"`
105 TargetUrl string `json:"targetUrl"`
106 EventType string `json:"eventType"`
107 MaxRetries int `json:"maxRetries"`
108 RetryTimer int `json:"retryTimer"`
111 type SubscriptionResp struct {
112 Id string `json:"id"`
113 Version int `json:"version"`
114 EventType string `json:"eventType"`
117 type SubscriptionNotif struct {
118 Id string `json:"id"`
119 Version int `json:"version"`
120 EventType string `json:"eventType"`
121 XappData []Xapp `json:"xapp"`
124 type Subscription struct {
126 resp SubscriptionResp
129 type SubscriptionDispatcher struct {
131 subscriptions cmap.ConcurrentMap
136 type MessageTypes struct {
137 TxMessages []string `yaml:"txMessages"`
138 RxMessages []string `yaml:"rxMessages"`
141 type EventType string
144 Created EventType = "created"
145 Updated EventType = "updated"
146 Deleted EventType = "deleted"
150 MdclogErr = 1 //! Error level log entry
151 MdclogWarn = 2 //! Warning level log entry
152 MdclogInfo = 3 //! Info level log entry
153 MdclogDebug = 4 //! Debug level log entry