mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-20 23:57:42 +01:00
95 lines
3.6 KiB
Go Template
95 lines
3.6 KiB
Go Template
|
// Code generated by go-swagger; DO NOT EDIT.
|
||
|
|
||
|
|
||
|
{{ if .Copyright -}}// {{ comment .Copyright -}}{{ end }}
|
||
|
|
||
|
|
||
|
package {{ .Name }}
|
||
|
|
||
|
// This file was generated by the swagger tool.
|
||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
"github.com/go-openapi/errors"
|
||
|
"github.com/go-openapi/swag"
|
||
|
"github.com/go-openapi/runtime"
|
||
|
"github.com/go-openapi/validate"
|
||
|
|
||
|
strfmt "github.com/go-openapi/strfmt"
|
||
|
|
||
|
{{ range .DefaultImports }}{{ printf "%q" .}}
|
||
|
{{ end }}
|
||
|
{{ range $key, $value := .Imports }}{{ $key }} {{ printf "%q" $value }}
|
||
|
{{ end }}
|
||
|
)
|
||
|
|
||
|
//go:generate mockery -name API -inpkg
|
||
|
|
||
|
// API is the interface of the {{ humanize .Name }} client
|
||
|
type API interface {
|
||
|
{{ range .Operations -}}
|
||
|
/*
|
||
|
{{ pascalize .Name }} {{ if .Summary }}{{ pluralizeFirstWord (humanize .Summary) }}{{ if .Description }}
|
||
|
|
||
|
{{ blockcomment .Description }}{{ end }}{{ else if .Description}}{{ blockcomment .Description }}{{ else }}{{ humanize .Name }} API{{ end -}}
|
||
|
*/
|
||
|
{{ pascalize .Name }}(ctx context.Context, params *{{ pascalize .Name }}Params{{ if .HasStreamingResponse }}, writer io.Writer{{ end }}) {{ if .SuccessResponse }}({{ range .SuccessResponses }}*{{ pascalize .Name }}, {{ end }}{{ end }}error{{ if .SuccessResponse }}){{ end }}
|
||
|
{{ end -}}
|
||
|
}
|
||
|
|
||
|
// New creates a new {{ humanize .Name }} API client.
|
||
|
func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client {
|
||
|
return &Client{
|
||
|
transport: transport,
|
||
|
formats: formats,
|
||
|
authInfo: authInfo,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
Client {{ if .Summary }}{{ .Summary }}{{ if .Description }}
|
||
|
|
||
|
{{ blockcomment .Description }}{{ end }}{{ else if .Description}}{{ blockcomment .Description }}{{ else }}for {{ humanize .Name }} API{{ end }}
|
||
|
*/
|
||
|
type Client struct {
|
||
|
transport runtime.ClientTransport
|
||
|
formats strfmt.Registry
|
||
|
authInfo runtime.ClientAuthInfoWriter
|
||
|
}
|
||
|
|
||
|
{{ range .Operations -}}
|
||
|
/*
|
||
|
{{ pascalize .Name }} {{ if .Summary }}{{ pluralizeFirstWord (humanize .Summary) }}{{ if .Description }}
|
||
|
|
||
|
{{ blockcomment .Description }}{{ end }}{{ else if .Description}}{{ blockcomment .Description }}{{ else }}{{ humanize .Name }} API{{ end }}
|
||
|
*/
|
||
|
func (a *Client) {{ pascalize .Name }}(ctx context.Context, params *{{ pascalize .Name }}Params{{ if .HasStreamingResponse }}, writer io.Writer{{ end }}) {{ if .SuccessResponse }}({{ range .SuccessResponses }}*{{ pascalize .Name }}, {{ end }}{{ end }}error{{ if .SuccessResponse }}){{ end }} {
|
||
|
{{ $length := len .SuccessResponses }}
|
||
|
{{ if .SuccessResponse }}result{{else}}_{{ end }}, err := a.transport.Submit(&runtime.ClientOperation{
|
||
|
ID: {{ printf "%q" .Name }},
|
||
|
Method: {{ printf "%q" .Method }},
|
||
|
PathPattern: {{ printf "%q" .Path }},
|
||
|
ProducesMediaTypes: {{ printf "%#v" .ProducesMediaTypes }},
|
||
|
ConsumesMediaTypes: {{ printf "%#v" .ConsumesMediaTypes }},
|
||
|
Schemes: {{ printf "%#v" .Schemes }},
|
||
|
Params: params,
|
||
|
Reader: &{{ pascalize .Name }}Reader{formats: a.formats{{ if .HasStreamingResponse }}, writer: writer{{ end }}},
|
||
|
{{ if .Authorized -}}
|
||
|
AuthInfo: a.authInfo,
|
||
|
{{ end -}}
|
||
|
Context: ctx,
|
||
|
Client: params.HTTPClient,
|
||
|
})
|
||
|
if err != nil {
|
||
|
return {{ if .SuccessResponse }}{{ padSurround "nil" "nil" 0 $length }}, {{ end }}err
|
||
|
}
|
||
|
{{ if .SuccessResponse }}{{ if eq $length 1 }}return result.(*{{ pascalize .SuccessResponse.Name }}), nil{{ else }}switch value := result.(type) { {{ range $i, $v := .SuccessResponses }}
|
||
|
case *{{ pascalize $v.Name }}:
|
||
|
return {{ padSurround "value" "nil" $i $length }}, nil{{ end }} }
|
||
|
return {{ padSurround "nil" "nil" 0 $length }}, nil{{ end }}
|
||
|
{{ else }}return nil{{ end }}
|
||
|
|
||
|
}
|
||
|
{{ end }}
|