imageaudit-20191230/Sources/AlibabacloudImageaudit20191230/Client.swift (87 lines of code) (raw):
import Foundation
import Tea
import TeaUtils
import AlibabacloudOpenApi
import AlibabaCloudOpenApiUtil
import AlibabacloudEndpointUtil
open class Client : AlibabacloudOpenApi.Client {
public override init(_ config: AlibabacloudOpenApi.Config) throws {
try super.init(config)
self._endpointRule = "regional"
try checkConfig(config as! AlibabacloudOpenApi.Config)
self._endpoint = try getEndpoint("imageaudit", self._regionId ?? "", self._endpointRule ?? "", self._network ?? "", self._suffix ?? "", self._endpointMap ?? [:], self._endpoint ?? "")
}
public func getEndpoint(_ productId: String, _ regionId: String, _ endpointRule: String, _ network: String, _ suffix: String, _ endpointMap: [String: String], _ endpoint: String) throws -> String {
if (!TeaUtils.Client.empty(endpoint)) {
return endpoint as! String
}
if (!TeaUtils.Client.isUnset(endpointMap) && !TeaUtils.Client.empty(endpointMap[regionId as! String])) {
return endpointMap[regionId as! String] ?? ""
}
return try AlibabacloudEndpointUtil.Client.getEndpointRules(productId, regionId, endpointRule, network, suffix)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func scanImageWithOptions(_ request: ScanImageRequest, _ runtime: TeaUtils.RuntimeOptions) async throws -> ScanImageResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.scene)) {
body["Scene"] = request.scene ?? [];
}
if (!TeaUtils.Client.isUnset(request.task)) {
body["Task"] = request.task ?? [];
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "ScanImage",
"version": "2019-12-30",
"protocol": "HTTPS",
"pathname": "/",
"method": "POST",
"authType": "AK",
"style": "RPC",
"reqBodyType": "formData",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(ScanImageResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func scanImage(_ request: ScanImageRequest) async throws -> ScanImageResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
return try await scanImageWithOptions(request as! ScanImageRequest, runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func scanTextWithOptions(_ request: ScanTextRequest, _ runtime: TeaUtils.RuntimeOptions) async throws -> ScanTextResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.labels)) {
body["Labels"] = request.labels ?? [];
}
if (!TeaUtils.Client.isUnset(request.tasks)) {
body["Tasks"] = request.tasks ?? [];
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "ScanText",
"version": "2019-12-30",
"protocol": "HTTPS",
"pathname": "/",
"method": "POST",
"authType": "AK",
"style": "RPC",
"reqBodyType": "formData",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(ScanTextResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func scanText(_ request: ScanTextRequest) async throws -> ScanTextResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
return try await scanTextWithOptions(request as! ScanTextRequest, runtime as! TeaUtils.RuntimeOptions)
}
}