com.aliyun.imageaudit.Client Maven / Gradle / Ivy
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.imageaudit;
import com.aliyun.tea.*;
import com.aliyun.imageaudit.models.*;
public class Client {
public String _endpoint;
public String _regionId;
public String _protocol;
public String _userAgent;
public Integer _readTimeout;
public Integer _connectTimeout;
public String _httpProxy;
public String _httpsProxy;
public String _noProxy;
public String _socks5Proxy;
public String _socks5NetWork;
public Integer _maxIdleConns;
public com.aliyun.credentials.Client _credential;
public Client(Config config) throws Exception {
if (com.aliyun.teautil.Common.isUnset(TeaModel.buildMap(config))) {
throw new TeaException(TeaConverter.buildMap(
new TeaPair("name", "ParameterMissing"),
new TeaPair("message", "'config' can not be unset")
));
}
if (com.aliyun.teautil.Common.empty(config.endpoint)) {
throw new TeaException(TeaConverter.buildMap(
new TeaPair("name", "ParameterMissing"),
new TeaPair("message", "'config.endpoint' can not be empty")
));
}
if (com.aliyun.teautil.Common.empty(config.regionId)) {
throw new TeaException(TeaConverter.buildMap(
new TeaPair("name", "ParameterMissing"),
new TeaPair("message", "'config.regionId' can not be empty")
));
}
if (com.aliyun.teautil.Common.empty(config.type)) {
config.type = "access_key";
}
com.aliyun.credentials.models.Config credentialConfig = com.aliyun.credentials.models.Config.build(TeaConverter.buildMap(
new TeaPair("accessKeyId", config.accessKeyId),
new TeaPair("type", config.type),
new TeaPair("accessKeySecret", config.accessKeySecret),
new TeaPair("securityToken", config.securityToken)
));
this._credential = new com.aliyun.credentials.Client(credentialConfig);
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;
}
public java.util.Map _request(String action, String protocol, String method, java.util.Map request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
java.util.Map runtime_ = TeaConverter.buildMap(
new TeaPair("timeouted", "retry"),
new TeaPair("readTimeout", com.aliyun.teautil.Common.defaultNumber(runtime.readTimeout, _readTimeout)),
new TeaPair("connectTimeout", com.aliyun.teautil.Common.defaultNumber(runtime.connectTimeout, _connectTimeout)),
new TeaPair("httpProxy", com.aliyun.teautil.Common.defaultString(runtime.httpProxy, _httpProxy)),
new TeaPair("httpsProxy", com.aliyun.teautil.Common.defaultString(runtime.httpsProxy, _httpsProxy)),
new TeaPair("noProxy", com.aliyun.teautil.Common.defaultString(runtime.noProxy, _noProxy)),
new TeaPair("maxIdleConns", com.aliyun.teautil.Common.defaultNumber(runtime.maxIdleConns, _maxIdleConns)),
new TeaPair("retry", TeaConverter.buildMap(
new TeaPair("retryable", runtime.autoretry),
new TeaPair("maxAttempts", com.aliyun.teautil.Common.defaultNumber(runtime.maxAttempts, 2))
)),
new TeaPair("backoff", TeaConverter.buildMap(
new TeaPair("policy", com.aliyun.teautil.Common.defaultString(runtime.backoffPolicy, "no")),
new TeaPair("period", com.aliyun.teautil.Common.defaultNumber(runtime.backoffPeriod, 0))
)),
new TeaPair("ignoreSSL", runtime.ignoreSSL)
);
TeaRequest _lastRequest = null;
long _now = System.currentTimeMillis();
int _retryTimes = 0;
while (Tea.allowRetry((java.util.Map) runtime_.get("retry"), _retryTimes, _now)) {
if (_retryTimes > 0) {
int backoffTime = Tea.getBackoffTime(runtime_.get("backoff"), _retryTimes);
if (backoffTime > 0) {
Tea.sleep(backoffTime);
}
}
_retryTimes = _retryTimes + 1;
try {
TeaRequest request_ = new TeaRequest();
String accessKeyId = this.getAccessKeyId();
String accessKeySecret = this.getAccessKeySecret();
request_.protocol = com.aliyun.teautil.Common.defaultString(_protocol, protocol);
request_.method = method;
request_.pathname = "/";
request_.query = com.aliyun.common.Common.query(TeaConverter.merge(Object.class,
TeaConverter.buildMap(
new TeaPair("Action", action),
new TeaPair("Format", "json"),
new TeaPair("RegionId", _regionId),
new TeaPair("Timestamp", com.aliyun.common.Common.getTimestamp()),
new TeaPair("Version", "2019-12-30"),
new TeaPair("SignatureMethod", "HMAC-SHA1"),
new TeaPair("SignatureVersion", "1.0"),
new TeaPair("SignatureNonce", com.aliyun.teautil.Common.getNonce()),
new TeaPair("AccessKeyId", accessKeyId)
),
request
));
request_.headers = TeaConverter.buildMap(
new TeaPair("host", com.aliyun.common.Common.getHost("imageaudit", _regionId, _endpoint)),
new TeaPair("user-agent", this.getUserAgent())
);
request_.query.put("Signature", com.aliyun.common.Common.getSignature(request_, accessKeySecret));
_lastRequest = request_;
TeaResponse response_ = Tea.doAction(request_, runtime_);
Object obj = com.aliyun.teautil.Common.readAsJSON(response_.body);
java.util.Map body = com.aliyun.teautil.Common.assertAsMap(obj);
if (com.aliyun.common.Common.hasError(body)) {
throw new TeaException(TeaConverter.buildMap(
new TeaPair("message", body.get("Message")),
new TeaPair("data", body),
new TeaPair("code", body.get("Code"))
));
}
return body;
} catch (Exception e) {
if (Tea.isRetryable(e)) {
continue;
}
throw e;
}
}
throw new TeaUnretryableException(_lastRequest);
}
public ScanTextResponse scanText(ScanTextRequest request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
return TeaModel.toModel(this._request("ScanText", "HTTPS", "POST", TeaModel.buildMap(request), runtime), new ScanTextResponse());
}
public ScanImageResponse scanImage(ScanImageRequest request, com.aliyun.teautil.models.RuntimeOptions runtime) throws Exception {
return TeaModel.toModel(this._request("ScanImage", "HTTPS", "POST", TeaModel.buildMap(request), runtime), new ScanImageResponse());
}
public String getUserAgent() throws Exception {
String userAgent = com.aliyun.teautil.Common.getUserAgent(_userAgent);
return userAgent;
}
public String getAccessKeyId() throws Exception {
if (com.aliyun.teautil.Common.isUnset(_credential)) {
return "";
}
String accessKeyId = _credential.getAccessKeyId();
return accessKeyId;
}
public String getAccessKeySecret() throws Exception {
if (com.aliyun.teautil.Common.isUnset(_credential)) {
return "";
}
String secret = _credential.getAccessKeySecret();
return secret;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy