Support Open Service API.
This commit is contained in:
@@ -31,21 +31,21 @@ ImmClient::ImmClient(const Credentials &credentials, const ClientConfiguration &
|
||||
RpcServiceClient(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, "");
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imm");
|
||||
}
|
||||
|
||||
ImmClient::ImmClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imm");
|
||||
}
|
||||
|
||||
ImmClient::ImmClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(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, "");
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imm");
|
||||
}
|
||||
|
||||
ImmClient::~ImmClient()
|
||||
@@ -2463,6 +2463,42 @@ ImmClient::ListVideosOutcomeCallable ImmClient::listVideosCallable(const ListVid
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
ImmClient::OpenImmServiceOutcome ImmClient::openImmService(const OpenImmServiceRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return OpenImmServiceOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return OpenImmServiceOutcome(OpenImmServiceResult(outcome.result()));
|
||||
else
|
||||
return OpenImmServiceOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void ImmClient::openImmServiceAsync(const OpenImmServiceRequest& request, const OpenImmServiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, openImmService(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
ImmClient::OpenImmServiceOutcomeCallable ImmClient::openImmServiceCallable(const OpenImmServiceRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<OpenImmServiceOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->openImmService(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
ImmClient::PutProjectOutcome ImmClient::putProject(const PutProjectRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
|
||||
@@ -41,9 +41,16 @@ void GetDRMLicenseResult::parse(const std::string &payload)
|
||||
setRequestId(value["RequestId"].asString());
|
||||
if(!value["DRMData"].isNull())
|
||||
dRMData_ = value["DRMData"].asString();
|
||||
if(!value["DeviceInfo"].isNull())
|
||||
deviceInfo_ = value["DeviceInfo"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string GetDRMLicenseResult::getDeviceInfo()const
|
||||
{
|
||||
return deviceInfo_;
|
||||
}
|
||||
|
||||
std::string GetDRMLicenseResult::getDRMData()const
|
||||
{
|
||||
return dRMData_;
|
||||
|
||||
@@ -55,14 +55,14 @@ void GetVideoResult::parse(const std::string &payload)
|
||||
for (auto valueVideoTagsVideoTagsItem : allVideoTagsNode)
|
||||
{
|
||||
VideoTagsItem videoTagsObject;
|
||||
if(!valueVideoTagsVideoTagsItem["VideoTagName"].isNull())
|
||||
videoTagsObject.videoTagName = valueVideoTagsVideoTagsItem["VideoTagName"].asString();
|
||||
if(!valueVideoTagsVideoTagsItem["VideoTagEnName"].isNull())
|
||||
videoTagsObject.videoTagEnName = valueVideoTagsVideoTagsItem["VideoTagEnName"].asString();
|
||||
if(!valueVideoTagsVideoTagsItem["VideoTagConfidence"].isNull())
|
||||
videoTagsObject.videoTagConfidence = std::stof(valueVideoTagsVideoTagsItem["VideoTagConfidence"].asString());
|
||||
if(!valueVideoTagsVideoTagsItem["VideoTagLevel"].isNull())
|
||||
videoTagsObject.videoTagLevel = std::stoi(valueVideoTagsVideoTagsItem["VideoTagLevel"].asString());
|
||||
if(!valueVideoTagsVideoTagsItem["TagName"].isNull())
|
||||
videoTagsObject.tagName = valueVideoTagsVideoTagsItem["TagName"].asString();
|
||||
if(!valueVideoTagsVideoTagsItem["ParentTagName"].isNull())
|
||||
videoTagsObject.parentTagName = valueVideoTagsVideoTagsItem["ParentTagName"].asString();
|
||||
if(!valueVideoTagsVideoTagsItem["TagConfidence"].isNull())
|
||||
videoTagsObject.tagConfidence = std::stof(valueVideoTagsVideoTagsItem["TagConfidence"].asString());
|
||||
if(!valueVideoTagsVideoTagsItem["TagLevel"].isNull())
|
||||
videoTagsObject.tagLevel = std::stoi(valueVideoTagsVideoTagsItem["TagLevel"].asString());
|
||||
videoTags_.push_back(videoTagsObject);
|
||||
}
|
||||
auto allPersonsNode = value["Persons"]["PersonsItem"];
|
||||
|
||||
@@ -99,12 +99,14 @@ void ListVideosResult::parse(const std::string &payload)
|
||||
for (auto allVideosNodeVideoTagsVideoTagsItem : allVideoTagsNode)
|
||||
{
|
||||
VideosItem::VideoTagsItem videoTagsObject;
|
||||
if(!allVideosNodeVideoTagsVideoTagsItem["VideoTagName"].isNull())
|
||||
videoTagsObject.videoTagName = allVideosNodeVideoTagsVideoTagsItem["VideoTagName"].asString();
|
||||
if(!allVideosNodeVideoTagsVideoTagsItem["VideoTagEnName"].isNull())
|
||||
videoTagsObject.videoTagEnName = allVideosNodeVideoTagsVideoTagsItem["VideoTagEnName"].asString();
|
||||
if(!allVideosNodeVideoTagsVideoTagsItem["VideoTagConfidence"].isNull())
|
||||
videoTagsObject.videoTagConfidence = std::stof(allVideosNodeVideoTagsVideoTagsItem["VideoTagConfidence"].asString());
|
||||
if(!allVideosNodeVideoTagsVideoTagsItem["TagName"].isNull())
|
||||
videoTagsObject.tagName = allVideosNodeVideoTagsVideoTagsItem["TagName"].asString();
|
||||
if(!allVideosNodeVideoTagsVideoTagsItem["ParentTagName"].isNull())
|
||||
videoTagsObject.parentTagName = allVideosNodeVideoTagsVideoTagsItem["ParentTagName"].asString();
|
||||
if(!allVideosNodeVideoTagsVideoTagsItem["TagConfidence"].isNull())
|
||||
videoTagsObject.tagConfidence = std::stof(allVideosNodeVideoTagsVideoTagsItem["TagConfidence"].asString());
|
||||
if(!allVideosNodeVideoTagsVideoTagsItem["TagLevel"].isNull())
|
||||
videoTagsObject.tagLevel = std::stoi(allVideosNodeVideoTagsVideoTagsItem["TagLevel"].asString());
|
||||
videosObject.videoTags.push_back(videoTagsObject);
|
||||
}
|
||||
auto allCelebrityNode = allVideosNode["Celebrity"]["CelebrityItem"];
|
||||
|
||||
40
imm/src/model/OpenImmServiceRequest.cc
Normal file
40
imm/src/model/OpenImmServiceRequest.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/imm/model/OpenImmServiceRequest.h>
|
||||
|
||||
using AlibabaCloud::Imm::Model::OpenImmServiceRequest;
|
||||
|
||||
OpenImmServiceRequest::OpenImmServiceRequest() :
|
||||
RpcServiceRequest("imm", "2017-09-06", "OpenImmService")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
OpenImmServiceRequest::~OpenImmServiceRequest()
|
||||
{}
|
||||
|
||||
long OpenImmServiceRequest::getOwnerId()const
|
||||
{
|
||||
return ownerId_;
|
||||
}
|
||||
|
||||
void OpenImmServiceRequest::setOwnerId(long ownerId)
|
||||
{
|
||||
ownerId_ = ownerId;
|
||||
setParameter("OwnerId", std::to_string(ownerId));
|
||||
}
|
||||
|
||||
51
imm/src/model/OpenImmServiceResult.cc
Normal file
51
imm/src/model/OpenImmServiceResult.cc
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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/imm/model/OpenImmServiceResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Imm;
|
||||
using namespace AlibabaCloud::Imm::Model;
|
||||
|
||||
OpenImmServiceResult::OpenImmServiceResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
OpenImmServiceResult::OpenImmServiceResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
OpenImmServiceResult::~OpenImmServiceResult()
|
||||
{}
|
||||
|
||||
void OpenImmServiceResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
if(!value["OrderId"].isNull())
|
||||
orderId_ = value["OrderId"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string OpenImmServiceResult::getOrderId()const
|
||||
{
|
||||
return orderId_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user