- RANFunctionID
- SubscriptionDetails
properties:
+ SubscriptionId:
+ type: string
+ description: Optional subscription ID (Submgr allocates if not given)
ClientEndpoint:
type: object
description: xApp service address and port
// Editing this file might prove futile when you re-run the swagger generate command
import (
- "github.com/go-openapi/runtime"
+ "fmt"
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/runtime"
+ "github.com/go-openapi/strfmt"
)
// New creates a new common API client.
-func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
+func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
formats strfmt.Registry
}
+// ClientService is the interface for Client methods
+type ClientService interface {
+ Subscribe(params *SubscribeParams) (*SubscribeCreated, error)
+
+ Unsubscribe(params *UnsubscribeParams) (*UnsubscribeNoContent, error)
+
+ GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAllSubscriptionsOK, error)
+
+ SetTransport(transport runtime.ClientTransport)
+}
+
/*
-Subscribe subscribes a list of x2 a p event triggers to receive messages sent by r a n
+ Subscribe subscribes a list of x2 a p event triggers to receive messages sent by r a n
*/
func (a *Client) Subscribe(params *SubscribeParams) (*SubscribeCreated, error) {
// TODO: Validate the params before sending
if err != nil {
return nil, err
}
- return result.(*SubscribeCreated), nil
-
+ success, ok := result.(*SubscribeCreated)
+ if ok {
+ return success, nil
+ }
+ // unexpected success response
+ // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
+ msg := fmt.Sprintf("unexpected success response for Subscribe: API contract not enforced by server. Client expected to get an error, but got: %T", result)
+ panic(msg)
}
/*
-Unsubscribe unsubscribes x2 a p events from subscription manager
+ Unsubscribe unsubscribes x2 a p events from subscription manager
*/
func (a *Client) Unsubscribe(params *UnsubscribeParams) (*UnsubscribeNoContent, error) {
// TODO: Validate the params before sending
if err != nil {
return nil, err
}
- return result.(*UnsubscribeNoContent), nil
-
+ success, ok := result.(*UnsubscribeNoContent)
+ if ok {
+ return success, nil
+ }
+ // unexpected success response
+ // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
+ msg := fmt.Sprintf("unexpected success response for Unsubscribe: API contract not enforced by server. Client expected to get an error, but got: %T", result)
+ panic(msg)
}
/*
-GetAllSubscriptions returns list of subscriptions
+ GetAllSubscriptions returns list of subscriptions
*/
func (a *Client) GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAllSubscriptionsOK, error) {
// TODO: Validate the params before sending
Method: "GET",
PathPattern: "/subscriptions",
ProducesMediaTypes: []string{"application/json"},
- ConsumesMediaTypes: []string{""},
+ ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetAllSubscriptionsReader{formats: a.formats},
if err != nil {
return nil, err
}
- return result.(*GetAllSubscriptionsOK), nil
-
+ success, ok := result.(*GetAllSubscriptionsOK)
+ if ok {
+ return success, nil
+ }
+ // unexpected success response
+ // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
+ msg := fmt.Sprintf("unexpected success response for getAllSubscriptions: API contract not enforced by server. Client expected to get an error, but got: %T", result)
+ panic(msg)
}
// SetTransport changes the transport on the client
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
-
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/strfmt"
)
// NewGetAllSubscriptionsParams creates a new GetAllSubscriptionsParams object
"io"
"github.com/go-openapi/runtime"
+ "github.com/go-openapi/strfmt"
- strfmt "github.com/go-openapi/strfmt"
-
- clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
)
// GetAllSubscriptionsReader is a Reader for the GetAllSubscriptions structure.
// ReadResponse reads a server response into the received o.
func (o *GetAllSubscriptionsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
-
case 200:
result := NewGetAllSubscriptionsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
-
case 500:
result := NewGetAllSubscriptionsInternalServerError()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return fmt.Sprintf("[GET /subscriptions][%d] getAllSubscriptionsOK %+v", 200, o.Payload)
}
+func (o *GetAllSubscriptionsOK) GetPayload() clientmodel.SubscriptionList {
+ return o.Payload
+}
+
func (o *GetAllSubscriptionsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
+ "github.com/go-openapi/strfmt"
- strfmt "github.com/go-openapi/strfmt"
-
- clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
)
// NewSubscribeParams creates a new SubscribeParams object
"io"
"github.com/go-openapi/runtime"
+ "github.com/go-openapi/strfmt"
- strfmt "github.com/go-openapi/strfmt"
-
- clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
)
// SubscribeReader is a Reader for the Subscribe structure.
// ReadResponse reads a server response into the received o.
func (o *SubscribeReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
-
case 201:
result := NewSubscribeCreated()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
-
case 400:
result := NewSubscribeBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
-
case 500:
result := NewSubscribeInternalServerError()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return fmt.Sprintf("[POST /subscriptions][%d] subscribeCreated %+v", 201, o.Payload)
}
+func (o *SubscribeCreated) GetPayload() *clientmodel.SubscriptionResponse {
+ return o.Payload
+}
+
func (o *SubscribeCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(clientmodel.SubscriptionResponse)
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
-
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/strfmt"
)
// NewUnsubscribeParams creates a new UnsubscribeParams object
"fmt"
"github.com/go-openapi/runtime"
-
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/strfmt"
)
// UnsubscribeReader is a Reader for the Unsubscribe structure.
// ReadResponse reads a server response into the received o.
func (o *UnsubscribeReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
-
case 204:
result := NewUnsubscribeNoContent()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
-
case 400:
result := NewUnsubscribeBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
-
case 500:
result := NewUnsubscribeInternalServerError()
if err := result.readResponse(response, consumer, o.formats); err != nil {
import (
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
-
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/strfmt"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/common"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/xapp"
cli := new(RICSubscription)
cli.Transport = transport
-
cli.Common = common.New(transport, formats)
-
cli.Xapp = xapp.New(transport, formats)
-
return cli
}
// RICSubscription is a client for r i c subscription
type RICSubscription struct {
- Common *common.Client
+ Common common.ClientService
- Xapp *xapp.Client
+ Xapp xapp.ClientService
Transport runtime.ClientTransport
}
// SetTransport changes the transport on the client and all its subresources
func (c *RICSubscription) SetTransport(transport runtime.ClientTransport) {
c.Transport = transport
-
c.Common.SetTransport(transport)
-
c.Xapp.SetTransport(transport)
-
}
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
-
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/strfmt"
)
// NewGetXappConfigListParams creates a new GetXappConfigListParams object
"io"
"github.com/go-openapi/runtime"
+ "github.com/go-openapi/strfmt"
- strfmt "github.com/go-openapi/strfmt"
-
- clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
)
// GetXappConfigListReader is a Reader for the GetXappConfigList structure.
// ReadResponse reads a server response into the received o.
func (o *GetXappConfigListReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
-
case 200:
result := NewGetXappConfigListOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
-
case 500:
result := NewGetXappConfigListInternalServerError()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return fmt.Sprintf("[GET /config][%d] getXappConfigListOK %+v", 200, o.Payload)
}
+func (o *GetXappConfigListOK) GetPayload() clientmodel.XappConfigList {
+ return o.Payload
+}
+
func (o *GetXappConfigListOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
// Editing this file might prove futile when you re-run the swagger generate command
import (
- "github.com/go-openapi/runtime"
+ "fmt"
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/runtime"
+ "github.com/go-openapi/strfmt"
)
// New creates a new xapp API client.
-func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
+func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
formats strfmt.Registry
}
+// ClientService is the interface for Client methods
+type ClientService interface {
+ GetXappConfigList(params *GetXappConfigListParams) (*GetXappConfigListOK, error)
+
+ SetTransport(transport runtime.ClientTransport)
+}
+
/*
-GetXappConfigList returns the configuration of all xapps
+ GetXappConfigList returns the configuration of all xapps
*/
func (a *Client) GetXappConfigList(params *GetXappConfigListParams) (*GetXappConfigListOK, error) {
// TODO: Validate the params before sending
Method: "GET",
PathPattern: "/config",
ProducesMediaTypes: []string{"application/json", "application/xml"},
- ConsumesMediaTypes: []string{""},
+ ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetXappConfigListReader{formats: a.formats},
if err != nil {
return nil, err
}
- return result.(*GetXappConfigListOK), nil
-
+ success, ok := result.(*GetXappConfigListOK)
+ if ok {
+ return success, nil
+ }
+ // unexpected success response
+ // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
+ msg := fmt.Sprintf("unexpected success response for getXappConfigList: API contract not enforced by server. Client expected to get an error, but got: %T", result)
+ panic(msg)
}
// SetTransport changes the transport on the client
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// ActionDefinition E2SM Octet string. ActionDefinition is an OPTIONAL IE
+//
// swagger:model ActionDefinition
type ActionDefinition struct {
import (
"encoding/json"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// ActionToBeSetup action to be setup
+//
// swagger:model ActionToBeSetup
type ActionToBeSetup struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// ActionsToBeSetup actions to be setup
+//
// swagger:model ActionsToBeSetup
type ActionsToBeSetup []*ActionToBeSetup
import (
"encoding/json"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// ConfigMetadata config metadata
+//
// swagger:model ConfigMetadata
type ConfigMetadata struct {
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// EventTriggerDefinition E2SM Octet string
+//
// swagger:model EventTriggerDefinition
type EventTriggerDefinition struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SubscriptionData subscription data
+//
// swagger:model SubscriptionData
type SubscriptionData struct {
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionDetail subscription detail
+//
// swagger:model SubscriptionDetail
type SubscriptionDetail struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SubscriptionDetailsList subscription details list
+//
// swagger:model SubscriptionDetailsList
type SubscriptionDetailsList []*SubscriptionDetail
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionInstance subscription instance
+//
// swagger:model SubscriptionInstance
type SubscriptionInstance struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SubscriptionList A list of subscriptions
+//
// swagger:model SubscriptionList
type SubscriptionList []*SubscriptionData
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionParams subscription params
+//
// swagger:model SubscriptionParams
type SubscriptionParams struct {
// subscription details
// Required: true
SubscriptionDetails SubscriptionDetailsList `json:"SubscriptionDetails"`
+
+ // Optional subscription ID (Submgr allocates if not given)
+ SubscriptionID string `json:"SubscriptionId,omitempty"`
}
// Validate validates this subscription params
}
// SubscriptionParamsClientEndpoint xApp service address and port
+//
// swagger:model SubscriptionParamsClientEndpoint
type SubscriptionParamsClientEndpoint struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionResponse subscription response
+//
// swagger:model SubscriptionResponse
type SubscriptionResponse struct {
import (
"encoding/json"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubsequentAction SubsequentAction is an OPTIONAL IE
+//
// swagger:model SubsequentAction
type SubsequentAction struct {
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// XAppConfig x app config
+//
// swagger:model XAppConfig
type XAppConfig struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// XappConfigList xapp config list
+//
// swagger:model XappConfigList
type XappConfigList []*XAppConfig
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// ActionDefinition E2SM Octet string. ActionDefinition is an OPTIONAL IE
+//
// swagger:model ActionDefinition
type ActionDefinition struct {
import (
"encoding/json"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// ActionToBeSetup action to be setup
+//
// swagger:model ActionToBeSetup
type ActionToBeSetup struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// ActionsToBeSetup actions to be setup
+//
// swagger:model ActionsToBeSetup
type ActionsToBeSetup []*ActionToBeSetup
import (
"encoding/json"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// ConfigMetadata config metadata
+//
// swagger:model ConfigMetadata
type ConfigMetadata struct {
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// EventTriggerDefinition E2SM Octet string
+//
// swagger:model EventTriggerDefinition
type EventTriggerDefinition struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SubscriptionData subscription data
+//
// swagger:model SubscriptionData
type SubscriptionData struct {
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionDetail subscription detail
+//
// swagger:model SubscriptionDetail
type SubscriptionDetail struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SubscriptionDetailsList subscription details list
+//
// swagger:model SubscriptionDetailsList
type SubscriptionDetailsList []*SubscriptionDetail
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionInstance subscription instance
+//
// swagger:model SubscriptionInstance
type SubscriptionInstance struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SubscriptionList A list of subscriptions
+//
// swagger:model SubscriptionList
type SubscriptionList []*SubscriptionData
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionParams subscription params
+//
// swagger:model SubscriptionParams
type SubscriptionParams struct {
// subscription details
// Required: true
SubscriptionDetails SubscriptionDetailsList `json:"SubscriptionDetails"`
+
+ // Optional subscription ID (Submgr allocates if not given)
+ SubscriptionID string `json:"SubscriptionId,omitempty"`
}
// Validate validates this subscription params
}
// SubscriptionParamsClientEndpoint xApp service address and port
+//
// swagger:model SubscriptionParamsClientEndpoint
type SubscriptionParamsClientEndpoint struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubscriptionResponse subscription response
+//
// swagger:model SubscriptionResponse
type SubscriptionResponse struct {
import (
"encoding/json"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SubsequentAction SubsequentAction is an OPTIONAL IE
+//
// swagger:model SubsequentAction
type SubsequentAction struct {
// Editing this file might prove futile when you re-run the swagger generate command
import (
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// XAppConfig x app config
+//
// swagger:model XAppConfig
type XAppConfig struct {
import (
"strconv"
- strfmt "github.com/go-openapi/strfmt"
-
"github.com/go-openapi/errors"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// XappConfigList xapp config list
+//
// swagger:model XappConfigList
type XappConfigList []*XAppConfig
// Code generated by go-swagger; DO NOT EDIT.
-/*
-Package restapi RIC subscription
-This is the initial REST API for RIC subscription
-
-
- Schemes:
- http
- Host: hostname
- BasePath: /ric/v1
- Version: 0.0.1
- License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html
-
- Consumes:
- - application/json
-
- Produces:
- - application/json
- - application/xml
-
-swagger:meta
-*/
+// Package restapi RIC subscription
+//
+// This is the initial REST API for RIC subscription
+// Schemes:
+// http
+// Host: hostname
+// BasePath: /ric/v1
+// Version: 0.0.1
+// License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html
+//
+// Consumes:
+// - application/json
+//
+// Produces:
+// - application/json
+// - application/xml
+//
+// swagger:meta
package restapi
},
"SubscriptionDetails": {
"$ref": "#/definitions/SubscriptionDetailsList"
+ },
+ "SubscriptionId": {
+ "description": "Optional subscription ID (Submgr allocates if not given)",
+ "type": "string"
}
}
},
},
"SubscriptionDetails": {
"$ref": "#/definitions/SubscriptionDetailsList"
+ },
+ "SubscriptionId": {
+ "description": "Optional subscription ID (Submgr allocates if not given)",
+ "type": "string"
+ }
+ }
+ },
+ "SubscriptionParamsClientEndpoint": {
+ "description": "xApp service address and port",
+ "type": "object",
+ "properties": {
+ "HTTPPort": {
+ "description": "xApp HTTP service address port",
+ "type": "integer",
+ "maximum": 65535,
+ "minimum": 0
+ },
+ "Host": {
+ "description": "xApp service address name like 'service-ricxapp-xappname-http.ricxapp'",
+ "type": "string"
+ },
+ "RMRPort": {
+ "description": "xApp RMR service address port",
+ "type": "integer",
+ "maximum": 65535,
+ "minimum": 0
}
}
},
import (
"net/http"
- middleware "github.com/go-openapi/runtime/middleware"
+ "github.com/go-openapi/runtime/middleware"
)
// GetAllSubscriptionsHandlerFunc turns a function with the right signature into a get all subscriptions handler
"github.com/go-openapi/runtime"
- models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
)
// GetAllSubscriptionsOKCode is the HTTP code returned for type GetAllSubscriptionsOK
import (
"net/http"
- middleware "github.com/go-openapi/runtime/middleware"
+ "github.com/go-openapi/runtime/middleware"
)
// SubscribeHandlerFunc turns a function with the right signature into a subscribe handler
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
- models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
)
// NewSubscribeParams creates a new SubscribeParams object
"github.com/go-openapi/runtime"
- models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
)
// SubscribeCreatedCode is the HTTP code returned for type SubscribeCreated
import (
"net/http"
- middleware "github.com/go-openapi/runtime/middleware"
+ "github.com/go-openapi/runtime/middleware"
)
// UnsubscribeHandlerFunc turns a function with the right signature into a unsubscribe handler
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime/middleware"
-
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/strfmt"
)
// NewUnsubscribeParams creates a new UnsubscribeParams object
import (
"net/http"
- middleware "github.com/go-openapi/runtime/middleware"
+ "github.com/go-openapi/runtime/middleware"
)
// GetXappConfigListHandlerFunc turns a function with the right signature into a get xapp config list handler
"github.com/go-openapi/runtime"
- models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
)
// GetXappConfigListOKCode is the HTTP code returned for type GetXappConfigListOK
"net/http"
"strings"
- errors "github.com/go-openapi/errors"
- loads "github.com/go-openapi/loads"
- runtime "github.com/go-openapi/runtime"
- middleware "github.com/go-openapi/runtime/middleware"
- security "github.com/go-openapi/runtime/security"
- spec "github.com/go-openapi/spec"
- strfmt "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/loads"
+ "github.com/go-openapi/runtime"
+ "github.com/go-openapi/runtime/middleware"
+ "github.com/go-openapi/runtime/security"
+ "github.com/go-openapi/spec"
+ "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/common"
defaultProduces: "application/json",
customConsumers: make(map[string]runtime.Consumer),
customProducers: make(map[string]runtime.Producer),
+ PreServerShutdown: func() {},
ServerShutdown: func() {},
spec: spec,
ServeError: errors.ServeError,
BasicAuthenticator: security.BasicAuth,
APIKeyAuthenticator: security.APIKeyAuth,
BearerAuthenticator: security.BearerAuth,
- JSONConsumer: runtime.JSONConsumer(),
- JSONProducer: runtime.JSONProducer(),
- XMLProducer: runtime.XMLProducer(),
+
+ JSONConsumer: runtime.JSONConsumer(),
+
+ JSONProducer: runtime.JSONProducer(),
+ XMLProducer: runtime.XMLProducer(),
+
CommonSubscribeHandler: common.SubscribeHandlerFunc(func(params common.SubscribeParams) middleware.Responder {
- return middleware.NotImplemented("operation CommonSubscribe has not yet been implemented")
+ return middleware.NotImplemented("operation common.Subscribe has not yet been implemented")
}),
CommonUnsubscribeHandler: common.UnsubscribeHandlerFunc(func(params common.UnsubscribeParams) middleware.Responder {
- return middleware.NotImplemented("operation CommonUnsubscribe has not yet been implemented")
+ return middleware.NotImplemented("operation common.Unsubscribe has not yet been implemented")
}),
CommonGetAllSubscriptionsHandler: common.GetAllSubscriptionsHandlerFunc(func(params common.GetAllSubscriptionsParams) middleware.Responder {
- return middleware.NotImplemented("operation CommonGetAllSubscriptions has not yet been implemented")
+ return middleware.NotImplemented("operation common.GetAllSubscriptions has not yet been implemented")
}),
XappGetXappConfigListHandler: xapp.GetXappConfigListHandlerFunc(func(params xapp.GetXappConfigListParams) middleware.Responder {
- return middleware.NotImplemented("operation XappGetXappConfigList has not yet been implemented")
+ return middleware.NotImplemented("operation xapp.GetXappConfigList has not yet been implemented")
}),
}
}
// It has a default implementation in the security package, however you can replace it for your particular usage.
BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
- // JSONConsumer registers a consumer for a "application/json" mime type
+ // JSONConsumer registers a consumer for the following mime types:
+ // - application/json
JSONConsumer runtime.Consumer
- // JSONProducer registers a producer for a "application/json" mime type
+ // JSONProducer registers a producer for the following mime types:
+ // - application/json
JSONProducer runtime.Producer
- // XMLProducer registers a producer for a "application/xml" mime type
+ // XMLProducer registers a producer for the following mime types:
+ // - application/xml
XMLProducer runtime.Producer
// CommonSubscribeHandler sets the operation handler for the subscribe operation
CommonGetAllSubscriptionsHandler common.GetAllSubscriptionsHandler
// XappGetXappConfigListHandler sets the operation handler for the get xapp config list operation
XappGetXappConfigListHandler xapp.GetXappConfigListHandler
-
// ServeError is called when an error is received, there is a default handler
// but you can set your own with this
ServeError func(http.ResponseWriter, *http.Request, error)
+ // PreServerShutdown is called before the HTTP(S) server is shutdown
+ // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic
+ PreServerShutdown func()
+
// ServerShutdown is called when the HTTP(S) server is shut down and done
// handling all active connections and does not accept connections any more
ServerShutdown func()
if o.JSONProducer == nil {
unregistered = append(unregistered, "JSONProducer")
}
-
if o.XMLProducer == nil {
unregistered = append(unregistered, "XMLProducer")
}
if o.CommonSubscribeHandler == nil {
unregistered = append(unregistered, "common.SubscribeHandler")
}
-
if o.CommonUnsubscribeHandler == nil {
unregistered = append(unregistered, "common.UnsubscribeHandler")
}
-
if o.CommonGetAllSubscriptionsHandler == nil {
unregistered = append(unregistered, "common.GetAllSubscriptionsHandler")
}
-
if o.XappGetXappConfigListHandler == nil {
unregistered = append(unregistered, "xapp.GetXappConfigListHandler")
}
// AuthenticatorsFor gets the authenticators for the specified security schemes
func (o *XappFrameworkAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator {
-
return nil
-
}
// Authorizer returns the registered authorizer
func (o *XappFrameworkAPI) Authorizer() runtime.Authorizer {
-
return nil
-
}
-// ConsumersFor gets the consumers for the specified media types
+// ConsumersFor gets the consumers for the specified media types.
+// MIME type parameters are ignored here.
func (o *XappFrameworkAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer {
-
- result := make(map[string]runtime.Consumer)
+ result := make(map[string]runtime.Consumer, len(mediaTypes))
for _, mt := range mediaTypes {
switch mt {
-
case "application/json":
result["application/json"] = o.JSONConsumer
-
}
if c, ok := o.customConsumers[mt]; ok {
}
}
return result
-
}
-// ProducersFor gets the producers for the specified media types
+// ProducersFor gets the producers for the specified media types.
+// MIME type parameters are ignored here.
func (o *XappFrameworkAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer {
-
- result := make(map[string]runtime.Producer)
+ result := make(map[string]runtime.Producer, len(mediaTypes))
for _, mt := range mediaTypes {
switch mt {
-
case "application/json":
result["application/json"] = o.JSONProducer
-
case "application/xml":
result["application/xml"] = o.XMLProducer
-
}
if p, ok := o.customProducers[mt]; ok {
}
}
return result
-
}
// HandlerFor gets a http.Handler for the provided operation method and path
func (o *XappFrameworkAPI) initHandlerCache() {
o.Context() // don't care about the result, just that the initialization happened
-
if o.handlers == nil {
o.handlers = make(map[string]map[string]http.Handler)
}
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/subscriptions"] = common.NewSubscribe(o.context, o.CommonSubscribeHandler)
-
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/subscriptions/{subscriptionId}"] = common.NewUnsubscribe(o.context, o.CommonUnsubscribeHandler)
-
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/subscriptions"] = common.NewGetAllSubscriptions(o.context, o.CommonGetAllSubscriptionsHandler)
-
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/config"] = xapp.NewGetXappConfigList(o.context, o.XappGetXappConfigListHandler)
-
}
// Serve creates a http handler to serve the API over HTTP
func (o *XappFrameworkAPI) RegisterProducer(mediaType string, producer runtime.Producer) {
o.customProducers[mediaType] = producer
}
+
+// AddMiddlewareFor adds a http middleware to existing handler
+func (o *XappFrameworkAPI) AddMiddlewareFor(method, path string, builder middleware.Builder) {
+ um := strings.ToUpper(method)
+ if path == "/" {
+ path = ""
+ }
+ o.Init()
+ if h, ok := o.handlers[um][path]; ok {
+ o.handlers[method][path] = builder(h)
+ }
+}
}
s.api = api
- s.api.Logger = log.Printf
s.handler = configureAPI(api)
}
go handleInterrupt(once, s)
servers := []*http.Server{}
- wg.Add(1)
- go s.handleShutdown(wg, &servers)
if s.hasScheme(schemeUnix) {
domainSocket := new(http.Server)
// https://github.com/golang/go/tree/master/src/crypto/elliptic
CurvePreferences: []tls.CurveID{tls.CurveP256},
// Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility
- NextProtos: []string{"http/1.1", "h2"},
+ NextProtos: []string{"h2", "http/1.1"},
// https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols
MinVersion: tls.VersionTLS12,
// These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy
// call custom TLS configurator
configureTLS(httpsServer.TLSConfig)
- if len(httpsServer.TLSConfig.Certificates) == 0 {
+ if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil {
// after standard and custom config are passed, this ends up with no certificate
if s.TLSCertificate == "" {
if s.TLSCertificateKey == "" {
}(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig))
}
+ wg.Add(1)
+ go s.handleShutdown(wg, &servers)
+
wg.Wait()
return nil
}
ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout)
defer cancel()
+ // first execute the pre-shutdown hook
+ s.api.PreServerShutdown()
+
shutdownChan := make(chan bool)
for i := range servers {
server := servers[i]
// Subscription: Subscribe
api.CommonSubscribeHandler = common.SubscribeHandlerFunc(
func(params common.SubscribeParams) middleware.Responder {
+ Logger.Error("Subscribe: Params=%+v", params.SubscriptionParams)
if resp, err := createSubscription(params.SubscriptionParams); err == nil {
return common.NewSubscribeCreated().WithPayload(resp)
}
// Subscription: Unsubscribe
api.CommonUnsubscribeHandler = common.UnsubscribeHandlerFunc(
func(p common.UnsubscribeParams) middleware.Responder {
+ Logger.Error("Unsubscribe: SubscriptionID=%+v", p.SubscriptionID)
if err := delSubscription(p.SubscriptionID); err == nil {
return common.NewUnsubscribeNoContent()
}
import (
"fmt"
- "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
"github.com/stretchr/testify/assert"
"testing"
"time"
var (
suite *testing.T
- meid = "gnb123456"
- reqId = int64(1)
- seqId = int64(1)
- funId = int64(1)
- actionId = int64(1)
- actionType = "report"
+ meid = "gnb123456"
+ reqId = int64(1)
+ seqId = int64(1)
+ funId = int64(1)
+ actionId = int64(1)
+ actionType = "report"
subsequestActioType = "continue"
- timeToWait = "w10ms"
- direction = int64(0)
- procedureCode = int64(27)
- typeOfMessage = int64(1)
- subscriptionId = ""
- hPort = int64(8080)
- rPort = int64(4560)
- clientEndpoint = clientmodel.SubscriptionParamsClientEndpoint{Host: "localhost", HTTPPort: &hPort, RMRPort: &rPort}
+ timeToWait = "w10ms"
+ direction = int64(0)
+ procedureCode = int64(27)
+ typeOfMessage = int64(1)
+ subscriptionId = ""
+ hPort = int64(8080)
+ rPort = int64(4560)
+ clientEndpoint = clientmodel.SubscriptionParamsClientEndpoint{Host: "localhost", HTTPPort: &hPort, RMRPort: &rPort}
)
// Test cases
SubscriptionDetails: clientmodel.SubscriptionDetailsList{
&clientmodel.SubscriptionDetail{
RequestorID: &reqId,
- InstanceID: &seqId,
+ InstanceID: &seqId,
+ EventTriggers: &clientmodel.EventTriggerDefinition{
+ OctetString: "1234",
+ },
+ ActionToBeSetupList: clientmodel.ActionsToBeSetup{
+ &clientmodel.ActionToBeSetup{
+ ActionID: &actionId,
+ ActionType: &actionType,
+ ActionDefinition: &clientmodel.ActionDefinition{
+ OctetString: "5678",
+ },
+ SubsequentAction: &clientmodel.SubsequentAction{
+ SubsequentActionType: &subsequestActioType,
+ TimeToWait: &timeToWait,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ Subscription.SetResponseCB(func(resp *clientmodel.SubscriptionResponse) {
+ assert.Equal(t, len(resp.SubscriptionInstances), 1)
+ assert.Equal(t, *resp.SubscriptionInstances[0].RequestorID, int64(11))
+ assert.Equal(t, *resp.SubscriptionInstances[0].InstanceID, int64(22))
+ })
+
+ _, err := Subscription.Subscribe(&subscriptionParams)
+ assert.Equal(t, err, nil)
+}
+
+func TestSubscriptionWithClientProvidedIdHandling(t *testing.T) {
+ subscriptionParams := clientmodel.SubscriptionParams{
+ Meid: &meid,
+ RANFunctionID: &funId,
+ ClientEndpoint: &clientEndpoint,
+ SubscriptionID: "myxapp",
+ SubscriptionDetails: clientmodel.SubscriptionDetailsList{
+ &clientmodel.SubscriptionDetail{
+ RequestorID: &reqId,
+ InstanceID: &seqId,
EventTriggers: &clientmodel.EventTriggerDefinition{
OctetString: "1234",
},
ActionToBeSetupList: clientmodel.ActionsToBeSetup{
&clientmodel.ActionToBeSetup{
- ActionID: &actionId,
+ ActionID: &actionId,
ActionType: &actionType,
ActionDefinition: &clientmodel.ActionDefinition{
OctetString: "5678",
},
SubsequentAction: &clientmodel.SubsequentAction{
SubsequentActionType: &subsequestActioType,
- TimeToWait: &timeToWait,
+ TimeToWait: &timeToWait,
},
},
},
SubscriptionInstances: []*models.SubscriptionInstance{
{
RequestorID: &reqId,
- InstanceID: &instanceId,
+ InstanceID: &instanceId,
},
},
}