Add GetAuthToken OpenAPI.

This commit is contained in:
sdk-team
2020-06-18 15:38:53 +08:00
parent e611ec2db4
commit 2070ee03ba
9 changed files with 341 additions and 4 deletions

View File

@@ -1,3 +1,6 @@
2020-06-18 Version: 1.36.467
- Add GetAuthToken OpenAPI.
2020-06-18 Version: 1.36.466
- Public beta version.
- Add Api Overseas.

View File

@@ -1 +1 @@
1.36.466
1.36.467

View File

@@ -27,6 +27,8 @@ set(dypnsapi_public_header_model
include/alibabacloud/dypnsapi/model/DeleteVerifySchemeResult.h
include/alibabacloud/dypnsapi/model/DescribeVerifySchemeRequest.h
include/alibabacloud/dypnsapi/model/DescribeVerifySchemeResult.h
include/alibabacloud/dypnsapi/model/GetAuthTokenRequest.h
include/alibabacloud/dypnsapi/model/GetAuthTokenResult.h
include/alibabacloud/dypnsapi/model/GetMobileRequest.h
include/alibabacloud/dypnsapi/model/GetMobileResult.h
include/alibabacloud/dypnsapi/model/TwiceTelVerifyRequest.h
@@ -44,6 +46,8 @@ set(dypnsapi_src
src/model/DeleteVerifySchemeResult.cc
src/model/DescribeVerifySchemeRequest.cc
src/model/DescribeVerifySchemeResult.cc
src/model/GetAuthTokenRequest.cc
src/model/GetAuthTokenResult.cc
src/model/GetMobileRequest.cc
src/model/GetMobileResult.cc
src/model/TwiceTelVerifyRequest.cc

View File

@@ -28,6 +28,8 @@
#include "model/DeleteVerifySchemeResult.h"
#include "model/DescribeVerifySchemeRequest.h"
#include "model/DescribeVerifySchemeResult.h"
#include "model/GetAuthTokenRequest.h"
#include "model/GetAuthTokenResult.h"
#include "model/GetMobileRequest.h"
#include "model/GetMobileResult.h"
#include "model/TwiceTelVerifyRequest.h"
@@ -54,6 +56,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::DescribeVerifySchemeResult> DescribeVerifySchemeOutcome;
typedef std::future<DescribeVerifySchemeOutcome> DescribeVerifySchemeOutcomeCallable;
typedef std::function<void(const DypnsapiClient*, const Model::DescribeVerifySchemeRequest&, const DescribeVerifySchemeOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DescribeVerifySchemeAsyncHandler;
typedef Outcome<Error, Model::GetAuthTokenResult> GetAuthTokenOutcome;
typedef std::future<GetAuthTokenOutcome> GetAuthTokenOutcomeCallable;
typedef std::function<void(const DypnsapiClient*, const Model::GetAuthTokenRequest&, const GetAuthTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetAuthTokenAsyncHandler;
typedef Outcome<Error, Model::GetMobileResult> GetMobileOutcome;
typedef std::future<GetMobileOutcome> GetMobileOutcomeCallable;
typedef std::function<void(const DypnsapiClient*, const Model::GetMobileRequest&, const GetMobileOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetMobileAsyncHandler;
@@ -80,6 +85,9 @@ namespace AlibabaCloud
DescribeVerifySchemeOutcome describeVerifyScheme(const Model::DescribeVerifySchemeRequest &request)const;
void describeVerifySchemeAsync(const Model::DescribeVerifySchemeRequest& request, const DescribeVerifySchemeAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DescribeVerifySchemeOutcomeCallable describeVerifySchemeCallable(const Model::DescribeVerifySchemeRequest& request) const;
GetAuthTokenOutcome getAuthToken(const Model::GetAuthTokenRequest &request)const;
void getAuthTokenAsync(const Model::GetAuthTokenRequest& request, const GetAuthTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetAuthTokenOutcomeCallable getAuthTokenCallable(const Model::GetAuthTokenRequest& request) const;
GetMobileOutcome getMobile(const Model::GetMobileRequest &request)const;
void getMobileAsync(const Model::GetMobileRequest& request, const GetMobileAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetMobileOutcomeCallable getMobileCallable(const Model::GetMobileRequest& request) const;

View File

@@ -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.
*/
#ifndef ALIBABACLOUD_DYPNSAPI_MODEL_GETAUTHTOKENREQUEST_H_
#define ALIBABACLOUD_DYPNSAPI_MODEL_GETAUTHTOKENREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/dypnsapi/DypnsapiExport.h>
namespace AlibabaCloud
{
namespace Dypnsapi
{
namespace Model
{
class ALIBABACLOUD_DYPNSAPI_EXPORT GetAuthTokenRequest : public RpcServiceRequest
{
public:
GetAuthTokenRequest();
~GetAuthTokenRequest();
long getResourceOwnerId()const;
void setResourceOwnerId(long resourceOwnerId);
std::string getResourceOwnerAccount()const;
void setResourceOwnerAccount(const std::string& resourceOwnerAccount);
std::string getOrigin()const;
void setOrigin(const std::string& origin);
long getOwnerId()const;
void setOwnerId(long ownerId);
std::string getUrl()const;
void setUrl(const std::string& url);
std::string getAccessKeyId()const;
void setAccessKeyId(const std::string& accessKeyId);
private:
long resourceOwnerId_;
std::string resourceOwnerAccount_;
std::string origin_;
long ownerId_;
std::string url_;
std::string accessKeyId_;
};
}
}
}
#endif // !ALIBABACLOUD_DYPNSAPI_MODEL_GETAUTHTOKENREQUEST_H_

View File

@@ -0,0 +1,60 @@
/*
* 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_DYPNSAPI_MODEL_GETAUTHTOKENRESULT_H_
#define ALIBABACLOUD_DYPNSAPI_MODEL_GETAUTHTOKENRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/dypnsapi/DypnsapiExport.h>
namespace AlibabaCloud
{
namespace Dypnsapi
{
namespace Model
{
class ALIBABACLOUD_DYPNSAPI_EXPORT GetAuthTokenResult : public ServiceResult
{
public:
struct TokenInfo
{
std::string jwtToken;
std::string accessToken;
};
GetAuthTokenResult();
explicit GetAuthTokenResult(const std::string &payload);
~GetAuthTokenResult();
std::string getMessage()const;
TokenInfo getTokenInfo()const;
std::string getCode()const;
protected:
void parse(const std::string &payload);
private:
std::string message_;
TokenInfo tokenInfo_;
std::string code_;
};
}
}
}
#endif // !ALIBABACLOUD_DYPNSAPI_MODEL_GETAUTHTOKENRESULT_H_

View File

@@ -31,21 +31,21 @@ DypnsapiClient::DypnsapiClient(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, "");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "dypns");
}
DypnsapiClient::DypnsapiClient(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, "");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "dypns");
}
DypnsapiClient::DypnsapiClient(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, "");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "dypns");
}
DypnsapiClient::~DypnsapiClient()
@@ -159,6 +159,42 @@ DypnsapiClient::DescribeVerifySchemeOutcomeCallable DypnsapiClient::describeVeri
return task->get_future();
}
DypnsapiClient::GetAuthTokenOutcome DypnsapiClient::getAuthToken(const GetAuthTokenRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return GetAuthTokenOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return GetAuthTokenOutcome(GetAuthTokenResult(outcome.result()));
else
return GetAuthTokenOutcome(outcome.error());
}
void DypnsapiClient::getAuthTokenAsync(const GetAuthTokenRequest& request, const GetAuthTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, getAuthToken(request), context);
};
asyncExecute(new Runnable(fn));
}
DypnsapiClient::GetAuthTokenOutcomeCallable DypnsapiClient::getAuthTokenCallable(const GetAuthTokenRequest &request) const
{
auto task = std::make_shared<std::packaged_task<GetAuthTokenOutcome()>>(
[this, request]()
{
return this->getAuthToken(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
DypnsapiClient::GetMobileOutcome DypnsapiClient::getMobile(const GetMobileRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,95 @@
/*
* 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/dypnsapi/model/GetAuthTokenRequest.h>
using AlibabaCloud::Dypnsapi::Model::GetAuthTokenRequest;
GetAuthTokenRequest::GetAuthTokenRequest() :
RpcServiceRequest("dypnsapi", "2017-05-25", "GetAuthToken")
{
setMethod(HttpRequest::Method::Post);
}
GetAuthTokenRequest::~GetAuthTokenRequest()
{}
long GetAuthTokenRequest::getResourceOwnerId()const
{
return resourceOwnerId_;
}
void GetAuthTokenRequest::setResourceOwnerId(long resourceOwnerId)
{
resourceOwnerId_ = resourceOwnerId;
setParameter("ResourceOwnerId", std::to_string(resourceOwnerId));
}
std::string GetAuthTokenRequest::getResourceOwnerAccount()const
{
return resourceOwnerAccount_;
}
void GetAuthTokenRequest::setResourceOwnerAccount(const std::string& resourceOwnerAccount)
{
resourceOwnerAccount_ = resourceOwnerAccount;
setParameter("ResourceOwnerAccount", resourceOwnerAccount);
}
std::string GetAuthTokenRequest::getOrigin()const
{
return origin_;
}
void GetAuthTokenRequest::setOrigin(const std::string& origin)
{
origin_ = origin;
setParameter("Origin", origin);
}
long GetAuthTokenRequest::getOwnerId()const
{
return ownerId_;
}
void GetAuthTokenRequest::setOwnerId(long ownerId)
{
ownerId_ = ownerId;
setParameter("OwnerId", std::to_string(ownerId));
}
std::string GetAuthTokenRequest::getUrl()const
{
return url_;
}
void GetAuthTokenRequest::setUrl(const std::string& url)
{
url_ = url;
setParameter("Url", url);
}
std::string GetAuthTokenRequest::getAccessKeyId()const
{
return accessKeyId_;
}
void GetAuthTokenRequest::setAccessKeyId(const std::string& accessKeyId)
{
accessKeyId_ = accessKeyId;
setParameter("AccessKeyId", accessKeyId);
}

View File

@@ -0,0 +1,68 @@
/*
* 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/dypnsapi/model/GetAuthTokenResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Dypnsapi;
using namespace AlibabaCloud::Dypnsapi::Model;
GetAuthTokenResult::GetAuthTokenResult() :
ServiceResult()
{}
GetAuthTokenResult::GetAuthTokenResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
GetAuthTokenResult::~GetAuthTokenResult()
{}
void GetAuthTokenResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto tokenInfoNode = value["TokenInfo"];
if(!tokenInfoNode["JwtToken"].isNull())
tokenInfo_.jwtToken = tokenInfoNode["JwtToken"].asString();
if(!tokenInfoNode["AccessToken"].isNull())
tokenInfo_.accessToken = tokenInfoNode["AccessToken"].asString();
if(!value["Code"].isNull())
code_ = value["Code"].asString();
if(!value["Message"].isNull())
message_ = value["Message"].asString();
}
std::string GetAuthTokenResult::getMessage()const
{
return message_;
}
GetAuthTokenResult::TokenInfo GetAuthTokenResult::getTokenInfo()const
{
return tokenInfo_;
}
std::string GetAuthTokenResult::getCode()const
{
return code_;
}