imagesearch-20180319/Sources/AlibabacloudImageSearch20180319/Client.swift (116 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("imagesearch", 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 addItem(_ request: AddItemRequest) async throws -> AddItemResponse { var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:]) var headers: [String: String] = [:] return try await addItemWithOptions(request as! AddItemRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions) } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func addItemWithOptions(_ request: AddItemRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> AddItemResponse { try TeaUtils.Client.validateModel(request) var query: [String: Any] = [:] if (!TeaUtils.Client.isUnset(request.instanceName)) { query["instanceName"] = request.instanceName ?? ""; } var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([ "headers": headers as! [String: String], "query": AlibabaCloudOpenApiUtil.Client.query(query) ]) var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([ "action": "AddItem", "version": "2018-03-19", "protocol": "HTTPS", "pathname": "/item/add", "method": "POST", "authType": "AK", "style": "ROA", "reqBodyType": "json", "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(AddItemResponse(), tmp) } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func deleteItem(_ request: DeleteItemRequest) async throws -> DeleteItemResponse { var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:]) var headers: [String: String] = [:] return try await deleteItemWithOptions(request as! DeleteItemRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions) } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func deleteItemWithOptions(_ request: DeleteItemRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> DeleteItemResponse { try TeaUtils.Client.validateModel(request) var query: [String: Any] = [:] if (!TeaUtils.Client.isUnset(request.instanceName)) { query["instanceName"] = request.instanceName ?? ""; } var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([ "headers": headers as! [String: String], "query": AlibabaCloudOpenApiUtil.Client.query(query) ]) var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([ "action": "DeleteItem", "version": "2018-03-19", "protocol": "HTTPS", "pathname": "/item/delete", "method": "POST", "authType": "AK", "style": "ROA", "reqBodyType": "json", "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(DeleteItemResponse(), tmp) } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func searchItem(_ request: SearchItemRequest) async throws -> SearchItemResponse { var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:]) var headers: [String: String] = [:] return try await searchItemWithOptions(request as! SearchItemRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions) } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func searchItemWithOptions(_ request: SearchItemRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> SearchItemResponse { try TeaUtils.Client.validateModel(request) var query: [String: Any] = [:] if (!TeaUtils.Client.isUnset(request.instanceName)) { query["instanceName"] = request.instanceName ?? ""; } var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([ "headers": headers as! [String: String], "query": AlibabaCloudOpenApiUtil.Client.query(query) ]) var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([ "action": "SearchItem", "version": "2018-03-19", "protocol": "HTTPS", "pathname": "/item/search", "method": "POST", "authType": "AK", "style": "ROA", "reqBodyType": "json", "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(SearchItemResponse(), tmp) } }