mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-18 14:47:38 +01:00
c729e3b9e0
Signed-off-by: He Weiwei <hweiwei@vmware.com>
88 lines
2.1 KiB
Go Template
88 lines
2.1 KiB
Go Template
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
|
|
{{ if .Copyright -}}// {{ comment .Copyright -}}{{ end }}
|
|
|
|
|
|
package {{ .Package }}
|
|
|
|
// This file was generated by the swagger tool.
|
|
// Editing this file might prove futile when you re-run the swagger generate command
|
|
|
|
|
|
import (
|
|
"net/url"
|
|
"net/http"
|
|
|
|
rtclient "github.com/go-openapi/runtime/client"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/spec"
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/runtime"
|
|
"github.com/go-openapi/strfmt"
|
|
|
|
{{ range .DefaultImports -}}
|
|
{{ printf "%q" .}}
|
|
{{ end -}}
|
|
{{ range $key, $value := .Imports -}}
|
|
{{ $key }} {{ printf "%q" $value }}
|
|
{{ end -}}
|
|
)
|
|
|
|
const (
|
|
// DefaultHost is the default Host
|
|
// found in Meta (info) section of spec file
|
|
DefaultHost string = {{ printf "%#v" .Host }}
|
|
// DefaultBasePath is the default BasePath
|
|
// found in Meta (info) section of spec file
|
|
DefaultBasePath string = {{ printf "%#v" .BasePath }}
|
|
)
|
|
|
|
// DefaultSchemes are the default schemes found in Meta (info) section of spec file
|
|
var DefaultSchemes = {{ printf "%#v" .Schemes }}
|
|
|
|
type Config struct {
|
|
// URL is the base URL of the upstream server
|
|
URL *url.URL
|
|
// Transport is an inner transport for the client
|
|
Transport http.RoundTripper
|
|
// AuthInfo is for authentication
|
|
AuthInfo runtime.ClientAuthInfoWriter
|
|
}
|
|
|
|
// New creates a new {{ humanize .Name }} HTTP client.
|
|
func New(c Config) *{{ pascalize .Name }} {
|
|
var (
|
|
host = DefaultHost
|
|
basePath = DefaultBasePath
|
|
schemes = DefaultSchemes
|
|
)
|
|
|
|
if c.URL != nil {
|
|
host = c.URL.Host
|
|
basePath = c.URL.Path
|
|
schemes = []string{c.URL.Scheme}
|
|
}
|
|
|
|
transport := rtclient.New(host, basePath, schemes)
|
|
if c.Transport != nil {
|
|
transport.Transport = c.Transport
|
|
}
|
|
|
|
cli := new({{ pascalize .Name }})
|
|
cli.Transport = transport
|
|
{{ range .OperationGroups -}}
|
|
cli.{{ pascalize .Name }} = {{ .Name }}.New(transport, strfmt.Default, c.AuthInfo)
|
|
{{ end -}}
|
|
|
|
return cli
|
|
}
|
|
|
|
// {{ pascalize .Name }} is a client for {{ humanize .Name }}
|
|
type {{ pascalize .Name }} struct {
|
|
{{ range .OperationGroups -}}
|
|
{{ pascalize .Name }} *{{ snakize .Name }}.Client
|
|
{{ end -}}
|
|
Transport runtime.ClientTransport
|
|
}
|