Add CreateSshKey OpenAPI.

This commit is contained in:
sdk-team
2021-06-11 02:11:54 +00:00
parent 5599b4ad14
commit ac11b7e23d
9 changed files with 290 additions and 1 deletions

View File

@@ -483,6 +483,42 @@ CodeupClient::CreateRepositoryProtectedBranchOutcomeCallable CodeupClient::creat
return task->get_future();
}
CodeupClient::CreateSshKeyOutcome CodeupClient::createSshKey(const CreateSshKeyRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return CreateSshKeyOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return CreateSshKeyOutcome(CreateSshKeyResult(outcome.result()));
else
return CreateSshKeyOutcome(outcome.error());
}
void CodeupClient::createSshKeyAsync(const CreateSshKeyRequest& request, const CreateSshKeyAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, createSshKey(request), context);
};
asyncExecute(new Runnable(fn));
}
CodeupClient::CreateSshKeyOutcomeCallable CodeupClient::createSshKeyCallable(const CreateSshKeyRequest &request) const
{
auto task = std::make_shared<std::packaged_task<CreateSshKeyOutcome()>>(
[this, request]()
{
return this->createSshKey(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
CodeupClient::CreateTagOutcome CodeupClient::createTag(const CreateTagRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,41 @@
/*
* 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/codeup/model/CreateSshKeyRequest.h>
using AlibabaCloud::Codeup::Model::CreateSshKeyRequest;
CreateSshKeyRequest::CreateSshKeyRequest() :
RoaServiceRequest("codeup", "2020-04-14")
{
setResourcePath("/api/v3/user/keys");
setMethod(HttpRequest::Method::Post);
}
CreateSshKeyRequest::~CreateSshKeyRequest()
{}
std::string CreateSshKeyRequest::getAccessToken()const
{
return accessToken_;
}
void CreateSshKeyRequest::setAccessToken(const std::string& accessToken)
{
accessToken_ = accessToken;
setParameter("AccessToken", accessToken);
}

View File

@@ -0,0 +1,83 @@
/*
* 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/codeup/model/CreateSshKeyResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Codeup;
using namespace AlibabaCloud::Codeup::Model;
CreateSshKeyResult::CreateSshKeyResult() :
ServiceResult()
{}
CreateSshKeyResult::CreateSshKeyResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
CreateSshKeyResult::~CreateSshKeyResult()
{}
void CreateSshKeyResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto resultNode = value["Result"];
if(!resultNode["CreatedAt"].isNull())
result_.createdAt = resultNode["CreatedAt"].asString();
if(!resultNode["FingerPrint"].isNull())
result_.fingerPrint = resultNode["FingerPrint"].asString();
if(!resultNode["Id"].isNull())
result_.id = std::stol(resultNode["Id"].asString());
if(!resultNode["Key"].isNull())
result_.key = resultNode["Key"].asString();
if(!resultNode["KeyScope"].isNull())
result_.keyScope = resultNode["KeyScope"].asString();
if(!resultNode["Title"].isNull())
result_.title = resultNode["Title"].asString();
if(!value["ErrorCode"].isNull())
errorCode_ = value["ErrorCode"].asString();
if(!value["ErrorMessage"].isNull())
errorMessage_ = value["ErrorMessage"].asString();
if(!value["Success"].isNull())
success_ = value["Success"].asString() == "true";
}
std::string CreateSshKeyResult::getErrorCode()const
{
return errorCode_;
}
std::string CreateSshKeyResult::getErrorMessage()const
{
return errorMessage_;
}
bool CreateSshKeyResult::getSuccess()const
{
return success_;
}
CreateSshKeyResult::Result CreateSshKeyResult::getResult()const
{
return result_;
}