From 410b5a1a3e1bc6de9ad91b05112cefb43ff61a54 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Wed, 19 Jul 2023 09:03:42 +0000 Subject: [PATCH] Add new apis. --- VERSION | 2 +- swas-open/CMakeLists.txt | 4 ++ .../alibabacloud/swas-open/SWAS_OPENClient.h | 8 +++ .../swas-open/model/ListInstancesRequest.h | 3 + .../model/StartTerminalSessionRequest.h | 45 +++++++++++++ .../model/StartTerminalSessionResult.h | 55 ++++++++++++++++ swas-open/src/SWAS-OPENClient.cc | 36 ++++++++++ swas-open/src/model/ListInstancesRequest.cc | 9 +++ .../src/model/StartTerminalSessionRequest.cc | 45 +++++++++++++ .../src/model/StartTerminalSessionResult.cc | 65 +++++++++++++++++++ 10 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionRequest.h create mode 100644 swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionResult.h create mode 100644 swas-open/src/model/StartTerminalSessionRequest.cc create mode 100644 swas-open/src/model/StartTerminalSessionResult.cc diff --git a/VERSION b/VERSION index 0e7523d16..0951a7a4f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.1666 \ No newline at end of file +1.36.1667 \ No newline at end of file diff --git a/swas-open/CMakeLists.txt b/swas-open/CMakeLists.txt index 4ebc956a1..9f3277ced 100644 --- a/swas-open/CMakeLists.txt +++ b/swas-open/CMakeLists.txt @@ -139,6 +139,8 @@ set(swas-open_public_header_model include/alibabacloud/swas-open/model/StartInstanceResult.h include/alibabacloud/swas-open/model/StartInstancesRequest.h include/alibabacloud/swas-open/model/StartInstancesResult.h + include/alibabacloud/swas-open/model/StartTerminalSessionRequest.h + include/alibabacloud/swas-open/model/StartTerminalSessionResult.h include/alibabacloud/swas-open/model/StopDatabaseInstanceRequest.h include/alibabacloud/swas-open/model/StopDatabaseInstanceResult.h include/alibabacloud/swas-open/model/StopInstanceRequest.h @@ -276,6 +278,8 @@ set(swas-open_src src/model/StartInstanceResult.cc src/model/StartInstancesRequest.cc src/model/StartInstancesResult.cc + src/model/StartTerminalSessionRequest.cc + src/model/StartTerminalSessionResult.cc src/model/StopDatabaseInstanceRequest.cc src/model/StopDatabaseInstanceResult.cc src/model/StopInstanceRequest.cc diff --git a/swas-open/include/alibabacloud/swas-open/SWAS_OPENClient.h b/swas-open/include/alibabacloud/swas-open/SWAS_OPENClient.h index aa817ccbe..dd9331607 100644 --- a/swas-open/include/alibabacloud/swas-open/SWAS_OPENClient.h +++ b/swas-open/include/alibabacloud/swas-open/SWAS_OPENClient.h @@ -140,6 +140,8 @@ #include "model/StartInstanceResult.h" #include "model/StartInstancesRequest.h" #include "model/StartInstancesResult.h" +#include "model/StartTerminalSessionRequest.h" +#include "model/StartTerminalSessionResult.h" #include "model/StopDatabaseInstanceRequest.h" #include "model/StopDatabaseInstanceResult.h" #include "model/StopInstanceRequest.h" @@ -342,6 +344,9 @@ namespace AlibabaCloud typedef Outcome StartInstancesOutcome; typedef std::future StartInstancesOutcomeCallable; typedef std::function&)> StartInstancesAsyncHandler; + typedef Outcome StartTerminalSessionOutcome; + typedef std::future StartTerminalSessionOutcomeCallable; + typedef std::function&)> StartTerminalSessionAsyncHandler; typedef Outcome StopDatabaseInstanceOutcome; typedef std::future StopDatabaseInstanceOutcomeCallable; typedef std::function&)> StopDatabaseInstanceAsyncHandler; @@ -548,6 +553,9 @@ namespace AlibabaCloud StartInstancesOutcome startInstances(const Model::StartInstancesRequest &request)const; void startInstancesAsync(const Model::StartInstancesRequest& request, const StartInstancesAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; StartInstancesOutcomeCallable startInstancesCallable(const Model::StartInstancesRequest& request) const; + StartTerminalSessionOutcome startTerminalSession(const Model::StartTerminalSessionRequest &request)const; + void startTerminalSessionAsync(const Model::StartTerminalSessionRequest& request, const StartTerminalSessionAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + StartTerminalSessionOutcomeCallable startTerminalSessionCallable(const Model::StartTerminalSessionRequest& request) const; StopDatabaseInstanceOutcome stopDatabaseInstance(const Model::StopDatabaseInstanceRequest &request)const; void stopDatabaseInstanceAsync(const Model::StopDatabaseInstanceRequest& request, const StopDatabaseInstanceAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; StopDatabaseInstanceOutcomeCallable stopDatabaseInstanceCallable(const Model::StopDatabaseInstanceRequest& request) const; diff --git a/swas-open/include/alibabacloud/swas-open/model/ListInstancesRequest.h b/swas-open/include/alibabacloud/swas-open/model/ListInstancesRequest.h index 22ba7dc9a..224b45c5c 100644 --- a/swas-open/include/alibabacloud/swas-open/model/ListInstancesRequest.h +++ b/swas-open/include/alibabacloud/swas-open/model/ListInstancesRequest.h @@ -42,6 +42,8 @@ public: void setPublicIpAddresses(const std::string &publicIpAddresses); std::string getChargeType() const; void setChargeType(const std::string &chargeType); + std::string getStatus() const; + void setStatus(const std::string &status); private: int pageNumber_; @@ -50,6 +52,7 @@ private: int pageSize_; std::string publicIpAddresses_; std::string chargeType_; + std::string status_; }; } // namespace Model } // namespace SWAS_OPEN diff --git a/swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionRequest.h b/swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionRequest.h new file mode 100644 index 000000000..6760795f4 --- /dev/null +++ b/swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionRequest.h @@ -0,0 +1,45 @@ +/* + * 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_SWAS_OPEN_MODEL_STARTTERMINALSESSIONREQUEST_H_ +#define ALIBABACLOUD_SWAS_OPEN_MODEL_STARTTERMINALSESSIONREQUEST_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud { +namespace SWAS_OPEN { +namespace Model { +class ALIBABACLOUD_SWAS_OPEN_EXPORT StartTerminalSessionRequest : public RpcServiceRequest { +public: + StartTerminalSessionRequest(); + ~StartTerminalSessionRequest(); + std::string getInstanceId() const; + void setInstanceId(const std::string &instanceId); + std::string getRegionId() const; + void setRegionId(const std::string ®ionId); + +private: + std::string instanceId_; + std::string regionId_; +}; +} // namespace Model +} // namespace SWAS_OPEN +} // namespace AlibabaCloud +#endif // !ALIBABACLOUD_SWAS_OPEN_MODEL_STARTTERMINALSESSIONREQUEST_H_ diff --git a/swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionResult.h b/swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionResult.h new file mode 100644 index 000000000..e72cc7428 --- /dev/null +++ b/swas-open/include/alibabacloud/swas-open/model/StartTerminalSessionResult.h @@ -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_SWAS_OPEN_MODEL_STARTTERMINALSESSIONRESULT_H_ +#define ALIBABACLOUD_SWAS_OPEN_MODEL_STARTTERMINALSESSIONRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace SWAS_OPEN + { + namespace Model + { + class ALIBABACLOUD_SWAS_OPEN_EXPORT StartTerminalSessionResult : public ServiceResult + { + public: + + + StartTerminalSessionResult(); + explicit StartTerminalSessionResult(const std::string &payload); + ~StartTerminalSessionResult(); + std::string getSecurityToken()const; + std::string getWebSocketUrl()const; + std::string getSessionId()const; + + protected: + void parse(const std::string &payload); + private: + std::string securityToken_; + std::string webSocketUrl_; + std::string sessionId_; + + }; + } + } +} +#endif // !ALIBABACLOUD_SWAS_OPEN_MODEL_STARTTERMINALSESSIONRESULT_H_ \ No newline at end of file diff --git a/swas-open/src/SWAS-OPENClient.cc b/swas-open/src/SWAS-OPENClient.cc index 261808c39..9be6a1acf 100644 --- a/swas-open/src/SWAS-OPENClient.cc +++ b/swas-open/src/SWAS-OPENClient.cc @@ -2175,6 +2175,42 @@ SWAS_OPENClient::StartInstancesOutcomeCallable SWAS_OPENClient::startInstancesCa return task->get_future(); } +SWAS_OPENClient::StartTerminalSessionOutcome SWAS_OPENClient::startTerminalSession(const StartTerminalSessionRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return StartTerminalSessionOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return StartTerminalSessionOutcome(StartTerminalSessionResult(outcome.result())); + else + return StartTerminalSessionOutcome(outcome.error()); +} + +void SWAS_OPENClient::startTerminalSessionAsync(const StartTerminalSessionRequest& request, const StartTerminalSessionAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, startTerminalSession(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +SWAS_OPENClient::StartTerminalSessionOutcomeCallable SWAS_OPENClient::startTerminalSessionCallable(const StartTerminalSessionRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->startTerminalSession(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + SWAS_OPENClient::StopDatabaseInstanceOutcome SWAS_OPENClient::stopDatabaseInstance(const StopDatabaseInstanceRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/swas-open/src/model/ListInstancesRequest.cc b/swas-open/src/model/ListInstancesRequest.cc index 96a4bcc8f..31eaff403 100644 --- a/swas-open/src/model/ListInstancesRequest.cc +++ b/swas-open/src/model/ListInstancesRequest.cc @@ -79,3 +79,12 @@ void ListInstancesRequest::setChargeType(const std::string &chargeType) { setParameter(std::string("ChargeType"), chargeType); } +std::string ListInstancesRequest::getStatus() const { + return status_; +} + +void ListInstancesRequest::setStatus(const std::string &status) { + status_ = status; + setParameter(std::string("Status"), status); +} + diff --git a/swas-open/src/model/StartTerminalSessionRequest.cc b/swas-open/src/model/StartTerminalSessionRequest.cc new file mode 100644 index 000000000..7dba1d843 --- /dev/null +++ b/swas-open/src/model/StartTerminalSessionRequest.cc @@ -0,0 +1,45 @@ +/* + * 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::SWAS_OPEN::Model::StartTerminalSessionRequest; + +StartTerminalSessionRequest::StartTerminalSessionRequest() + : RpcServiceRequest("swas-open", "2020-06-01", "StartTerminalSession") { + setMethod(HttpRequest::Method::Post); +} + +StartTerminalSessionRequest::~StartTerminalSessionRequest() {} + +std::string StartTerminalSessionRequest::getInstanceId() const { + return instanceId_; +} + +void StartTerminalSessionRequest::setInstanceId(const std::string &instanceId) { + instanceId_ = instanceId; + setParameter(std::string("InstanceId"), instanceId); +} + +std::string StartTerminalSessionRequest::getRegionId() const { + return regionId_; +} + +void StartTerminalSessionRequest::setRegionId(const std::string ®ionId) { + regionId_ = regionId; + setParameter(std::string("RegionId"), regionId); +} + diff --git a/swas-open/src/model/StartTerminalSessionResult.cc b/swas-open/src/model/StartTerminalSessionResult.cc new file mode 100644 index 000000000..92a650bc1 --- /dev/null +++ b/swas-open/src/model/StartTerminalSessionResult.cc @@ -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 +#include + +using namespace AlibabaCloud::SWAS_OPEN; +using namespace AlibabaCloud::SWAS_OPEN::Model; + +StartTerminalSessionResult::StartTerminalSessionResult() : + ServiceResult() +{} + +StartTerminalSessionResult::StartTerminalSessionResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +StartTerminalSessionResult::~StartTerminalSessionResult() +{} + +void StartTerminalSessionResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + if(!value["SessionId"].isNull()) + sessionId_ = value["SessionId"].asString(); + if(!value["SecurityToken"].isNull()) + securityToken_ = value["SecurityToken"].asString(); + if(!value["WebSocketUrl"].isNull()) + webSocketUrl_ = value["WebSocketUrl"].asString(); + +} + +std::string StartTerminalSessionResult::getSecurityToken()const +{ + return securityToken_; +} + +std::string StartTerminalSessionResult::getWebSocketUrl()const +{ + return webSocketUrl_; +} + +std::string StartTerminalSessionResult::getSessionId()const +{ + return sessionId_; +} +