|
Packit Service |
509fd4 |
// Package cloudapi provides primitives to interact the openapi HTTP API.
|
|
Packit Service |
509fd4 |
//
|
|
Packit Service |
509fd4 |
// Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.
|
|
Packit Service |
509fd4 |
package cloudapi
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
import (
|
|
Packit Service |
509fd4 |
"bytes"
|
|
Packit Service |
bcdfb1 |
"compress/gzip"
|
|
Packit Service |
509fd4 |
"context"
|
|
Packit Service |
bcdfb1 |
"encoding/base64"
|
|
Packit Service |
509fd4 |
"encoding/json"
|
|
Packit Service |
509fd4 |
"fmt"
|
|
Packit Service |
509fd4 |
"github.com/deepmap/oapi-codegen/pkg/runtime"
|
|
Packit Service |
bcdfb1 |
"github.com/getkin/kin-openapi/openapi3"
|
|
Packit Service |
509fd4 |
"github.com/go-chi/chi"
|
|
Packit Service |
509fd4 |
"io"
|
|
Packit Service |
509fd4 |
"io/ioutil"
|
|
Packit Service |
509fd4 |
"net/http"
|
|
Packit Service |
509fd4 |
"net/url"
|
|
Packit Service |
509fd4 |
"strings"
|
|
Packit Service |
509fd4 |
)
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// AWSUploadRequestOptions defines model for AWSUploadRequestOptions.
|
|
Packit Service |
509fd4 |
type AWSUploadRequestOptions struct {
|
|
Packit Service |
509fd4 |
Ec2 AWSUploadRequestOptionsEc2 `json:"ec2"`
|
|
Packit Service |
509fd4 |
Region string `json:"region"`
|
|
Packit Service |
509fd4 |
S3 AWSUploadRequestOptionsS3 `json:"s3"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// AWSUploadRequestOptionsEc2 defines model for AWSUploadRequestOptionsEc2.
|
|
Packit Service |
509fd4 |
type AWSUploadRequestOptionsEc2 struct {
|
|
Packit Service |
509fd4 |
AccessKeyId string `json:"access_key_id"`
|
|
Packit Service |
509fd4 |
SecretAccessKey string `json:"secret_access_key"`
|
|
Packit Service |
509fd4 |
ShareWithAccounts *[]string `json:"share_with_accounts,omitempty"`
|
|
Packit Service |
509fd4 |
SnapshotName *string `json:"snapshot_name,omitempty"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// AWSUploadRequestOptionsS3 defines model for AWSUploadRequestOptionsS3.
|
|
Packit Service |
509fd4 |
type AWSUploadRequestOptionsS3 struct {
|
|
Packit Service |
509fd4 |
AccessKeyId string `json:"access_key_id"`
|
|
Packit Service |
509fd4 |
Bucket string `json:"bucket"`
|
|
Packit Service |
509fd4 |
SecretAccessKey string `json:"secret_access_key"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeRequest defines model for ComposeRequest.
|
|
Packit Service |
509fd4 |
type ComposeRequest struct {
|
|
Packit Service |
509fd4 |
Customizations *Customizations `json:"customizations,omitempty"`
|
|
Packit Service |
509fd4 |
Distribution string `json:"distribution"`
|
|
Packit Service |
509fd4 |
ImageRequests []ImageRequest `json:"image_requests"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeResult defines model for ComposeResult.
|
|
Packit Service |
509fd4 |
type ComposeResult struct {
|
|
Packit Service |
509fd4 |
Id string `json:"id"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeStatus defines model for ComposeStatus.
|
|
Packit Service |
509fd4 |
type ComposeStatus struct {
|
|
Packit Service |
bcdfb1 |
ImageStatus ImageStatus `json:"image_status"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Customizations defines model for Customizations.
|
|
Packit Service |
509fd4 |
type Customizations struct {
|
|
Packit Service |
bcdfb1 |
Packages *[]string `json:"packages,omitempty"`
|
|
Packit Service |
509fd4 |
Subscription *Subscription `json:"subscription,omitempty"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ImageRequest defines model for ImageRequest.
|
|
Packit Service |
509fd4 |
type ImageRequest struct {
|
|
Packit Service |
509fd4 |
Architecture string `json:"architecture"`
|
|
Packit Service |
509fd4 |
ImageType string `json:"image_type"`
|
|
Packit Service |
509fd4 |
Repositories []Repository `json:"repositories"`
|
|
Packit Service |
509fd4 |
UploadRequests []UploadRequest `json:"upload_requests"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ImageStatus defines model for ImageStatus.
|
|
Packit Service |
509fd4 |
type ImageStatus struct {
|
|
Packit Service |
bcdfb1 |
Status string `json:"status"`
|
|
Packit Service |
bcdfb1 |
UploadStatus *UploadStatus `json:"upload_status,omitempty"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Repository defines model for Repository.
|
|
Packit Service |
509fd4 |
type Repository struct {
|
|
Packit Service |
509fd4 |
Baseurl *string `json:"baseurl,omitempty"`
|
|
Packit Service |
509fd4 |
Metalink *string `json:"metalink,omitempty"`
|
|
Packit Service |
509fd4 |
Mirrorlist *string `json:"mirrorlist,omitempty"`
|
|
Packit Service |
509fd4 |
Rhsm bool `json:"rhsm"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Subscription defines model for Subscription.
|
|
Packit Service |
509fd4 |
type Subscription struct {
|
|
Packit Service |
509fd4 |
ActivationKey string `json:"activation-key"`
|
|
Packit Service |
509fd4 |
BaseUrl string `json:"base-url"`
|
|
Packit Service |
509fd4 |
Insights bool `json:"insights"`
|
|
Packit Service |
509fd4 |
Organization int `json:"organization"`
|
|
Packit Service |
509fd4 |
ServerUrl string `json:"server-url"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// UploadRequest defines model for UploadRequest.
|
|
Packit Service |
509fd4 |
type UploadRequest struct {
|
|
Packit Service |
509fd4 |
Options interface{} `json:"options"`
|
|
Packit Service |
bcdfb1 |
Type UploadTypes `json:"type"`
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// UploadStatus defines model for UploadStatus.
|
|
Packit Service |
bcdfb1 |
type UploadStatus struct {
|
|
Packit Service |
bcdfb1 |
Status string `json:"status"`
|
|
Packit Service |
bcdfb1 |
Type UploadTypes `json:"type"`
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// UploadTypes defines model for UploadTypes.
|
|
Packit Service |
bcdfb1 |
type UploadTypes string
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// List of UploadTypes
|
|
Packit Service |
bcdfb1 |
const (
|
|
Packit Service |
bcdfb1 |
UploadTypes_aws UploadTypes = "aws"
|
|
Packit Service |
bcdfb1 |
)
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// Version defines model for Version.
|
|
Packit Service |
bcdfb1 |
type Version struct {
|
|
Packit Service |
bcdfb1 |
Version string `json:"version"`
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeJSONBody defines parameters for Compose.
|
|
Packit Service |
509fd4 |
type ComposeJSONBody ComposeRequest
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeRequestBody defines body for Compose for application/json ContentType.
|
|
Packit Service |
509fd4 |
type ComposeJSONRequestBody ComposeJSONBody
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// RequestEditorFn is the function signature for the RequestEditor callback function
|
|
Packit Service |
509fd4 |
type RequestEditorFn func(ctx context.Context, req *http.Request) error
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Doer performs HTTP requests.
|
|
Packit Service |
509fd4 |
//
|
|
Packit Service |
509fd4 |
// The standard http.Client implements this interface.
|
|
Packit Service |
509fd4 |
type HttpRequestDoer interface {
|
|
Packit Service |
509fd4 |
Do(req *http.Request) (*http.Response, error)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Client which conforms to the OpenAPI3 specification for this service.
|
|
Packit Service |
509fd4 |
type Client struct {
|
|
Packit Service |
509fd4 |
// The endpoint of the server conforming to this interface, with scheme,
|
|
Packit Service |
509fd4 |
// https://api.deepmap.com for example.
|
|
Packit Service |
509fd4 |
Server string
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Doer for performing requests, typically a *http.Client with any
|
|
Packit Service |
509fd4 |
// customized settings, such as certificate chains.
|
|
Packit Service |
509fd4 |
Client HttpRequestDoer
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// A callback for modifying requests which are generated before sending over
|
|
Packit Service |
509fd4 |
// the network.
|
|
Packit Service |
509fd4 |
RequestEditor RequestEditorFn
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ClientOption allows setting custom parameters during construction
|
|
Packit Service |
509fd4 |
type ClientOption func(*Client) error
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Creates a new Client, with reasonable defaults
|
|
Packit Service |
509fd4 |
func NewClient(server string, opts ...ClientOption) (*Client, error) {
|
|
Packit Service |
509fd4 |
// create a client with sane default values
|
|
Packit Service |
509fd4 |
client := Client{
|
|
Packit Service |
509fd4 |
Server: server,
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
// mutate client and add all optional params
|
|
Packit Service |
509fd4 |
for _, o := range opts {
|
|
Packit Service |
509fd4 |
if err := o(&client); err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
// ensure the server URL always has a trailing slash
|
|
Packit Service |
509fd4 |
if !strings.HasSuffix(client.Server, "/") {
|
|
Packit Service |
509fd4 |
client.Server += "/"
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
// create httpClient, if not already present
|
|
Packit Service |
509fd4 |
if client.Client == nil {
|
|
Packit Service |
509fd4 |
client.Client = http.DefaultClient
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return &client, nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// WithHTTPClient allows overriding the default Doer, which is
|
|
Packit Service |
509fd4 |
// automatically created using http.Client. This is useful for tests.
|
|
Packit Service |
509fd4 |
func WithHTTPClient(doer HttpRequestDoer) ClientOption {
|
|
Packit Service |
509fd4 |
return func(c *Client) error {
|
|
Packit Service |
509fd4 |
c.Client = doer
|
|
Packit Service |
509fd4 |
return nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// WithRequestEditorFn allows setting up a callback function, which will be
|
|
Packit Service |
509fd4 |
// called right before sending the request. This can be used to mutate the request.
|
|
Packit Service |
509fd4 |
func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
|
|
Packit Service |
509fd4 |
return func(c *Client) error {
|
|
Packit Service |
509fd4 |
c.RequestEditor = fn
|
|
Packit Service |
509fd4 |
return nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// The interface specification for the client above.
|
|
Packit Service |
509fd4 |
type ClientInterface interface {
|
|
Packit Service |
509fd4 |
// Compose request with any body
|
|
Packit Service |
509fd4 |
ComposeWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error)
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
Compose(ctx context.Context, body ComposeJSONRequestBody) (*http.Response, error)
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeStatus request
|
|
Packit Service |
509fd4 |
ComposeStatus(ctx context.Context, id string) (*http.Response, error)
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// GetOpenapiJson request
|
|
Packit Service |
bcdfb1 |
GetOpenapiJson(ctx context.Context) (*http.Response, error)
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// GetVersion request
|
|
Packit Service |
bcdfb1 |
GetVersion(ctx context.Context) (*http.Response, error)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
func (c *Client) ComposeWithBody(ctx context.Context, contentType string, body io.Reader) (*http.Response, error) {
|
|
Packit Service |
509fd4 |
req, err := NewComposeRequestWithBody(c.Server, contentType, body)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
req = req.WithContext(ctx)
|
|
Packit Service |
509fd4 |
if c.RequestEditor != nil {
|
|
Packit Service |
509fd4 |
err = c.RequestEditor(ctx, req)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return c.Client.Do(req)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
func (c *Client) Compose(ctx context.Context, body ComposeJSONRequestBody) (*http.Response, error) {
|
|
Packit Service |
509fd4 |
req, err := NewComposeRequest(c.Server, body)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
req = req.WithContext(ctx)
|
|
Packit Service |
509fd4 |
if c.RequestEditor != nil {
|
|
Packit Service |
509fd4 |
err = c.RequestEditor(ctx, req)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return c.Client.Do(req)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
func (c *Client) ComposeStatus(ctx context.Context, id string) (*http.Response, error) {
|
|
Packit Service |
509fd4 |
req, err := NewComposeStatusRequest(c.Server, id)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
req = req.WithContext(ctx)
|
|
Packit Service |
509fd4 |
if c.RequestEditor != nil {
|
|
Packit Service |
509fd4 |
err = c.RequestEditor(ctx, req)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return c.Client.Do(req)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
bcdfb1 |
func (c *Client) GetOpenapiJson(ctx context.Context) (*http.Response, error) {
|
|
Packit Service |
bcdfb1 |
req, err := NewGetOpenapiJsonRequest(c.Server)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
req = req.WithContext(ctx)
|
|
Packit Service |
bcdfb1 |
if c.RequestEditor != nil {
|
|
Packit Service |
bcdfb1 |
err = c.RequestEditor(ctx, req)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return c.Client.Do(req)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
func (c *Client) GetVersion(ctx context.Context) (*http.Response, error) {
|
|
Packit Service |
bcdfb1 |
req, err := NewGetVersionRequest(c.Server)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
req = req.WithContext(ctx)
|
|
Packit Service |
bcdfb1 |
if c.RequestEditor != nil {
|
|
Packit Service |
bcdfb1 |
err = c.RequestEditor(ctx, req)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return c.Client.Do(req)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
509fd4 |
// NewComposeRequest calls the generic Compose builder with application/json body
|
|
Packit Service |
509fd4 |
func NewComposeRequest(server string, body ComposeJSONRequestBody) (*http.Request, error) {
|
|
Packit Service |
509fd4 |
var bodyReader io.Reader
|
|
Packit Service |
509fd4 |
buf, err := json.Marshal(body)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
bodyReader = bytes.NewReader(buf)
|
|
Packit Service |
509fd4 |
return NewComposeRequestWithBody(server, "application/json", bodyReader)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// NewComposeRequestWithBody generates requests for Compose with any type of body
|
|
Packit Service |
509fd4 |
func NewComposeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
|
|
Packit Service |
509fd4 |
var err error
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
queryUrl, err := url.Parse(server)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
basePath := fmt.Sprintf("/compose")
|
|
Packit Service |
509fd4 |
if basePath[0] == '/' {
|
|
Packit Service |
509fd4 |
basePath = basePath[1:]
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
queryUrl, err = queryUrl.Parse(basePath)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
req, err := http.NewRequest("POST", queryUrl.String(), body)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
req.Header.Add("Content-Type", contentType)
|
|
Packit Service |
509fd4 |
return req, nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// NewComposeStatusRequest generates requests for ComposeStatus
|
|
Packit Service |
509fd4 |
func NewComposeStatusRequest(server string, id string) (*http.Request, error) {
|
|
Packit Service |
509fd4 |
var err error
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
var pathParam0 string
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
pathParam0, err = runtime.StyleParam("simple", false, "id", id)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
queryUrl, err := url.Parse(server)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
basePath := fmt.Sprintf("/compose/%s", pathParam0)
|
|
Packit Service |
509fd4 |
if basePath[0] == '/' {
|
|
Packit Service |
509fd4 |
basePath = basePath[1:]
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
queryUrl, err = queryUrl.Parse(basePath)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
req, err := http.NewRequest("GET", queryUrl.String(), nil)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
return req, nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
bcdfb1 |
// NewGetOpenapiJsonRequest generates requests for GetOpenapiJson
|
|
Packit Service |
bcdfb1 |
func NewGetOpenapiJsonRequest(server string) (*http.Request, error) {
|
|
Packit Service |
bcdfb1 |
var err error
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
queryUrl, err := url.Parse(server)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
basePath := fmt.Sprintf("/openapi.json")
|
|
Packit Service |
bcdfb1 |
if basePath[0] == '/' {
|
|
Packit Service |
bcdfb1 |
basePath = basePath[1:]
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
queryUrl, err = queryUrl.Parse(basePath)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
req, err := http.NewRequest("GET", queryUrl.String(), nil)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
return req, nil
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// NewGetVersionRequest generates requests for GetVersion
|
|
Packit Service |
bcdfb1 |
func NewGetVersionRequest(server string) (*http.Request, error) {
|
|
Packit Service |
bcdfb1 |
var err error
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
queryUrl, err := url.Parse(server)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
basePath := fmt.Sprintf("/version")
|
|
Packit Service |
bcdfb1 |
if basePath[0] == '/' {
|
|
Packit Service |
bcdfb1 |
basePath = basePath[1:]
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
queryUrl, err = queryUrl.Parse(basePath)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
req, err := http.NewRequest("GET", queryUrl.String(), nil)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
return req, nil
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
509fd4 |
// ClientWithResponses builds on ClientInterface to offer response payloads
|
|
Packit Service |
509fd4 |
type ClientWithResponses struct {
|
|
Packit Service |
509fd4 |
ClientInterface
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// NewClientWithResponses creates a new ClientWithResponses, which wraps
|
|
Packit Service |
509fd4 |
// Client with return type handling
|
|
Packit Service |
509fd4 |
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
|
|
Packit Service |
509fd4 |
client, err := NewClient(server, opts...)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return &ClientWithResponses{client}, nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// WithBaseURL overrides the baseURL.
|
|
Packit Service |
509fd4 |
func WithBaseURL(baseURL string) ClientOption {
|
|
Packit Service |
509fd4 |
return func(c *Client) error {
|
|
Packit Service |
509fd4 |
newBaseURL, err := url.Parse(baseURL)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
c.Server = newBaseURL.String()
|
|
Packit Service |
509fd4 |
return nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ClientWithResponsesInterface is the interface specification for the client with responses above.
|
|
Packit Service |
509fd4 |
type ClientWithResponsesInterface interface {
|
|
Packit Service |
509fd4 |
// Compose request with any body
|
|
Packit Service |
509fd4 |
ComposeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*ComposeResponse, error)
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
ComposeWithResponse(ctx context.Context, body ComposeJSONRequestBody) (*ComposeResponse, error)
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeStatus request
|
|
Packit Service |
509fd4 |
ComposeStatusWithResponse(ctx context.Context, id string) (*ComposeStatusResponse, error)
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// GetOpenapiJson request
|
|
Packit Service |
bcdfb1 |
GetOpenapiJsonWithResponse(ctx context.Context) (*GetOpenapiJsonResponse, error)
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// GetVersion request
|
|
Packit Service |
bcdfb1 |
GetVersionWithResponse(ctx context.Context) (*GetVersionResponse, error)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
type ComposeResponse struct {
|
|
Packit Service |
509fd4 |
Body []byte
|
|
Packit Service |
509fd4 |
HTTPResponse *http.Response
|
|
Packit Service |
509fd4 |
JSON201 *ComposeResult
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Status returns HTTPResponse.Status
|
|
Packit Service |
509fd4 |
func (r ComposeResponse) Status() string {
|
|
Packit Service |
509fd4 |
if r.HTTPResponse != nil {
|
|
Packit Service |
509fd4 |
return r.HTTPResponse.Status
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return http.StatusText(0)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// StatusCode returns HTTPResponse.StatusCode
|
|
Packit Service |
509fd4 |
func (r ComposeResponse) StatusCode() int {
|
|
Packit Service |
509fd4 |
if r.HTTPResponse != nil {
|
|
Packit Service |
509fd4 |
return r.HTTPResponse.StatusCode
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return 0
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
type ComposeStatusResponse struct {
|
|
Packit Service |
509fd4 |
Body []byte
|
|
Packit Service |
509fd4 |
HTTPResponse *http.Response
|
|
Packit Service |
509fd4 |
JSON200 *ComposeStatus
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Status returns HTTPResponse.Status
|
|
Packit Service |
509fd4 |
func (r ComposeStatusResponse) Status() string {
|
|
Packit Service |
509fd4 |
if r.HTTPResponse != nil {
|
|
Packit Service |
509fd4 |
return r.HTTPResponse.Status
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return http.StatusText(0)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// StatusCode returns HTTPResponse.StatusCode
|
|
Packit Service |
509fd4 |
func (r ComposeStatusResponse) StatusCode() int {
|
|
Packit Service |
509fd4 |
if r.HTTPResponse != nil {
|
|
Packit Service |
509fd4 |
return r.HTTPResponse.StatusCode
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return 0
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
bcdfb1 |
type GetOpenapiJsonResponse struct {
|
|
Packit Service |
bcdfb1 |
Body []byte
|
|
Packit Service |
bcdfb1 |
HTTPResponse *http.Response
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// Status returns HTTPResponse.Status
|
|
Packit Service |
bcdfb1 |
func (r GetOpenapiJsonResponse) Status() string {
|
|
Packit Service |
bcdfb1 |
if r.HTTPResponse != nil {
|
|
Packit Service |
bcdfb1 |
return r.HTTPResponse.Status
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return http.StatusText(0)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// StatusCode returns HTTPResponse.StatusCode
|
|
Packit Service |
bcdfb1 |
func (r GetOpenapiJsonResponse) StatusCode() int {
|
|
Packit Service |
bcdfb1 |
if r.HTTPResponse != nil {
|
|
Packit Service |
bcdfb1 |
return r.HTTPResponse.StatusCode
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return 0
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
type GetVersionResponse struct {
|
|
Packit Service |
bcdfb1 |
Body []byte
|
|
Packit Service |
bcdfb1 |
HTTPResponse *http.Response
|
|
Packit Service |
bcdfb1 |
JSON200 *Version
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// Status returns HTTPResponse.Status
|
|
Packit Service |
bcdfb1 |
func (r GetVersionResponse) Status() string {
|
|
Packit Service |
bcdfb1 |
if r.HTTPResponse != nil {
|
|
Packit Service |
bcdfb1 |
return r.HTTPResponse.Status
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return http.StatusText(0)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// StatusCode returns HTTPResponse.StatusCode
|
|
Packit Service |
bcdfb1 |
func (r GetVersionResponse) StatusCode() int {
|
|
Packit Service |
bcdfb1 |
if r.HTTPResponse != nil {
|
|
Packit Service |
bcdfb1 |
return r.HTTPResponse.StatusCode
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return 0
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
509fd4 |
// ComposeWithBodyWithResponse request with arbitrary body returning *ComposeResponse
|
|
Packit Service |
509fd4 |
func (c *ClientWithResponses) ComposeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*ComposeResponse, error) {
|
|
Packit Service |
509fd4 |
rsp, err := c.ComposeWithBody(ctx, contentType, body)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return ParseComposeResponse(rsp)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
func (c *ClientWithResponses) ComposeWithResponse(ctx context.Context, body ComposeJSONRequestBody) (*ComposeResponse, error) {
|
|
Packit Service |
509fd4 |
rsp, err := c.Compose(ctx, body)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return ParseComposeResponse(rsp)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeStatusWithResponse request returning *ComposeStatusResponse
|
|
Packit Service |
509fd4 |
func (c *ClientWithResponses) ComposeStatusWithResponse(ctx context.Context, id string) (*ComposeStatusResponse, error) {
|
|
Packit Service |
509fd4 |
rsp, err := c.ComposeStatus(ctx, id)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
return ParseComposeStatusResponse(rsp)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
bcdfb1 |
// GetOpenapiJsonWithResponse request returning *GetOpenapiJsonResponse
|
|
Packit Service |
bcdfb1 |
func (c *ClientWithResponses) GetOpenapiJsonWithResponse(ctx context.Context) (*GetOpenapiJsonResponse, error) {
|
|
Packit Service |
bcdfb1 |
rsp, err := c.GetOpenapiJson(ctx)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return ParseGetOpenapiJsonResponse(rsp)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// GetVersionWithResponse request returning *GetVersionResponse
|
|
Packit Service |
bcdfb1 |
func (c *ClientWithResponses) GetVersionWithResponse(ctx context.Context) (*GetVersionResponse, error) {
|
|
Packit Service |
bcdfb1 |
rsp, err := c.GetVersion(ctx)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return ParseGetVersionResponse(rsp)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
509fd4 |
// ParseComposeResponse parses an HTTP response from a ComposeWithResponse call
|
|
Packit Service |
509fd4 |
func ParseComposeResponse(rsp *http.Response) (*ComposeResponse, error) {
|
|
Packit Service |
509fd4 |
bodyBytes, err := ioutil.ReadAll(rsp.Body)
|
|
Packit Service |
509fd4 |
defer rsp.Body.Close()
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
response := &ComposeResponse{
|
|
Packit Service |
509fd4 |
Body: bodyBytes,
|
|
Packit Service |
509fd4 |
HTTPResponse: rsp,
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
switch {
|
|
Packit Service |
509fd4 |
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201:
|
|
Packit Service |
509fd4 |
var dest ComposeResult
|
|
Packit Service |
509fd4 |
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
response.JSON201 = &dest
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
return response, nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ParseComposeStatusResponse parses an HTTP response from a ComposeStatusWithResponse call
|
|
Packit Service |
509fd4 |
func ParseComposeStatusResponse(rsp *http.Response) (*ComposeStatusResponse, error) {
|
|
Packit Service |
509fd4 |
bodyBytes, err := ioutil.ReadAll(rsp.Body)
|
|
Packit Service |
509fd4 |
defer rsp.Body.Close()
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
response := &ComposeStatusResponse{
|
|
Packit Service |
509fd4 |
Body: bodyBytes,
|
|
Packit Service |
509fd4 |
HTTPResponse: rsp,
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
switch {
|
|
Packit Service |
509fd4 |
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
Packit Service |
509fd4 |
var dest ComposeStatus
|
|
Packit Service |
509fd4 |
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
Packit Service |
509fd4 |
return nil, err
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
response.JSON200 = &dest
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
return response, nil
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
bcdfb1 |
// ParseGetOpenapiJsonResponse parses an HTTP response from a GetOpenapiJsonWithResponse call
|
|
Packit Service |
bcdfb1 |
func ParseGetOpenapiJsonResponse(rsp *http.Response) (*GetOpenapiJsonResponse, error) {
|
|
Packit Service |
bcdfb1 |
bodyBytes, err := ioutil.ReadAll(rsp.Body)
|
|
Packit Service |
bcdfb1 |
defer rsp.Body.Close()
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
response := &GetOpenapiJsonResponse{
|
|
Packit Service |
bcdfb1 |
Body: bodyBytes,
|
|
Packit Service |
bcdfb1 |
HTTPResponse: rsp,
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
switch {
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
return response, nil
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// ParseGetVersionResponse parses an HTTP response from a GetVersionWithResponse call
|
|
Packit Service |
bcdfb1 |
func ParseGetVersionResponse(rsp *http.Response) (*GetVersionResponse, error) {
|
|
Packit Service |
bcdfb1 |
bodyBytes, err := ioutil.ReadAll(rsp.Body)
|
|
Packit Service |
bcdfb1 |
defer rsp.Body.Close()
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
response := &GetVersionResponse{
|
|
Packit Service |
bcdfb1 |
Body: bodyBytes,
|
|
Packit Service |
bcdfb1 |
HTTPResponse: rsp,
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
switch {
|
|
Packit Service |
bcdfb1 |
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
Packit Service |
bcdfb1 |
var dest Version
|
|
Packit Service |
bcdfb1 |
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, err
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
response.JSON200 = &dest
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
return response, nil
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
509fd4 |
// ServerInterface represents all server handlers.
|
|
Packit Service |
509fd4 |
type ServerInterface interface {
|
|
Packit Service |
509fd4 |
// Create compose
|
|
Packit Service |
509fd4 |
// (POST /compose)
|
|
Packit Service |
509fd4 |
Compose(w http.ResponseWriter, r *http.Request)
|
|
Packit Service |
509fd4 |
// The status of a compose
|
|
Packit Service |
509fd4 |
// (GET /compose/{id})
|
|
Packit Service |
509fd4 |
ComposeStatus(w http.ResponseWriter, r *http.Request, id string)
|
|
Packit Service |
bcdfb1 |
// get the openapi json specification
|
|
Packit Service |
bcdfb1 |
// (GET /openapi.json)
|
|
Packit Service |
bcdfb1 |
GetOpenapiJson(w http.ResponseWriter, r *http.Request)
|
|
Packit Service |
bcdfb1 |
// get the service version
|
|
Packit Service |
bcdfb1 |
// (GET /version)
|
|
Packit Service |
bcdfb1 |
GetVersion(w http.ResponseWriter, r *http.Request)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ServerInterfaceWrapper converts contexts to parameters.
|
|
Packit Service |
509fd4 |
type ServerInterfaceWrapper struct {
|
|
Packit Service |
509fd4 |
Handler ServerInterface
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// Compose operation middleware
|
|
Packit Service |
509fd4 |
func (siw *ServerInterfaceWrapper) Compose(w http.ResponseWriter, r *http.Request) {
|
|
Packit Service |
509fd4 |
ctx := r.Context()
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
siw.Handler.Compose(w, r.WithContext(ctx))
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ComposeStatus operation middleware
|
|
Packit Service |
509fd4 |
func (siw *ServerInterfaceWrapper) ComposeStatus(w http.ResponseWriter, r *http.Request) {
|
|
Packit Service |
509fd4 |
ctx := r.Context()
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
var err error
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// ------------- Path parameter "id" -------------
|
|
Packit Service |
509fd4 |
var id string
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
err = runtime.BindStyledParameter("simple", false, "id", chi.URLParam(r, "id"), &id)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
http.Error(w, fmt.Sprintf("Invalid format for parameter id: %s", err), http.StatusBadRequest)
|
|
Packit Service |
509fd4 |
return
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
siw.Handler.ComposeStatus(w, r.WithContext(ctx), id)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
bcdfb1 |
// GetOpenapiJson operation middleware
|
|
Packit Service |
bcdfb1 |
func (siw *ServerInterfaceWrapper) GetOpenapiJson(w http.ResponseWriter, r *http.Request) {
|
|
Packit Service |
bcdfb1 |
ctx := r.Context()
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
siw.Handler.GetOpenapiJson(w, r.WithContext(ctx))
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// GetVersion operation middleware
|
|
Packit Service |
bcdfb1 |
func (siw *ServerInterfaceWrapper) GetVersion(w http.ResponseWriter, r *http.Request) {
|
|
Packit Service |
bcdfb1 |
ctx := r.Context()
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
siw.Handler.GetVersion(w, r.WithContext(ctx))
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
509fd4 |
// Handler creates http.Handler with routing matching OpenAPI spec.
|
|
Packit Service |
509fd4 |
func Handler(si ServerInterface) http.Handler {
|
|
Packit Service |
509fd4 |
return HandlerFromMux(si, chi.NewRouter())
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
|
|
Packit Service |
509fd4 |
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler {
|
|
Packit Service |
509fd4 |
wrapper := ServerInterfaceWrapper{
|
|
Packit Service |
509fd4 |
Handler: si,
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
r.Group(func(r chi.Router) {
|
|
Packit Service |
509fd4 |
r.Post("/compose", wrapper.Compose)
|
|
Packit Service |
509fd4 |
})
|
|
Packit Service |
509fd4 |
r.Group(func(r chi.Router) {
|
|
Packit Service |
509fd4 |
r.Get("/compose/{id}", wrapper.ComposeStatus)
|
|
Packit Service |
509fd4 |
})
|
|
Packit Service |
bcdfb1 |
r.Group(func(r chi.Router) {
|
|
Packit Service |
bcdfb1 |
r.Get("/openapi.json", wrapper.GetOpenapiJson)
|
|
Packit Service |
bcdfb1 |
})
|
|
Packit Service |
bcdfb1 |
r.Group(func(r chi.Router) {
|
|
Packit Service |
bcdfb1 |
r.Get("/version", wrapper.GetVersion)
|
|
Packit Service |
bcdfb1 |
})
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
return r
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// Base64 encoded, gzipped, json marshaled Swagger object
|
|
Packit Service |
bcdfb1 |
var swaggerSpec = []string{
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
"H4sIAAAAAAAC/8RXaW/buhL9KwTf+yhbju2kqYHiIU3dwl2Som77WvQaAS2NLTYSqZKjOLmF//sFqSWi",
|
|
Packit Service |
bcdfb1 |
"qaxIcT/FEclZzpw5HP6mkcxyKUCgppPfVEcJZMz+PPr//EueShZ/gl8FaDzNkUthl3Ilc1DIwf4H0dD8",
|
|
Packit Service |
bcdfb1 |
"+a+CFZ3Q/4TXFsPKXHiDrWk0pNuAKlhzKaypS5blKdAJhaK3AY29PRpQvMrNJ42Ki7U5oEePdDgf0a11",
|
|
Packit Service |
bcdfb1 |
"+KvgCmI6+VE7t0YDm8ui8SiXPyFC4/GWBDw8WBSB1mfncHXGYzero3ezo9np/PXpq5OTZ9NvRx8+vp92",
|
|
Packit Service |
bcdfb1 |
"JgiRAjy7tuSa2bxlqfr2BcXr6YdZ+O7Zh1fTkzfh8uPlpxU//l7ZfTf9TgO6kipjSCc0Z1pvpIo73SVM",
|
|
Packit Service |
bcdfb1 |
"wdmGY2JcyqIiQ+PwB90bjsb7B88Onw/2LEAcIbN7PFvVB6YUu7K2Bct1IvFMsAzcNLKrXr3qR7VTJhfU",
|
|
Packit Service |
bcdfb1 |
"LoQeULb56I9UbVlE54BejtXnf7vMDwa0SagL2WPTcxoqXH04o0KjzPjfrBGN29r12N29DWjMTdzLAj1l",
|
|
Packit Service |
bcdfb1 |
"UAmkvcMuOHnG1nCmypCsz4amtzmfmWN1Ih6Dd2Bz4vJc3oqULtIOoHbJtjccgWm1Hhw+X/b2hvGox8b7",
|
|
Packit Service |
bcdfb1 |
"B73x8OBgf388HgwGg3bBi4LfXWwe08V1KHNkWHQIeZmMblbvBK0y5Hlr27F+PTK4jnMWnbM17IpOLjWu",
|
|
Packit Service |
bcdfb1 |
"FegHCk6x1JHiec2c27KYt/dutx3Vc8jhi4aKEo4QYaF2tO3y8ODsYHwzS8vP7RMs413bFeRSc5SqLtJ9",
|
|
Packit Service |
bcdfb1 |
"KP2pPnTVhVBhJfHhjeJI6Z2d4mDjpL2TlB/Qogb+JqZecxREkRlvurDCZTqD8bR0mYOIDYpGyHha/Sx9",
|
|
Packit Service |
bcdfb1 |
"lb/N3a8RLNSLoFWLa2tePapY79clJWI3tEmrQVr18nJdMg2FSl2yJIi5noRhFIu+gjhh2I9kFkZSIAgM",
|
|
Packit Service |
bcdfb1 |
"jUqFRigPw8OwpGJo7EgdSh068qHSriwzQJZycd7tNeNKSaX7K4ilYrmSplv6Uq3D+tz/TIVflOu90fCv",
|
|
Packit Service |
bcdfb1 |
"YjAYHhhGvGga484QrJOUa3xwEM1JN4zRY8JQic5aurOUMgUm/DHSbOuS//mOHO1OHcgvrCz2vOvfjEf2",
|
|
Packit Service |
bcdfb1 |
"Uu6Vt/G9RjlT5V4nXXy23CN7LjRfJzvjIKoCAg+QgEq1ZqJSeefAcDAejIbj5gwXCGtQ5QikLkD5EbdV",
|
|
Packit Service |
bcdfb1 |
"vG/AbQV+53XnBBLsguw4bSHWyrarkK76eZWU188jKeB0RSc/HvVEodtFo6z3EZfPVzn42lLpbB3Uzfk8",
|
|
Packit Service |
bcdfb1 |
"lcKqQohKRm+4oR+fTBVLZWjRxF7uboXINrozgK+gdGf7XVwv3M6oeuNiu7VdsZLmTAyt1qZzUBc8AoKS",
|
|
Packit Service |
bcdfb1 |
"2PuGMBETLjSyNCX2+tN9GtCURyC0BaR8EtGjnEUJkGHfDHa2ExqR22w2fWaXrbJVZ3X4fnY8PZlPe8P+",
|
|
Packit Service |
bcdfb1 |
"oJ9gllqYOdrWOZ2/tO6raU+RKJVFTFhu5osmY7pnWzYHYRYmdNQf9M1jO2eYWGzKKpWBmknMT/hYAUMg",
|
|
Packit Service |
bcdfb1 |
"jAjYkGp3QHJpriDO0vSKRFJorpGLNZErouECFKuxsPCUtykBFiUGN0yAKxKDOVIOi33LYlD2v1lsvFZh",
|
|
Packit Service |
bcdfb1 |
"lQUCjS9lbJWzuvysrOZ5yiN7JvypywKXTLvzJeK+a7YuEYzy2Q86l6YOxtpwsPf03u1bwTrfgbzcQBKm",
|
|
Packit Service |
bcdfb1 |
"iUamEGLLVV1kGTPTQ12Uunhmsa5k+JvHWxPCGjqq+QbQ4E/KbjP1YqTqaiKVNZgCQlyb7pPPCdeEiygt",
|
|
Packit Service |
bcdfb1 |
"YtBkkwAmoMxeIZFwJFYxIIY4sLVmqZbEDAjE9I+5d7gUhC1lUTpWNusbCz6vVSBnimWAoLTVWDeL2SsT",
|
|
Packit Service |
bcdfb1 |
"eRVinQtKsrYvcC7s9YkJDerms68nt8JBq1pP/jBbePQZPDV9mnnTo4+LixGAsece4RLDPGV8x/FuIp7x",
|
|
Packit Service |
bcdfb1 |
"mbhgKW/4QXhcOhg/lYMv4lzIjXAcONz/vENfpwkqqevXkFZN4HLtDeBpue+ttrNDV63cqBRgoYQmaLoh",
|
|
Packit Service |
bcdfb1 |
"llGRmTzdwNZVb1UxEBMD0TlEfFVV2jCFrQ2j7extLpqAhq37qbNna7u6unrq/YGf1tdm6Y/Rr3bRUTrm",
|
|
Packit Service |
bcdfb1 |
"hdgNkL9ru/0nAAD//+8m7NSkFgAA",
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
// GetSwagger returns the Swagger specification corresponding to the generated code
|
|
Packit Service |
bcdfb1 |
// in this file.
|
|
Packit Service |
bcdfb1 |
func GetSwagger() (*openapi3.Swagger, error) {
|
|
Packit Service |
bcdfb1 |
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, fmt.Errorf("error base64 decoding spec: %s", err)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
zr, err := gzip.NewReader(bytes.NewReader(zipped))
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, fmt.Errorf("error decompressing spec: %s", err)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
var buf bytes.Buffer
|
|
Packit Service |
bcdfb1 |
_, err = buf.ReadFrom(zr)
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, fmt.Errorf("error decompressing spec: %s", err)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
|
|
Packit Service |
bcdfb1 |
swagger, err := openapi3.NewSwaggerLoader().LoadSwaggerFromData(buf.Bytes())
|
|
Packit Service |
bcdfb1 |
if err != nil {
|
|
Packit Service |
bcdfb1 |
return nil, fmt.Errorf("error loading Swagger: %s", err)
|
|
Packit Service |
bcdfb1 |
}
|
|
Packit Service |
bcdfb1 |
return swagger, nil
|
|
Packit Service |
bcdfb1 |
}
|