...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package alert
18
19
20
21
22 import (
23 "fmt"
24
25 "github.com/go-openapi/runtime"
26 "github.com/go-openapi/strfmt"
27 )
28
29
30 func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
31 return &Client{transport: transport, formats: formats}
32 }
33
34
37 type Client struct {
38 transport runtime.ClientTransport
39 formats strfmt.Registry
40 }
41
42
43 type ClientOption func(*runtime.ClientOperation)
44
45
46 type ClientService interface {
47 GetAlerts(params *GetAlertsParams, opts ...ClientOption) (*GetAlertsOK, error)
48
49 PostAlerts(params *PostAlertsParams, opts ...ClientOption) (*PostAlertsOK, error)
50
51 SetTransport(transport runtime.ClientTransport)
52 }
53
54
57 func (a *Client) GetAlerts(params *GetAlertsParams, opts ...ClientOption) (*GetAlertsOK, error) {
58
59 if params == nil {
60 params = NewGetAlertsParams()
61 }
62 op := &runtime.ClientOperation{
63 ID: "getAlerts",
64 Method: "GET",
65 PathPattern: "/alerts",
66 ProducesMediaTypes: []string{"application/json"},
67 ConsumesMediaTypes: []string{"application/json"},
68 Schemes: []string{"http"},
69 Params: params,
70 Reader: &GetAlertsReader{formats: a.formats},
71 Context: params.Context,
72 Client: params.HTTPClient,
73 }
74 for _, opt := range opts {
75 opt(op)
76 }
77
78 result, err := a.transport.Submit(op)
79 if err != nil {
80 return nil, err
81 }
82 success, ok := result.(*GetAlertsOK)
83 if ok {
84 return success, nil
85 }
86
87
88 msg := fmt.Sprintf("unexpected success response for getAlerts: API contract not enforced by server. Client expected to get an error, but got: %T", result)
89 panic(msg)
90 }
91
92
95 func (a *Client) PostAlerts(params *PostAlertsParams, opts ...ClientOption) (*PostAlertsOK, error) {
96
97 if params == nil {
98 params = NewPostAlertsParams()
99 }
100 op := &runtime.ClientOperation{
101 ID: "postAlerts",
102 Method: "POST",
103 PathPattern: "/alerts",
104 ProducesMediaTypes: []string{"application/json"},
105 ConsumesMediaTypes: []string{"application/json"},
106 Schemes: []string{"http"},
107 Params: params,
108 Reader: &PostAlertsReader{formats: a.formats},
109 Context: params.Context,
110 Client: params.HTTPClient,
111 }
112 for _, opt := range opts {
113 opt(op)
114 }
115
116 result, err := a.transport.Submit(op)
117 if err != nil {
118 return nil, err
119 }
120 success, ok := result.(*PostAlertsOK)
121 if ok {
122 return success, nil
123 }
124
125
126 msg := fmt.Sprintf("unexpected success response for postAlerts: API contract not enforced by server. Client expected to get an error, but got: %T", result)
127 panic(msg)
128 }
129
130
131 func (a *Client) SetTransport(transport runtime.ClientTransport) {
132 a.transport = transport
133 }
134
View as plain text