github.com/hsdp/go-swagger@v0.19.0/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 {{ range .DefaultImports -}} 25 {{ printf "%q" .}} 26 {{ end -}} 27 {{ range $key, $value := .Imports -}} 28 {{ $key }} {{ printf "%q" $value }} 29 {{ end -}} 30 ) 31 32 const ( 33 // DefaultHost is the default Host 34 // found in Meta (info) section of spec file 35 DefaultHost string = {{ printf "%#v" .Host }} 36 // DefaultBasePath is the default BasePath 37 // found in Meta (info) section of spec file 38 DefaultBasePath string = {{ printf "%#v" .BasePath }} 39 ) 40 41 // DefaultSchemes are the default schemes found in Meta (info) section of spec file 42 var DefaultSchemes = {{ printf "%#v" .Schemes }} 43 44 type Config struct { 45 // URL is the base URL of the upstream server 46 URL *url.URL 47 // Transport is an inner transport for the client 48 Transport http.RoundTripper 49 // AuthInfo is for authentication 50 AuthInfo runtime.ClientAuthInfoWriter 51 } 52 53 // New creates a new {{ humanize .Name }} HTTP client. 54 func New(c Config) *{{ pascalize .Name }} { 55 var ( 56 host = DefaultHost 57 basePath = DefaultBasePath 58 schemes = DefaultSchemes 59 ) 60 61 if c.URL != nil { 62 host = c.URL.Host 63 basePath = c.URL.Path 64 schemes = []string{c.URL.Scheme} 65 } 66 67 transport := rtclient.New(host, basePath, schemes) 68 if c.Transport != nil { 69 transport.Transport = c.Transport 70 } 71 72 cli := new({{ pascalize .Name }}) 73 cli.Transport = transport 74 {{ range .OperationGroups -}} 75 cli.{{ pascalize .Name }} = {{ .Name }}.New(transport, strfmt.Default, c.AuthInfo) 76 {{ end -}} 77 78 return cli 79 } 80 81 // {{ pascalize .Name }} is a client for {{ humanize .Name }} 82 type {{ pascalize .Name }} struct { 83 {{ range .OperationGroups -}} 84 {{ pascalize .Name }} *{{ snakize .Name }}.Client 85 {{ end -}} 86 Transport runtime.ClientTransport 87 }