1 // Package providermanagementapi provides primitives to interact with the openapi HTTP API.
3 // Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT.
4 package providermanagementapi
17 "github.com/deepmap/oapi-codegen/pkg/runtime"
20 // RequestEditorFn is the function signature for the RequestEditor callback function
21 type RequestEditorFn func(ctx context.Context, req *http.Request) error
23 // Doer performs HTTP requests.
25 // The standard http.Client implements this interface.
26 type HttpRequestDoer interface {
27 Do(req *http.Request) (*http.Response, error)
30 // Client which conforms to the OpenAPI3 specification for this service.
32 // The endpoint of the server conforming to this interface, with scheme,
33 // https://api.deepmap.com for example. This can contain a path relative
34 // to the server, such as https://api.deepmap.com/dev-test, and all the
35 // paths in the swagger spec will be appended to the server.
38 // Doer for performing requests, typically a *http.Client with any
39 // customized settings, such as certificate chains.
40 Client HttpRequestDoer
42 // A list of callbacks for modifying requests which are generated before sending over
44 RequestEditors []RequestEditorFn
47 // ClientOption allows setting custom parameters during construction
48 type ClientOption func(*Client) error
50 // Creates a new Client, with reasonable defaults
51 func NewClient(server string, opts ...ClientOption) (*Client, error) {
52 // create a client with sane default values
56 // mutate client and add all optional params
57 for _, o := range opts {
58 if err := o(&client); err != nil {
62 // ensure the server URL always has a trailing slash
63 if !strings.HasSuffix(client.Server, "/") {
66 // create httpClient, if not already present
67 if client.Client == nil {
68 client.Client = &http.Client{}
73 // WithHTTPClient allows overriding the default Doer, which is
74 // automatically created using http.Client. This is useful for tests.
75 func WithHTTPClient(doer HttpRequestDoer) ClientOption {
76 return func(c *Client) error {
82 // WithRequestEditorFn allows setting up a callback function, which will be
83 // called right before sending the request. This can be used to mutate the request.
84 func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
85 return func(c *Client) error {
86 c.RequestEditors = append(c.RequestEditors, fn)
91 // The interface specification for the client above.
92 type ClientInterface interface {
93 // PostRegistrations request with any body
94 PostRegistrationsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
96 PostRegistrations(ctx context.Context, body PostRegistrationsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
98 // DeleteRegistrationsRegistrationId request
99 DeleteRegistrationsRegistrationId(ctx context.Context, registrationId string, reqEditors ...RequestEditorFn) (*http.Response, error)
101 // ModifyIndApiProviderEnrolment request with any body
102 ModifyIndApiProviderEnrolmentWithBody(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
104 // PutRegistrationsRegistrationId request with any body
105 PutRegistrationsRegistrationIdWithBody(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
107 PutRegistrationsRegistrationId(ctx context.Context, registrationId string, body PutRegistrationsRegistrationIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
110 func (c *Client) PostRegistrationsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
111 req, err := NewPostRegistrationsRequestWithBody(c.Server, contentType, body)
115 req = req.WithContext(ctx)
116 if err := c.applyEditors(ctx, req, reqEditors); err != nil {
119 return c.Client.Do(req)
122 func (c *Client) PostRegistrations(ctx context.Context, body PostRegistrationsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
123 req, err := NewPostRegistrationsRequest(c.Server, body)
127 req = req.WithContext(ctx)
128 if err := c.applyEditors(ctx, req, reqEditors); err != nil {
131 return c.Client.Do(req)
134 func (c *Client) DeleteRegistrationsRegistrationId(ctx context.Context, registrationId string, reqEditors ...RequestEditorFn) (*http.Response, error) {
135 req, err := NewDeleteRegistrationsRegistrationIdRequest(c.Server, registrationId)
139 req = req.WithContext(ctx)
140 if err := c.applyEditors(ctx, req, reqEditors); err != nil {
143 return c.Client.Do(req)
146 func (c *Client) ModifyIndApiProviderEnrolmentWithBody(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
147 req, err := NewModifyIndApiProviderEnrolmentRequestWithBody(c.Server, registrationId, contentType, body)
151 req = req.WithContext(ctx)
152 if err := c.applyEditors(ctx, req, reqEditors); err != nil {
155 return c.Client.Do(req)
158 func (c *Client) PutRegistrationsRegistrationIdWithBody(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
159 req, err := NewPutRegistrationsRegistrationIdRequestWithBody(c.Server, registrationId, contentType, body)
163 req = req.WithContext(ctx)
164 if err := c.applyEditors(ctx, req, reqEditors); err != nil {
167 return c.Client.Do(req)
170 func (c *Client) PutRegistrationsRegistrationId(ctx context.Context, registrationId string, body PutRegistrationsRegistrationIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
171 req, err := NewPutRegistrationsRegistrationIdRequest(c.Server, registrationId, body)
175 req = req.WithContext(ctx)
176 if err := c.applyEditors(ctx, req, reqEditors); err != nil {
179 return c.Client.Do(req)
182 // NewPostRegistrationsRequest calls the generic PostRegistrations builder with application/json body
183 func NewPostRegistrationsRequest(server string, body PostRegistrationsJSONRequestBody) (*http.Request, error) {
184 var bodyReader io.Reader
185 buf, err := json.Marshal(body)
189 bodyReader = bytes.NewReader(buf)
190 return NewPostRegistrationsRequestWithBody(server, "application/json", bodyReader)
193 // NewPostRegistrationsRequestWithBody generates requests for PostRegistrations with any type of body
194 func NewPostRegistrationsRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
197 serverURL, err := url.Parse(server)
202 operationPath := fmt.Sprintf("/registrations")
203 if operationPath[0] == '/' {
204 operationPath = "." + operationPath
207 queryURL, err := serverURL.Parse(operationPath)
212 req, err := http.NewRequest("POST", queryURL.String(), body)
217 req.Header.Add("Content-Type", contentType)
222 // NewDeleteRegistrationsRegistrationIdRequest generates requests for DeleteRegistrationsRegistrationId
223 func NewDeleteRegistrationsRegistrationIdRequest(server string, registrationId string) (*http.Request, error) {
226 var pathParam0 string
228 pathParam0, err = runtime.StyleParamWithLocation("simple", false, "registrationId", runtime.ParamLocationPath, registrationId)
233 serverURL, err := url.Parse(server)
238 operationPath := fmt.Sprintf("/registrations/%s", pathParam0)
239 if operationPath[0] == '/' {
240 operationPath = "." + operationPath
243 queryURL, err := serverURL.Parse(operationPath)
248 req, err := http.NewRequest("DELETE", queryURL.String(), nil)
256 // NewModifyIndApiProviderEnrolmentRequestWithBody generates requests for ModifyIndApiProviderEnrolment with any type of body
257 func NewModifyIndApiProviderEnrolmentRequestWithBody(server string, registrationId string, contentType string, body io.Reader) (*http.Request, error) {
260 var pathParam0 string
262 pathParam0, err = runtime.StyleParamWithLocation("simple", false, "registrationId", runtime.ParamLocationPath, registrationId)
267 serverURL, err := url.Parse(server)
272 operationPath := fmt.Sprintf("/registrations/%s", pathParam0)
273 if operationPath[0] == '/' {
274 operationPath = "." + operationPath
277 queryURL, err := serverURL.Parse(operationPath)
282 req, err := http.NewRequest("PATCH", queryURL.String(), body)
287 req.Header.Add("Content-Type", contentType)
292 // NewPutRegistrationsRegistrationIdRequest calls the generic PutRegistrationsRegistrationId builder with application/json body
293 func NewPutRegistrationsRegistrationIdRequest(server string, registrationId string, body PutRegistrationsRegistrationIdJSONRequestBody) (*http.Request, error) {
294 var bodyReader io.Reader
295 buf, err := json.Marshal(body)
299 bodyReader = bytes.NewReader(buf)
300 return NewPutRegistrationsRegistrationIdRequestWithBody(server, registrationId, "application/json", bodyReader)
303 // NewPutRegistrationsRegistrationIdRequestWithBody generates requests for PutRegistrationsRegistrationId with any type of body
304 func NewPutRegistrationsRegistrationIdRequestWithBody(server string, registrationId string, contentType string, body io.Reader) (*http.Request, error) {
307 var pathParam0 string
309 pathParam0, err = runtime.StyleParamWithLocation("simple", false, "registrationId", runtime.ParamLocationPath, registrationId)
314 serverURL, err := url.Parse(server)
319 operationPath := fmt.Sprintf("/registrations/%s", pathParam0)
320 if operationPath[0] == '/' {
321 operationPath = "." + operationPath
324 queryURL, err := serverURL.Parse(operationPath)
329 req, err := http.NewRequest("PUT", queryURL.String(), body)
334 req.Header.Add("Content-Type", contentType)
339 func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
340 for _, r := range c.RequestEditors {
341 if err := r(ctx, req); err != nil {
345 for _, r := range additionalEditors {
346 if err := r(ctx, req); err != nil {
353 // ClientWithResponses builds on ClientInterface to offer response payloads
354 type ClientWithResponses struct {
358 // NewClientWithResponses creates a new ClientWithResponses, which wraps
359 // Client with return type handling
360 func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
361 client, err := NewClient(server, opts...)
365 return &ClientWithResponses{client}, nil
368 // WithBaseURL overrides the baseURL.
369 func WithBaseURL(baseURL string) ClientOption {
370 return func(c *Client) error {
371 newBaseURL, err := url.Parse(baseURL)
375 c.Server = newBaseURL.String()
380 // ClientWithResponsesInterface is the interface specification for the client with responses above.
381 type ClientWithResponsesInterface interface {
382 // PostRegistrations request with any body
383 PostRegistrationsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostRegistrationsResponse, error)
385 PostRegistrationsWithResponse(ctx context.Context, body PostRegistrationsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostRegistrationsResponse, error)
387 // DeleteRegistrationsRegistrationId request
388 DeleteRegistrationsRegistrationIdWithResponse(ctx context.Context, registrationId string, reqEditors ...RequestEditorFn) (*DeleteRegistrationsRegistrationIdResponse, error)
390 // ModifyIndApiProviderEnrolment request with any body
391 ModifyIndApiProviderEnrolmentWithBodyWithResponse(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ModifyIndApiProviderEnrolmentResponse, error)
393 // PutRegistrationsRegistrationId request with any body
394 PutRegistrationsRegistrationIdWithBodyWithResponse(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutRegistrationsRegistrationIdResponse, error)
396 PutRegistrationsRegistrationIdWithResponse(ctx context.Context, registrationId string, body PutRegistrationsRegistrationIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutRegistrationsRegistrationIdResponse, error)
399 type PostRegistrationsResponse struct {
401 HTTPResponse *http.Response
402 JSON201 *APIProviderEnrolmentDetails
405 // Status returns HTTPResponse.Status
406 func (r PostRegistrationsResponse) Status() string {
407 if r.HTTPResponse != nil {
408 return r.HTTPResponse.Status
410 return http.StatusText(0)
413 // StatusCode returns HTTPResponse.StatusCode
414 func (r PostRegistrationsResponse) StatusCode() int {
415 if r.HTTPResponse != nil {
416 return r.HTTPResponse.StatusCode
421 type DeleteRegistrationsRegistrationIdResponse struct {
423 HTTPResponse *http.Response
426 // Status returns HTTPResponse.Status
427 func (r DeleteRegistrationsRegistrationIdResponse) Status() string {
428 if r.HTTPResponse != nil {
429 return r.HTTPResponse.Status
431 return http.StatusText(0)
434 // StatusCode returns HTTPResponse.StatusCode
435 func (r DeleteRegistrationsRegistrationIdResponse) StatusCode() int {
436 if r.HTTPResponse != nil {
437 return r.HTTPResponse.StatusCode
442 type ModifyIndApiProviderEnrolmentResponse struct {
444 HTTPResponse *http.Response
445 JSON200 *APIProviderEnrolmentDetails
448 // Status returns HTTPResponse.Status
449 func (r ModifyIndApiProviderEnrolmentResponse) Status() string {
450 if r.HTTPResponse != nil {
451 return r.HTTPResponse.Status
453 return http.StatusText(0)
456 // StatusCode returns HTTPResponse.StatusCode
457 func (r ModifyIndApiProviderEnrolmentResponse) StatusCode() int {
458 if r.HTTPResponse != nil {
459 return r.HTTPResponse.StatusCode
464 type PutRegistrationsRegistrationIdResponse struct {
466 HTTPResponse *http.Response
467 JSON200 *APIProviderEnrolmentDetails
470 // Status returns HTTPResponse.Status
471 func (r PutRegistrationsRegistrationIdResponse) Status() string {
472 if r.HTTPResponse != nil {
473 return r.HTTPResponse.Status
475 return http.StatusText(0)
478 // StatusCode returns HTTPResponse.StatusCode
479 func (r PutRegistrationsRegistrationIdResponse) StatusCode() int {
480 if r.HTTPResponse != nil {
481 return r.HTTPResponse.StatusCode
486 // PostRegistrationsWithBodyWithResponse request with arbitrary body returning *PostRegistrationsResponse
487 func (c *ClientWithResponses) PostRegistrationsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostRegistrationsResponse, error) {
488 rsp, err := c.PostRegistrationsWithBody(ctx, contentType, body, reqEditors...)
492 return ParsePostRegistrationsResponse(rsp)
495 func (c *ClientWithResponses) PostRegistrationsWithResponse(ctx context.Context, body PostRegistrationsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostRegistrationsResponse, error) {
496 rsp, err := c.PostRegistrations(ctx, body, reqEditors...)
500 return ParsePostRegistrationsResponse(rsp)
503 // DeleteRegistrationsRegistrationIdWithResponse request returning *DeleteRegistrationsRegistrationIdResponse
504 func (c *ClientWithResponses) DeleteRegistrationsRegistrationIdWithResponse(ctx context.Context, registrationId string, reqEditors ...RequestEditorFn) (*DeleteRegistrationsRegistrationIdResponse, error) {
505 rsp, err := c.DeleteRegistrationsRegistrationId(ctx, registrationId, reqEditors...)
509 return ParseDeleteRegistrationsRegistrationIdResponse(rsp)
512 // ModifyIndApiProviderEnrolmentWithBodyWithResponse request with arbitrary body returning *ModifyIndApiProviderEnrolmentResponse
513 func (c *ClientWithResponses) ModifyIndApiProviderEnrolmentWithBodyWithResponse(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ModifyIndApiProviderEnrolmentResponse, error) {
514 rsp, err := c.ModifyIndApiProviderEnrolmentWithBody(ctx, registrationId, contentType, body, reqEditors...)
518 return ParseModifyIndApiProviderEnrolmentResponse(rsp)
521 // PutRegistrationsRegistrationIdWithBodyWithResponse request with arbitrary body returning *PutRegistrationsRegistrationIdResponse
522 func (c *ClientWithResponses) PutRegistrationsRegistrationIdWithBodyWithResponse(ctx context.Context, registrationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutRegistrationsRegistrationIdResponse, error) {
523 rsp, err := c.PutRegistrationsRegistrationIdWithBody(ctx, registrationId, contentType, body, reqEditors...)
527 return ParsePutRegistrationsRegistrationIdResponse(rsp)
530 func (c *ClientWithResponses) PutRegistrationsRegistrationIdWithResponse(ctx context.Context, registrationId string, body PutRegistrationsRegistrationIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutRegistrationsRegistrationIdResponse, error) {
531 rsp, err := c.PutRegistrationsRegistrationId(ctx, registrationId, body, reqEditors...)
535 return ParsePutRegistrationsRegistrationIdResponse(rsp)
538 // ParsePostRegistrationsResponse parses an HTTP response from a PostRegistrationsWithResponse call
539 func ParsePostRegistrationsResponse(rsp *http.Response) (*PostRegistrationsResponse, error) {
540 bodyBytes, err := ioutil.ReadAll(rsp.Body)
541 defer func() { _ = rsp.Body.Close() }()
546 response := &PostRegistrationsResponse{
552 case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201:
553 var dest APIProviderEnrolmentDetails
554 if err := json.Unmarshal(bodyBytes, &dest); err != nil {
557 response.JSON201 = &dest
564 // ParseDeleteRegistrationsRegistrationIdResponse parses an HTTP response from a DeleteRegistrationsRegistrationIdWithResponse call
565 func ParseDeleteRegistrationsRegistrationIdResponse(rsp *http.Response) (*DeleteRegistrationsRegistrationIdResponse, error) {
566 bodyBytes, err := ioutil.ReadAll(rsp.Body)
567 defer func() { _ = rsp.Body.Close() }()
572 response := &DeleteRegistrationsRegistrationIdResponse{
580 // ParseModifyIndApiProviderEnrolmentResponse parses an HTTP response from a ModifyIndApiProviderEnrolmentWithResponse call
581 func ParseModifyIndApiProviderEnrolmentResponse(rsp *http.Response) (*ModifyIndApiProviderEnrolmentResponse, error) {
582 bodyBytes, err := ioutil.ReadAll(rsp.Body)
583 defer func() { _ = rsp.Body.Close() }()
588 response := &ModifyIndApiProviderEnrolmentResponse{
594 case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
595 var dest APIProviderEnrolmentDetails
596 if err := json.Unmarshal(bodyBytes, &dest); err != nil {
599 response.JSON200 = &dest
606 // ParsePutRegistrationsRegistrationIdResponse parses an HTTP response from a PutRegistrationsRegistrationIdWithResponse call
607 func ParsePutRegistrationsRegistrationIdResponse(rsp *http.Response) (*PutRegistrationsRegistrationIdResponse, error) {
608 bodyBytes, err := ioutil.ReadAll(rsp.Body)
609 defer func() { _ = rsp.Body.Close() }()
614 response := &PutRegistrationsRegistrationIdResponse{
620 case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
621 var dest APIProviderEnrolmentDetails
622 if err := json.Unmarshal(bodyBytes, &dest); err != nil {
625 response.JSON200 = &dest