github.com/arunkumar7540/cli@v6.45.0+incompatible/command/v7/shared/noaa_client.go (about) 1 package shared 2 3 import ( 4 "crypto/tls" 5 "net/http" 6 7 "code.cloudfoundry.org/cli/api/uaa" 8 "code.cloudfoundry.org/cli/api/uaa/noaabridge" 9 "code.cloudfoundry.org/cli/command" 10 "github.com/cloudfoundry/noaa/consumer" 11 ) 12 13 // NewNOAAClient returns back a configured NOAA Client. 14 func NewNOAAClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) *consumer.Consumer { 15 client := consumer.New( 16 apiURL, 17 &tls.Config{ 18 InsecureSkipVerify: config.SkipSSLValidation(), 19 }, 20 http.ProxyFromEnvironment, 21 ) 22 client.RefreshTokenFrom(noaabridge.NewTokenRefresher(uaaClient, config)) 23 client.SetMaxRetryCount(config.NOAARequestRetryCount()) 24 25 noaaDebugPrinter := NOAADebugPrinter{} 26 27 // if verbose, set debug printer on noaa client 28 verbose, location := config.Verbose() 29 30 client.SetDebugPrinter(&noaaDebugPrinter) 31 32 if verbose { 33 noaaDebugPrinter.addOutput(ui.RequestLoggerTerminalDisplay()) 34 } 35 if location != nil { 36 noaaDebugPrinter.addOutput(ui.RequestLoggerFileWriter(location)) 37 } 38 39 return client 40 }