Add optional subscription ID 14/6014/1
authorMohamed Abukar <abukar.mohamed@nokia.com>
Thu, 6 May 2021 11:16:03 +0000 (11:16 +0000)
committerMohamed Abukar <abukar.mohamed@nokia.com>
Thu, 6 May 2021 11:17:59 +0000 (11:17 +0000)
Change-Id: I039ed2b92da32ea2ba4829658db175fc28bbc794
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
57 files changed:
api/xapp_rest_api.yaml
pkg/clientapi/common/common_client.go
pkg/clientapi/common/get_all_subscriptions_parameters.go
pkg/clientapi/common/get_all_subscriptions_responses.go
pkg/clientapi/common/subscribe_parameters.go
pkg/clientapi/common/subscribe_responses.go
pkg/clientapi/common/unsubscribe_parameters.go
pkg/clientapi/common/unsubscribe_responses.go
pkg/clientapi/r_i_c_subscription_client.go
pkg/clientapi/xapp/get_xapp_config_list_parameters.go
pkg/clientapi/xapp/get_xapp_config_list_responses.go
pkg/clientapi/xapp/xapp_client.go
pkg/clientmodel/action_definition.go
pkg/clientmodel/action_to_be_setup.go
pkg/clientmodel/actions_to_be_setup.go
pkg/clientmodel/config_metadata.go
pkg/clientmodel/event_trigger_definition.go
pkg/clientmodel/subscription_data.go
pkg/clientmodel/subscription_detail.go
pkg/clientmodel/subscription_details_list.go
pkg/clientmodel/subscription_instance.go
pkg/clientmodel/subscription_list.go
pkg/clientmodel/subscription_params.go
pkg/clientmodel/subscription_response.go
pkg/clientmodel/subsequent_action.go
pkg/clientmodel/x_app_config.go
pkg/clientmodel/xapp_config_list.go
pkg/models/action_definition.go
pkg/models/action_to_be_setup.go
pkg/models/actions_to_be_setup.go
pkg/models/config_metadata.go
pkg/models/event_trigger_definition.go
pkg/models/subscription_data.go
pkg/models/subscription_detail.go
pkg/models/subscription_details_list.go
pkg/models/subscription_instance.go
pkg/models/subscription_list.go
pkg/models/subscription_params.go
pkg/models/subscription_response.go
pkg/models/subsequent_action.go
pkg/models/x_app_config.go
pkg/models/xapp_config_list.go
pkg/restapi/doc.go
pkg/restapi/embedded_spec.go
pkg/restapi/operations/common/get_all_subscriptions.go
pkg/restapi/operations/common/get_all_subscriptions_responses.go
pkg/restapi/operations/common/subscribe.go
pkg/restapi/operations/common/subscribe_parameters.go
pkg/restapi/operations/common/subscribe_responses.go
pkg/restapi/operations/common/unsubscribe.go
pkg/restapi/operations/common/unsubscribe_parameters.go
pkg/restapi/operations/xapp/get_xapp_config_list.go
pkg/restapi/operations/xapp/get_xapp_config_list_responses.go
pkg/restapi/operations/xapp_framework_api.go
pkg/restapi/server.go
pkg/xapp/subscription.go
pkg/xapp/subscription_test.go

index 8554ca2..018a696 100755 (executable)
@@ -223,6 +223,9 @@ definitions:
       - RANFunctionID
       - SubscriptionDetails
     properties:
+      SubscriptionId:
+        type: string
+        description: Optional subscription ID (Submgr allocates if not given)
       ClientEndpoint:
         type: object
         description: xApp service address and port
index de4a4d7..e3642d4 100644 (file)
@@ -6,13 +6,14 @@ package common
 // 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}
 }
 
