github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/contributed-templates/stratoscale/client/petstore_client.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package client 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "net/http" 10 "net/url" 11 12 "github.com/go-openapi/runtime" 13 rtclient "github.com/go-openapi/runtime/client" 14 "github.com/go-openapi/strfmt" 15 16 "github.com/thetreep/go-swagger/examples/contributed-templates/stratoscale/client/pet" 17 "github.com/thetreep/go-swagger/examples/contributed-templates/stratoscale/client/store" 18 ) 19 20 const ( 21 // DefaultHost is the default Host 22 // found in Meta (info) section of spec file 23 DefaultHost string = "petstore.service.strato" 24 // DefaultBasePath is the default BasePath 25 // found in Meta (info) section of spec file 26 DefaultBasePath string = "/api/v2" 27 ) 28 29 // DefaultSchemes are the default schemes found in Meta (info) section of spec file 30 var DefaultSchemes = []string{"http"} 31 32 type Config struct { 33 // URL is the base URL of the upstream server 34 URL *url.URL 35 // Transport is an inner transport for the client 36 Transport http.RoundTripper 37 // AuthInfo is for authentication 38 AuthInfo runtime.ClientAuthInfoWriter 39 } 40 41 // New creates a new petstore HTTP client. 42 func New(c Config) *Petstore { 43 var ( 44 host = DefaultHost 45 basePath = DefaultBasePath 46 schemes = DefaultSchemes 47 ) 48 49 if c.URL != nil { 50 host = c.URL.Host 51 basePath = c.URL.Path 52 schemes = []string{c.URL.Scheme} 53 } 54 55 transport := rtclient.New(host, basePath, schemes) 56 if c.Transport != nil { 57 transport.Transport = c.Transport 58 } 59 60 cli := new(Petstore) 61 cli.Transport = transport 62 cli.Pet = pet.New(transport, strfmt.Default, c.AuthInfo) 63 cli.Store = store.New(transport, strfmt.Default, c.AuthInfo) 64 return cli 65 } 66 67 // Petstore is a client for petstore 68 type Petstore struct { 69 Pet pet.API 70 Store store.API 71 Transport runtime.ClientTransport 72 }