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