Skip to content

Commit

Permalink
Support command audit for ecs.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdk-team committed Sep 27, 2024
1 parent 66cb681 commit bb7cab3
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.36.1990
1.36.1991
4 changes: 4 additions & 0 deletions ecs-workbench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -47,6 +49,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::ListInstanceRecordsResult> ListInstanceRecordsOutcome;
typedef std::future<ListInstanceRecordsOutcome> ListInstanceRecordsOutcomeCallable;
typedef std::function<void(const Ecs_workbenchClient*, const Model::ListInstanceRecordsRequest&, const ListInstanceRecordsOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListInstanceRecordsAsyncHandler;
typedef Outcome<Error, Model::ListTerminalCommandsResult> ListTerminalCommandsOutcome;
typedef std::future<ListTerminalCommandsOutcome> ListTerminalCommandsOutcomeCallable;
typedef std::function<void(const Ecs_workbenchClient*, const Model::ListTerminalCommandsRequest&, const ListTerminalCommandsOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListTerminalCommandsAsyncHandler;
typedef Outcome<Error, Model::LoginInstanceResult> LoginInstanceOutcome;
typedef std::future<LoginInstanceOutcome> LoginInstanceOutcomeCallable;
typedef std::function<void(const Ecs_workbenchClient*, const Model::LoginInstanceRequest&, const LoginInstanceOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> LoginInstanceAsyncHandler;
Expand All @@ -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<const AsyncCallerContext>& 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& context = nullptr) const;
LoginInstanceOutcomeCallable loginInstanceCallable(const Model::LoginInstanceRequest& request) const;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <alibabacloud/ecs-workbench/Ecs_workbenchExport.h>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <string>
#include <vector>
#include <map>

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 &regionId);
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_
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/ecs-workbench/Ecs_workbenchExport.h>

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<TerminalCommandListItem> getTerminalCommandList()const;

protected:
void parse(const std::string &payload);
private:
int totalCount_;
int pageSize_;
int pageNumber_;
std::vector<TerminalCommandListItem> terminalCommandList_;

};
}
}
}
#endif // !ALIBABACLOUD_ECS_WORKBENCH_MODEL_LISTTERMINALCOMMANDSRESULT_H_
36 changes: 36 additions & 0 deletions ecs-workbench/src/Ecs-workbenchClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<const AsyncCallerContext>& 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<std::packaged_task<ListTerminalCommandsOutcome()>>(
[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();
Expand Down
63 changes: 63 additions & 0 deletions ecs-workbench/src/model/ListTerminalCommandsRequest.cc
Original file line number Diff line number Diff line change
@@ -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 <alibabacloud/ecs-workbench/model/ListTerminalCommandsRequest.h>

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 &regionId) {
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);
}

84 changes: 84 additions & 0 deletions ecs-workbench/src/model/ListTerminalCommandsResult.cc
Original file line number Diff line number Diff line change
@@ -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 <alibabacloud/ecs-workbench/model/ListTerminalCommandsResult.h>
#include <json/json.h>

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::TerminalCommandListItem> ListTerminalCommandsResult::getTerminalCommandList()const
{
return terminalCommandList_;
}

0 comments on commit bb7cab3

Please sign in to comment.