Generated 2023-08-01 for AiMiaoBi.
This commit is contained in:
86
aimiaobi/CMakeLists.txt
Normal file
86
aimiaobi/CMakeLists.txt
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||||
|
|
||||||
|
set(aimiaobi_public_header
|
||||||
|
include/alibabacloud/aimiaobi/AiMiaoBiClient.h
|
||||||
|
include/alibabacloud/aimiaobi/AiMiaoBiExport.h )
|
||||||
|
|
||||||
|
set(aimiaobi_public_header_model
|
||||||
|
include/alibabacloud/aimiaobi/model/CreateTokenRequest.h
|
||||||
|
include/alibabacloud/aimiaobi/model/CreateTokenResult.h )
|
||||||
|
|
||||||
|
set(aimiaobi_src
|
||||||
|
src/AiMiaoBiClient.cc
|
||||||
|
src/model/CreateTokenRequest.cc
|
||||||
|
src/model/CreateTokenResult.cc )
|
||||||
|
|
||||||
|
add_library(aimiaobi ${LIB_TYPE}
|
||||||
|
${aimiaobi_public_header}
|
||||||
|
${aimiaobi_public_header_model}
|
||||||
|
${aimiaobi_src})
|
||||||
|
|
||||||
|
set_target_properties(aimiaobi
|
||||||
|
PROPERTIES
|
||||||
|
LINKER_LANGUAGE CXX
|
||||||
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||||
|
OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}aimiaobi
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${LIB_TYPE} STREQUAL "SHARED")
|
||||||
|
set_target_properties(aimiaobi
|
||||||
|
PROPERTIES
|
||||||
|
DEFINE_SYMBOL ALIBABACLOUD_AIMIAOBI_LIBRARY)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(aimiaobi
|
||||||
|
PRIVATE include
|
||||||
|
${CMAKE_SOURCE_DIR}/core/include
|
||||||
|
)
|
||||||
|
target_link_libraries(aimiaobi
|
||||||
|
core)
|
||||||
|
|
||||||
|
if(CMAKE_HOST_WIN32)
|
||||||
|
ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
|
||||||
|
set(jsoncpp_install_dir ${INSTALL_DIR})
|
||||||
|
add_dependencies(aimiaobi
|
||||||
|
jsoncpp)
|
||||||
|
target_include_directories(aimiaobi
|
||||||
|
PRIVATE ${jsoncpp_install_dir}/include)
|
||||||
|
target_link_libraries(aimiaobi
|
||||||
|
${jsoncpp_install_dir}/lib/jsoncpp.lib)
|
||||||
|
set_target_properties(aimiaobi
|
||||||
|
PROPERTIES
|
||||||
|
COMPILE_OPTIONS "/bigobj")
|
||||||
|
else()
|
||||||
|
target_include_directories(aimiaobi
|
||||||
|
PRIVATE /usr/include/jsoncpp)
|
||||||
|
target_link_libraries(aimiaobi
|
||||||
|
jsoncpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES ${aimiaobi_public_header}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/aimiaobi)
|
||||||
|
install(FILES ${aimiaobi_public_header_model}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/aimiaobi/model)
|
||||||
|
install(TARGETS aimiaobi
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
54
aimiaobi/include/alibabacloud/aimiaobi/AiMiaoBiClient.h
Normal file
54
aimiaobi/include/alibabacloud/aimiaobi/AiMiaoBiClient.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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_AIMIAOBI_AIMIAOBICLIENT_H_
|
||||||
|
#define ALIBABACLOUD_AIMIAOBI_AIMIAOBICLIENT_H_
|
||||||
|
|
||||||
|
#include <future>
|
||||||
|
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||||
|
#include <alibabacloud/core/EndpointProvider.h>
|
||||||
|
#include <alibabacloud/core/RpcServiceClient.h>
|
||||||
|
#include "AiMiaoBiExport.h"
|
||||||
|
#include "model/CreateTokenRequest.h"
|
||||||
|
#include "model/CreateTokenResult.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace AlibabaCloud
|
||||||
|
{
|
||||||
|
namespace AiMiaoBi
|
||||||
|
{
|
||||||
|
class ALIBABACLOUD_AIMIAOBI_EXPORT AiMiaoBiClient : public RpcServiceClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef Outcome<Error, Model::CreateTokenResult> CreateTokenOutcome;
|
||||||
|
typedef std::future<CreateTokenOutcome> CreateTokenOutcomeCallable;
|
||||||
|
typedef std::function<void(const AiMiaoBiClient*, const Model::CreateTokenRequest&, const CreateTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateTokenAsyncHandler;
|
||||||
|
|
||||||
|
AiMiaoBiClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||||
|
AiMiaoBiClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||||
|
AiMiaoBiClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
|
||||||
|
~AiMiaoBiClient();
|
||||||
|
CreateTokenOutcome createToken(const Model::CreateTokenRequest &request)const;
|
||||||
|
void createTokenAsync(const Model::CreateTokenRequest& request, const CreateTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||||
|
CreateTokenOutcomeCallable createTokenCallable(const Model::CreateTokenRequest& request) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<EndpointProvider> endpointProvider_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !ALIBABACLOUD_AIMIAOBI_AIMIAOBICLIENT_H_
|
||||||
32
aimiaobi/include/alibabacloud/aimiaobi/AiMiaoBiExport.h
Normal file
32
aimiaobi/include/alibabacloud/aimiaobi/AiMiaoBiExport.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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_AIMIAOBI_AIMIAOBIEXPORT_H_
|
||||||
|
#define ALIBABACLOUD_AIMIAOBI_AIMIAOBIEXPORT_H_
|
||||||
|
|
||||||
|
#include <alibabacloud/core/Global.h>
|
||||||
|
|
||||||
|
#if defined(ALIBABACLOUD_SHARED)
|
||||||
|
# if defined(ALIBABACLOUD_AIMIAOBI_LIBRARY)
|
||||||
|
# define ALIBABACLOUD_AIMIAOBI_EXPORT ALIBABACLOUD_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define ALIBABACLOUD_AIMIAOBI_EXPORT ALIBABACLOUD_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define ALIBABACLOUD_AIMIAOBI_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // !ALIBABACLOUD_AIMIAOBI_AIMIAOBIEXPORT_H_
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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_AIMIAOBI_MODEL_CREATETOKENREQUEST_H_
|
||||||
|
#define ALIBABACLOUD_AIMIAOBI_MODEL_CREATETOKENREQUEST_H_
|
||||||
|
|
||||||
|
#include <alibabacloud/aimiaobi/AiMiaoBiExport.h>
|
||||||
|
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace AlibabaCloud {
|
||||||
|
namespace AiMiaoBi {
|
||||||
|
namespace Model {
|
||||||
|
class ALIBABACLOUD_AIMIAOBI_EXPORT CreateTokenRequest : public RpcServiceRequest {
|
||||||
|
public:
|
||||||
|
CreateTokenRequest();
|
||||||
|
~CreateTokenRequest();
|
||||||
|
std::string getAgentKey() const;
|
||||||
|
void setAgentKey(const std::string &agentKey);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string agentKey_;
|
||||||
|
};
|
||||||
|
} // namespace Model
|
||||||
|
} // namespace AiMiaoBi
|
||||||
|
} // namespace AlibabaCloud
|
||||||
|
#endif // !ALIBABACLOUD_AIMIAOBI_MODEL_CREATETOKENREQUEST_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_AIMIAOBI_MODEL_CREATETOKENRESULT_H_
|
||||||
|
#define ALIBABACLOUD_AIMIAOBI_MODEL_CREATETOKENRESULT_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
#include <alibabacloud/core/ServiceResult.h>
|
||||||
|
#include <alibabacloud/aimiaobi/AiMiaoBiExport.h>
|
||||||
|
|
||||||
|
namespace AlibabaCloud
|
||||||
|
{
|
||||||
|
namespace AiMiaoBi
|
||||||
|
{
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
class ALIBABACLOUD_AIMIAOBI_EXPORT CreateTokenResult : public ServiceResult
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
long expiredTime;
|
||||||
|
std::string token;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CreateTokenResult();
|
||||||
|
explicit CreateTokenResult(const std::string &payload);
|
||||||
|
~CreateTokenResult();
|
||||||
|
std::string getMessage()const;
|
||||||
|
int getHttpStatusCode()const;
|
||||||
|
Data getData()const;
|
||||||
|
std::string getCode()const;
|
||||||
|
bool getSuccess()const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void parse(const std::string &payload);
|
||||||
|
private:
|
||||||
|
std::string message_;
|
||||||
|
int httpStatusCode_;
|
||||||
|
Data data_;
|
||||||
|
std::string code_;
|
||||||
|
bool success_;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // !ALIBABACLOUD_AIMIAOBI_MODEL_CREATETOKENRESULT_H_
|
||||||
89
aimiaobi/src/AiMiaoBiClient.cc
Normal file
89
aimiaobi/src/AiMiaoBiClient.cc
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* 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/aimiaobi/AiMiaoBiClient.h>
|
||||||
|
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||||
|
|
||||||
|
using namespace AlibabaCloud;
|
||||||
|
using namespace AlibabaCloud::Location;
|
||||||
|
using namespace AlibabaCloud::AiMiaoBi;
|
||||||
|
using namespace AlibabaCloud::AiMiaoBi::Model;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const std::string SERVICE_NAME = "AiMiaoBi";
|
||||||
|
}
|
||||||
|
|
||||||
|
AiMiaoBiClient::AiMiaoBiClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||||
|
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, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
AiMiaoBiClient::AiMiaoBiClient(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, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
AiMiaoBiClient::AiMiaoBiClient(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, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
AiMiaoBiClient::~AiMiaoBiClient()
|
||||||
|
{}
|
||||||
|
|
||||||
|
AiMiaoBiClient::CreateTokenOutcome AiMiaoBiClient::createToken(const CreateTokenRequest &request) const
|
||||||
|
{
|
||||||
|
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||||
|
if (!endpointOutcome.isSuccess())
|
||||||
|
return CreateTokenOutcome(endpointOutcome.error());
|
||||||
|
|
||||||
|
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||||
|
|
||||||
|
if (outcome.isSuccess())
|
||||||
|
return CreateTokenOutcome(CreateTokenResult(outcome.result()));
|
||||||
|
else
|
||||||
|
return CreateTokenOutcome(outcome.error());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AiMiaoBiClient::createTokenAsync(const CreateTokenRequest& request, const CreateTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||||
|
{
|
||||||
|
auto fn = [this, request, handler, context]()
|
||||||
|
{
|
||||||
|
handler(this, request, createToken(request), context);
|
||||||
|
};
|
||||||
|
|
||||||
|
asyncExecute(new Runnable(fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
AiMiaoBiClient::CreateTokenOutcomeCallable AiMiaoBiClient::createTokenCallable(const CreateTokenRequest &request) const
|
||||||
|
{
|
||||||
|
auto task = std::make_shared<std::packaged_task<CreateTokenOutcome()>>(
|
||||||
|
[this, request]()
|
||||||
|
{
|
||||||
|
return this->createToken(request);
|
||||||
|
});
|
||||||
|
|
||||||
|
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||||
|
return task->get_future();
|
||||||
|
}
|
||||||
|
|
||||||
36
aimiaobi/src/model/CreateTokenRequest.cc
Normal file
36
aimiaobi/src/model/CreateTokenRequest.cc
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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/aimiaobi/model/CreateTokenRequest.h>
|
||||||
|
|
||||||
|
using AlibabaCloud::AiMiaoBi::Model::CreateTokenRequest;
|
||||||
|
|
||||||
|
CreateTokenRequest::CreateTokenRequest()
|
||||||
|
: RpcServiceRequest("aimiaobi", "2023-08-01", "CreateToken") {
|
||||||
|
setMethod(HttpRequest::Method::Post);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateTokenRequest::~CreateTokenRequest() {}
|
||||||
|
|
||||||
|
std::string CreateTokenRequest::getAgentKey() const {
|
||||||
|
return agentKey_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTokenRequest::setAgentKey(const std::string &agentKey) {
|
||||||
|
agentKey_ = agentKey;
|
||||||
|
setParameter(std::string("AgentKey"), agentKey);
|
||||||
|
}
|
||||||
|
|
||||||
82
aimiaobi/src/model/CreateTokenResult.cc
Normal file
82
aimiaobi/src/model/CreateTokenResult.cc
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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/aimiaobi/model/CreateTokenResult.h>
|
||||||
|
#include <json/json.h>
|
||||||
|
|
||||||
|
using namespace AlibabaCloud::AiMiaoBi;
|
||||||
|
using namespace AlibabaCloud::AiMiaoBi::Model;
|
||||||
|
|
||||||
|
CreateTokenResult::CreateTokenResult() :
|
||||||
|
ServiceResult()
|
||||||
|
{}
|
||||||
|
|
||||||
|
CreateTokenResult::CreateTokenResult(const std::string &payload) :
|
||||||
|
ServiceResult()
|
||||||
|
{
|
||||||
|
parse(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateTokenResult::~CreateTokenResult()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void CreateTokenResult::parse(const std::string &payload)
|
||||||
|
{
|
||||||
|
Json::Reader reader;
|
||||||
|
Json::Value value;
|
||||||
|
reader.parse(payload, value);
|
||||||
|
setRequestId(value["RequestId"].asString());
|
||||||
|
auto dataNode = value["Data"];
|
||||||
|
if(!dataNode["Token"].isNull())
|
||||||
|
data_.token = dataNode["Token"].asString();
|
||||||
|
if(!dataNode["ExpiredTime"].isNull())
|
||||||
|
data_.expiredTime = std::stol(dataNode["ExpiredTime"].asString());
|
||||||
|
if(!value["Success"].isNull())
|
||||||
|
success_ = value["Success"].asString() == "true";
|
||||||
|
if(!value["Code"].isNull())
|
||||||
|
code_ = value["Code"].asString();
|
||||||
|
if(!value["Message"].isNull())
|
||||||
|
message_ = value["Message"].asString();
|
||||||
|
if(!value["HttpStatusCode"].isNull())
|
||||||
|
httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CreateTokenResult::getMessage()const
|
||||||
|
{
|
||||||
|
return message_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CreateTokenResult::getHttpStatusCode()const
|
||||||
|
{
|
||||||
|
return httpStatusCode_;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateTokenResult::Data CreateTokenResult::getData()const
|
||||||
|
{
|
||||||
|
return data_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CreateTokenResult::getCode()const
|
||||||
|
{
|
||||||
|
return code_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CreateTokenResult::getSuccess()const
|
||||||
|
{
|
||||||
|
return success_;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user