Add optional subscription ID
[ric-plt/xapp-frame.git] / pkg / clientapi / common / common_client.go
1 // Code generated by go-swagger; DO NOT EDIT.
2
3 package common
4
5 // This file was generated by the swagger tool.
6 // Editing this file might prove futile when you re-run the swagger generate command
7
8 import (
9         "fmt"
10
11         "github.com/go-openapi/runtime"
12         "github.com/go-openapi/strfmt"
13 )
14
15 // New creates a new common API client.
16 func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
17         return &Client{transport: transport, formats: formats}
18 }
19
20 /*
21 Client for common API
22 */
23 type Client struct {
24         transport runtime.ClientTransport
25         formats   strfmt.Registry
26 }
27
28 // ClientService is the interface for Client methods
29 type ClientService interface {
30         Subscribe(params *SubscribeParams) (*SubscribeCreated, error)
31
32         Unsubscribe(params *UnsubscribeParams) (*UnsubscribeNoContent, error)
33
34         GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAllSubscriptionsOK, error)
35
36         SetTransport(transport runtime.ClientTransport)
37 }
38
39 /*
40   Subscribe subscribes a list of x2 a p event triggers to receive messages sent by r a n
41 */
42 func (a *Client) Subscribe(params *SubscribeParams) (*SubscribeCreated, error) {
43         // TODO: Validate the params before sending
44         if params == nil {
45                 params = NewSubscribeParams()
46         }
47
48         result, err := a.transport.Submit(&runtime.ClientOperation{
49                 ID:                 "Subscribe",
50                 Method:             "POST",
51                 PathPattern:        "/subscriptions",
52                 ProducesMediaTypes: []string{"application/json"},
53                 ConsumesMediaTypes: []string{"application/json"},
54                 Schemes:            []string{"http"},
55                 Params:             params,
56                 Reader:             &SubscribeReader{formats: a.formats},
57                 Context:            params.Context,
58                 Client:             params.HTTPClient,
59         })
60         if err != nil {
61                 return nil, err
62         }
63         success, ok := result.(*SubscribeCreated)
64         if ok {
65                 return success, nil
66         }
67         // unexpected success response
68         // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
69         msg := fmt.Sprintf("unexpected success response for Subscribe: API contract not enforced by server. Client expected to get an error, but got: %T", result)
70         panic(msg)
71 }
72
73 /*
74   Unsubscribe unsubscribes x2 a p events from subscription manager
75 */
76 func (a *Client) Unsubscribe(params *UnsubscribeParams) (*UnsubscribeNoContent, error) {
77         // TODO: Validate the params before sending
78         if params == nil {
79                 params = NewUnsubscribeParams()
80         }
81
82         result, err := a.transport.Submit(&runtime.ClientOperation{
83                 ID:                 "Unsubscribe",
84                 Method:             "DELETE",
85                 PathPattern:        "/subscriptions/{subscriptionId}",
86                 ProducesMediaTypes: []string{"application/json"},
87                 ConsumesMediaTypes: []string{"application/json"},
88                 Schemes:            []string{"http"},
89                 Params:             params,
90                 Reader:             &UnsubscribeReader{formats: a.formats},
91                 Context:            params.Context,
92                 Client:             params.HTTPClient,
93         })
94         if err != nil {
95                 return nil, err
96         }
97         success, ok := result.(*UnsubscribeNoContent)
98         if ok {
99                 return success, nil
100         }
101         // unexpected success response
102         // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
103         msg := fmt.Sprintf("unexpected success response for Unsubscribe: API contract not enforced by server. Client expected to get an error, but got: %T", result)
104         panic(msg)
105 }
106
107 /*
108   GetAllSubscriptions returns list of subscriptions
109 */
110 func (a *Client) GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAllSubscriptionsOK, error) {
111         // TODO: Validate the params before sending
112         if params == nil {
113                 params = NewGetAllSubscriptionsParams()
114         }
115
116         result, err := a.transport.Submit(&runtime.ClientOperation{
117                 ID:                 "getAllSubscriptions",
118                 Method:             "GET",
119                 PathPattern:        "/subscriptions",
120                 ProducesMediaTypes: []string{"application/json"},
121                 ConsumesMediaTypes: []string{"application/json"},
122                 Schemes:            []string{"http"},
123                 Params:             params,
124                 Reader:             &GetAllSubscriptionsReader{formats: a.formats},
125                 Context:            params.Context,
126                 Client:             params.HTTPClient,
127         })
128         if err != nil {
129                 return nil, err
130         }
131         success, ok := result.(*GetAllSubscriptionsOK)
132         if ok {
133                 return success, nil
134         }
135         // unexpected success response
136         // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
137         msg := fmt.Sprintf("unexpected success response for getAllSubscriptions: API contract not enforced by server. Client expected to get an error, but got: %T", result)
138         panic(msg)
139 }
140
141 // SetTransport changes the transport on the client
142 func (a *Client) SetTransport(transport runtime.ClientTransport) {
143         a.transport = transport
144 }