intelligentcreation-20250301/Sources/AlibabacloudIntelligentCreation20250301/Client.swift (186 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 = ""
try checkConfig(config as! AlibabacloudOpenApi.Config)
self._endpoint = try getEndpoint("intelligentcreation", 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 createLabelTaskWithOptions(_ request: CreateLabelTaskRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> CreateLabelTaskResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.callbackUrl)) {
body["CallbackUrl"] = request.callbackUrl ?? "";
}
if (!TeaUtils.Client.isUnset(request.fileUrl)) {
body["FileUrl"] = request.fileUrl ?? "";
}
if (!TeaUtils.Client.isUnset(request.idempotentId)) {
body["IdempotentId"] = request.idempotentId ?? "";
}
if (!TeaUtils.Client.isUnset(request.labelTemplateId)) {
body["LabelTemplateId"] = request.labelTemplateId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "CreateLabelTask",
"version": "2025-03-01",
"protocol": "HTTPS",
"pathname": "/tongjian/yic-tongjian/openService/v2/aitag/createLabelTask",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
if (TeaUtils.Client.isUnset(self._signatureVersion) || !TeaUtils.Client.equalString(self._signatureVersion, "v4")) {
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateLabelTaskResponse(), tmp)
}
else {
var tmp: [String: Any] = try await execute(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateLabelTaskResponse(), tmp)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createLabelTask(_ request: CreateLabelTaskRequest) async throws -> CreateLabelTaskResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await createLabelTaskWithOptions(request as! CreateLabelTaskRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createOssUploadTokenWithOptions(_ request: CreateOssUploadTokenRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> CreateOssUploadTokenResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.fileName)) {
body["FileName"] = request.fileName ?? "";
}
if (!TeaUtils.Client.isUnset(request.fileType)) {
body["FileType"] = request.fileType ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "CreateOssUploadToken",
"version": "2025-03-01",
"protocol": "HTTPS",
"pathname": "/tongjian/yic-tongjian/openService/v2/base/createOssUploadToken",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
if (TeaUtils.Client.isUnset(self._signatureVersion) || !TeaUtils.Client.equalString(self._signatureVersion, "v4")) {
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateOssUploadTokenResponse(), tmp)
}
else {
var tmp: [String: Any] = try await execute(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateOssUploadTokenResponse(), tmp)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createOssUploadToken(_ request: CreateOssUploadTokenRequest) async throws -> CreateOssUploadTokenResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await createOssUploadTokenWithOptions(request as! CreateOssUploadTokenRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createTextLabelWithOptions(_ request: CreateTextLabelRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> CreateTextLabelResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.data)) {
body["Data"] = request.data ?? "";
}
if (!TeaUtils.Client.isUnset(request.labelTemplateId)) {
body["LabelTemplateId"] = request.labelTemplateId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "CreateTextLabel",
"version": "2025-03-01",
"protocol": "HTTPS",
"pathname": "/tongjian/yic-tongjian/openService/v2/aitag/createTextLabel",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
if (TeaUtils.Client.isUnset(self._signatureVersion) || !TeaUtils.Client.equalString(self._signatureVersion, "v4")) {
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateTextLabelResponse(), tmp)
}
else {
var tmp: [String: Any] = try await execute(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateTextLabelResponse(), tmp)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createTextLabel(_ request: CreateTextLabelRequest) async throws -> CreateTextLabelResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await createTextLabelWithOptions(request as! CreateTextLabelRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func getLabelTaskResultWithOptions(_ request: GetLabelTaskResultRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> GetLabelTaskResultResponse {
try TeaUtils.Client.validateModel(request)
var query: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.taskId)) {
query["TaskId"] = request.taskId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"query": AlibabaCloudOpenApiUtil.Client.query(query)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "GetLabelTaskResult",
"version": "2025-03-01",
"protocol": "HTTPS",
"pathname": "/tongjian/yic-tongjian/openService/v2/aitag/getLabelTaskResult",
"method": "GET",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
if (TeaUtils.Client.isUnset(self._signatureVersion) || !TeaUtils.Client.equalString(self._signatureVersion, "v4")) {
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(GetLabelTaskResultResponse(), tmp)
}
else {
var tmp: [String: Any] = try await execute(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(GetLabelTaskResultResponse(), tmp)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func getLabelTaskResult(_ request: GetLabelTaskResultRequest) async throws -> GetLabelTaskResultResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await getLabelTaskResultWithOptions(request as! GetLabelTaskResultRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
}