public Client(Config config) { if (AlibabaCloud.TeaUtil.Common.IsUnset(config.ToMap())) { throw new TeaException(new Dictionary <string, string> { { "name", "ParameterMissing" }, { "message", "'config' can not be unset" }, }); } if (AlibabaCloud.TeaUtil.Common.Empty(config.Type)) { config.Type = "access_key"; } Aliyun.Credentials.Models.Config credentialConfig = new Aliyun.Credentials.Models.Config { AccessKeyId = config.AccessKeyId, Type = config.Type, AccessKeySecret = config.AccessKeySecret, SecurityToken = config.SecurityToken, }; this._credential = new Aliyun.Credentials.Client(credentialConfig); this._endpoint = config.Endpoint; this._protocol = config.Protocol; this._userAgent = config.UserAgent; }
/** * Init client with Config * @param config config contains the necessary information to create a client */ public Client(Config config) { if (AlibabaCloud.TeaUtil.Common.IsUnset(config.ToMap())) { throw new TeaException(new Dictionary <string, string> { { "code", "ParameterMissing" }, { "message", "'config' can not be unset" }, }); } AlibabaCloud.TeaUtil.Common.ValidateModel(config); if (!AlibabaCloud.TeaUtil.Common.Empty(config.AccessKeyId) && !AlibabaCloud.TeaUtil.Common.Empty(config.AccessKeySecret)) { if (!AlibabaCloud.TeaUtil.Common.Empty(config.SecurityToken)) { config.Type = "sts"; } else { config.Type = "access_key"; } Aliyun.Credentials.Models.Config credentialConfig = new Aliyun.Credentials.Models.Config { AccessKeyId = config.AccessKeyId, Type = config.Type, AccessKeySecret = config.AccessKeySecret, SecurityToken = config.SecurityToken, }; this._credential = new Aliyun.Credentials.Client(credentialConfig); } else if (!AlibabaCloud.TeaUtil.Common.IsUnset(config.Credential)) { this._credential = config.Credential; } else { throw new TeaException(new Dictionary <string, string> { { "code", "ParameterMissing" }, { "message", "'accessKeyId' and 'accessKeySecret' or 'credential' can not be unset" }, }); } this._network = config.Network; this._suffix = config.Suffix; this._endpoint = config.Endpoint; this._protocol = config.Protocol; this._regionId = config.RegionId; this._userAgent = config.UserAgent; this._readTimeout = config.ReadTimeout; this._connectTimeout = config.ConnectTimeout; this._httpProxy = config.HttpProxy; this._httpsProxy = config.HttpsProxy; this._noProxy = config.NoProxy; this._socks5Proxy = config.Socks5Proxy; this._socks5NetWork = config.Socks5NetWork; this._maxIdleConns = config.MaxIdleConns; this._endpointType = config.EndpointType; this._openPlatformEndpoint = config.OpenPlatformEndpoint; }