Add OnsMessageDetail for query message body.
This commit is contained in:
@@ -735,6 +735,42 @@ OnsClient::OnsInstanceUpdateOutcomeCallable OnsClient::onsInstanceUpdateCallable
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
OnsClient::OnsMessageDetailOutcome OnsClient::onsMessageDetail(const OnsMessageDetailRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return OnsMessageDetailOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return OnsMessageDetailOutcome(OnsMessageDetailResult(outcome.result()));
|
||||
else
|
||||
return OnsMessageDetailOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void OnsClient::onsMessageDetailAsync(const OnsMessageDetailRequest& request, const OnsMessageDetailAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, onsMessageDetail(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
OnsClient::OnsMessageDetailOutcomeCallable OnsClient::onsMessageDetailCallable(const OnsMessageDetailRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<OnsMessageDetailOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->onsMessageDetail(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
OnsClient::OnsMessageGetByKeyOutcome OnsClient::onsMessageGetByKey(const OnsMessageGetByKeyRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
|
||||
@@ -43,6 +43,15 @@ void OnsGroupCreateRequest::setRemark(const std::string &remark) {
|
||||
setParameter(std::string("Remark"), remark);
|
||||
}
|
||||
|
||||
std::string OnsGroupCreateRequest::getUserId() const {
|
||||
return userId_;
|
||||
}
|
||||
|
||||
void OnsGroupCreateRequest::setUserId(const std::string &userId) {
|
||||
userId_ = userId;
|
||||
setParameter(std::string("UserId"), userId);
|
||||
}
|
||||
|
||||
std::string OnsGroupCreateRequest::getInstanceId() const {
|
||||
return instanceId_;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,15 @@ OnsInstanceBaseInfoRequest::OnsInstanceBaseInfoRequest()
|
||||
|
||||
OnsInstanceBaseInfoRequest::~OnsInstanceBaseInfoRequest() {}
|
||||
|
||||
std::string OnsInstanceBaseInfoRequest::getUserId() const {
|
||||
return userId_;
|
||||
}
|
||||
|
||||
void OnsInstanceBaseInfoRequest::setUserId(const std::string &userId) {
|
||||
userId_ = userId;
|
||||
setParameter(std::string("UserId"), userId);
|
||||
}
|
||||
|
||||
std::string OnsInstanceBaseInfoRequest::getInstanceId() const {
|
||||
return instanceId_;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ void OnsInstanceInServiceListResult::parse(const std::string &payload)
|
||||
dataObject.instanceId = valueDataInstanceVO["InstanceId"].asString();
|
||||
if(!valueDataInstanceVO["InstanceType"].isNull())
|
||||
dataObject.instanceType = std::stoi(valueDataInstanceVO["InstanceType"].asString());
|
||||
if(!valueDataInstanceVO["CreateTime"].isNull())
|
||||
dataObject.createTime = std::stol(valueDataInstanceVO["CreateTime"].asString());
|
||||
auto allTagsNode = valueDataInstanceVO["Tags"]["Tag"];
|
||||
for (auto valueDataInstanceVOTagsTag : allTagsNode)
|
||||
{
|
||||
|
||||
54
ons/src/model/OnsMessageDetailRequest.cc
Normal file
54
ons/src/model/OnsMessageDetailRequest.cc
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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/ons/model/OnsMessageDetailRequest.h>
|
||||
|
||||
using AlibabaCloud::Ons::Model::OnsMessageDetailRequest;
|
||||
|
||||
OnsMessageDetailRequest::OnsMessageDetailRequest()
|
||||
: RpcServiceRequest("ons", "2019-02-14", "OnsMessageDetail") {
|
||||
setMethod(HttpRequest::Method::Get);
|
||||
}
|
||||
|
||||
OnsMessageDetailRequest::~OnsMessageDetailRequest() {}
|
||||
|
||||
std::string OnsMessageDetailRequest::getMsgId() const {
|
||||
return msgId_;
|
||||
}
|
||||
|
||||
void OnsMessageDetailRequest::setMsgId(const std::string &msgId) {
|
||||
msgId_ = msgId;
|
||||
setParameter(std::string("MsgId"), msgId);
|
||||
}
|
||||
|
||||
std::string OnsMessageDetailRequest::getInstanceId() const {
|
||||
return instanceId_;
|
||||
}
|
||||
|
||||
void OnsMessageDetailRequest::setInstanceId(const std::string &instanceId) {
|
||||
instanceId_ = instanceId;
|
||||
setParameter(std::string("InstanceId"), instanceId);
|
||||
}
|
||||
|
||||
std::string OnsMessageDetailRequest::getTopic() const {
|
||||
return topic_;
|
||||
}
|
||||
|
||||
void OnsMessageDetailRequest::setTopic(const std::string &topic) {
|
||||
topic_ = topic;
|
||||
setParameter(std::string("Topic"), topic);
|
||||
}
|
||||
|
||||
93
ons/src/model/OnsMessageDetailResult.cc
Normal file
93
ons/src/model/OnsMessageDetailResult.cc
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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/ons/model/OnsMessageDetailResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Ons;
|
||||
using namespace AlibabaCloud::Ons::Model;
|
||||
|
||||
OnsMessageDetailResult::OnsMessageDetailResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
OnsMessageDetailResult::OnsMessageDetailResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
OnsMessageDetailResult::~OnsMessageDetailResult()
|
||||
{}
|
||||
|
||||
void OnsMessageDetailResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
if(!dataNode["OffsetId"].isNull())
|
||||
data_.offsetId = dataNode["OffsetId"].asString();
|
||||
if(!dataNode["StoreSize"].isNull())
|
||||
data_.storeSize = std::stoi(dataNode["StoreSize"].asString());
|
||||
if(!dataNode["ReconsumeTimes"].isNull())
|
||||
data_.reconsumeTimes = std::stoi(dataNode["ReconsumeTimes"].asString());
|
||||
if(!dataNode["StoreTimestamp"].isNull())
|
||||
data_.storeTimestamp = std::stol(dataNode["StoreTimestamp"].asString());
|
||||
if(!dataNode["Body"].isNull())
|
||||
data_.body = dataNode["Body"].asString();
|
||||
if(!dataNode["InstanceId"].isNull())
|
||||
data_.instanceId = dataNode["InstanceId"].asString();
|
||||
if(!dataNode["MsgId"].isNull())
|
||||
data_.msgId = dataNode["MsgId"].asString();
|
||||
if(!dataNode["Flag"].isNull())
|
||||
data_.flag = std::stoi(dataNode["Flag"].asString());
|
||||
if(!dataNode["StoreHost"].isNull())
|
||||
data_.storeHost = dataNode["StoreHost"].asString();
|
||||
if(!dataNode["Topic"].isNull())
|
||||
data_.topic = dataNode["Topic"].asString();
|
||||
if(!dataNode["BornTimestamp"].isNull())
|
||||
data_.bornTimestamp = std::stol(dataNode["BornTimestamp"].asString());
|
||||
if(!dataNode["BodyCRC"].isNull())
|
||||
data_.bodyCRC = std::stoi(dataNode["BodyCRC"].asString());
|
||||
if(!dataNode["BornHost"].isNull())
|
||||
data_.bornHost = dataNode["BornHost"].asString();
|
||||
auto allPropertyListNode = dataNode["PropertyList"]["MessageProperty"];
|
||||
for (auto dataNodePropertyListMessageProperty : allPropertyListNode)
|
||||
{
|
||||
Data::MessageProperty messagePropertyObject;
|
||||
if(!dataNodePropertyListMessageProperty["Value"].isNull())
|
||||
messagePropertyObject.value = dataNodePropertyListMessageProperty["Value"].asString();
|
||||
if(!dataNodePropertyListMessageProperty["Name"].isNull())
|
||||
messagePropertyObject.name = dataNodePropertyListMessageProperty["Name"].asString();
|
||||
data_.propertyList.push_back(messagePropertyObject);
|
||||
}
|
||||
if(!value["HelpUrl"].isNull())
|
||||
helpUrl_ = value["HelpUrl"].asString();
|
||||
|
||||
}
|
||||
|
||||
OnsMessageDetailResult::Data OnsMessageDetailResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
std::string OnsMessageDetailResult::getHelpUrl()const
|
||||
{
|
||||
return helpUrl_;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,15 @@ void OnsTopicCreateRequest::setRemark(const std::string &remark) {
|
||||
setParameter(std::string("Remark"), remark);
|
||||
}
|
||||
|
||||
std::string OnsTopicCreateRequest::getUserId() const {
|
||||
return userId_;
|
||||
}
|
||||
|
||||
void OnsTopicCreateRequest::setUserId(const std::string &userId) {
|
||||
userId_ = userId;
|
||||
setParameter(std::string("UserId"), userId);
|
||||
}
|
||||
|
||||
std::string OnsTopicCreateRequest::getInstanceId() const {
|
||||
return instanceId_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user