@@ -24,8 +25,19 @@ type Client struct {
        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
@@ -48,12 +60,18 @@ func (a *Client) Subscribe(params *SubscribeParams) (*SubscribeCreated, error) {
        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
@@ -76,12 +94,18 @@ func (a *Client) Unsubscribe(params *UnsubscribeParams) (*UnsubscribeNoContent,
        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
@@ -94,7 +118,7 @@ func (a *Client) GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAll
                Method:             "GET",
                PathPattern:        "/subscriptions",
                ProducesMediaTypes: []string{"application/json"},
-               ConsumesMediaTypes: []string{""},
+               ConsumesMediaTypes: []string{"application/json"},
                Schemes:            []string{"http"},
                Params:             params,
                Reader:             &GetAllSubscriptionsReader{formats: a.formats},
@@ -104,8 +128,14 @@ func (a *Client) GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAll
        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
index 1139f90..9caeeba 100644 (file)
@@ -13,8 +13,7 @@ import (
        "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
index 2c774de..807fc44 100644 (file)
@@ -10,10 +10,9 @@ import (
        "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.
@@ -24,14 +23,12 @@ type GetAllSubscriptionsReader struct {
 // 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 {
@@ -61,6 +58,10 @@ func (o *GetAllSubscriptionsOK) Error() string {
        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
index 81ad7b3..1447a0f 100644 (file)
@@ -13,10 +13,9 @@ import (
        "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
index 5fb377d..db86016 100644 (file)
@@ -10,10 +10,9 @@ import (
        "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.
@@ -24,21 +23,18 @@ type SubscribeReader struct {
 // 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 {
@@ -68,6 +64,10 @@ func (o *SubscribeCreated) Error() string {
        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)
index 6d32e7e..95c03e0 100644 (file)
@@ -13,8 +13,7 @@ import (
        "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
index 8d6b470..276c05c 100644 (file)
@@ -9,8 +9,7 @@ import (
        "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.
@@ -21,21 +20,18 @@ type UnsubscribeReader struct {
 // 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 {
index d5df71c..47b7c1c 100644 (file)
@@ -8,8 +8,7 @@ package clientapi
 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"
@@ -57,11 +56,8 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *RICSubscri
 
        cli := new(RICSubscription)
        cli.Transport = transport
-
        cli.Common = common.New(transport, formats)
-
        cli.Xapp = xapp.New(transport, formats)
-
        return cli
 }
 
@@ -106,9 +102,9 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
 
 // 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
 }
@@ -116,9 +112,6 @@ type RICSubscription struct {
 // 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)
-
 }
index b577424..0dd891b 100644 (file)
@@ -13,8 +13,7 @@ import (
        "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
index 3ddd2fb..ed07aed 100644 (file)
@@ -10,10 +10,9 @@ import (
        "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.
@@ -24,14 +23,12 @@ type GetXappConfigListReader struct {
 // 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 {
@@ -61,6 +58,10 @@ func (o *GetXappConfigListOK) Error() string {
        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
index a914611..fd20c51 100644 (file)
@@ -6,13 +6,14 @@ package xapp
 // 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}
 }
 
@@ -24,8 +25,15 @@ type Client struct {
        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
@@ -38,7 +46,7 @@ func (a *Client) GetXappConfigList(params *GetXappConfigListParams) (*GetXappCon
                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},
@@ -48,8 +56,14 @@ func (a *Client) GetXappConfigList(params *GetXappConfigListParams) (*GetXappCon
        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
index 54ca9d2..71851c2 100644 (file)
@@ -6,12 +6,12 @@ package clientmodel
 // 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 {
 
index 88a0b4b..a72a9e2 100644 (file)
@@ -8,14 +8,14 @@ package clientmodel
 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 {
 
index 397022e..6bffaac 100644 (file)
@@ -8,13 +8,13 @@ package clientmodel
 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
 
index c75f0d1..2755a2a 100644 (file)
@@ -8,14 +8,14 @@ package clientmodel
 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 {
 
index b9c82a6..a4bbd60 100644 (file)
@@ -6,12 +6,12 @@ package clientmodel
 // 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 {
 
index deeddca..92d7165 100644 (file)
@@ -8,13 +8,13 @@ package clientmodel
 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 {
 
index f7a7f1d..0a66540 100644 (file)
@@ -6,14 +6,14 @@ package clientmodel
 // 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 {
 
index fbb3fa7..9d4f60d 100644 (file)
@@ -8,13 +8,13 @@ package clientmodel
 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
 
index 7853a3b..2d8ba46 100644 (file)
@@ -6,14 +6,14 @@ package clientmodel
 // 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 {
 
index e5b7479..59a4570 100644 (file)
@@ -8,13 +8,13 @@ package clientmodel
 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
 
index 68e3072..fdd41ca 100644 (file)
@@ -6,14 +6,14 @@ package clientmodel
 // 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 {
 
@@ -34,6 +34,9 @@ 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
@@ -141,6 +144,7 @@ func (m *SubscriptionParams) UnmarshalBinary(b []byte) error {
 }
 
 // SubscriptionParamsClientEndpoint xApp service address and port
+//
 // swagger:model SubscriptionParamsClientEndpoint
 type SubscriptionParamsClientEndpoint struct {
 
index 2714b5b..d325629 100644 (file)
@@ -8,14 +8,14 @@ package clientmodel
 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 {
 
index b0c8a0f..d9184e3 100644 (file)
@@ -8,14 +8,14 @@ package clientmodel
 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 {
 
index b744f3f..1536ae8 100644 (file)
@@ -6,14 +6,14 @@ package clientmodel
 // 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 {
 
index 758b7ec..9f0a8c7 100644 (file)
@@ -8,13 +8,13 @@ package clientmodel
 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
 
index 740196f..cef3607 100644 (file)
@@ -6,12 +6,12 @@ package models
 // 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 {
 
index be945b0..3ee10a4 100644 (file)
@@ -8,14 +8,14 @@ package models
 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 {
 
index d6ba1a7..f900148 100644 (file)
@@ -8,13 +8,13 @@ package models
 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
 
index f564287..f2b30e6 100644 (file)
@@ -8,14 +8,14 @@ package models
 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 {
 
index 944614f..6316e4a 100644 (file)
@@ -6,12 +6,12 @@ package models
 // 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 {
 
index 5d665c0..c22db46 100644 (file)
@@ -8,13 +8,13 @@ package models
 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 {
 
index c592c53..ee474a8 100644 (file)
@@ -6,14 +6,14 @@ package models
 // 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 {
 
index 583da99..c52b06b 100644 (file)
@@ -8,13 +8,13 @@ package models
 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
 
index 19c0afe..6c98abd 100644 (file)
@@ -6,14 +6,14 @@ package models
 // 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 {
 
index 5059e21..b622142 100644 (file)
@@ -8,13 +8,13 @@ package models
 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
 
index dc57dee..5616e98 100644 (file)
@@ -6,14 +6,14 @@ package models
 // 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 {
 
@@ -34,6 +34,9 @@ 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
@@ -141,6 +144,7 @@ func (m *SubscriptionParams) UnmarshalBinary(b []byte) error {
 }
 
 // SubscriptionParamsClientEndpoint xApp service address and port
+//
 // swagger:model SubscriptionParamsClientEndpoint
 type SubscriptionParamsClientEndpoint struct {
 
index c62b4f1..97c937e 100644 (file)
@@ -8,14 +8,14 @@ package models
 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 {
 
index c8468c5..694725e 100644 (file)
@@ -8,14 +8,14 @@ package models
 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 {
 
index 076e314..f1ec552 100644 (file)
@@ -6,14 +6,14 @@ package models
 // 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 {
 
index e57ed02..050538b 100644 (file)
@@ -8,13 +8,13 @@ package models
 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
 
index c73c1aa..0886c5c 100644 (file)
@@ -1,24 +1,21 @@
 // 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
index b031520..7ddaba9 100644 (file)
@@ -349,6 +349,10 @@ func init() {
         },
         "SubscriptionDetails": {
           "$ref": "#/definitions/SubscriptionDetailsList"
+        },
+        "SubscriptionId": {
+          "description": "Optional subscription ID (Submgr allocates if not given)",
+          "type": "string"
         }
       }
     },
@@ -774,6 +778,32 @@ func init() {
         },
         "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
         }
       }
     },
index 59efa4c..af640e6 100644 (file)
@@ -8,7 +8,7 @@ package common
 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
index d1e8f0a..16ec29d 100644 (file)
@@ -10,7 +10,7 @@ import (
 
        "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
index 49bd617..17d19da 100644 (file)
@@ -8,7 +8,7 @@ package common
 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
index 7749315..ae5c234 100644 (file)
@@ -12,7 +12,7 @@ import (
        "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
index fc5515c..4af5582 100644 (file)
@@ -10,7 +10,7 @@ import (
 
        "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
index 84dac86..a8efd36 100644 (file)
@@ -8,7 +8,7 @@ package common
 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
index 19f5111..4458fb1 100644 (file)
@@ -10,8 +10,7 @@ import (
 
        "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
index 9fc02d3..1d0c141 100644 (file)
@@ -8,7 +8,7 @@ package xapp
 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
index bddbfea..96c663f 100644 (file)
@@ -10,7 +10,7 @@ import (
 
        "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
index e16707e..83f3bb5 100644 (file)
@@ -10,13 +10,13 @@ import (
        "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"
@@ -32,26 +32,30 @@ func NewXappFrameworkAPI(spec *loads.Document) *XappFrameworkAPI {
                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")
                }),
        }
 }
@@ -78,12 +82,15 @@ type XappFrameworkAPI struct {
        // 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
@@ -94,11 +101,14 @@ type XappFrameworkAPI struct {
        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()
@@ -156,7 +166,6 @@ func (o *XappFrameworkAPI) Validate() error {
        if o.JSONProducer == nil {
                unregistered = append(unregistered, "JSONProducer")
        }
-
        if o.XMLProducer == nil {
                unregistered = append(unregistered, "XMLProducer")
        }
@@ -164,15 +173,12 @@ func (o *XappFrameworkAPI) Validate() error {
        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")
        }
@@ -191,28 +197,22 @@ func (o *XappFrameworkAPI) ServeErrorFor(operationID string) func(http.ResponseW
 
 // 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 {
@@ -220,22 +220,18 @@ func (o *XappFrameworkAPI) ConsumersFor(mediaTypes []string) map[string]runtime.
                }
        }
        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 {
@@ -243,7 +239,6 @@ func (o *XappFrameworkAPI) ProducersFor(mediaTypes []string) map[string]runtime.
                }
        }
        return result
-
 }
 
 // HandlerFor gets a http.Handler for the provided operation method and path
@@ -273,7 +268,6 @@ func (o *XappFrameworkAPI) Context() *middleware.Context {
 
 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)
        }
@@ -282,22 +276,18 @@ func (o *XappFrameworkAPI) initHandlerCache() {
                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
@@ -327,3 +317,15 @@ func (o *XappFrameworkAPI) RegisterConsumer(mediaType string, consumer runtime.C
 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)
+       }
+}
index 23fda83..e4647a2 100644 (file)
@@ -133,7 +133,6 @@ func (s *Server) SetAPI(api *operations.XappFrameworkAPI) {
        }
 
        s.api = api
-       s.api.Logger = log.Printf
        s.handler = configureAPI(api)
 }
 
@@ -174,8 +173,6 @@ func (s *Server) Serve() (err error) {
        go handleInterrupt(once, s)
 
        servers := []*http.Server{}
-       wg.Add(1)
-       go s.handleShutdown(wg, &servers)
 
        if s.hasScheme(schemeUnix) {
                domainSocket := new(http.Server)
@@ -252,7 +249,7 @@ func (s *Server) Serve() (err error) {
                        // 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
@@ -293,7 +290,7 @@ func (s *Server) Serve() (err error) {
                // 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 == "" {
@@ -325,6 +322,9 @@ func (s *Server) Serve() (err error) {
                }(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig))
        }
 
+       wg.Add(1)
+       go s.handleShutdown(wg, &servers)
+
        wg.Wait()
        return nil
 }
@@ -420,6 +420,9 @@ func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server)
        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]
index a7e7a3c..6a6983c 100755 (executable)
@@ -119,6 +119,7 @@ func (r *Subscriber) Listen(createSubscription SubscriptionHandler, getSubscript
        // 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)
                        }
@@ -128,6 +129,7 @@ func (r *Subscriber) Listen(createSubscription SubscriptionHandler, getSubscript
        // 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()
                        }
index 72c5bc7..39a5d93 100755 (executable)
@@ -8,8 +8,8 @@ package xapp
 
 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"
@@ -18,21 +18,21 @@ import (
 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
@@ -61,20 +61,60 @@ func TestSubscriptionHandling(t *testing.T) {
                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,
                                                },
                                        },
                                },
@@ -109,7 +149,7 @@ func processSubscriptions(subscriptionId string) {
                SubscriptionInstances: []*models.SubscriptionInstance{
                        {
                                RequestorID: &reqId,
-                               InstanceID: &instanceId,
+                               InstanceID:  &instanceId,
                        },
                },
        }