From bb7cab374e19b35c1b1ca59ee01678fe3ac072c3 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Fri, 27 Sep 2024 02:31:15 +0000 Subject: [PATCH] Support command audit for ecs. --- VERSION | 2 +- ecs-workbench/CMakeLists.txt | 4 + .../ecs-workbench/Ecs_workbenchClient.h | 8 ++ .../model/ListTerminalCommandsRequest.h | 51 +++++++++++ .../model/ListTerminalCommandsResult.h | 64 ++++++++++++++ ecs-workbench/src/Ecs-workbenchClient.cc | 36 ++++++++ .../src/model/ListTerminalCommandsRequest.cc | 63 ++++++++++++++ .../src/model/ListTerminalCommandsResult.cc | 84 +++++++++++++++++++ 8 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsRequest.h create mode 100644 ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsResult.h create mode 100644 ecs-workbench/src/model/ListTerminalCommandsRequest.cc create mode 100644 ecs-workbench/src/model/ListTerminalCommandsResult.cc diff --git a/VERSION b/VERSION index eef687b65..e856ed819 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.1990 \ No newline at end of file +1.36.1991 \ No newline at end of file diff --git a/ecs-workbench/CMakeLists.txt b/ecs-workbench/CMakeLists.txt index 549f335f8..8d4026973 100644 --- a/ecs-workbench/CMakeLists.txt +++ b/ecs-workbench/CMakeLists.txt @@ -25,6 +25,8 @@ set(ecs-workbench_public_header_model include/alibabacloud/ecs-workbench/model/GetInstanceRecordConfigResult.h include/alibabacloud/ecs-workbench/model/ListInstanceRecordsRequest.h include/alibabacloud/ecs-workbench/model/ListInstanceRecordsResult.h + include/alibabacloud/ecs-workbench/model/ListTerminalCommandsRequest.h + include/alibabacloud/ecs-workbench/model/ListTerminalCommandsResult.h include/alibabacloud/ecs-workbench/model/LoginInstanceRequest.h include/alibabacloud/ecs-workbench/model/LoginInstanceResult.h include/alibabacloud/ecs-workbench/model/SetInstanceRecordConfigRequest.h @@ -38,6 +40,8 @@ set(ecs-workbench_src src/model/GetInstanceRecordConfigResult.cc src/model/ListInstanceRecordsRequest.cc src/model/ListInstanceRecordsResult.cc + src/model/ListTerminalCommandsRequest.cc + src/model/ListTerminalCommandsResult.cc src/model/LoginInstanceRequest.cc src/model/LoginInstanceResult.cc src/model/SetInstanceRecordConfigRequest.cc diff --git a/ecs-workbench/include/alibabacloud/ecs-workbench/Ecs_workbenchClient.h b/ecs-workbench/include/alibabacloud/ecs-workbench/Ecs_workbenchClient.h index 2d8a7d9f7..6ec5fa025 100644 --- a/ecs-workbench/include/alibabacloud/ecs-workbench/Ecs_workbenchClient.h +++ b/ecs-workbench/include/alibabacloud/ecs-workbench/Ecs_workbenchClient.h @@ -26,6 +26,8 @@ #include "model/GetInstanceRecordConfigResult.h" #include "model/ListInstanceRecordsRequest.h" #include "model/ListInstanceRecordsResult.h" +#include "model/ListTerminalCommandsRequest.h" +#include "model/ListTerminalCommandsResult.h" #include "model/LoginInstanceRequest.h" #include "model/LoginInstanceResult.h" #include "model/SetInstanceRecordConfigRequest.h" @@ -47,6 +49,9 @@ namespace AlibabaCloud typedef Outcome ListInstanceRecordsOutcome; typedef std::future ListInstanceRecordsOutcomeCallable; typedef std::function&)> ListInstanceRecordsAsyncHandler; + typedef Outcome ListTerminalCommandsOutcome; + typedef std::future ListTerminalCommandsOutcomeCallable; + typedef std::function&)> ListTerminalCommandsAsyncHandler; typedef Outcome LoginInstanceOutcome; typedef std::future LoginInstanceOutcomeCallable; typedef std::function&)> LoginInstanceAsyncHandler; @@ -67,6 +72,9 @@ namespace AlibabaCloud ListInstanceRecordsOutcome listInstanceRecords(const Model::ListInstanceRecordsRequest &request)const; void listInstanceRecordsAsync(const Model::ListInstanceRecordsRequest& request, const ListInstanceRecordsAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ListInstanceRecordsOutcomeCallable listInstanceRecordsCallable(const Model::ListInstanceRecordsRequest& request) const; + ListTerminalCommandsOutcome listTerminalCommands(const Model::ListTerminalCommandsRequest &request)const; + void listTerminalCommandsAsync(const Model::ListTerminalCommandsRequest& request, const ListTerminalCommandsAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + ListTerminalCommandsOutcomeCallable listTerminalCommandsCallable(const Model::ListTerminalCommandsRequest& request) const; LoginInstanceOutcome loginInstance(const Model::LoginInstanceRequest &request)const; void loginInstanceAsync(const Model::LoginInstanceRequest& request, const LoginInstanceAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; LoginInstanceOutcomeCallable loginInstanceCallable(const Model::LoginInstanceRequest& request) const; diff --git a/ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsRequest.h b/ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsRequest.h new file mode 100644 index 000000000..9ef1d8f96 --- /dev/null +++ b/ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsRequest.h @@ -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. + */ + +#ifndef ALIBABACLOUD_ECS_WORKBENCH_MODEL_LISTTERMINALCOMMANDSREQUEST_H_ +#define ALIBABACLOUD_ECS_WORKBENCH_MODEL_LISTTERMINALCOMMANDSREQUEST_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud { +namespace Ecs_workbench { +namespace Model { +class ALIBABACLOUD_ECS_WORKBENCH_EXPORT ListTerminalCommandsRequest : public RpcServiceRequest { +public: + ListTerminalCommandsRequest(); + ~ListTerminalCommandsRequest(); + int getPageNumber() const; + void setPageNumber(int pageNumber); + std::string getRegionId() const; + void setRegionId(const std::string ®ionId); + int getPageSize() const; + void setPageSize(int pageSize); + std::string getTerminalSessionToken() const; + void setTerminalSessionToken(const std::string &terminalSessionToken); + +private: + int pageNumber_; + std::string regionId_; + int pageSize_; + std::string terminalSessionToken_; +}; +} // namespace Model +} // namespace Ecs_workbench +} // namespace AlibabaCloud +#endif // !ALIBABACLOUD_ECS_WORKBENCH_MODEL_LISTTERMINALCOMMANDSREQUEST_H_ diff --git a/ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsResult.h b/ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsResult.h new file mode 100644 index 000000000..1ed65d516 --- /dev/null +++ b/ecs-workbench/include/alibabacloud/ecs-workbench/model/ListTerminalCommandsResult.h @@ -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_ECS_WORKBENCH_MODEL_LISTTERMINALCOMMANDSRESULT_H_ +#define ALIBABACLOUD_ECS_WORKBENCH_MODEL_LISTTERMINALCOMMANDSRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Ecs_workbench + { + namespace Model + { + class ALIBABACLOUD_ECS_WORKBENCH_EXPORT ListTerminalCommandsResult : public ServiceResult + { + public: + struct TerminalCommandListItem + { + std::string commandLine; + std::string createTime; + std::string loginUser; + std::string executePath; + }; + + + ListTerminalCommandsResult(); + explicit ListTerminalCommandsResult(const std::string &payload); + ~ListTerminalCommandsResult(); + int getTotalCount()const; + int getPageSize()const; + int getPageNumber()const; + std::vector getTerminalCommandList()const; + + protected: + void parse(const std::string &payload); + private: + int totalCount_; + int pageSize_; + int pageNumber_; + std::vector terminalCommandList_; + + }; + } + } +} +#endif // !ALIBABACLOUD_ECS_WORKBENCH_MODEL_LISTTERMINALCOMMANDSRESULT_H_ \ No newline at end of file diff --git a/ecs-workbench/src/Ecs-workbenchClient.cc b/ecs-workbench/src/Ecs-workbenchClient.cc index b834cd846..8f20f889a 100644 --- a/ecs-workbench/src/Ecs-workbenchClient.cc +++ b/ecs-workbench/src/Ecs-workbenchClient.cc @@ -123,6 +123,42 @@ Ecs_workbenchClient::ListInstanceRecordsOutcomeCallable Ecs_workbenchClient::lis return task->get_future(); } +Ecs_workbenchClient::ListTerminalCommandsOutcome Ecs_workbenchClient::listTerminalCommands(const ListTerminalCommandsRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return ListTerminalCommandsOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return ListTerminalCommandsOutcome(ListTerminalCommandsResult(outcome.result())); + else + return ListTerminalCommandsOutcome(outcome.error()); +} + +void Ecs_workbenchClient::listTerminalCommandsAsync(const ListTerminalCommandsRequest& request, const ListTerminalCommandsAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, listTerminalCommands(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +Ecs_workbenchClient::ListTerminalCommandsOutcomeCallable Ecs_workbenchClient::listTerminalCommandsCallable(const ListTerminalCommandsRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->listTerminalCommands(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + Ecs_workbenchClient::LoginInstanceOutcome Ecs_workbenchClient::loginInstance(const LoginInstanceRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/ecs-workbench/src/model/ListTerminalCommandsRequest.cc b/ecs-workbench/src/model/ListTerminalCommandsRequest.cc new file mode 100644 index 000000000..2f0da63bf --- /dev/null +++ b/ecs-workbench/src/model/ListTerminalCommandsRequest.cc @@ -0,0 +1,63 @@ +/* + * 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 + +using AlibabaCloud::Ecs_workbench::Model::ListTerminalCommandsRequest; + +ListTerminalCommandsRequest::ListTerminalCommandsRequest() + : RpcServiceRequest("ecs-workbench", "2022-02-20", "ListTerminalCommands") { + setMethod(HttpRequest::Method::Post); +} + +ListTerminalCommandsRequest::~ListTerminalCommandsRequest() {} + +int ListTerminalCommandsRequest::getPageNumber() const { + return pageNumber_; +} + +void ListTerminalCommandsRequest::setPageNumber(int pageNumber) { + pageNumber_ = pageNumber; + setBodyParameter(std::string("PageNumber"), std::to_string(pageNumber)); +} + +std::string ListTerminalCommandsRequest::getRegionId() const { + return regionId_; +} + +void ListTerminalCommandsRequest::setRegionId(const std::string ®ionId) { + regionId_ = regionId; + setBodyParameter(std::string("RegionId"), regionId); +} + +int ListTerminalCommandsRequest::getPageSize() const { + return pageSize_; +} + +void ListTerminalCommandsRequest::setPageSize(int pageSize) { + pageSize_ = pageSize; + setBodyParameter(std::string("PageSize"), std::to_string(pageSize)); +} + +std::string ListTerminalCommandsRequest::getTerminalSessionToken() const { + return terminalSessionToken_; +} + +void ListTerminalCommandsRequest::setTerminalSessionToken(const std::string &terminalSessionToken) { + terminalSessionToken_ = terminalSessionToken; + setBodyParameter(std::string("TerminalSessionToken"), terminalSessionToken); +} + diff --git a/ecs-workbench/src/model/ListTerminalCommandsResult.cc b/ecs-workbench/src/model/ListTerminalCommandsResult.cc new file mode 100644 index 000000000..5e8eff231 --- /dev/null +++ b/ecs-workbench/src/model/ListTerminalCommandsResult.cc @@ -0,0 +1,84 @@ +/* + * 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 +#include + +using namespace AlibabaCloud::Ecs_workbench; +using namespace AlibabaCloud::Ecs_workbench::Model; + +ListTerminalCommandsResult::ListTerminalCommandsResult() : + ServiceResult() +{} + +ListTerminalCommandsResult::ListTerminalCommandsResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +ListTerminalCommandsResult::~ListTerminalCommandsResult() +{} + +void ListTerminalCommandsResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto allTerminalCommandListNode = value["TerminalCommandList"]["TerminalCommandListItem"]; + for (auto valueTerminalCommandListTerminalCommandListItem : allTerminalCommandListNode) + { + TerminalCommandListItem terminalCommandListObject; + if(!valueTerminalCommandListTerminalCommandListItem["CreateTime"].isNull()) + terminalCommandListObject.createTime = valueTerminalCommandListTerminalCommandListItem["CreateTime"].asString(); + if(!valueTerminalCommandListTerminalCommandListItem["CommandLine"].isNull()) + terminalCommandListObject.commandLine = valueTerminalCommandListTerminalCommandListItem["CommandLine"].asString(); + if(!valueTerminalCommandListTerminalCommandListItem["LoginUser"].isNull()) + terminalCommandListObject.loginUser = valueTerminalCommandListTerminalCommandListItem["LoginUser"].asString(); + if(!valueTerminalCommandListTerminalCommandListItem["ExecutePath"].isNull()) + terminalCommandListObject.executePath = valueTerminalCommandListTerminalCommandListItem["ExecutePath"].asString(); + terminalCommandList_.push_back(terminalCommandListObject); + } + if(!value["TotalCount"].isNull()) + totalCount_ = std::stoi(value["TotalCount"].asString()); + if(!value["PageSize"].isNull()) + pageSize_ = std::stoi(value["PageSize"].asString()); + if(!value["PageNumber"].isNull()) + pageNumber_ = std::stoi(value["PageNumber"].asString()); + +} + +int ListTerminalCommandsResult::getTotalCount()const +{ + return totalCount_; +} + +int ListTerminalCommandsResult::getPageSize()const +{ + return pageSize_; +} + +int ListTerminalCommandsResult::getPageNumber()const +{ + return pageNumber_; +} + +std::vector ListTerminalCommandsResult::getTerminalCommandList()const +{ + return terminalCommandList_; +} +