SDK.
This commit is contained in:
125
cloudauth-console/src/Cloudauth-consoleClient.cc
Normal file
125
cloudauth-console/src/Cloudauth-consoleClient.cc
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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/cloudauth-console/Cloudauth_consoleClient.h>
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Location;
|
||||
using namespace AlibabaCloud::Cloudauth_console;
|
||||
using namespace AlibabaCloud::Cloudauth_console::Model;
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string SERVICE_NAME = "Cloudauth-console";
|
||||
}
|
||||
|
||||
Cloudauth_consoleClient::Cloudauth_consoleClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||
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, "cloudauth-console");
|
||||
}
|
||||
|
||||
Cloudauth_consoleClient::Cloudauth_consoleClient(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, "cloudauth-console");
|
||||
}
|
||||
|
||||
Cloudauth_consoleClient::Cloudauth_consoleClient(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, "cloudauth-console");
|
||||
}
|
||||
|
||||
Cloudauth_consoleClient::~Cloudauth_consoleClient()
|
||||
{}
|
||||
|
||||
Cloudauth_consoleClient::RetrieveFaceOutcome Cloudauth_consoleClient::retrieveFace(const RetrieveFaceRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return RetrieveFaceOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return RetrieveFaceOutcome(RetrieveFaceResult(outcome.result()));
|
||||
else
|
||||
return RetrieveFaceOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void Cloudauth_consoleClient::retrieveFaceAsync(const RetrieveFaceRequest& request, const RetrieveFaceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, retrieveFace(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
Cloudauth_consoleClient::RetrieveFaceOutcomeCallable Cloudauth_consoleClient::retrieveFaceCallable(const RetrieveFaceRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<RetrieveFaceOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->retrieveFace(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
Cloudauth_consoleClient::UploadIdentifyRecordOutcome Cloudauth_consoleClient::uploadIdentifyRecord(const UploadIdentifyRecordRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return UploadIdentifyRecordOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return UploadIdentifyRecordOutcome(UploadIdentifyRecordResult(outcome.result()));
|
||||
else
|
||||
return UploadIdentifyRecordOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void Cloudauth_consoleClient::uploadIdentifyRecordAsync(const UploadIdentifyRecordRequest& request, const UploadIdentifyRecordAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, uploadIdentifyRecord(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
Cloudauth_consoleClient::UploadIdentifyRecordOutcomeCallable Cloudauth_consoleClient::uploadIdentifyRecordCallable(const UploadIdentifyRecordRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<UploadIdentifyRecordOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->uploadIdentifyRecord(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
62
cloudauth-console/src/model/RetrieveFaceRequest.cc
Normal file
62
cloudauth-console/src/model/RetrieveFaceRequest.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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/cloudauth-console/model/RetrieveFaceRequest.h>
|
||||
|
||||
using AlibabaCloud::Cloudauth_console::Model::RetrieveFaceRequest;
|
||||
|
||||
RetrieveFaceRequest::RetrieveFaceRequest() :
|
||||
RpcServiceRequest("cloudauth-console", "2019-04-03", "RetrieveFace")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
RetrieveFaceRequest::~RetrieveFaceRequest()
|
||||
{}
|
||||
|
||||
std::string RetrieveFaceRequest::getFace64String()const
|
||||
{
|
||||
return face64String_;
|
||||
}
|
||||
|
||||
void RetrieveFaceRequest::setFace64String(const std::string& face64String)
|
||||
{
|
||||
face64String_ = face64String;
|
||||
setBodyParameter("Face64String", face64String);
|
||||
}
|
||||
|
||||
std::string RetrieveFaceRequest::getFaceUrl()const
|
||||
{
|
||||
return faceUrl_;
|
||||
}
|
||||
|
||||
void RetrieveFaceRequest::setFaceUrl(const std::string& faceUrl)
|
||||
{
|
||||
faceUrl_ = faceUrl;
|
||||
setParameter("FaceUrl", faceUrl);
|
||||
}
|
||||
|
||||
std::string RetrieveFaceRequest::getProjectId()const
|
||||
{
|
||||
return projectId_;
|
||||
}
|
||||
|
||||
void RetrieveFaceRequest::setProjectId(const std::string& projectId)
|
||||
{
|
||||
projectId_ = projectId;
|
||||
setParameter("ProjectId", projectId);
|
||||
}
|
||||
|
||||
68
cloudauth-console/src/model/RetrieveFaceResult.cc
Normal file
68
cloudauth-console/src/model/RetrieveFaceResult.cc
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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/cloudauth-console/model/RetrieveFaceResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Cloudauth_console;
|
||||
using namespace AlibabaCloud::Cloudauth_console::Model;
|
||||
|
||||
RetrieveFaceResult::RetrieveFaceResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
RetrieveFaceResult::RetrieveFaceResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
RetrieveFaceResult::~RetrieveFaceResult()
|
||||
{}
|
||||
|
||||
void RetrieveFaceResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto allDataNode = value["Data"]["DataItem"];
|
||||
for (auto valueDataDataItem : allDataNode)
|
||||
{
|
||||
DataItem dataObject;
|
||||
if(!valueDataDataItem["UserId"].isNull())
|
||||
dataObject.userId = std::stol(valueDataDataItem["UserId"].asString());
|
||||
if(!valueDataDataItem["UserName"].isNull())
|
||||
dataObject.userName = valueDataDataItem["UserName"].asString();
|
||||
if(!valueDataDataItem["Rate"].isNull())
|
||||
dataObject.rate = valueDataDataItem["Rate"].asString();
|
||||
data_.push_back(dataObject);
|
||||
}
|
||||
if(!value["Success"].isNull())
|
||||
success_ = value["Success"].asString() == "true";
|
||||
|
||||
}
|
||||
|
||||
std::vector<RetrieveFaceResult::DataItem> RetrieveFaceResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
bool RetrieveFaceResult::getSuccess()const
|
||||
{
|
||||
return success_;
|
||||
}
|
||||
|
||||
150
cloudauth-console/src/model/UploadIdentifyRecordRequest.cc
Normal file
150
cloudauth-console/src/model/UploadIdentifyRecordRequest.cc
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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/cloudauth-console/model/UploadIdentifyRecordRequest.h>
|
||||
|
||||
using AlibabaCloud::Cloudauth_console::Model::UploadIdentifyRecordRequest;
|
||||
|
||||
UploadIdentifyRecordRequest::UploadIdentifyRecordRequest() :
|
||||
RpcServiceRequest("cloudauth-console", "2019-04-03", "UploadIdentifyRecord")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
UploadIdentifyRecordRequest::~UploadIdentifyRecordRequest()
|
||||
{}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getExt()const
|
||||
{
|
||||
return ext_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setExt(const std::string& ext)
|
||||
{
|
||||
ext_ = ext;
|
||||
setParameter("Ext", ext);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getIdentifyingImageUrl()const
|
||||
{
|
||||
return identifyingImageUrl_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setIdentifyingImageUrl(const std::string& identifyingImageUrl)
|
||||
{
|
||||
identifyingImageUrl_ = identifyingImageUrl;
|
||||
setParameter("IdentifyingImageUrl", identifyingImageUrl);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getIdentifyingImageBase64()const
|
||||
{
|
||||
return identifyingImageBase64_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setIdentifyingImageBase64(const std::string& identifyingImageBase64)
|
||||
{
|
||||
identifyingImageBase64_ = identifyingImageBase64;
|
||||
setBodyParameter("IdentifyingImageBase64", identifyingImageBase64);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getDeviceSecret()const
|
||||
{
|
||||
return deviceSecret_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setDeviceSecret(const std::string& deviceSecret)
|
||||
{
|
||||
deviceSecret_ = deviceSecret;
|
||||
setParameter("DeviceSecret", deviceSecret);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getProductKey()const
|
||||
{
|
||||
return productKey_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setProductKey(const std::string& productKey)
|
||||
{
|
||||
productKey_ = productKey;
|
||||
setParameter("ProductKey", productKey);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getUserId()const
|
||||
{
|
||||
return userId_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setUserId(const std::string& userId)
|
||||
{
|
||||
userId_ = userId;
|
||||
setParameter("UserId", userId);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getIotId()const
|
||||
{
|
||||
return iotId_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setIotId(const std::string& iotId)
|
||||
{
|
||||
iotId_ = iotId;
|
||||
setParameter("IotId", iotId);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getDeviceName()const
|
||||
{
|
||||
return deviceName_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setDeviceName(const std::string& deviceName)
|
||||
{
|
||||
deviceName_ = deviceName;
|
||||
setParameter("DeviceName", deviceName);
|
||||
}
|
||||
|
||||
long UploadIdentifyRecordRequest::getIdentifyingTime()const
|
||||
{
|
||||
return identifyingTime_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setIdentifyingTime(long identifyingTime)
|
||||
{
|
||||
identifyingTime_ = identifyingTime;
|
||||
setParameter("IdentifyingTime", std::to_string(identifyingTime));
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getProjectId()const
|
||||
{
|
||||
return projectId_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setProjectId(const std::string& projectId)
|
||||
{
|
||||
projectId_ = projectId;
|
||||
setParameter("ProjectId", projectId);
|
||||
}
|
||||
|
||||
std::string UploadIdentifyRecordRequest::getUserName()const
|
||||
{
|
||||
return userName_;
|
||||
}
|
||||
|
||||
void UploadIdentifyRecordRequest::setUserName(const std::string& userName)
|
||||
{
|
||||
userName_ = userName;
|
||||
setParameter("UserName", userName);
|
||||
}
|
||||
|
||||
58
cloudauth-console/src/model/UploadIdentifyRecordResult.cc
Normal file
58
cloudauth-console/src/model/UploadIdentifyRecordResult.cc
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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/cloudauth-console/model/UploadIdentifyRecordResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Cloudauth_console;
|
||||
using namespace AlibabaCloud::Cloudauth_console::Model;
|
||||
|
||||
UploadIdentifyRecordResult::UploadIdentifyRecordResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
UploadIdentifyRecordResult::UploadIdentifyRecordResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
UploadIdentifyRecordResult::~UploadIdentifyRecordResult()
|
||||
{}
|
||||
|
||||
void UploadIdentifyRecordResult::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["HttpStatusCode"].isNull())
|
||||
httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
|
||||
|
||||
}
|
||||
|
||||
int UploadIdentifyRecordResult::getHttpStatusCode()const
|
||||
{
|
||||
return httpStatusCode_;
|
||||
}
|
||||
|
||||
bool UploadIdentifyRecordResult::getSuccess()const
|
||||
{
|
||||
return success_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user