NewNetworkingClient creates a new cfnetworking client.
(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI)
| 10 | |
| 11 | // NewNetworkingClient creates a new cfnetworking client. |
| 12 | func NewNetworkingClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) (*cfnetv1.Client, error) { |
| 13 | if apiURL == "" { |
| 14 | return nil, translatableerror.CFNetworkingEndpointNotFoundError{} |
| 15 | } |
| 16 | |
| 17 | wrappers := []cfnetv1.ConnectionWrapper{} |
| 18 | |
| 19 | verbose, location := config.Verbose() |
| 20 | if verbose { |
| 21 | wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) |
| 22 | } |
| 23 | if location != nil { |
| 24 | wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) |
| 25 | } |
| 26 | |
| 27 | authWrapper := wrapper.NewUAAAuthentication(uaaClient, config) |
| 28 | wrappers = append(wrappers, authWrapper) |
| 29 | |
| 30 | wrappers = append(wrappers, wrapper.NewRetryRequest(config.RequestRetryCount())) |
| 31 | |
| 32 | return cfnetv1.NewClient(cfnetv1.Config{ |
| 33 | AppName: config.BinaryName(), |
| 34 | AppVersion: config.BinaryVersion(), |
| 35 | DialTimeout: config.DialTimeout(), |
| 36 | SkipSSLValidation: config.SkipSSLValidation(), |
| 37 | URL: apiURL, |
| 38 | Wrappers: wrappers, |
| 39 | }), nil |
| 40 | } |
no test coverage detected