in providers/ionoscloud/ionoscloud_service.go [106:224]
func NewClientByType(username, password, token, url string, clientType clientType) interface{} {
switch clientType {
case ionosClient:
{
newConfig := ionoscloud.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go/%s_os/%s_arch/%s", ionoscloud.Version, runtime.GOOS, runtime.GOARCH)
return ionoscloud.NewAPIClient(newConfig)
}
case dbaasPgSQLClient:
{
newConfig := dbaasPgSQL.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go-dbaas-postgres/%s_os/%s_arch/%s", dbaasPgSQL.Version, runtime.GOOS, runtime.GOARCH)
return dbaasPgSQL.NewAPIClient(newConfig)
}
case dbaasMongoClient:
{
newConfig := dbaasMongo.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go-dbaas-mongo/%s_os/%s_arch/%s", dbaasMongo.Version, runtime.GOOS, runtime.GOARCH)
return dbaasMongo.NewAPIClient(newConfig)
}
case certificateManagerClient:
{
newConfig := certificateManager.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go-cert-manager/%s_os/%s_arch/%s", certificateManager.Version, runtime.GOOS, runtime.GOARCH)
return certificateManager.NewAPIClient(newConfig)
}
case containerRegistryClient:
{
newConfig := containerRegistry.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go-container-registry/%s_os/%s_arch/%s", containerRegistry.Version, runtime.GOOS, runtime.GOARCH)
return containerRegistry.NewAPIClient(newConfig)
}
case dataPlatformClient:
{
newConfig := dataPlatform.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go-dataplatform/%s_os/%s_arch/%s", dataPlatform.Version, runtime.GOOS, runtime.GOARCH)
return dataPlatform.NewAPIClient(newConfig)
}
case dnsClient:
{
newConfig := dns.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go-dns/%s_os/%s_arch/%s", dns.Version, runtime.GOOS, runtime.GOARCH)
return dns.NewAPIClient(newConfig)
}
case loggingClient:
{
newConfig := logging.NewConfiguration(username, password, token, url)
if os.Getenv(helpers.IonosDebug) != "" {
newConfig.Debug = true
}
newConfig.MaxRetries = helpers.MaxRetries
newConfig.WaitTime = helpers.MaxWaitTime
newConfig.HTTPClient = &http.Client{Transport: CreateTransport()}
newConfig.UserAgent = fmt.Sprintf(
"terraformer_ionos-cloud-sdk-go-logging/%s_os/%s_arch/%s", logging.Version, runtime.GOOS, runtime.GOARCH)
return logging.NewAPIClient(newConfig)
}
default:
log.Printf("[ERROR] unknown client type %d", clientType)
}
return nil
}