X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=pkg%2Fcontrol%2Frestendpoint.go;fp=pkg%2Fcontrol%2Frestendpoint.go;h=b872c47c09b10f8facc2c24426353becbed66bd4;hb=afbf95f5756a7b781859beb1e68b41f7319ed208;hp=0000000000000000000000000000000000000000;hpb=1c72bbc4fc5a8ad674dff70abd4713f369ecb43b;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/restendpoint.go b/pkg/control/restendpoint.go new file mode 100644 index 0000000..b872c47 --- /dev/null +++ b/pkg/control/restendpoint.go @@ -0,0 +1,57 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ + +package control + +import ( + "fmt" + "strconv" + + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" +) + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +func ConstructEndpointAddresses(clientEndpoint models.SubscriptionParamsClientEndpoint) (string, string, error) { + + var HTTP_port int64 = *clientEndpoint.HTTPPort + var RMR_port int64 = *clientEndpoint.RMRPort + var host string = clientEndpoint.Host + var xAppHTTPEndPoint string + var xAppRMREndPoint string + + if *clientEndpoint.HTTPPort > 0 { + xAppHTTPEndPoint = host + ":" + strconv.FormatInt(*clientEndpoint.HTTPPort, 10) + } + if *clientEndpoint.RMRPort > 0 { + xAppRMREndPoint = host + ":" + strconv.FormatInt(*clientEndpoint.RMRPort, 10) + } + if host == "" || (HTTP_port == 0 && RMR_port == 0) { + err := fmt.Errorf("ClientEndpoint aprovided no PORT numbers") + return "INVALID_HTTP_ADDRESS:" + host + (string)(*clientEndpoint.HTTPPort), + "INVALID_RMR_ADDRESS:" + host + (string)(*clientEndpoint.RMRPort), + err + } + + xapp.Logger.Info("xAppHttpEndPoint=%v, xAppRrmEndPoint=%v", xAppHTTPEndPoint, xAppRMREndPoint) + + return xAppHTTPEndPoint, xAppRMREndPoint, nil +}