Skip to content

Commit 164bc90

Browse files
committed
init sdk
1 parent bdba38a commit 164bc90

File tree

9 files changed

+495
-1
lines changed

9 files changed

+495
-1
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.36.2072
1+
1.36.2073

dms/CMakeLists.txt

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#
2+
# Copyright 2009-2017 Alibaba Cloud All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include)
18+
19+
set(dms_public_header
20+
include/alibabacloud/dms/DmsClient.h
21+
include/alibabacloud/dms/DmsExport.h )
22+
23+
set(dms_public_header_model
24+
include/alibabacloud/dms/model/CreateAirflowLoginTokenRequest.h
25+
include/alibabacloud/dms/model/CreateAirflowLoginTokenResult.h )
26+
27+
set(dms_src
28+
src/DmsClient.cc
29+
src/model/CreateAirflowLoginTokenRequest.cc
30+
src/model/CreateAirflowLoginTokenResult.cc )
31+
32+
add_library(dms ${LIB_TYPE}
33+
${dms_public_header}
34+
${dms_public_header_model}
35+
${dms_src})
36+
37+
set_target_properties(dms
38+
PROPERTIES
39+
LINKER_LANGUAGE CXX
40+
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
41+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
42+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
43+
OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}dms
44+
)
45+
46+
if(${LIB_TYPE} STREQUAL "SHARED")
47+
set_target_properties(dms
48+
PROPERTIES
49+
DEFINE_SYMBOL ALIBABACLOUD_DMS_LIBRARY)
50+
endif()
51+
52+
target_include_directories(dms
53+
PRIVATE include
54+
${CMAKE_SOURCE_DIR}/core/include
55+
)
56+
target_link_libraries(dms
57+
core)
58+
59+
if(CMAKE_HOST_WIN32)
60+
ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
61+
set(jsoncpp_install_dir ${INSTALL_DIR})
62+
add_dependencies(dms
63+
jsoncpp)
64+
target_include_directories(dms
65+
PRIVATE ${jsoncpp_install_dir}/include)
66+
target_link_libraries(dms
67+
${jsoncpp_install_dir}/lib/jsoncpp.lib)
68+
set_target_properties(dms
69+
PROPERTIES
70+
COMPILE_OPTIONS "/bigobj")
71+
else()
72+
target_include_directories(dms
73+
PRIVATE /usr/include/jsoncpp)
74+
target_link_libraries(dms
75+
jsoncpp)
76+
endif()
77+
78+
install(FILES ${dms_public_header}
79+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/dms)
80+
install(FILES ${dms_public_header_model}
81+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/dms/model)
82+
install(TARGETS dms
83+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
84+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
85+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
86+
)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef ALIBABACLOUD_DMS_DMSCLIENT_H_
18+
#define ALIBABACLOUD_DMS_DMSCLIENT_H_
19+
20+
#include <future>
21+
#include <alibabacloud/core/AsyncCallerContext.h>
22+
#include <alibabacloud/core/EndpointProvider.h>
23+
#include <alibabacloud/core/RpcServiceClient.h>
24+
#include "DmsExport.h"
25+
#include "model/CreateAirflowLoginTokenRequest.h"
26+
#include "model/CreateAirflowLoginTokenResult.h"
27+
28+
29+
namespace AlibabaCloud
30+
{
31+
namespace Dms
32+
{
33+
class ALIBABACLOUD_DMS_EXPORT DmsClient : public RpcServiceClient
34+
{
35+
public:
36+
typedef Outcome<Error, Model::CreateAirflowLoginTokenResult> CreateAirflowLoginTokenOutcome;
37+
typedef std::future<CreateAirflowLoginTokenOutcome> CreateAirflowLoginTokenOutcomeCallable;
38+
typedef std::function<void(const DmsClient*, const Model::CreateAirflowLoginTokenRequest&, const CreateAirflowLoginTokenOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateAirflowLoginTokenAsyncHandler;
39+
40+
DmsClient(const Credentials &credentials, const ClientConfiguration &configuration);
41+
DmsClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
42+
DmsClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
43+
~DmsClient();
44+
CreateAirflowLoginTokenOutcome createAirflowLoginToken(const Model::CreateAirflowLoginTokenRequest &request)const;
45+
void createAirflowLoginTokenAsync(const Model::CreateAirflowLoginTokenRequest& request, const CreateAirflowLoginTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
46+
CreateAirflowLoginTokenOutcomeCallable createAirflowLoginTokenCallable(const Model::CreateAirflowLoginTokenRequest& request) const;
47+
48+
private:
49+
std::shared_ptr<EndpointProvider> endpointProvider_;
50+
};
51+
}
52+
}
53+
54+
#endif // !ALIBABACLOUD_DMS_DMSCLIENT_H_
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef ALIBABACLOUD_DMS_DMSEXPORT_H_
18+
#define ALIBABACLOUD_DMS_DMSEXPORT_H_
19+
20+
#include <alibabacloud/core/Global.h>
21+
22+
#if defined(ALIBABACLOUD_SHARED)
23+
# if defined(ALIBABACLOUD_DMS_LIBRARY)
24+
# define ALIBABACLOUD_DMS_EXPORT ALIBABACLOUD_DECL_EXPORT
25+
# else
26+
# define ALIBABACLOUD_DMS_EXPORT ALIBABACLOUD_DECL_IMPORT
27+
# endif
28+
#else
29+
# define ALIBABACLOUD_DMS_EXPORT
30+
#endif
31+
32+
#endif // !ALIBABACLOUD_DMS_DMSEXPORT_H_
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENREQUEST_H_
18+
#define ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENREQUEST_H_
19+
20+
#include <alibabacloud/dms/DmsExport.h>
21+
#include <alibabacloud/core/RpcServiceRequest.h>
22+
#include <string>
23+
#include <vector>
24+
#include <map>
25+
26+
namespace AlibabaCloud {
27+
namespace Dms {
28+
namespace Model {
29+
class ALIBABACLOUD_DMS_EXPORT CreateAirflowLoginTokenRequest : public RpcServiceRequest {
30+
public:
31+
CreateAirflowLoginTokenRequest();
32+
~CreateAirflowLoginTokenRequest();
33+
std::string getAirflowId() const;
34+
void setAirflowId(const std::string &airflowId);
35+
36+
private:
37+
std::string airflowId_;
38+
};
39+
} // namespace Model
40+
} // namespace Dms
41+
} // namespace AlibabaCloud
42+
#endif // !ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENREQUEST_H_
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENRESULT_H_
18+
#define ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENRESULT_H_
19+
20+
#include <string>
21+
#include <vector>
22+
#include <utility>
23+
#include <alibabacloud/core/ServiceResult.h>
24+
#include <alibabacloud/dms/DmsExport.h>
25+
26+
namespace AlibabaCloud
27+
{
28+
namespace Dms
29+
{
30+
namespace Model
31+
{
32+
class ALIBABACLOUD_DMS_EXPORT CreateAirflowLoginTokenResult : public ServiceResult
33+
{
34+
public:
35+
struct Data
36+
{
37+
std::string token;
38+
std::string host;
39+
};
40+
41+
42+
CreateAirflowLoginTokenResult();
43+
explicit CreateAirflowLoginTokenResult(const std::string &payload);
44+
~CreateAirflowLoginTokenResult();
45+
std::string getMessage()const;
46+
int getHttpStatusCode()const;
47+
Data getData()const;
48+
std::string getErrorCode()const;
49+
std::string getCode()const;
50+
bool getSuccess()const;
51+
52+
protected:
53+
void parse(const std::string &payload);
54+
private:
55+
std::string message_;
56+
int httpStatusCode_;
57+
Data data_;
58+
std::string errorCode_;
59+
std::string code_;
60+
bool success_;
61+
62+
};
63+
}
64+
}
65+
}
66+
#endif // !ALIBABACLOUD_DMS_MODEL_CREATEAIRFLOWLOGINTOKENRESULT_H_

dms/src/DmsClient.cc

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <alibabacloud/dms/DmsClient.h>
18+
#include <alibabacloud/core/SimpleCredentialsProvider.h>
19+
20+
using namespace AlibabaCloud;
21+
using namespace AlibabaCloud::Location;
22+
using namespace AlibabaCloud::Dms;
23+
using namespace AlibabaCloud::Dms::Model;
24+
25+
namespace
26+
{
27+
const std::string SERVICE_NAME = "Dms";
28+
}
29+
30+
DmsClient::DmsClient(const Credentials &credentials, const ClientConfiguration &configuration) :
31+
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
32+
{
33+
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
34+
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
35+
}
36+
37+
DmsClient::DmsClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
38+
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
39+
{
40+
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
41+
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
42+
}
43+
44+
DmsClient::DmsClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
45+
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
46+
{
47+
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
48+
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
49+
}
50+
51+
DmsClient::~DmsClient()
52+
{}
53+
54+
DmsClient::CreateAirflowLoginTokenOutcome DmsClient::createAirflowLoginToken(const CreateAirflowLoginTokenRequest &request) const
55+
{
56+
auto endpointOutcome = endpointProvider_->getEndpoint();
57+
if (!endpointOutcome.isSuccess())
58+
return CreateAirflowLoginTokenOutcome(endpointOutcome.error());
59+
60+
auto outcome = makeRequest(endpointOutcome.result(), request);
61+
62+
if (outcome.isSuccess())
63+
return CreateAirflowLoginTokenOutcome(CreateAirflowLoginTokenResult(outcome.result()));
64+
else
65+
return CreateAirflowLoginTokenOutcome(outcome.error());
66+
}
67+
68+
void DmsClient::createAirflowLoginTokenAsync(const CreateAirflowLoginTokenRequest& request, const CreateAirflowLoginTokenAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
69+
{
70+
auto fn = [this, request, handler, context]()
71+
{
72+
handler(this, request, createAirflowLoginToken(request), context);
73+
};
74+
75+
asyncExecute(new Runnable(fn));
76+
}
77+
78+
DmsClient::CreateAirflowLoginTokenOutcomeCallable DmsClient::createAirflowLoginTokenCallable(const CreateAirflowLoginTokenRequest &request) const
79+
{
80+
auto task = std::make_shared<std::packaged_task<CreateAirflowLoginTokenOutcome()>>(
81+
[this, request]()
82+
{
83+
return this->createAirflowLoginToken(request);
84+
});
85+
86+
asyncExecute(new Runnable([task]() { (*task)(); }));
87+
return task->get_future();
88+
}
89+

0 commit comments

Comments
 (0)