public T Build() { Client client = Activator.CreateInstance <T>(); if (this._credentials == null) { this._credentials = EnvCredentials.LoadCredentialsFromEnv(CredentialType[0]); } if (!CredentialType.Contains(this._credentials.GetType().Name)) { throw new ArgumentException( $"credential type error, support credential type is {Join(",", CredentialType)}"); } client.WithHttpConfig(_httpConfig ?? HttpConfig.GetDefaultConfig()) .InitSdkHttpClient(this._httpHandler, this._enableLogging, this._logLevel); if (this._region != null) { this._endPoint = _region.Endpoint; this._credentials = _credentials.ProcessAuthParams(client._sdkHttpClient, _region.Id); } if (!_endPoint.StartsWith(HttpScheme)) { _endPoint = HttpsScheme + "://" + _endPoint; } client.WithCredential(this._credentials) .WithEndPoint(this._endPoint); return((T)client); }
public T Build() { Client client = Activator.CreateInstance <T>(); if (this._credential == null) { this._credential = GetCredentialFromEnvironmentVariables(); } client.WithCredential(this._credential) .WithEndPoint(this._endPoint) .WithHttpConfig(_httpConfig ?? HttpConfig.GetDefaultConfig()); return((T)client); }
public T Build() { Client client = Activator.CreateInstance <T>(); if (this._credentials == null) { this._credentials = Credentials.GetCredentialFromEnvironment <T>(_credentialType[0]); } if (!_credentialType.Contains(this._credentials.GetType().Name)) { throw new ArgumentException( $"credential type error, support credential type is {Join(",", _credentialType)}"); } client.WithCredential(this._credentials) .WithEndPoint(this._endPoint) .WithHttpConfig(this._httpConfig ?? HttpConfig.GetDefaultConfig()); client.InitSdkHttpClient(this._httpHandler, this._enableLogging, this._logLevel); return((T)client); }
private Client WithCredential(Credentials credentials) { this._credential = credentials ?? throw new ArgumentNullException(CredentialsNull); this._httpConfig = HttpConfig.GetDefaultConfig(); return(this); }