Api init.

This commit is contained in:
sdk-team
2022-05-23 09:42:37 +00:00
parent a607d32bc9
commit 68690f1498
10 changed files with 502 additions and 1 deletions

View File

@@ -1,3 +1,6 @@
2022-05-23 Version: 1.36.1132
- Api init.
2022-05-23 Version: 1.36.1131
- Support systemdisk encrypt and arns.
- Update tag parameters.

View File

@@ -1 +1 @@
1.36.1131
1.36.1132

86
btripopen/CMakeLists.txt Normal file
View 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(btripopen_public_header
include/alibabacloud/btripopen/BtripOpenClient.h
include/alibabacloud/btripopen/BtripOpenExport.h )
set(btripopen_public_header_model
include/alibabacloud/btripopen/model/TakeAccessTokenRequest.h
include/alibabacloud/btripopen/model/TakeAccessTokenResult.h )
set(btripopen_src
src/BtripOpenClient.cc
src/model/TakeAccessTokenRequest.cc
src/model/TakeAccessTokenResult.cc )
add_library(btripopen ${LIB_TYPE}
${btripopen_public_header}
${btripopen_public_header_model}
${btripopen_src})
set_target_properties(btripopen
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}btripopen
)
if(${LIB_TYPE} STREQUAL "SHARED")
set_target_properties(btripopen
PROPERTIES
DEFINE_SYMBOL ALIBABACLOUD_BTRIPOPEN_LIBRARY)
endif()
target_include_directories(btripopen
PRIVATE include
${CMAKE_SOURCE_DIR}/core/include
)
target_link_libraries(btripopen
core)
if(CMAKE_HOST_WIN32)
ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
set(jsoncpp_install_dir ${INSTALL_DIR})
add_dependencies(btripopen
jsoncpp)
target_include_directories(btripopen
PRIVATE ${jsoncpp_install_dir}/include)
target_link_libraries(btripopen
${jsoncpp_install_dir}/lib/jsoncpp.lib)
set_target_properties(btripopen
PROPERTIES
COMPILE_OPTIONS "/bigobj")
else()
target_include_directories(btripopen
PRIVATE /usr/include/jsoncpp)
target_link_libraries(btripopen
jsoncpp)
endif()
install(FILES ${btripopen_public_header}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/btripopen)
install(FILES ${btripopen_public_header_model}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/btripopen/model)
install(TARGETS btripopen
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View 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_BTRIPOPEN_BTRIPOPENCLIENT_H_
#define ALIBABACLOUD_BTRIPOPEN_BTRIPOPENCLIENT_H_
#include <future>
#include <alibabacloud/core/AsyncCallerContext.h>
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RoaServiceClient.h>
#include "BtripOpenExport.h"
#include "model/TakeAccessTokenRequest.h"
#include "model/TakeAccessTokenResult.h"
namespace AlibabaCloud
{
namespace BtripOpen
{
class ALIBABACLOUD_BTRIPOPEN_EXPORT BtripOpenClient : public RoaServiceClient
{
public:
typedef Outcome<Error, Model::TakeAccessTokenResult> TakeAccessTokenOutcome;
typedef std::future<TakeAccessTokenOutcome> TakeAccessTokenOutcomeCallable;
typedef std::function<void(const BtripOpenClient*, const Model::TakeAccessTokenRequest&, const TakeAccessTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> TakeAccessTokenAsyncHandler;
BtripOpenClient(const Credentials &credentials, const ClientConfiguration &configuration);
BtripOpenClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
BtripOpenClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~BtripOpenClient();
TakeAccessTokenOutcome takeAccessToken(const Model::TakeAccessTokenRequest &request)const;
void takeAccessTokenAsync(const Model::TakeAccessTokenRequest& request, const TakeAccessTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
TakeAccessTokenOutcomeCallable takeAccessTokenCallable(const Model::TakeAccessTokenRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;
};
}
}
#endif // !ALIBABACLOUD_BTRIPOPEN_BTRIPOPENCLIENT_H_

View 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_BTRIPOPEN_BTRIPOPENEXPORT_H_
#define ALIBABACLOUD_BTRIPOPEN_BTRIPOPENEXPORT_H_
#include <alibabacloud/core/Global.h>
#if defined(ALIBABACLOUD_SHARED)
# if defined(ALIBABACLOUD_BTRIPOPEN_LIBRARY)
# define ALIBABACLOUD_BTRIPOPEN_EXPORT ALIBABACLOUD_DECL_EXPORT
# else
# define ALIBABACLOUD_BTRIPOPEN_EXPORT ALIBABACLOUD_DECL_IMPORT
# endif
#else
# define ALIBABACLOUD_BTRIPOPEN_EXPORT
#endif
#endif // !ALIBABACLOUD_BTRIPOPEN_BTRIPOPENEXPORT_H_

View File

@@ -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_BTRIPOPEN_MODEL_TAKEACCESSTOKENREQUEST_H_
#define ALIBABACLOUD_BTRIPOPEN_MODEL_TAKEACCESSTOKENREQUEST_H_
#include <alibabacloud/btripopen/BtripOpenExport.h>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <string>
#include <vector>
#include <map>
namespace AlibabaCloud {
namespace BtripOpen {
namespace Model {
class ALIBABACLOUD_BTRIPOPEN_EXPORT TakeAccessTokenRequest : public RoaServiceRequest {
public:
TakeAccessTokenRequest();
~TakeAccessTokenRequest();
std::string getApp_key() const;
void setApp_key(const std::string &app_key);
std::string getApp_secret() const;
void setApp_secret(const std::string &app_secret);
private:
std::string app_key_;
std::string app_secret_;
};
} // namespace Model
} // namespace BtripOpen
} // namespace AlibabaCloud
#endif // !ALIBABACLOUD_BTRIPOPEN_MODEL_TAKEACCESSTOKENREQUEST_H_

View File

@@ -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_BTRIPOPEN_MODEL_TAKEACCESSTOKENRESULT_H_
#define ALIBABACLOUD_BTRIPOPEN_MODEL_TAKEACCESSTOKENRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/btripopen/BtripOpenExport.h>
namespace AlibabaCloud
{
namespace BtripOpen
{
namespace Model
{
class ALIBABACLOUD_BTRIPOPEN_EXPORT TakeAccessTokenResult : public ServiceResult
{
public:
struct Data
{
long expire;
std::string access_token;
};
TakeAccessTokenResult();
explicit TakeAccessTokenResult(const std::string &payload);
~TakeAccessTokenResult();
std::string getRequestId()const;
std::string getMessage()const;
Data getData()const;
std::string getCode()const;
std::string getSuccess()const;
protected:
void parse(const std::string &payload);
private:
std::string requestId_;
std::string message_;
Data data_;
std::string code_;
std::string success_;
};
}
}
}
#endif // !ALIBABACLOUD_BTRIPOPEN_MODEL_TAKEACCESSTOKENRESULT_H_

View 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/btripopen/BtripOpenClient.h>
#include <alibabacloud/core/SimpleCredentialsProvider.h>
using namespace AlibabaCloud;
using namespace AlibabaCloud::Location;
using namespace AlibabaCloud::BtripOpen;
using namespace AlibabaCloud::BtripOpen::Model;
namespace
{
const std::string SERVICE_NAME = "btripOpen";
}
BtripOpenClient::BtripOpenClient(const Credentials &credentials, const ClientConfiguration &configuration) :
RoaServiceClient(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, "");
}
BtripOpenClient::BtripOpenClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RoaServiceClient(SERVICE_NAME, credentialsProvider, configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
BtripOpenClient::BtripOpenClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RoaServiceClient(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, "");
}
BtripOpenClient::~BtripOpenClient()
{}
BtripOpenClient::TakeAccessTokenOutcome BtripOpenClient::takeAccessToken(const TakeAccessTokenRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return TakeAccessTokenOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return TakeAccessTokenOutcome(TakeAccessTokenResult(outcome.result()));
else
return TakeAccessTokenOutcome(outcome.error());
}
void BtripOpenClient::takeAccessTokenAsync(const TakeAccessTokenRequest& request, const TakeAccessTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, takeAccessToken(request), context);
};
asyncExecute(new Runnable(fn));
}
BtripOpenClient::TakeAccessTokenOutcomeCallable BtripOpenClient::takeAccessTokenCallable(const TakeAccessTokenRequest &request) const
{
auto task = std::make_shared<std::packaged_task<TakeAccessTokenOutcome()>>(
[this, request]()
{
return this->takeAccessToken(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

View File

@@ -0,0 +1,46 @@
/*
* 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/btripopen/model/TakeAccessTokenRequest.h>
using AlibabaCloud::BtripOpen::Model::TakeAccessTokenRequest;
TakeAccessTokenRequest::TakeAccessTokenRequest()
: RoaServiceRequest("btripopen", "2022-05-17") {
setResourcePath("/btrip/open/access-token/take"};
setMethod(HttpRequest::Method::Get);
}
TakeAccessTokenRequest::~TakeAccessTokenRequest() {}
std::string TakeAccessTokenRequest::getApp_key() const {
return app_key_;
}
void TakeAccessTokenRequest::setApp_key(const std::string &app_key) {
app_key_ = app_key;
setParameter(std::string("app_key"), app_key);
}
std::string TakeAccessTokenRequest::getApp_secret() const {
return app_secret_;
}
void TakeAccessTokenRequest::setApp_secret(const std::string &app_secret) {
app_secret_ = app_secret;
setParameter(std::string("app_secret"), app_secret);
}

View 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/btripopen/model/TakeAccessTokenResult.h>
#include <json/json.h>
using namespace AlibabaCloud::BtripOpen;
using namespace AlibabaCloud::BtripOpen::Model;
TakeAccessTokenResult::TakeAccessTokenResult() :
ServiceResult()
{}
TakeAccessTokenResult::TakeAccessTokenResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
TakeAccessTokenResult::~TakeAccessTokenResult()
{}
void TakeAccessTokenResult::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["access_token"].isNull())
data_.access_token = dataNode["access_token"].asString();
if(!dataNode["expire"].isNull())
data_.expire = std::stol(dataNode["expire"].asString());
if(!value["requestId"].isNull())
requestId_ = value["requestId"].asString();
if(!value["code"].isNull())
code_ = value["code"].asString();
if(!value["message"].isNull())
message_ = value["message"].asString();
if(!value["success"].isNull())
success_ = value["success"].asString();
}
std::string TakeAccessTokenResult::getRequestId()const
{
return requestId_;
}
std::string TakeAccessTokenResult::getMessage()const
{
return message_;
}
TakeAccessTokenResult::Data TakeAccessTokenResult::getData()const
{
return data_;
}
std::string TakeAccessTokenResult::getCode()const
{
return code_;
}
std::string TakeAccessTokenResult::getSuccess()const
{
return success_;
}