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.
19 This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 platform project (RICP).
22 ==================================================================================
25 Mnemonic: httpgetter.go
26 Abstract: HTTPgetter NBI implementation
27 Simple HTTP getter solution.
35 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
37 "routing-manager/pkg/rpe"
38 "routing-manager/pkg/rtmgr"
39 "routing-manager/pkg/sdl"
44 type HttpGetter struct {
46 FetchAllXApps FetchAllXAppsHandler
49 func NewHttpGetter() *HttpGetter {
50 instance := new(HttpGetter)
51 instance.FetchAllXApps = fetchAllXApps
55 var myClient = &http.Client{Timeout: 15 * time.Second}
57 func fetchAllXApps(xmurl string) (*[]rtmgr.XApp, error) {
58 xapp.Logger.Info("Invoked httpGetter.fetchXappList: " + xmurl)
59 r, err := myClient.Get(xmurl)
65 if r.StatusCode == 200 {
66 xapp.Logger.Debug("http client raw response: %v", r)
67 var xApps []rtmgr.XApp
68 err = json.NewDecoder(r.Body).Decode(&xApps)
70 xapp.Logger.Warn("Json decode failed: " + err.Error())
72 xapp.Logger.Info("HTTP GET: OK")
73 xapp.Logger.Debug("httpGetter.fetchXappList returns: %v", xApps)
76 xapp.Logger.Warn("httpGetter got an unexpected http status code: %v", r.StatusCode)
80 func (g *HttpGetter) Initialize(xmurl string, nbiif string, fileName string, configfile string, e2murl string,
81 sdlEngine sdl.Engine, rpeEngine rpe.Engine, m *sync.Mutex) error {
85 func (g *HttpGetter) Terminate() error {