github.com/sap/cf-mta-plugin@v2.6.3+incompatible/clients/cfrestclient/http_cloud_foundry_client_extended.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package cfrestclient 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 "github.com/go-openapi/runtime" 10 httptransport "github.com/go-openapi/runtime/client" 11 12 strfmt "github.com/go-openapi/strfmt" 13 14 "github.com/cloudfoundry-incubator/multiapps-cli-plugin/clients/cfrestclient/operations" 15 ) 16 17 // Default cloud foundry client extended HTTP client. 18 var Default = NewHTTPClient(nil) 19 20 const ( 21 // DefaultHost is the default Host 22 // found in Meta (info) section of spec file 23 DefaultHost string = "api.cf.sap.hana.ondemand.com" 24 // DefaultBasePath is the default BasePath 25 // found in Meta (info) section of spec file 26 DefaultBasePath string = "/v2/" 27 DefaultRawBasePath string = "/v2/" 28 ) 29 30 // DefaultSchemes are the default schemes found in Meta (info) section of spec file 31 var DefaultSchemes = []string{"https"} 32 33 // NewHTTPClient creates a new cloud foundry client extended HTTP client. 34 func NewHTTPClient(formats strfmt.Registry) *CloudFoundryClientExtended { 35 return NewHTTPClientWithConfig(formats, nil) 36 } 37 38 // NewHTTPClientWithConfig creates a new cloud foundry client extended HTTP client, 39 // using a customizable transport config. 40 func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *CloudFoundryClientExtended { 41 // ensure nullable parameters have default 42 if formats == nil { 43 formats = strfmt.Default 44 } 45 if cfg == nil { 46 cfg = DefaultTransportConfig() 47 } 48 49 // create transport and client 50 transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.RawBasePath, cfg.Schemes) 51 return New(transport, formats) 52 } 53 54 // New creates a new cloud foundry client extended client 55 func New(transport runtime.ClientTransport, formats strfmt.Registry) *CloudFoundryClientExtended { 56 cli := new(CloudFoundryClientExtended) 57 cli.Transport = transport 58 59 cli.Operations = operations.New(transport, formats) 60 61 return cli 62 } 63 64 // DefaultTransportConfig creates a TransportConfig with the 65 // default settings taken from the meta section of the spec file. 66 func DefaultTransportConfig() *TransportConfig { 67 return &TransportConfig{ 68 Host: DefaultHost, 69 BasePath: DefaultBasePath, 70 RawBasePath: DefaultRawBasePath, 71 Schemes: DefaultSchemes, 72 } 73 } 74 75 // TransportConfig contains the transport related info, 76 // found in the meta section of the spec file. 77 type TransportConfig struct { 78 Host string 79 BasePath string 80 RawBasePath string 81 Schemes []string 82 } 83 84 // WithHost overrides the default host, 85 // provided by the meta section of the spec file. 86 func (cfg *TransportConfig) WithHost(host string) *TransportConfig { 87 cfg.Host = host 88 return cfg 89 } 90 91 // WithBasePath overrides the default basePath, 92 // provided by the meta section of the spec file. 93 func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { 94 cfg.BasePath = basePath 95 return cfg 96 } 97 98 // WithSchemes overrides the default schemes, 99 // provided by the meta section of the spec file. 100 func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { 101 cfg.Schemes = schemes 102 return cfg 103 } 104 105 // CloudFoundryClientExtended is a client for cloud foundry client extended 106 type CloudFoundryClientExtended struct { 107 Operations *operations.Client 108 109 Transport runtime.ClientTransport 110 } 111 112 // SetTransport changes the transport on the client and all its subresources 113 func (c *CloudFoundryClientExtended) SetTransport(transport runtime.ClientTransport) { 114 c.Transport = transport 115 116 c.Operations.SetTransport(transport) 117 118 }