Init commit

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
This commit is contained in:
haowei.yao
2017-12-27 10:03:32 +08:00
commit f6db1a27e4
112 changed files with 7050 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
/*
* 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/core/location/LocationClient.h>
#include <alibabacloud/core/SimpleCredentialsProvider.h>
using namespace AlibabaCloud;
using namespace AlibabaCloud::Location;
LocationClient::LocationClient(const Credentials &credentials, const ClientConfiguration &configuration) :
RpcServiceClient(std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
{
}
LocationClient::LocationClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RpcServiceClient(credentialsProvider, configuration)
{
}
LocationClient::LocationClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RpcServiceClient(std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
{
}
LocationClient::~LocationClient()
{}
CoreClient::EndpointOutcome LocationClient::endpoint()const
{
return CoreClient::EndpointOutcome("location.aliyuncs.com");
}
LocationClient::DescribeEndpointsOutcome LocationClient::describeEndpoints(const Model::DescribeEndpointsRequest &request) const
{
auto endpointOutcome = endpoint();
if (!endpointOutcome.isSuccess())
return DescribeEndpointsOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return DescribeEndpointsOutcome(Model::DescribeEndpointsResult(outcome.result()));
else
return DescribeEndpointsOutcome(outcome.error());
}
void LocationClient::describeEndpointsAsync(const Model::DescribeEndpointsRequest& request, const DescribeEndpointsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
std::async(std::launch::async,
[this, request, handler, context]()
{
handler(this, request, describeEndpoints(request), context);
});
}
LocationClient::DescribeEndpointsOutcomeCallable LocationClient::describeEndpointsCallable(const Model::DescribeEndpointsRequest &request) const
{
auto task = std::make_shared<std::packaged_task<DescribeEndpointsOutcome()>>(
[this, request]()
{
return this->describeEndpoints(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

View File

@@ -0,0 +1,26 @@
/*
* 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/core/location/LocationRequest.h>
using namespace AlibabaCloud::Location;
LocationRequest::LocationRequest(const std::string & action) :
RpcServiceRequest("location", "2015-06-12", action)
{ }
LocationRequest::~LocationRequest()
{ }

View File

@@ -0,0 +1,58 @@
/*
* 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/core/location/model/DescribeEndpointsRequest.h>
using namespace AlibabaCloud::Location;
using namespace AlibabaCloud::Location::Model;
DescribeEndpointsRequest::DescribeEndpointsRequest() :
LocationRequest("DescribeEndpoints")
{}
DescribeEndpointsRequest::~DescribeEndpointsRequest()
{}
std::string DescribeEndpointsRequest::serviceCode()const
{
return parameter("ServiceCode");
}
void DescribeEndpointsRequest::setServiceCode(const std::string & serviceCode)
{
setParameter("ServiceCode", serviceCode);
}
std::string DescribeEndpointsRequest::id()const
{
return parameter("Id");
}
void DescribeEndpointsRequest::setId(const std::string & id)
{
setParameter("Id", id);
}
std::string DescribeEndpointsRequest::type()const
{
return parameter("Type");
}
void DescribeEndpointsRequest::setType(const std::string & type)
{
setParameter("Type", type);
}

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/core/location/model/DescribeEndpointsResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Location;
using namespace AlibabaCloud::Location::Model;
DescribeEndpointsResult::DescribeEndpointsResult() :
ServiceResult()
{
}
DescribeEndpointsResult::DescribeEndpointsResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DescribeEndpointsResult::~DescribeEndpointsResult()
{}
void DescribeEndpointsResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
success_ = value["Success"].asBool();
auto allEndpoints = value["Endpoints"]["Endpoint"];
for (const auto &item : allEndpoints)
{
Endpoint region;
region.endpoint = item["Endpoint"].asString();
region.id = item["Id"].asString();
region.namespace_ = item["Namespace"].asString();
region.serivceCode = item["SerivceCode"].asString();
region.type = item["Type"].asString();
auto allProtocols = item["Protocols"]["Protocols"];
for (const auto &item : allProtocols)
{
region.protocols.push_back(item.asString());
}
endpoints_.push_back(region);
}
}
std::vector<DescribeEndpointsResult::Endpoint> DescribeEndpointsResult::endpoints()const
{
return endpoints_;
}
void DescribeEndpointsResult::setEndpoints(const std::vector<Endpoint> & endpoints)
{
endpoints_ = endpoints;
}
bool DescribeEndpointsResult::success()const
{
return success_;
}
void DescribeEndpointsResult::setSuccess(const bool & success)
{
success_ = success;
}