Enhancements of REST-based E2 subscription interface
[ric-plt/xapp-frame.git] / pkg / clientapi / common / common_client.go
index 8db6f11..de4a4d7 100644 (file)
@@ -24,6 +24,34 @@ type Client struct {
        formats   strfmt.Registry
 }
 
+/*
+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 params == nil {
+               params = NewSubscribeParams()
+       }
+
+       result, err := a.transport.Submit(&runtime.ClientOperation{
+               ID:                 "Subscribe",
+               Method:             "POST",
+               PathPattern:        "/subscriptions",
+               ProducesMediaTypes: []string{"application/json"},
+               ConsumesMediaTypes: []string{"application/json"},
+               Schemes:            []string{"http"},
+               Params:             params,
+               Reader:             &SubscribeReader{formats: a.formats},
+               Context:            params.Context,
+               Client:             params.HTTPClient,
+       })
+       if err != nil {
+               return nil, err
+       }
+       return result.(*SubscribeCreated), nil
+
+}
+
 /*
 Unsubscribe unsubscribes x2 a p events from subscription manager
 */
@@ -52,6 +80,34 @@ func (a *Client) Unsubscribe(params *UnsubscribeParams) (*UnsubscribeNoContent,
 
 }
 
+/*
+GetAllSubscriptions returns list of subscriptions
+*/
+func (a *Client) GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAllSubscriptionsOK, error) {
+       // TODO: Validate the params before sending
+       if params == nil {
+               params = NewGetAllSubscriptionsParams()
+       }
+
+       result, err := a.transport.Submit(&runtime.ClientOperation{
+               ID:                 "getAllSubscriptions",
+               Method:             "GET",
+               PathPattern:        "/subscriptions",
+               ProducesMediaTypes: []string{"application/json"},
+               ConsumesMediaTypes: []string{""},
+               Schemes:            []string{"http"},
+               Params:             params,
+               Reader:             &GetAllSubscriptionsReader{formats: a.formats},
+               Context:            params.Context,
+               Client:             params.HTTPClient,
+       })
+       if err != nil {
+               return nil, err
+       }
+       return result.(*GetAllSubscriptionsOK), nil
+
+}
+
 // SetTransport changes the transport on the client
 func (a *Client) SetTransport(transport runtime.ClientTransport) {
        a.transport = transport