Add UpdateConsumerOffset api.

This commit is contained in:
sdk-team
2023-04-25 11:50:15 +00:00
parent fd111fd0e2
commit 93a074e698
16 changed files with 341 additions and 4 deletions

View File

@@ -85,6 +85,8 @@ set(alikafka_public_header_model
include/alibabacloud/alikafka/model/UntagResourcesResult.h
include/alibabacloud/alikafka/model/UpdateAllowedIpRequest.h
include/alibabacloud/alikafka/model/UpdateAllowedIpResult.h
include/alibabacloud/alikafka/model/UpdateConsumerOffsetRequest.h
include/alibabacloud/alikafka/model/UpdateConsumerOffsetResult.h
include/alibabacloud/alikafka/model/UpdateInstanceConfigRequest.h
include/alibabacloud/alikafka/model/UpdateInstanceConfigResult.h
include/alibabacloud/alikafka/model/UpgradeInstanceVersionRequest.h
@@ -160,6 +162,8 @@ set(alikafka_src
src/model/UntagResourcesResult.cc
src/model/UpdateAllowedIpRequest.cc
src/model/UpdateAllowedIpResult.cc
src/model/UpdateConsumerOffsetRequest.cc
src/model/UpdateConsumerOffsetResult.cc
src/model/UpdateInstanceConfigRequest.cc
src/model/UpdateInstanceConfigResult.cc
src/model/UpgradeInstanceVersionRequest.cc

View File

@@ -86,6 +86,8 @@
#include "model/UntagResourcesResult.h"
#include "model/UpdateAllowedIpRequest.h"
#include "model/UpdateAllowedIpResult.h"
#include "model/UpdateConsumerOffsetRequest.h"
#include "model/UpdateConsumerOffsetResult.h"
#include "model/UpdateInstanceConfigRequest.h"
#include "model/UpdateInstanceConfigResult.h"
#include "model/UpgradeInstanceVersionRequest.h"
@@ -199,6 +201,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::UpdateAllowedIpResult> UpdateAllowedIpOutcome;
typedef std::future<UpdateAllowedIpOutcome> UpdateAllowedIpOutcomeCallable;
typedef std::function<void(const AlikafkaClient*, const Model::UpdateAllowedIpRequest&, const UpdateAllowedIpOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateAllowedIpAsyncHandler;
typedef Outcome<Error, Model::UpdateConsumerOffsetResult> UpdateConsumerOffsetOutcome;
typedef std::future<UpdateConsumerOffsetOutcome> UpdateConsumerOffsetOutcomeCallable;
typedef std::function<void(const AlikafkaClient*, const Model::UpdateConsumerOffsetRequest&, const UpdateConsumerOffsetOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateConsumerOffsetAsyncHandler;
typedef Outcome<Error, Model::UpdateInstanceConfigResult> UpdateInstanceConfigOutcome;
typedef std::future<UpdateInstanceConfigOutcome> UpdateInstanceConfigOutcomeCallable;
typedef std::function<void(const AlikafkaClient*, const Model::UpdateInstanceConfigRequest&, const UpdateInstanceConfigOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UpdateInstanceConfigAsyncHandler;
@@ -312,6 +317,9 @@ namespace AlibabaCloud
UpdateAllowedIpOutcome updateAllowedIp(const Model::UpdateAllowedIpRequest &request)const;
void updateAllowedIpAsync(const Model::UpdateAllowedIpRequest& request, const UpdateAllowedIpAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateAllowedIpOutcomeCallable updateAllowedIpCallable(const Model::UpdateAllowedIpRequest& request) const;
UpdateConsumerOffsetOutcome updateConsumerOffset(const Model::UpdateConsumerOffsetRequest &request)const;
void updateConsumerOffsetAsync(const Model::UpdateConsumerOffsetRequest& request, const UpdateConsumerOffsetAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateConsumerOffsetOutcomeCallable updateConsumerOffsetCallable(const Model::UpdateConsumerOffsetRequest& request) const;
UpdateInstanceConfigOutcome updateInstanceConfig(const Model::UpdateInstanceConfigRequest &request)const;
void updateInstanceConfigAsync(const Model::UpdateInstanceConfigRequest& request, const UpdateInstanceConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UpdateInstanceConfigOutcomeCallable updateInstanceConfigCallable(const Model::UpdateInstanceConfigRequest& request) const;

View File

@@ -40,6 +40,7 @@ namespace AlibabaCloud
std::string key;
};
std::string instanceId;
bool automaticallyCreatedGroup;
std::string consumerId;
std::string regionId;
std::vector<ConsumerVO::TagVO> tags;

View File

@@ -75,6 +75,7 @@ namespace AlibabaCloud
std::string domainEndpoint;
int paidType;
std::string standardZoneId;
std::string ioMaxSpec;
std::string regionId;
};

View File

@@ -42,6 +42,7 @@ namespace AlibabaCloud
int partitionNumOfBuy;
int partitionLeft;
int topicQuota;
int partitionQuota;
int topicNumOfBuy;
int partitionUsed;
int groupLeft;

View File

@@ -44,6 +44,7 @@ namespace AlibabaCloud
bool compactTopic;
std::string instanceId;
long createTime;
bool autoCreate;
std::string statusName;
std::string regionId;
std::string topic;

View File

@@ -0,0 +1,64 @@
/*
* 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_ALIKAFKA_MODEL_UPDATECONSUMEROFFSETREQUEST_H_
#define ALIBABACLOUD_ALIKAFKA_MODEL_UPDATECONSUMEROFFSETREQUEST_H_
#include <alibabacloud/alikafka/AlikafkaExport.h>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <string>
#include <vector>
#include <map>
namespace AlibabaCloud {
namespace Alikafka {
namespace Model {
class ALIBABACLOUD_ALIKAFKA_EXPORT UpdateConsumerOffsetRequest : public RpcServiceRequest {
public:
struct Offsets {
int partition;
long offset;
};
UpdateConsumerOffsetRequest();
~UpdateConsumerOffsetRequest();
std::string getConsumerId() const;
void setConsumerId(const std::string &consumerId);
std::string getResetType() const;
void setResetType(const std::string &resetType);
std::string getInstanceId() const;
void setInstanceId(const std::string &instanceId);
std::string getRegionId() const;
void setRegionId(const std::string &regionId);
std::vector<Offsets> getOffsets() const;
void setOffsets(const std::vector<Offsets> &offsets);
std::string getTopic() const;
void setTopic(const std::string &topic);
std::string getTime() const;
void setTime(const std::string &time);
private:
std::string consumerId_;
std::string resetType_;
std::string instanceId_;
std::string regionId_;
std::vector<Offsets> offsets_;
std::string topic_;
std::string time_;
};
} // namespace Model
} // namespace Alikafka
} // namespace AlibabaCloud
#endif // !ALIBABACLOUD_ALIKAFKA_MODEL_UPDATECONSUMEROFFSETREQUEST_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_ALIKAFKA_MODEL_UPDATECONSUMEROFFSETRESULT_H_
#define ALIBABACLOUD_ALIKAFKA_MODEL_UPDATECONSUMEROFFSETRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/alikafka/AlikafkaExport.h>
namespace AlibabaCloud
{
namespace Alikafka
{
namespace Model
{
class ALIBABACLOUD_ALIKAFKA_EXPORT UpdateConsumerOffsetResult : public ServiceResult
{
public:
UpdateConsumerOffsetResult();
explicit UpdateConsumerOffsetResult(const std::string &payload);
~UpdateConsumerOffsetResult();
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_ALIKAFKA_MODEL_UPDATECONSUMEROFFSETRESULT_H_

View File

@@ -31,21 +31,21 @@ AlikafkaClient::AlikafkaClient(const Credentials &credentials, const ClientConfi
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, "alikafka");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
AlikafkaClient::AlikafkaClient(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, "alikafka");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
AlikafkaClient::AlikafkaClient(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, "alikafka");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
AlikafkaClient::~AlikafkaClient()
@@ -1203,6 +1203,42 @@ AlikafkaClient::UpdateAllowedIpOutcomeCallable AlikafkaClient::updateAllowedIpCa
return task->get_future();
}
AlikafkaClient::UpdateConsumerOffsetOutcome AlikafkaClient::updateConsumerOffset(const UpdateConsumerOffsetRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return UpdateConsumerOffsetOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return UpdateConsumerOffsetOutcome(UpdateConsumerOffsetResult(outcome.result()));
else
return UpdateConsumerOffsetOutcome(outcome.error());
}
void AlikafkaClient::updateConsumerOffsetAsync(const UpdateConsumerOffsetRequest& request, const UpdateConsumerOffsetAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, updateConsumerOffset(request), context);
};
asyncExecute(new Runnable(fn));
}
AlikafkaClient::UpdateConsumerOffsetOutcomeCallable AlikafkaClient::updateConsumerOffsetCallable(const UpdateConsumerOffsetRequest &request) const
{
auto task = std::make_shared<std::packaged_task<UpdateConsumerOffsetOutcome()>>(
[this, request]()
{
return this->updateConsumerOffset(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
AlikafkaClient::UpdateInstanceConfigOutcome AlikafkaClient::updateInstanceConfig(const UpdateInstanceConfigRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -51,6 +51,8 @@ void GetConsumerListResult::parse(const std::string &payload)
consumerListObject.remark = valueConsumerListConsumerVO["Remark"].asString();
if(!valueConsumerListConsumerVO["RegionId"].isNull())
consumerListObject.regionId = valueConsumerListConsumerVO["RegionId"].asString();
if(!valueConsumerListConsumerVO["AutomaticallyCreatedGroup"].isNull())
consumerListObject.automaticallyCreatedGroup = valueConsumerListConsumerVO["AutomaticallyCreatedGroup"].asString() == "true";
auto allTagsNode = valueConsumerListConsumerVO["Tags"]["TagVO"];
for (auto valueConsumerListConsumerVOTagsTagVO : allTagsNode)
{

View File

@@ -105,6 +105,8 @@ void GetInstanceListResult::parse(const std::string &payload)
instanceListObject.kmsKeyId = valueInstanceListInstanceVO["KmsKeyId"].asString();
if(!valueInstanceListInstanceVO["StandardZoneId"].isNull())
instanceListObject.standardZoneId = valueInstanceListInstanceVO["StandardZoneId"].asString();
if(!valueInstanceListInstanceVO["IoMaxSpec"].isNull())
instanceListObject.ioMaxSpec = valueInstanceListInstanceVO["IoMaxSpec"].asString();
auto allTagsNode = valueInstanceListInstanceVO["Tags"]["TagVO"];
for (auto valueInstanceListInstanceVOTagsTagVO : allTagsNode)
{

View File

@@ -62,6 +62,8 @@ void GetQuotaTipResult::parse(const std::string &payload)
quotaData_.groupUsed = std::stoi(quotaDataNode["GroupUsed"].asString());
if(!quotaDataNode["IsPartitionBuy"].isNull())
quotaData_.isPartitionBuy = std::stoi(quotaDataNode["IsPartitionBuy"].asString());
if(!quotaDataNode["PartitionQuota"].isNull())
quotaData_.partitionQuota = std::stoi(quotaDataNode["PartitionQuota"].asString());
if(!value["Code"].isNull())
code_ = std::stoi(value["Code"].asString());
if(!value["Message"].isNull())

View File

@@ -63,6 +63,8 @@ void GetTopicListResult::parse(const std::string &payload)
topicListObject.localTopic = valueTopicListTopicVO["LocalTopic"].asString() == "true";
if(!valueTopicListTopicVO["RegionId"].isNull())
topicListObject.regionId = valueTopicListTopicVO["RegionId"].asString();
if(!valueTopicListTopicVO["AutoCreate"].isNull())
topicListObject.autoCreate = valueTopicListTopicVO["AutoCreate"].asString() == "true";
auto allTagsNode = valueTopicListTopicVO["Tags"]["TagVO"];
for (auto valueTopicListTopicVOTagsTagVO : allTagsNode)
{

View 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/alikafka/model/UpdateConsumerOffsetRequest.h>
using AlibabaCloud::Alikafka::Model::UpdateConsumerOffsetRequest;
UpdateConsumerOffsetRequest::UpdateConsumerOffsetRequest()
: RpcServiceRequest("alikafka", "2019-09-16", "UpdateConsumerOffset") {
setMethod(HttpRequest::Method::Post);
}
UpdateConsumerOffsetRequest::~UpdateConsumerOffsetRequest() {}
std::string UpdateConsumerOffsetRequest::getConsumerId() const {
return consumerId_;
}
void UpdateConsumerOffsetRequest::setConsumerId(const std::string &consumerId) {
consumerId_ = consumerId;
setParameter(std::string("ConsumerId"), consumerId);
}
std::string UpdateConsumerOffsetRequest::getResetType() const {
return resetType_;
}
void UpdateConsumerOffsetRequest::setResetType(const std::string &resetType) {
resetType_ = resetType;
setParameter(std::string("ResetType"), resetType);
}
std::string UpdateConsumerOffsetRequest::getInstanceId() const {
return instanceId_;
}
void UpdateConsumerOffsetRequest::setInstanceId(const std::string &instanceId) {
instanceId_ = instanceId;
setParameter(std::string("InstanceId"), instanceId);
}
std::string UpdateConsumerOffsetRequest::getRegionId() const {
return regionId_;
}
void UpdateConsumerOffsetRequest::setRegionId(const std::string &regionId) {
regionId_ = regionId;
setParameter(std::string("RegionId"), regionId);
}
std::vector<UpdateConsumerOffsetRequest::Offsets> UpdateConsumerOffsetRequest::getOffsets() const {
return offsets_;
}
void UpdateConsumerOffsetRequest::setOffsets(const std::vector<UpdateConsumerOffsetRequest::Offsets> &offsets) {
offsets_ = offsets;
for(int dep1 = 0; dep1 != offsets.size(); dep1++) {
setParameter(std::string("Offsets") + "." + std::to_string(dep1 + 1) + ".Partition", std::to_string(offsets[dep1].partition));
setParameter(std::string("Offsets") + "." + std::to_string(dep1 + 1) + ".Offset", std::to_string(offsets[dep1].offset));
}
}
std::string UpdateConsumerOffsetRequest::getTopic() const {
return topic_;
}
void UpdateConsumerOffsetRequest::setTopic(const std::string &topic) {
topic_ = topic;
setParameter(std::string("Topic"), topic);
}
std::string UpdateConsumerOffsetRequest::getTime() const {
return time_;
}
void UpdateConsumerOffsetRequest::setTime(const std::string &time) {
time_ = time;
setParameter(std::string("Time"), time);
}

View File

@@ -0,0 +1,65 @@
/*
* 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/alikafka/model/UpdateConsumerOffsetResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Alikafka;
using namespace AlibabaCloud::Alikafka::Model;
UpdateConsumerOffsetResult::UpdateConsumerOffsetResult() :
ServiceResult()
{}
UpdateConsumerOffsetResult::UpdateConsumerOffsetResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
UpdateConsumerOffsetResult::~UpdateConsumerOffsetResult()
{}
void UpdateConsumerOffsetResult::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["Code"].isNull())
code_ = std::stoi(value["Code"].asString());
if(!value["Message"].isNull())
message_ = value["Message"].asString();
}
std::string UpdateConsumerOffsetResult::getMessage()const
{
return message_;
}
int UpdateConsumerOffsetResult::getCode()const
{
return code_;
}
bool UpdateConsumerOffsetResult::getSuccess()const
{
return success_;
}