You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
38 lines
1.0 KiB
package decortsdk
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
|
)
|
|
|
|
type ClientInterface interface {
|
|
CloudAPI() *cloudapi.CloudAPI
|
|
CloudBroker() *cloudbroker.CloudBroker
|
|
}
|
|
|
|
func NewUniversal(cfg config.UniversalConfig) (ClientInterface, error) {
|
|
countConfigs := 0
|
|
var client ClientInterface
|
|
|
|
switch {
|
|
case cfg.Decs3oConfig != nil && reflect.TypeOf(*cfg.Decs3oConfig) == reflect.TypeOf(config.Config{}):
|
|
client = New(*cfg.Decs3oConfig)
|
|
countConfigs++
|
|
case cfg.BVSConfig != nil && reflect.TypeOf(*cfg.BVSConfig) == reflect.TypeOf(config.BVSConfig{}):
|
|
client = NewBVS(*cfg.BVSConfig)
|
|
countConfigs++
|
|
case cfg.LegacyConfig != nil && reflect.TypeOf(*cfg.LegacyConfig) == reflect.TypeOf(config.LegacyConfig{}):
|
|
client = NewLegacy(*cfg.LegacyConfig)
|
|
countConfigs++
|
|
}
|
|
if countConfigs != 1 {
|
|
return nil, fmt.Errorf("only 1 config can be used at a time")
|
|
}
|
|
|
|
return client, nil
|
|
}
|