// Package invokermanagementapi provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT. package invokermanagementapi import ( "bytes" "context" "encoding/json" "fmt" "io" "io/ioutil" "net/http" "net/url" "strings" "github.com/deepmap/oapi-codegen/pkg/runtime" ) // RequestEditorFn is the function signature for the RequestEditor callback function type RequestEditorFn func(ctx context.Context, req *http.Request) error // Doer performs HTTP requests. // // The standard http.Client implements this interface. type HttpRequestDoer interface { Do(req *http.Request) (*http.Response, error) } // Client which conforms to the OpenAPI3 specification for this service. type Client struct { // The endpoint of the server conforming to this interface, with scheme, // https://api.deepmap.com for example. This can contain a path relative // to the server, such as https://api.deepmap.com/dev-test, and all the // paths in the swagger spec will be appended to the server. Server string // Doer for performing requests, typically a *http.Client with any // customized settings, such as certificate chains. Client HttpRequestDoer // A list of callbacks for modifying requests which are generated before sending over // the network. RequestEditors []RequestEditorFn } // ClientOption allows setting custom parameters during construction type ClientOption func(*Client) error // Creates a new Client, with reasonable defaults func NewClient(server string, opts ...ClientOption) (*Client, error) { // create a client with sane default values client := Client{ Server: server, } // mutate client and add all optional params for _, o := range opts { if err := o(&client); err != nil { return nil, err } } // ensure the server URL always has a trailing slash if !strings.HasSuffix(client.Server, "/") { client.Server += "/" } // create httpClient, if not already present if client.Client == nil { client.Client = &http.Client{} } return &client, nil } // WithHTTPClient allows overriding the default Doer, which is // automatically created using http.Client. This is useful for tests. func WithHTTPClient(doer HttpRequestDoer) ClientOption { return func(c *Client) error { c.Client = doer return nil } } // WithRequestEditorFn allows setting up a callback function, which will be // called right before sending the request. This can be used to mutate the request. func WithRequestEditorFn(fn RequestEditorFn) ClientOption { return func(c *Client) error { c.RequestEditors = append(c.RequestEditors, fn) return nil } } // The interface specification for the client above. type ClientInterface interface { // PostOnboardedInvokers request with any body PostOnboardedInvokersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) PostOnboardedInvokers(ctx context.Context, body PostOnboardedInvokersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // DeleteOnboardedInvokersOnboardingId request DeleteOnboardedInvokersOnboardingId(ctx context.Context, onboardingId string, reqEditors ...RequestEditorFn) (*http.Response, error) // ModifyIndApiInvokeEnrolment request with any body ModifyIndApiInvokeEnrolmentWithBody(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) // PutOnboardedInvokersOnboardingId request with any body PutOnboardedInvokersOnboardingIdWithBody(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) PutOnboardedInvokersOnboardingId(ctx context.Context, onboardingId string, body PutOnboardedInvokersOnboardingIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) PostOnboardedInvokersWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewPostOnboardedInvokersRequestWithBody(c.Server, contentType, body) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) PostOnboardedInvokers(ctx context.Context, body PostOnboardedInvokersJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewPostOnboardedInvokersRequest(c.Server, body) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) DeleteOnboardedInvokersOnboardingId(ctx context.Context, onboardingId string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewDeleteOnboardedInvokersOnboardingIdRequest(c.Server, onboardingId) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) ModifyIndApiInvokeEnrolmentWithBody(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewModifyIndApiInvokeEnrolmentRequestWithBody(c.Server, onboardingId, contentType, body) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) PutOnboardedInvokersOnboardingIdWithBody(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewPutOnboardedInvokersOnboardingIdRequestWithBody(c.Server, onboardingId, contentType, body) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } func (c *Client) PutOnboardedInvokersOnboardingId(ctx context.Context, onboardingId string, body PutOnboardedInvokersOnboardingIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewPutOnboardedInvokersOnboardingIdRequest(c.Server, onboardingId, body) if err != nil { return nil, err } req = req.WithContext(ctx) if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } return c.Client.Do(req) } // NewPostOnboardedInvokersRequest calls the generic PostOnboardedInvokers builder with application/json body func NewPostOnboardedInvokersRequest(server string, body PostOnboardedInvokersJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) return NewPostOnboardedInvokersRequestWithBody(server, "application/json", bodyReader) } // NewPostOnboardedInvokersRequestWithBody generates requests for PostOnboardedInvokers with any type of body func NewPostOnboardedInvokersRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { var err error serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/onboardedInvokers") if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err } req.Header.Add("Content-Type", contentType) return req, nil } // NewDeleteOnboardedInvokersOnboardingIdRequest generates requests for DeleteOnboardedInvokersOnboardingId func NewDeleteOnboardedInvokersOnboardingIdRequest(server string, onboardingId string) (*http.Request, error) { var err error var pathParam0 string pathParam0, err = runtime.StyleParamWithLocation("simple", false, "onboardingId", runtime.ParamLocationPath, onboardingId) if err != nil { return nil, err } serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/onboardedInvokers/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } req, err := http.NewRequest("DELETE", queryURL.String(), nil) if err != nil { return nil, err } return req, nil } // NewModifyIndApiInvokeEnrolmentRequestWithBody generates requests for ModifyIndApiInvokeEnrolment with any type of body func NewModifyIndApiInvokeEnrolmentRequestWithBody(server string, onboardingId string, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string pathParam0, err = runtime.StyleParamWithLocation("simple", false, "onboardingId", runtime.ParamLocationPath, onboardingId) if err != nil { return nil, err } serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/onboardedInvokers/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } req, err := http.NewRequest("PATCH", queryURL.String(), body) if err != nil { return nil, err } req.Header.Add("Content-Type", contentType) return req, nil } // NewPutOnboardedInvokersOnboardingIdRequest calls the generic PutOnboardedInvokersOnboardingId builder with application/json body func NewPutOnboardedInvokersOnboardingIdRequest(server string, onboardingId string, body PutOnboardedInvokersOnboardingIdJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) return NewPutOnboardedInvokersOnboardingIdRequestWithBody(server, onboardingId, "application/json", bodyReader) } // NewPutOnboardedInvokersOnboardingIdRequestWithBody generates requests for PutOnboardedInvokersOnboardingId with any type of body func NewPutOnboardedInvokersOnboardingIdRequestWithBody(server string, onboardingId string, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string pathParam0, err = runtime.StyleParamWithLocation("simple", false, "onboardingId", runtime.ParamLocationPath, onboardingId) if err != nil { return nil, err } serverURL, err := url.Parse(server) if err != nil { return nil, err } operationPath := fmt.Sprintf("/onboardedInvokers/%s", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } queryURL, err := serverURL.Parse(operationPath) if err != nil { return nil, err } req, err := http.NewRequest("PUT", queryURL.String(), body) if err != nil { return nil, err } req.Header.Add("Content-Type", contentType) return req, nil } func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { for _, r := range c.RequestEditors { if err := r(ctx, req); err != nil { return err } } for _, r := range additionalEditors { if err := r(ctx, req); err != nil { return err } } return nil } // ClientWithResponses builds on ClientInterface to offer response payloads type ClientWithResponses struct { ClientInterface } // NewClientWithResponses creates a new ClientWithResponses, which wraps // Client with return type handling func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { client, err := NewClient(server, opts...) if err != nil { return nil, err } return &ClientWithResponses{client}, nil } // WithBaseURL overrides the baseURL. func WithBaseURL(baseURL string) ClientOption { return func(c *Client) error { newBaseURL, err := url.Parse(baseURL) if err != nil { return err } c.Server = newBaseURL.String() return nil } } // ClientWithResponsesInterface is the interface specification for the client with responses above. type ClientWithResponsesInterface interface { // PostOnboardedInvokers request with any body PostOnboardedInvokersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostOnboardedInvokersResponse, error) PostOnboardedInvokersWithResponse(ctx context.Context, body PostOnboardedInvokersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostOnboardedInvokersResponse, error) // DeleteOnboardedInvokersOnboardingId request DeleteOnboardedInvokersOnboardingIdWithResponse(ctx context.Context, onboardingId string, reqEditors ...RequestEditorFn) (*DeleteOnboardedInvokersOnboardingIdResponse, error) // ModifyIndApiInvokeEnrolment request with any body ModifyIndApiInvokeEnrolmentWithBodyWithResponse(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ModifyIndApiInvokeEnrolmentResponse, error) // PutOnboardedInvokersOnboardingId request with any body PutOnboardedInvokersOnboardingIdWithBodyWithResponse(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutOnboardedInvokersOnboardingIdResponse, error) PutOnboardedInvokersOnboardingIdWithResponse(ctx context.Context, onboardingId string, body PutOnboardedInvokersOnboardingIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutOnboardedInvokersOnboardingIdResponse, error) } type PostOnboardedInvokersResponse struct { Body []byte HTTPResponse *http.Response JSON201 *APIInvokerEnrolmentDetails } // Status returns HTTPResponse.Status func (r PostOnboardedInvokersResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r PostOnboardedInvokersResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type DeleteOnboardedInvokersOnboardingIdResponse struct { Body []byte HTTPResponse *http.Response } // Status returns HTTPResponse.Status func (r DeleteOnboardedInvokersOnboardingIdResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r DeleteOnboardedInvokersOnboardingIdResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type ModifyIndApiInvokeEnrolmentResponse struct { Body []byte HTTPResponse *http.Response JSON200 *APIInvokerEnrolmentDetails } // Status returns HTTPResponse.Status func (r ModifyIndApiInvokeEnrolmentResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r ModifyIndApiInvokeEnrolmentResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } type PutOnboardedInvokersOnboardingIdResponse struct { Body []byte HTTPResponse *http.Response JSON200 *APIInvokerEnrolmentDetails } // Status returns HTTPResponse.Status func (r PutOnboardedInvokersOnboardingIdResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } return http.StatusText(0) } // StatusCode returns HTTPResponse.StatusCode func (r PutOnboardedInvokersOnboardingIdResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } // PostOnboardedInvokersWithBodyWithResponse request with arbitrary body returning *PostOnboardedInvokersResponse func (c *ClientWithResponses) PostOnboardedInvokersWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostOnboardedInvokersResponse, error) { rsp, err := c.PostOnboardedInvokersWithBody(ctx, contentType, body, reqEditors...) if err != nil { return nil, err } return ParsePostOnboardedInvokersResponse(rsp) } func (c *ClientWithResponses) PostOnboardedInvokersWithResponse(ctx context.Context, body PostOnboardedInvokersJSONRequestBody, reqEditors ...RequestEditorFn) (*PostOnboardedInvokersResponse, error) { rsp, err := c.PostOnboardedInvokers(ctx, body, reqEditors...) if err != nil { return nil, err } return ParsePostOnboardedInvokersResponse(rsp) } // DeleteOnboardedInvokersOnboardingIdWithResponse request returning *DeleteOnboardedInvokersOnboardingIdResponse func (c *ClientWithResponses) DeleteOnboardedInvokersOnboardingIdWithResponse(ctx context.Context, onboardingId string, reqEditors ...RequestEditorFn) (*DeleteOnboardedInvokersOnboardingIdResponse, error) { rsp, err := c.DeleteOnboardedInvokersOnboardingId(ctx, onboardingId, reqEditors...) if err != nil { return nil, err } return ParseDeleteOnboardedInvokersOnboardingIdResponse(rsp) } // ModifyIndApiInvokeEnrolmentWithBodyWithResponse request with arbitrary body returning *ModifyIndApiInvokeEnrolmentResponse func (c *ClientWithResponses) ModifyIndApiInvokeEnrolmentWithBodyWithResponse(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ModifyIndApiInvokeEnrolmentResponse, error) { rsp, err := c.ModifyIndApiInvokeEnrolmentWithBody(ctx, onboardingId, contentType, body, reqEditors...) if err != nil { return nil, err } return ParseModifyIndApiInvokeEnrolmentResponse(rsp) } // PutOnboardedInvokersOnboardingIdWithBodyWithResponse request with arbitrary body returning *PutOnboardedInvokersOnboardingIdResponse func (c *ClientWithResponses) PutOnboardedInvokersOnboardingIdWithBodyWithResponse(ctx context.Context, onboardingId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutOnboardedInvokersOnboardingIdResponse, error) { rsp, err := c.PutOnboardedInvokersOnboardingIdWithBody(ctx, onboardingId, contentType, body, reqEditors...) if err != nil { return nil, err } return ParsePutOnboardedInvokersOnboardingIdResponse(rsp) } func (c *ClientWithResponses) PutOnboardedInvokersOnboardingIdWithResponse(ctx context.Context, onboardingId string, body PutOnboardedInvokersOnboardingIdJSONRequestBody, reqEditors ...RequestEditorFn) (*PutOnboardedInvokersOnboardingIdResponse, error) { rsp, err := c.PutOnboardedInvokersOnboardingId(ctx, onboardingId, body, reqEditors...) if err != nil { return nil, err } return ParsePutOnboardedInvokersOnboardingIdResponse(rsp) } // ParsePostOnboardedInvokersResponse parses an HTTP response from a PostOnboardedInvokersWithResponse call func ParsePostOnboardedInvokersResponse(rsp *http.Response) (*PostOnboardedInvokersResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &PostOnboardedInvokersResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: var dest APIInvokerEnrolmentDetails if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON201 = &dest } return response, nil } // ParseDeleteOnboardedInvokersOnboardingIdResponse parses an HTTP response from a DeleteOnboardedInvokersOnboardingIdWithResponse call func ParseDeleteOnboardedInvokersOnboardingIdResponse(rsp *http.Response) (*DeleteOnboardedInvokersOnboardingIdResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &DeleteOnboardedInvokersOnboardingIdResponse{ Body: bodyBytes, HTTPResponse: rsp, } return response, nil } // ParseModifyIndApiInvokeEnrolmentResponse parses an HTTP response from a ModifyIndApiInvokeEnrolmentWithResponse call func ParseModifyIndApiInvokeEnrolmentResponse(rsp *http.Response) (*ModifyIndApiInvokeEnrolmentResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &ModifyIndApiInvokeEnrolmentResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest APIInvokerEnrolmentDetails if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil } // ParsePutOnboardedInvokersOnboardingIdResponse parses an HTTP response from a PutOnboardedInvokersOnboardingIdWithResponse call func ParsePutOnboardedInvokersOnboardingIdResponse(rsp *http.Response) (*PutOnboardedInvokersOnboardingIdResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } response := &PutOnboardedInvokersOnboardingIdResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest APIInvokerEnrolmentDetails if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest } return response, nil }