github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/generator/templates/contrib/stratoscale/client/facade.gotmpl (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 4 {{ if .Copyright -}}// {{ comment .Copyright -}}{{ end }} 5 6 7 package {{ .Package }} 8 9 // This file was generated by the swagger tool. 10 // Editing this file might prove futile when you re-run the swagger generate command 11 12 13 import ( 14 "net/url" 15 "net/http" 16 17 rtclient "github.com/go-openapi/runtime/client" 18 "github.com/go-openapi/swag" 19 "github.com/go-openapi/spec" 20 "github.com/go-openapi/errors" 21 "github.com/go-openapi/runtime" 22 "github.com/go-openapi/strfmt" 23 24 {{ imports .DefaultImports }} 25 {{ imports .Imports }} 26 ) 27 28 const ( 29 // DefaultHost is the default Host 30 // found in Meta (info) section of spec file 31 DefaultHost string = {{ printf "%#v" .Host }} 32 // DefaultBasePath is the default BasePath 33 // found in Meta (info) section of spec file 34 DefaultBasePath string = {{ printf "%#v" .BasePath }} 35 ) 36 37 // DefaultSchemes are the default schemes found in Meta (info) section of spec file 38 var DefaultSchemes = {{ printf "%#v" .Schemes }} 39 40 type Config struct { 41 // URL is the base URL of the upstream server 42 URL *url.URL 43 // Transport is an inner transport for the client 44 Transport http.RoundTripper 45 // AuthInfo is for authentication 46 AuthInfo runtime.ClientAuthInfoWriter 47 } 48 49 // New creates a new {{ humanize .Name }} HTTP client. 50 func New(c Config) *{{ pascalize .Name }} { 51 var ( 52 host = DefaultHost 53 basePath = DefaultBasePath 54 schemes = DefaultSchemes 55 ) 56 57 if c.URL != nil { 58 host = c.URL.Host 59 basePath = c.URL.Path 60 schemes = []string{c.URL.Scheme} 61 } 62 63 transport := rtclient.New(host, basePath, schemes) 64 if c.Transport != nil { 65 transport.Transport = c.Transport 66 } 67 68 cli := new({{ pascalize .Name }}) 69 cli.Transport = transport 70 {{ range .OperationGroups -}} 71 cli.{{ pascalize .Name }} = {{ .PackageAlias }}.New(transport, strfmt.Default, c.AuthInfo) 72 {{ end -}} 73 74 return cli 75 } 76 77 // {{ pascalize .Name }} is a client for {{ humanize .Name }} 78 type {{ pascalize .Name }} struct { 79 {{ range .OperationGroups -}} 80 {{ pascalize .Name }} {{ .PackageAlias }}.API 81 {{ end -}} 82 Transport runtime.ClientTransport 83 }