I think that we can spare the users of clouadpi of writing "rhsm": "false" into the requests so I decided to make this property optional and default to false. This is nice because it matches the behaviour of Weldr repositories and sources so we can also use test/data/repositories without any changes after openapi validation is enabled. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
829 lines
32 KiB
Go
829 lines
32 KiB
Go
// Package v2 provides primitives to interact with the openapi HTTP API.
|
|
//
|
|
// Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.
|
|
package v2
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
"encoding/base64"
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/deepmap/oapi-codegen/pkg/runtime"
|
|
"github.com/getkin/kin-openapi/openapi3"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
const (
|
|
BearerScopes = "Bearer.Scopes"
|
|
)
|
|
|
|
// Defines values for ComposeStatusValue.
|
|
const (
|
|
ComposeStatusValueFailure ComposeStatusValue = "failure"
|
|
|
|
ComposeStatusValuePending ComposeStatusValue = "pending"
|
|
|
|
ComposeStatusValueSuccess ComposeStatusValue = "success"
|
|
)
|
|
|
|
// Defines values for ImageStatusValue.
|
|
const (
|
|
ImageStatusValueBuilding ImageStatusValue = "building"
|
|
|
|
ImageStatusValueFailure ImageStatusValue = "failure"
|
|
|
|
ImageStatusValuePending ImageStatusValue = "pending"
|
|
|
|
ImageStatusValueRegistering ImageStatusValue = "registering"
|
|
|
|
ImageStatusValueSuccess ImageStatusValue = "success"
|
|
|
|
ImageStatusValueUploading ImageStatusValue = "uploading"
|
|
)
|
|
|
|
// Defines values for ImageTypes.
|
|
const (
|
|
ImageTypesAws ImageTypes = "aws"
|
|
|
|
ImageTypesAwsHaRhui ImageTypes = "aws-ha-rhui"
|
|
|
|
ImageTypesAwsRhui ImageTypes = "aws-rhui"
|
|
|
|
ImageTypesAwsSapRhui ImageTypes = "aws-sap-rhui"
|
|
|
|
ImageTypesAzure ImageTypes = "azure"
|
|
|
|
ImageTypesAzureRhui ImageTypes = "azure-rhui"
|
|
|
|
ImageTypesEdgeCommit ImageTypes = "edge-commit"
|
|
|
|
ImageTypesEdgeContainer ImageTypes = "edge-container"
|
|
|
|
ImageTypesEdgeInstaller ImageTypes = "edge-installer"
|
|
|
|
ImageTypesGcp ImageTypes = "gcp"
|
|
|
|
ImageTypesGuestImage ImageTypes = "guest-image"
|
|
|
|
ImageTypesImageInstaller ImageTypes = "image-installer"
|
|
|
|
ImageTypesVsphere ImageTypes = "vsphere"
|
|
)
|
|
|
|
// Defines values for UploadStatusValue.
|
|
const (
|
|
UploadStatusValueFailure UploadStatusValue = "failure"
|
|
|
|
UploadStatusValuePending UploadStatusValue = "pending"
|
|
|
|
UploadStatusValueRunning UploadStatusValue = "running"
|
|
|
|
UploadStatusValueSuccess UploadStatusValue = "success"
|
|
)
|
|
|
|
// Defines values for UploadTypes.
|
|
const (
|
|
UploadTypesAws UploadTypes = "aws"
|
|
|
|
UploadTypesAwsS3 UploadTypes = "aws.s3"
|
|
|
|
UploadTypesAzure UploadTypes = "azure"
|
|
|
|
UploadTypesGcp UploadTypes = "gcp"
|
|
)
|
|
|
|
// AWSEC2UploadOptions defines model for AWSEC2UploadOptions.
|
|
type AWSEC2UploadOptions struct {
|
|
Region string `json:"region"`
|
|
ShareWithAccounts []string `json:"share_with_accounts"`
|
|
SnapshotName *string `json:"snapshot_name,omitempty"`
|
|
}
|
|
|
|
// AWSEC2UploadStatus defines model for AWSEC2UploadStatus.
|
|
type AWSEC2UploadStatus struct {
|
|
Ami string `json:"ami"`
|
|
Region string `json:"region"`
|
|
}
|
|
|
|
// AWSS3UploadOptions defines model for AWSS3UploadOptions.
|
|
type AWSS3UploadOptions struct {
|
|
Region string `json:"region"`
|
|
}
|
|
|
|
// AWSS3UploadStatus defines model for AWSS3UploadStatus.
|
|
type AWSS3UploadStatus struct {
|
|
Url string `json:"url"`
|
|
}
|
|
|
|
// AzureUploadOptions defines model for AzureUploadOptions.
|
|
type AzureUploadOptions struct {
|
|
// Name of the uploaded image. It must be unique in the given resource group.
|
|
// If name is omitted from the request, a random one based on a UUID is
|
|
// generated.
|
|
ImageName *string `json:"image_name,omitempty"`
|
|
|
|
// Location where the image should be uploaded and registered.
|
|
// How to list all locations:
|
|
// https://docs.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest#az_account_list_locations'
|
|
Location string `json:"location"`
|
|
|
|
// Name of the resource group where the image should be uploaded.
|
|
ResourceGroup string `json:"resource_group"`
|
|
|
|
// ID of subscription where the image should be uploaded.
|
|
SubscriptionId string `json:"subscription_id"`
|
|
|
|
// ID of the tenant where the image should be uploaded.
|
|
// How to find it in the Azure Portal:
|
|
// https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-how-to-find-tenant
|
|
TenantId string `json:"tenant_id"`
|
|
}
|
|
|
|
// AzureUploadStatus defines model for AzureUploadStatus.
|
|
type AzureUploadStatus struct {
|
|
ImageName string `json:"image_name"`
|
|
}
|
|
|
|
// ComposeId defines model for ComposeId.
|
|
type ComposeId struct {
|
|
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
|
|
ObjectReference `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
Id string `json:"id"`
|
|
}
|
|
|
|
// ComposeLogs defines model for ComposeLogs.
|
|
type ComposeLogs struct {
|
|
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
|
|
ObjectReference `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
ImageBuilds []interface{} `json:"image_builds"`
|
|
Koji *KojiLogs `json:"koji,omitempty"`
|
|
}
|
|
|
|
// ComposeManifests defines model for ComposeManifests.
|
|
type ComposeManifests struct {
|
|
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
|
|
ObjectReference `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
Manifests []interface{} `json:"manifests"`
|
|
}
|
|
|
|
// ComposeMetadata defines model for ComposeMetadata.
|
|
type ComposeMetadata struct {
|
|
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
|
|
ObjectReference `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
// ID (hash) of the built commit
|
|
OstreeCommit *string `json:"ostree_commit,omitempty"`
|
|
|
|
// Package list including NEVRA
|
|
Packages *[]PackageMetadata `json:"packages,omitempty"`
|
|
}
|
|
|
|
// ComposeRequest defines model for ComposeRequest.
|
|
type ComposeRequest struct {
|
|
Customizations *Customizations `json:"customizations,omitempty"`
|
|
Distribution string `json:"distribution"`
|
|
ImageRequest *ImageRequest `json:"image_request,omitempty"`
|
|
ImageRequests *[]ImageRequest `json:"image_requests,omitempty"`
|
|
Koji *Koji `json:"koji,omitempty"`
|
|
}
|
|
|
|
// ComposeStatus defines model for ComposeStatus.
|
|
type ComposeStatus struct {
|
|
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
|
|
ObjectReference `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
ImageStatus ImageStatus `json:"image_status"`
|
|
ImageStatuses *[]ImageStatus `json:"image_statuses,omitempty"`
|
|
KojiStatus *KojiStatus `json:"koji_status,omitempty"`
|
|
Status ComposeStatusValue `json:"status"`
|
|
}
|
|
|
|
// ComposeStatusError defines model for ComposeStatusError.
|
|
type ComposeStatusError struct {
|
|
Details *interface{} `json:"details,omitempty"`
|
|
Id int `json:"id"`
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
// ComposeStatusValue defines model for ComposeStatusValue.
|
|
type ComposeStatusValue string
|
|
|
|
// Customizations defines model for Customizations.
|
|
type Customizations struct {
|
|
Filesystem *[]Filesystem `json:"filesystem,omitempty"`
|
|
Packages *[]string `json:"packages,omitempty"`
|
|
|
|
// Extra repositories for packages specified in customizations. These
|
|
// repositories will only be used to depsolve and retrieve packages
|
|
// for the OS itself (they will not be available for the build root or
|
|
// any other part of the build process). The package_sets field for these
|
|
// repositories is ignored.
|
|
PayloadRepositories *[]Repository `json:"payload_repositories,omitempty"`
|
|
Subscription *Subscription `json:"subscription,omitempty"`
|
|
Users *[]User `json:"users,omitempty"`
|
|
}
|
|
|
|
// Error defines model for Error.
|
|
type Error struct {
|
|
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
|
|
ObjectReference `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
Code string `json:"code"`
|
|
OperationId string `json:"operation_id"`
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
// ErrorList defines model for ErrorList.
|
|
type ErrorList struct {
|
|
// Embedded struct due to allOf(#/components/schemas/List)
|
|
List `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
Items []Error `json:"items"`
|
|
}
|
|
|
|
// Filesystem defines model for Filesystem.
|
|
type Filesystem struct {
|
|
MinSize uint64 `json:"min_size"`
|
|
Mountpoint string `json:"mountpoint"`
|
|
}
|
|
|
|
// GCPUploadOptions defines model for GCPUploadOptions.
|
|
type GCPUploadOptions struct {
|
|
// Name of an existing STANDARD Storage class Bucket.
|
|
Bucket string `json:"bucket"`
|
|
|
|
// The name to use for the imported and shared Compute Engine image.
|
|
// The image name must be unique within the GCP project, which is used
|
|
// for the OS image upload and import. If not specified a random
|
|
// 'composer-api-<uuid>' string is used as the image name.
|
|
ImageName *string `json:"image_name,omitempty"`
|
|
|
|
// The GCP region where the OS image will be imported to and shared from.
|
|
// The value must be a valid GCP location. See https://cloud.google.com/storage/docs/locations.
|
|
// If not specified, the multi-region location closest to the source
|
|
// (source Storage Bucket location) is chosen automatically.
|
|
Region string `json:"region"`
|
|
|
|
// List of valid Google accounts to share the imported Compute Engine image with.
|
|
// Each string must contain a specifier of the account type. Valid formats are:
|
|
// - 'user:{emailid}': An email address that represents a specific
|
|
// Google account. For example, 'alice@example.com'.
|
|
// - 'serviceAccount:{emailid}': An email address that represents a
|
|
// service account. For example, 'my-other-app@appspot.gserviceaccount.com'.
|
|
// - 'group:{emailid}': An email address that represents a Google group.
|
|
// For example, 'admins@example.com'.
|
|
// - 'domain:{domain}': The G Suite domain (primary) that represents all
|
|
// the users of that domain. For example, 'google.com' or 'example.com'.
|
|
// If not specified, the imported Compute Engine image is not shared with any
|
|
// account.
|
|
ShareWithAccounts *[]string `json:"share_with_accounts,omitempty"`
|
|
}
|
|
|
|
// GCPUploadStatus defines model for GCPUploadStatus.
|
|
type GCPUploadStatus struct {
|
|
ImageName string `json:"image_name"`
|
|
ProjectId string `json:"project_id"`
|
|
}
|
|
|
|
// ImageRequest defines model for ImageRequest.
|
|
type ImageRequest struct {
|
|
Architecture string `json:"architecture"`
|
|
ImageType ImageTypes `json:"image_type"`
|
|
Ostree *OSTree `json:"ostree,omitempty"`
|
|
Repositories []Repository `json:"repositories"`
|
|
UploadOptions *UploadOptions `json:"upload_options,omitempty"`
|
|
}
|
|
|
|
// ImageStatus defines model for ImageStatus.
|
|
type ImageStatus struct {
|
|
Error *ComposeStatusError `json:"error,omitempty"`
|
|
Status ImageStatusValue `json:"status"`
|
|
UploadStatus *UploadStatus `json:"upload_status,omitempty"`
|
|
}
|
|
|
|
// ImageStatusValue defines model for ImageStatusValue.
|
|
type ImageStatusValue string
|
|
|
|
// ImageTypes defines model for ImageTypes.
|
|
type ImageTypes string
|
|
|
|
// Koji defines model for Koji.
|
|
type Koji struct {
|
|
Name string `json:"name"`
|
|
Release string `json:"release"`
|
|
Server string `json:"server"`
|
|
TaskId int `json:"task_id"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
// KojiLogs defines model for KojiLogs.
|
|
type KojiLogs struct {
|
|
Import interface{} `json:"import"`
|
|
Init interface{} `json:"init"`
|
|
}
|
|
|
|
// KojiStatus defines model for KojiStatus.
|
|
type KojiStatus struct {
|
|
BuildId *int `json:"build_id,omitempty"`
|
|
}
|
|
|
|
// List defines model for List.
|
|
type List struct {
|
|
Kind string `json:"kind"`
|
|
Page int `json:"page"`
|
|
Size int `json:"size"`
|
|
Total int `json:"total"`
|
|
}
|
|
|
|
// OSTree defines model for OSTree.
|
|
type OSTree struct {
|
|
Parent *string `json:"parent,omitempty"`
|
|
Ref *string `json:"ref,omitempty"`
|
|
Url *string `json:"url,omitempty"`
|
|
}
|
|
|
|
// ObjectReference defines model for ObjectReference.
|
|
type ObjectReference struct {
|
|
Href string `json:"href"`
|
|
Id string `json:"id"`
|
|
Kind string `json:"kind"`
|
|
}
|
|
|
|
// PackageMetadata defines model for PackageMetadata.
|
|
type PackageMetadata struct {
|
|
Arch string `json:"arch"`
|
|
Epoch *string `json:"epoch,omitempty"`
|
|
Name string `json:"name"`
|
|
Release string `json:"release"`
|
|
Sigmd5 string `json:"sigmd5"`
|
|
Signature *string `json:"signature,omitempty"`
|
|
Type string `json:"type"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
// Repository defines model for Repository.
|
|
type Repository struct {
|
|
Baseurl *string `json:"baseurl,omitempty"`
|
|
CheckGpg *bool `json:"check_gpg,omitempty"`
|
|
|
|
// GPG key used to sign packages in this repository.
|
|
Gpgkey *string `json:"gpgkey,omitempty"`
|
|
IgnoreSsl *bool `json:"ignore_ssl,omitempty"`
|
|
Metalink *string `json:"metalink,omitempty"`
|
|
Mirrorlist *string `json:"mirrorlist,omitempty"`
|
|
|
|
// Naming package sets for a repository assigns it to a specific part
|
|
// (pipeline) of the build process.
|
|
PackageSets *[]string `json:"package_sets,omitempty"`
|
|
|
|
// Determines whether a valid subscription is required to access this repository.
|
|
Rhsm *bool `json:"rhsm,omitempty"`
|
|
}
|
|
|
|
// Subscription defines model for Subscription.
|
|
type Subscription struct {
|
|
ActivationKey string `json:"activation_key"`
|
|
BaseUrl string `json:"base_url"`
|
|
Insights bool `json:"insights"`
|
|
Organization string `json:"organization"`
|
|
ServerUrl string `json:"server_url"`
|
|
}
|
|
|
|
// UploadOptions defines model for UploadOptions.
|
|
type UploadOptions interface{}
|
|
|
|
// UploadStatus defines model for UploadStatus.
|
|
type UploadStatus struct {
|
|
Options interface{} `json:"options"`
|
|
Status UploadStatusValue `json:"status"`
|
|
Type UploadTypes `json:"type"`
|
|
}
|
|
|
|
// UploadStatusValue defines model for UploadStatusValue.
|
|
type UploadStatusValue string
|
|
|
|
// UploadTypes defines model for UploadTypes.
|
|
type UploadTypes string
|
|
|
|
// User defines model for User.
|
|
type User struct {
|
|
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
|
|
ObjectReference `yaml:",inline"`
|
|
// Embedded fields due to inline allOf schema
|
|
Groups *[]string `json:"groups,omitempty"`
|
|
Key *string `json:"key,omitempty"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// Page defines model for page.
|
|
type Page string
|
|
|
|
// Size defines model for size.
|
|
type Size string
|
|
|
|
// PostComposeJSONBody defines parameters for PostCompose.
|
|
type PostComposeJSONBody ComposeRequest
|
|
|
|
// GetErrorListParams defines parameters for GetErrorList.
|
|
type GetErrorListParams struct {
|
|
// Page index
|
|
Page *Page `json:"page,omitempty"`
|
|
|
|
// Number of items in each page
|
|
Size *Size `json:"size,omitempty"`
|
|
}
|
|
|
|
// PostComposeJSONRequestBody defines body for PostCompose for application/json ContentType.
|
|
type PostComposeJSONRequestBody PostComposeJSONBody
|
|
|
|
// ServerInterface represents all server handlers.
|
|
type ServerInterface interface {
|
|
// Create compose
|
|
// (POST /compose)
|
|
PostCompose(ctx echo.Context) error
|
|
// The status of a compose
|
|
// (GET /composes/{id})
|
|
GetComposeStatus(ctx echo.Context, id string) error
|
|
// Get logs for a compose.
|
|
// (GET /composes/{id}/logs)
|
|
GetComposeLogs(ctx echo.Context, id string) error
|
|
// Get the manifests for a compose.
|
|
// (GET /composes/{id}/manifests)
|
|
GetComposeManifests(ctx echo.Context, id string) error
|
|
// Get the metadata for a compose.
|
|
// (GET /composes/{id}/metadata)
|
|
GetComposeMetadata(ctx echo.Context, id string) error
|
|
// Get a list of all possible errors
|
|
// (GET /errors)
|
|
GetErrorList(ctx echo.Context, params GetErrorListParams) error
|
|
// Get error description
|
|
// (GET /errors/{id})
|
|
GetError(ctx echo.Context, id string) error
|
|
// Get the openapi spec in json format
|
|
// (GET /openapi)
|
|
GetOpenapi(ctx echo.Context) error
|
|
}
|
|
|
|
// ServerInterfaceWrapper converts echo contexts to parameters.
|
|
type ServerInterfaceWrapper struct {
|
|
Handler ServerInterface
|
|
}
|
|
|
|
// PostCompose converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) PostCompose(ctx echo.Context) error {
|
|
var err error
|
|
|
|
ctx.Set(BearerScopes, []string{""})
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.PostCompose(ctx)
|
|
return err
|
|
}
|
|
|
|
// GetComposeStatus converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetComposeStatus(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id string
|
|
|
|
err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
ctx.Set(BearerScopes, []string{""})
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetComposeStatus(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetComposeLogs converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetComposeLogs(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id string
|
|
|
|
err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetComposeLogs(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetComposeManifests converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetComposeManifests(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id string
|
|
|
|
err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetComposeManifests(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetComposeMetadata converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetComposeMetadata(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id string
|
|
|
|
err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
ctx.Set(BearerScopes, []string{""})
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetComposeMetadata(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetErrorList converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetErrorList(ctx echo.Context) error {
|
|
var err error
|
|
|
|
ctx.Set(BearerScopes, []string{""})
|
|
|
|
// Parameter object where we will unmarshal all parameters from the context
|
|
var params GetErrorListParams
|
|
// ------------- Optional query parameter "page" -------------
|
|
|
|
err = runtime.BindQueryParameter("form", true, false, "page", ctx.QueryParams(), ¶ms.Page)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter page: %s", err))
|
|
}
|
|
|
|
// ------------- Optional query parameter "size" -------------
|
|
|
|
err = runtime.BindQueryParameter("form", true, false, "size", ctx.QueryParams(), ¶ms.Size)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter size: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetErrorList(ctx, params)
|
|
return err
|
|
}
|
|
|
|
// GetError converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetError(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id string
|
|
|
|
err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id)
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
ctx.Set(BearerScopes, []string{""})
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetError(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetOpenapi converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetOpenapi(ctx echo.Context) error {
|
|
var err error
|
|
|
|
ctx.Set(BearerScopes, []string{""})
|
|
|
|
// Invoke the callback with all the unmarshalled arguments
|
|
err = w.Handler.GetOpenapi(ctx)
|
|
return err
|
|
}
|
|
|
|
// This is a simple interface which specifies echo.Route addition functions which
|
|
// are present on both echo.Echo and echo.Group, since we want to allow using
|
|
// either of them for path registration
|
|
type EchoRouter interface {
|
|
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
}
|
|
|
|
// RegisterHandlers adds each server route to the EchoRouter.
|
|
func RegisterHandlers(router EchoRouter, si ServerInterface) {
|
|
RegisterHandlersWithBaseURL(router, si, "")
|
|
}
|
|
|
|
// Registers handlers, and prepends BaseURL to the paths, so that the paths
|
|
// can be served under a prefix.
|
|
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
|
|
|
|
wrapper := ServerInterfaceWrapper{
|
|
Handler: si,
|
|
}
|
|
|
|
router.POST(baseURL+"/compose", wrapper.PostCompose)
|
|
router.GET(baseURL+"/composes/:id", wrapper.GetComposeStatus)
|
|
router.GET(baseURL+"/composes/:id/logs", wrapper.GetComposeLogs)
|
|
router.GET(baseURL+"/composes/:id/manifests", wrapper.GetComposeManifests)
|
|
router.GET(baseURL+"/composes/:id/metadata", wrapper.GetComposeMetadata)
|
|
router.GET(baseURL+"/errors", wrapper.GetErrorList)
|
|
router.GET(baseURL+"/errors/:id", wrapper.GetError)
|
|
router.GET(baseURL+"/openapi", wrapper.GetOpenapi)
|
|
|
|
}
|
|
|
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
|
var swaggerSpec = []string{
|
|
|
|
"H4sIAAAAAAAC/+x8eXPiOhbvV1Exr6rvrbCYnaTq1gwQQtiyAFnIpSslbGELbMmRZJbc6u/+SrINBkxC",
|
|
"Znpm3rzq/qMDtnQ2nfPT0ZHEXwmdOi4liAieuPgr4UIGHSQQC76ZSP41ENcZdgWmJHGRuIMmApgYaJVI",
|
|
"JtAKOq6NdpovoO2hxEUim/jxI5nAss+bh9g6kUwQ6Mg3qmUywXULOVB2EWtXPueCYWKqbhy/x/C+8ZwJ",
|
|
"YoBOARbI4QATgKBugYBgVJqQwEYaTTsqj2r7kTw/wpeKdPVp0KjnHlybQuNWiebrz6iLmMA+f4ZMJfNf",
|
|
"oVSJiwTyUkvERSqbSO6zSCa4BRl6XWJhvUJdp14wJJvefyayuXyhWCpXzrVsLvE9mVA2iBF3QxwyBteK",
|
|
"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rDJjzEBhKoCH9Y9G7LgXCz4TVjUM62gotYe3N78no7HR4FWIuPaEO8JHfPjIaehYOFn",
|
|
"MYiL8R/RMGqqM9BmWAoNvTwujHZuuX4YS5uWJ4RTHwmPEa5+zCHsp4RRS5DgUCmJ/gJEGqiDz5vGOlWB",
|
|
"xcMT38HwGWiKCTIAFCC6eKNcrQX9OjgkmeB7KiSXLn4Qitvbw7/i8dN43BrrSFDuDPdBYP7/GWu74XFC",
|
|
"0EWOu3wcc0FDP+QO4sy/oYFWUBc7ExFT4YcMYCAXEUPGYTTWwp9y8e8NfBQZoZy/AuPzwNhcaj8SF+FQ",
|
|
"fiUufuXov3L0/9dy9ANsisM7RTyaUxxAzPZa6AG4xGm2bZJRh0ePbZ5E2qnTpf/W0N/qEOft/k9l0CkI",
|
|
"jPErzP47YeY7+v9ekMGNA0HbBi7lHE9stPGmbZh9XtCDxN8iIfrmt758ybY3WCdroKbO+EA9LQPY0P1X",
|
|
"Z/38f3gO3wzlrxj9FaNfiVG/b5S0isvNht/x+e82aBLv1bvCBuRUtMp1s7RBsCL+X8wcPlTnx+a4TRzO",
|
|
"9ILLstTwdP+G9+ZSz+6WLnRxWvLhFg5+RQ+6OONft1K1AcRS4U39zCKn8om9jWYBTUzMjxhwAU30L7JR",
|
|
"RiThZd4Nm8/ofP/xfwMAAP//XHsRRt1XAAA=",
|
|
}
|
|
|
|
// GetSwagger returns the content of the embedded swagger specification file
|
|
// or error if failed to decode
|
|
func decodeSpec() ([]byte, error) {
|
|
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error base64 decoding spec: %s", err)
|
|
}
|
|
zr, err := gzip.NewReader(bytes.NewReader(zipped))
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error decompressing spec: %s", err)
|
|
}
|
|
var buf bytes.Buffer
|
|
_, err = buf.ReadFrom(zr)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error decompressing spec: %s", err)
|
|
}
|
|
|
|
return buf.Bytes(), nil
|
|
}
|
|
|
|
var rawSpec = decodeSpecCached()
|
|
|
|
// a naive cached of a decoded swagger spec
|
|
func decodeSpecCached() func() ([]byte, error) {
|
|
data, err := decodeSpec()
|
|
return func() ([]byte, error) {
|
|
return data, err
|
|
}
|
|
}
|
|
|
|
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
|
|
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
|
|
var res = make(map[string]func() ([]byte, error))
|
|
if len(pathToFile) > 0 {
|
|
res[pathToFile] = rawSpec
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
// GetSwagger returns the Swagger specification corresponding to the generated code
|
|
// in this file. The external references of Swagger specification are resolved.
|
|
// The logic of resolving external references is tightly connected to "import-mapping" feature.
|
|
// Externally referenced files must be embedded in the corresponding golang packages.
|
|
// Urls can be supported but this task was out of the scope.
|
|
func GetSwagger() (swagger *openapi3.T, err error) {
|
|
var resolvePath = PathToRawSpec("")
|
|
|
|
loader := openapi3.NewLoader()
|
|
loader.IsExternalRefsAllowed = true
|
|
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
|
|
var pathToFile = url.String()
|
|
pathToFile = path.Clean(pathToFile)
|
|
getSpec, ok := resolvePath[pathToFile]
|
|
if !ok {
|
|
err1 := fmt.Errorf("path not found: %s", pathToFile)
|
|
return nil, err1
|
|
}
|
|
return getSpec()
|
|
}
|
|
var specData []byte
|
|
specData, err = rawSpec()
|
|
if err != nil {
|
|
return
|
|
}
|
|
swagger, err = loader.LoadFromData(specData)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|