IMAGESEARCH SDK Auto Released By shenshi,Version:1.34.41

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
This commit is contained in:
haowei.yao
2019-03-18 15:40:31 +08:00
parent d51acd44d7
commit 549e90ee7c
19 changed files with 1068 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
2019-03-18 Version: 1.34.41
1, Update Dependency
2019-03-18 Version: 1.34.40
1, move AssociatePerson\Tag field
2, Optimize RealName field

View File

@@ -107,4 +107,5 @@ add_subdirectory(ubsms)
add_subdirectory(yundun)
add_subdirectory(arms4finance)
add_subdirectory(arms4finance)
add_subdirectory(imagesearch)

View File

@@ -1 +1 @@
1.34.40
1.34.41

View File

@@ -0,0 +1,94 @@
#
# Copyright 2009-2017 Alibaba Cloud All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include)
set(imagesearch_public_header
include/alibabacloud/imagesearch/ImageSearchClient.h
include/alibabacloud/imagesearch/ImageSearchExport.h )
set(imagesearch_public_header_model
include/alibabacloud/imagesearch/model/DeleteItemRequest.h
include/alibabacloud/imagesearch/model/DeleteItemResult.h
include/alibabacloud/imagesearch/model/AddItemRequest.h
include/alibabacloud/imagesearch/model/AddItemResult.h
include/alibabacloud/imagesearch/model/SearchItemRequest.h
include/alibabacloud/imagesearch/model/SearchItemResult.h )
set(imagesearch_src
src/ImageSearchClient.cc
src/model/DeleteItemRequest.cc
src/model/DeleteItemResult.cc
src/model/AddItemRequest.cc
src/model/AddItemResult.cc
src/model/SearchItemRequest.cc
src/model/SearchItemResult.cc )
add_library(imagesearch ${LIB_TYPE}
${imagesearch_public_header}
${imagesearch_public_header_model}
${imagesearch_src})
set_target_properties(imagesearch
PROPERTIES
LINKER_LANGUAGE CXX
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}imagesearch
)
if(${LIB_TYPE} STREQUAL "SHARED")
set_target_properties(imagesearch
PROPERTIES
DEFINE_SYMBOL ALIBABACLOUD_IMAGESEARCH_LIBRARY)
endif()
target_include_directories(imagesearch
PRIVATE include
${CMAKE_SOURCE_DIR}/core/include
)
target_link_libraries(imagesearch
core)
if(CMAKE_HOST_WIN32)
ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
set(jsoncpp_install_dir ${INSTALL_DIR})
add_dependencies(imagesearch
jsoncpp)
target_include_directories(imagesearch
PRIVATE ${jsoncpp_install_dir}/include)
target_link_libraries(imagesearch
${jsoncpp_install_dir}/lib/jsoncpp.lib)
set_target_properties(imagesearch
PROPERTIES
COMPILE_OPTIONS "/bigobj")
else()
target_include_directories(imagesearch
PRIVATE /usr/include/jsoncpp)
target_link_libraries(imagesearch
jsoncpp)
endif()
install(FILES ${imagesearch_public_header}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/imagesearch)
install(FILES ${imagesearch_public_header_model}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/imagesearch/model)
install(TARGETS imagesearch
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View File

@@ -0,0 +1,70 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_IMAGESEARCHCLIENT_H_
#define ALIBABACLOUD_IMAGESEARCH_IMAGESEARCHCLIENT_H_
#include <future>
#include <alibabacloud/core/AsyncCallerContext.h>
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RoaServiceClient.h>
#include "ImageSearchExport.h"
#include "model/DeleteItemRequest.h"
#include "model/DeleteItemResult.h"
#include "model/AddItemRequest.h"
#include "model/AddItemResult.h"
#include "model/SearchItemRequest.h"
#include "model/SearchItemResult.h"
namespace AlibabaCloud
{
namespace ImageSearch
{
class ALIBABACLOUD_IMAGESEARCH_EXPORT ImageSearchClient : public RoaServiceClient
{
public:
typedef Outcome<Error, Model::DeleteItemResult> DeleteItemOutcome;
typedef std::future<DeleteItemOutcome> DeleteItemOutcomeCallable;
typedef std::function<void(const ImageSearchClient*, const Model::DeleteItemRequest&, const DeleteItemOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DeleteItemAsyncHandler;
typedef Outcome<Error, Model::AddItemResult> AddItemOutcome;
typedef std::future<AddItemOutcome> AddItemOutcomeCallable;
typedef std::function<void(const ImageSearchClient*, const Model::AddItemRequest&, const AddItemOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AddItemAsyncHandler;
typedef Outcome<Error, Model::SearchItemResult> SearchItemOutcome;
typedef std::future<SearchItemOutcome> SearchItemOutcomeCallable;
typedef std::function<void(const ImageSearchClient*, const Model::SearchItemRequest&, const SearchItemOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SearchItemAsyncHandler;
ImageSearchClient(const Credentials &credentials, const ClientConfiguration &configuration);
ImageSearchClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
ImageSearchClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~ImageSearchClient();
DeleteItemOutcome deleteItem(const Model::DeleteItemRequest &request)const;
void deleteItemAsync(const Model::DeleteItemRequest& request, const DeleteItemAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DeleteItemOutcomeCallable deleteItemCallable(const Model::DeleteItemRequest& request) const;
AddItemOutcome addItem(const Model::AddItemRequest &request)const;
void addItemAsync(const Model::AddItemRequest& request, const AddItemAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
AddItemOutcomeCallable addItemCallable(const Model::AddItemRequest& request) const;
SearchItemOutcome searchItem(const Model::SearchItemRequest &request)const;
void searchItemAsync(const Model::SearchItemRequest& request, const SearchItemAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
SearchItemOutcomeCallable searchItemCallable(const Model::SearchItemRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;
};
}
}
#endif // !ALIBABACLOUD_IMAGESEARCH_IMAGESEARCHCLIENT_H_

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_IMAGESEARCHEXPORT_H_
#define ALIBABACLOUD_IMAGESEARCH_IMAGESEARCHEXPORT_H_
#include <alibabacloud/core/Global.h>
#if defined(ALIBABACLOUD_SHARED)
# if defined(ALIBABACLOUD_IMAGESEARCH_LIBRARY)
# define ALIBABACLOUD_IMAGESEARCH_EXPORT ALIBABACLOUD_DECL_EXPORT
# else
# define ALIBABACLOUD_IMAGESEARCH_EXPORT ALIBABACLOUD_DECL_IMPORT
# endif
#else
# define ALIBABACLOUD_IMAGESEARCH_EXPORT
#endif
#endif // !ALIBABACLOUD_IMAGESEARCH_IMAGESEARCHEXPORT_H_

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_MODEL_ADDITEMREQUEST_H_
#define ALIBABACLOUD_IMAGESEARCH_MODEL_ADDITEMREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <alibabacloud/imagesearch/ImageSearchExport.h>
namespace AlibabaCloud
{
namespace ImageSearch
{
namespace Model
{
class ALIBABACLOUD_IMAGESEARCH_EXPORT AddItemRequest : public RoaServiceRequest
{
public:
AddItemRequest();
~AddItemRequest();
std::string getInstanceName()const;
void setInstanceName(const std::string& instanceName);
private:
std::string instanceName_;
};
}
}
}
#endif // !ALIBABACLOUD_IMAGESEARCH_MODEL_ADDITEMREQUEST_H_

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_MODEL_ADDITEMRESULT_H_
#define ALIBABACLOUD_IMAGESEARCH_MODEL_ADDITEMRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/imagesearch/ImageSearchExport.h>
namespace AlibabaCloud
{
namespace ImageSearch
{
namespace Model
{
class ALIBABACLOUD_IMAGESEARCH_EXPORT AddItemResult : public ServiceResult
{
public:
AddItemResult();
explicit AddItemResult(const std::string &payload);
~AddItemResult();
std::string getMessage()const;
int getCode()const;
bool getSuccess()const;
protected:
void parse(const std::string &payload);
private:
std::string message_;
int code_;
bool success_;
};
}
}
}
#endif // !ALIBABACLOUD_IMAGESEARCH_MODEL_ADDITEMRESULT_H_

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_MODEL_DELETEITEMREQUEST_H_
#define ALIBABACLOUD_IMAGESEARCH_MODEL_DELETEITEMREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <alibabacloud/imagesearch/ImageSearchExport.h>
namespace AlibabaCloud
{
namespace ImageSearch
{
namespace Model
{
class ALIBABACLOUD_IMAGESEARCH_EXPORT DeleteItemRequest : public RoaServiceRequest
{
public:
DeleteItemRequest();
~DeleteItemRequest();
std::string getInstanceName()const;
void setInstanceName(const std::string& instanceName);
private:
std::string instanceName_;
};
}
}
}
#endif // !ALIBABACLOUD_IMAGESEARCH_MODEL_DELETEITEMREQUEST_H_

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_MODEL_DELETEITEMRESULT_H_
#define ALIBABACLOUD_IMAGESEARCH_MODEL_DELETEITEMRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/imagesearch/ImageSearchExport.h>
namespace AlibabaCloud
{
namespace ImageSearch
{
namespace Model
{
class ALIBABACLOUD_IMAGESEARCH_EXPORT DeleteItemResult : public ServiceResult
{
public:
DeleteItemResult();
explicit DeleteItemResult(const std::string &payload);
~DeleteItemResult();
std::string getMessage()const;
int getCode()const;
bool getSuccess()const;
protected:
void parse(const std::string &payload);
private:
std::string message_;
int code_;
bool success_;
};
}
}
}
#endif // !ALIBABACLOUD_IMAGESEARCH_MODEL_DELETEITEMRESULT_H_

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_MODEL_SEARCHITEMREQUEST_H_
#define ALIBABACLOUD_IMAGESEARCH_MODEL_SEARCHITEMREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <alibabacloud/imagesearch/ImageSearchExport.h>
namespace AlibabaCloud
{
namespace ImageSearch
{
namespace Model
{
class ALIBABACLOUD_IMAGESEARCH_EXPORT SearchItemRequest : public RoaServiceRequest
{
public:
SearchItemRequest();
~SearchItemRequest();
std::string getInstanceName()const;
void setInstanceName(const std::string& instanceName);
private:
std::string instanceName_;
};
}
}
}
#endif // !ALIBABACLOUD_IMAGESEARCH_MODEL_SEARCHITEMREQUEST_H_

View File

@@ -0,0 +1,86 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_IMAGESEARCH_MODEL_SEARCHITEMRESULT_H_
#define ALIBABACLOUD_IMAGESEARCH_MODEL_SEARCHITEMRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/imagesearch/ImageSearchExport.h>
namespace AlibabaCloud
{
namespace ImageSearch
{
namespace Model
{
class ALIBABACLOUD_IMAGESEARCH_EXPORT SearchItemResult : public ServiceResult
{
public:
struct Head
{
int docsFound;
int docsReturn;
int searchTime;
};
struct PicInfo
{
struct Category
{
std::string id;
std::string name;
};
std::string category;
std::vector<Category> allCategory;
std::string region;
};
struct Auction
{
std::string picName;
std::string custContent;
std::string catId;
std::string itemId;
std::string sortExprValues;
};
SearchItemResult();
explicit SearchItemResult(const std::string &payload);
~SearchItemResult();
Head getHead()const;
std::string getMessage()const;
std::vector<Auction> getAuctions()const;
PicInfo getPicInfo()const;
int getCode()const;
bool getSuccess()const;
protected:
void parse(const std::string &payload);
private:
Head head_;
std::string message_;
std::vector<Auction> auctions_;
PicInfo picInfo_;
int code_;
bool success_;
};
}
}
}
#endif // !ALIBABACLOUD_IMAGESEARCH_MODEL_SEARCHITEMRESULT_H_

View File

@@ -0,0 +1,161 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/imagesearch/ImageSearchClient.h>
#include <alibabacloud/core/SimpleCredentialsProvider.h>
using namespace AlibabaCloud;
using namespace AlibabaCloud::Location;
using namespace AlibabaCloud::ImageSearch;
using namespace AlibabaCloud::ImageSearch::Model;
namespace
{
const std::string SERVICE_NAME = "ImageSearch";
}
ImageSearchClient::ImageSearchClient(const Credentials &credentials, const ClientConfiguration &configuration) :
RoaServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imagesearch");
}
ImageSearchClient::ImageSearchClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RoaServiceClient(SERVICE_NAME, credentialsProvider, configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imagesearch");
}
ImageSearchClient::ImageSearchClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RoaServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
{
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imagesearch");
}
ImageSearchClient::~ImageSearchClient()
{}
ImageSearchClient::DeleteItemOutcome ImageSearchClient::deleteItem(const DeleteItemRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return DeleteItemOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return DeleteItemOutcome(DeleteItemResult(outcome.result()));
else
return DeleteItemOutcome(outcome.error());
}
void ImageSearchClient::deleteItemAsync(const DeleteItemRequest& request, const DeleteItemAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, deleteItem(request), context);
};
asyncExecute(new Runnable(fn));
}
ImageSearchClient::DeleteItemOutcomeCallable ImageSearchClient::deleteItemCallable(const DeleteItemRequest &request) const
{
auto task = std::make_shared<std::packaged_task<DeleteItemOutcome()>>(
[this, request]()
{
return this->deleteItem(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
ImageSearchClient::AddItemOutcome ImageSearchClient::addItem(const AddItemRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return AddItemOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return AddItemOutcome(AddItemResult(outcome.result()));
else
return AddItemOutcome(outcome.error());
}
void ImageSearchClient::addItemAsync(const AddItemRequest& request, const AddItemAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, addItem(request), context);
};
asyncExecute(new Runnable(fn));
}
ImageSearchClient::AddItemOutcomeCallable ImageSearchClient::addItemCallable(const AddItemRequest &request) const
{
auto task = std::make_shared<std::packaged_task<AddItemOutcome()>>(
[this, request]()
{
return this->addItem(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
ImageSearchClient::SearchItemOutcome ImageSearchClient::searchItem(const SearchItemRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return SearchItemOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return SearchItemOutcome(SearchItemResult(outcome.result()));
else
return SearchItemOutcome(outcome.error());
}
void ImageSearchClient::searchItemAsync(const SearchItemRequest& request, const SearchItemAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, searchItem(request), context);
};
asyncExecute(new Runnable(fn));
}
ImageSearchClient::SearchItemOutcomeCallable ImageSearchClient::searchItemCallable(const SearchItemRequest &request) const
{
auto task = std::make_shared<std::packaged_task<SearchItemOutcome()>>(
[this, request]()
{
return this->searchItem(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/imagesearch/model/AddItemRequest.h>
using AlibabaCloud::ImageSearch::Model::AddItemRequest;
AddItemRequest::AddItemRequest() :
RoaServiceRequest("imagesearch", "2018-01-20")
{}
AddItemRequest::~AddItemRequest()
{}
std::string AddItemRequest::getInstanceName()const
{
return instanceName_;
}
void AddItemRequest::setInstanceName(const std::string& instanceName)
{
instanceName_ = instanceName;
setParameter("InstanceName", instanceName);
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/imagesearch/model/AddItemResult.h>
#include <json/json.h>
using namespace AlibabaCloud::ImageSearch;
using namespace AlibabaCloud::ImageSearch::Model;
AddItemResult::AddItemResult() :
ServiceResult()
{}
AddItemResult::AddItemResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
AddItemResult::~AddItemResult()
{}
void AddItemResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
if(!value["Message"].isNull())
message_ = value["Message"].asString();
if(!value["Code"].isNull())
code_ = std::stoi(value["Code"].asString());
}
std::string AddItemResult::getMessage()const
{
return message_;
}
int AddItemResult::getCode()const
{
return code_;
}
bool AddItemResult::getSuccess()const
{
return success_;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/imagesearch/model/DeleteItemRequest.h>
using AlibabaCloud::ImageSearch::Model::DeleteItemRequest;
DeleteItemRequest::DeleteItemRequest() :
RoaServiceRequest("imagesearch", "2018-01-20")
{}
DeleteItemRequest::~DeleteItemRequest()
{}
std::string DeleteItemRequest::getInstanceName()const
{
return instanceName_;
}
void DeleteItemRequest::setInstanceName(const std::string& instanceName)
{
instanceName_ = instanceName;
setParameter("InstanceName", instanceName);
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/imagesearch/model/DeleteItemResult.h>
#include <json/json.h>
using namespace AlibabaCloud::ImageSearch;
using namespace AlibabaCloud::ImageSearch::Model;
DeleteItemResult::DeleteItemResult() :
ServiceResult()
{}
DeleteItemResult::DeleteItemResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DeleteItemResult::~DeleteItemResult()
{}
void DeleteItemResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
if(!value["Message"].isNull())
message_ = value["Message"].asString();
if(!value["Code"].isNull())
code_ = std::stoi(value["Code"].asString());
}
std::string DeleteItemResult::getMessage()const
{
return message_;
}
int DeleteItemResult::getCode()const
{
return code_;
}
bool DeleteItemResult::getSuccess()const
{
return success_;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/imagesearch/model/SearchItemRequest.h>
using AlibabaCloud::ImageSearch::Model::SearchItemRequest;
SearchItemRequest::SearchItemRequest() :
RoaServiceRequest("imagesearch", "2018-01-20")
{}
SearchItemRequest::~SearchItemRequest()
{}
std::string SearchItemRequest::getInstanceName()const
{
return instanceName_;
}
void SearchItemRequest::setInstanceName(const std::string& instanceName)
{
instanceName_ = instanceName;
setParameter("InstanceName", instanceName);
}

View File

@@ -0,0 +1,119 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/imagesearch/model/SearchItemResult.h>
#include <json/json.h>
using namespace AlibabaCloud::ImageSearch;
using namespace AlibabaCloud::ImageSearch::Model;
SearchItemResult::SearchItemResult() :
ServiceResult()
{}
SearchItemResult::SearchItemResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
SearchItemResult::~SearchItemResult()
{}
void SearchItemResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto allAuctions = value["Auctions"]["Auction"];
for (auto value : allAuctions)
{
Auction auctionsObject;
if(!value["CustContent"].isNull())
auctionsObject.custContent = value["CustContent"].asString();
if(!value["ItemId"].isNull())
auctionsObject.itemId = value["ItemId"].asString();
if(!value["SortExprValues"].isNull())
auctionsObject.sortExprValues = value["SortExprValues"].asString();
if(!value["CatId"].isNull())
auctionsObject.catId = value["CatId"].asString();
if(!value["PicName"].isNull())
auctionsObject.picName = value["PicName"].asString();
auctions_.push_back(auctionsObject);
}
auto headNode = value["Head"];
if(!headNode["SearchTime"].isNull())
head_.searchTime = std::stoi(headNode["SearchTime"].asString());
if(!headNode["DocsFound"].isNull())
head_.docsFound = std::stoi(headNode["DocsFound"].asString());
if(!headNode["DocsReturn"].isNull())
head_.docsReturn = std::stoi(headNode["DocsReturn"].asString());
auto picInfoNode = value["PicInfo"];
if(!picInfoNode["Category"].isNull())
picInfo_.category = picInfoNode["Category"].asString();
if(!picInfoNode["Region"].isNull())
picInfo_.region = picInfoNode["Region"].asString();
auto allAllCategory = value["AllCategory"]["Category"];
for (auto value : allAllCategory)
{
PicInfo::Category categoryObject;
if(!value["Name"].isNull())
categoryObject.name = value["Name"].asString();
if(!value["Id"].isNull())
categoryObject.id = value["Id"].asString();
picInfo_.allCategory.push_back(categoryObject);
}
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
if(!value["Message"].isNull())
message_ = value["Message"].asString();
if(!value["Code"].isNull())
code_ = std::stoi(value["Code"].asString());
}
SearchItemResult::Head SearchItemResult::getHead()const
{
return head_;
}
std::string SearchItemResult::getMessage()const
{
return message_;
}
std::vector<SearchItemResult::Auction> SearchItemResult::getAuctions()const
{
return auctions_;
}
SearchItemResult::PicInfo SearchItemResult::getPicInfo()const
{
return picInfo_;
}
int SearchItemResult::getCode()const
{
return code_;
}
bool SearchItemResult::getSuccess()const
{
return success_;
}