Support DescribeIpv4Location.

This commit is contained in:
sdk-team
2020-04-10 11:53:07 +08:00
parent 485d712ddd
commit 20774ebe3a
9 changed files with 315 additions and 1 deletions

View File

@@ -1,3 +1,6 @@
2020-04-10 Version: 1.36.349
- Support DescribeIpv4Location.
2020-04-09 Version: 1.36.348
- Add prometheus api AddGrafana and AddIntegration.

View File

@@ -1 +1 @@
1.36.348
1.36.349

View File

@@ -27,6 +27,8 @@ set(geoip_public_header_model
include/alibabacloud/geoip/model/DescribeGeoipInstanceStatisticsResult.h
include/alibabacloud/geoip/model/DescribeGeoipInstancesRequest.h
include/alibabacloud/geoip/model/DescribeGeoipInstancesResult.h
include/alibabacloud/geoip/model/DescribeIpv4LocationRequest.h
include/alibabacloud/geoip/model/DescribeIpv4LocationResult.h
include/alibabacloud/geoip/model/DescribeIpv6LocationRequest.h
include/alibabacloud/geoip/model/DescribeIpv6LocationResult.h )
@@ -38,6 +40,8 @@ set(geoip_src
src/model/DescribeGeoipInstanceStatisticsResult.cc
src/model/DescribeGeoipInstancesRequest.cc
src/model/DescribeGeoipInstancesResult.cc
src/model/DescribeIpv4LocationRequest.cc
src/model/DescribeIpv4LocationResult.cc
src/model/DescribeIpv6LocationRequest.cc
src/model/DescribeIpv6LocationResult.cc )

View File

@@ -28,6 +28,8 @@
#include "model/DescribeGeoipInstanceStatisticsResult.h"
#include "model/DescribeGeoipInstancesRequest.h"
#include "model/DescribeGeoipInstancesResult.h"
#include "model/DescribeIpv4LocationRequest.h"
#include "model/DescribeIpv4LocationResult.h"
#include "model/DescribeIpv6LocationRequest.h"
#include "model/DescribeIpv6LocationResult.h"
@@ -48,6 +50,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::DescribeGeoipInstancesResult> DescribeGeoipInstancesOutcome;
typedef std::future<DescribeGeoipInstancesOutcome> DescribeGeoipInstancesOutcomeCallable;
typedef std::function<void(const GeoipClient*, const Model::DescribeGeoipInstancesRequest&, const DescribeGeoipInstancesOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DescribeGeoipInstancesAsyncHandler;
typedef Outcome<Error, Model::DescribeIpv4LocationResult> DescribeIpv4LocationOutcome;
typedef std::future<DescribeIpv4LocationOutcome> DescribeIpv4LocationOutcomeCallable;
typedef std::function<void(const GeoipClient*, const Model::DescribeIpv4LocationRequest&, const DescribeIpv4LocationOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DescribeIpv4LocationAsyncHandler;
typedef Outcome<Error, Model::DescribeIpv6LocationResult> DescribeIpv6LocationOutcome;
typedef std::future<DescribeIpv6LocationOutcome> DescribeIpv6LocationOutcomeCallable;
typedef std::function<void(const GeoipClient*, const Model::DescribeIpv6LocationRequest&, const DescribeIpv6LocationOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DescribeIpv6LocationAsyncHandler;
@@ -65,6 +70,9 @@ namespace AlibabaCloud
DescribeGeoipInstancesOutcome describeGeoipInstances(const Model::DescribeGeoipInstancesRequest &request)const;
void describeGeoipInstancesAsync(const Model::DescribeGeoipInstancesRequest& request, const DescribeGeoipInstancesAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DescribeGeoipInstancesOutcomeCallable describeGeoipInstancesCallable(const Model::DescribeGeoipInstancesRequest& request) const;
DescribeIpv4LocationOutcome describeIpv4Location(const Model::DescribeIpv4LocationRequest &request)const;
void describeIpv4LocationAsync(const Model::DescribeIpv4LocationRequest& request, const DescribeIpv4LocationAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DescribeIpv4LocationOutcomeCallable describeIpv4LocationCallable(const Model::DescribeIpv4LocationRequest& request) const;
DescribeIpv6LocationOutcome describeIpv6Location(const Model::DescribeIpv6LocationRequest &request)const;
void describeIpv6LocationAsync(const Model::DescribeIpv6LocationRequest& request, const DescribeIpv6LocationAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DescribeIpv6LocationOutcomeCallable describeIpv6LocationCallable(const Model::DescribeIpv6LocationRequest& request) const;

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_GEOIP_MODEL_DESCRIBEIPV4LOCATIONREQUEST_H_
#define ALIBABACLOUD_GEOIP_MODEL_DESCRIBEIPV4LOCATIONREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/geoip/GeoipExport.h>
namespace AlibabaCloud
{
namespace Geoip
{
namespace Model
{
class ALIBABACLOUD_GEOIP_EXPORT DescribeIpv4LocationRequest : public RpcServiceRequest
{
public:
DescribeIpv4LocationRequest();
~DescribeIpv4LocationRequest();
std::string getIp()const;
void setIp(const std::string& ip);
std::string getUserClientIp()const;
void setUserClientIp(const std::string& userClientIp);
std::string getLang()const;
void setLang(const std::string& lang);
private:
std::string ip_;
std::string userClientIp_;
std::string lang_;
};
}
}
}
#endif // !ALIBABACLOUD_GEOIP_MODEL_DESCRIBEIPV4LOCATIONREQUEST_H_

View File

@@ -0,0 +1,61 @@
/*
* 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_GEOIP_MODEL_DESCRIBEIPV4LOCATIONRESULT_H_
#define ALIBABACLOUD_GEOIP_MODEL_DESCRIBEIPV4LOCATIONRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/geoip/GeoipExport.h>
namespace AlibabaCloud
{
namespace Geoip
{
namespace Model
{
class ALIBABACLOUD_GEOIP_EXPORT DescribeIpv4LocationResult : public ServiceResult
{
public:
DescribeIpv4LocationResult();
explicit DescribeIpv4LocationResult(const std::string &payload);
~DescribeIpv4LocationResult();
std::string getIp()const;
std::string getIsp()const;
std::string getCountry()const;
std::string getCity()const;
std::string getCounty()const;
std::string getProvince()const;
protected:
void parse(const std::string &payload);
private:
std::string ip_;
std::string isp_;
std::string country_;
std::string city_;
std::string county_;
std::string province_;
};
}
}
}
#endif // !ALIBABACLOUD_GEOIP_MODEL_DESCRIBEIPV4LOCATIONRESULT_H_

View File

@@ -159,6 +159,42 @@ GeoipClient::DescribeGeoipInstancesOutcomeCallable GeoipClient::describeGeoipIns
return task->get_future();
}
GeoipClient::DescribeIpv4LocationOutcome GeoipClient::describeIpv4Location(const DescribeIpv4LocationRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return DescribeIpv4LocationOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return DescribeIpv4LocationOutcome(DescribeIpv4LocationResult(outcome.result()));
else
return DescribeIpv4LocationOutcome(outcome.error());
}
void GeoipClient::describeIpv4LocationAsync(const DescribeIpv4LocationRequest& request, const DescribeIpv4LocationAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, describeIpv4Location(request), context);
};
asyncExecute(new Runnable(fn));
}
GeoipClient::DescribeIpv4LocationOutcomeCallable GeoipClient::describeIpv4LocationCallable(const DescribeIpv4LocationRequest &request) const
{
auto task = std::make_shared<std::packaged_task<DescribeIpv4LocationOutcome()>>(
[this, request]()
{
return this->describeIpv4Location(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
GeoipClient::DescribeIpv6LocationOutcome GeoipClient::describeIpv6Location(const DescribeIpv6LocationRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,62 @@
/*
* 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/geoip/model/DescribeIpv4LocationRequest.h>
using AlibabaCloud::Geoip::Model::DescribeIpv4LocationRequest;
DescribeIpv4LocationRequest::DescribeIpv4LocationRequest() :
RpcServiceRequest("geoip", "2020-01-01", "DescribeIpv4Location")
{
setMethod(HttpRequest::Method::Post);
}
DescribeIpv4LocationRequest::~DescribeIpv4LocationRequest()
{}
std::string DescribeIpv4LocationRequest::getIp()const
{
return ip_;
}
void DescribeIpv4LocationRequest::setIp(const std::string& ip)
{
ip_ = ip;
setParameter("Ip", ip);
}
std::string DescribeIpv4LocationRequest::getUserClientIp()const
{
return userClientIp_;
}
void DescribeIpv4LocationRequest::setUserClientIp(const std::string& userClientIp)
{
userClientIp_ = userClientIp;
setParameter("UserClientIp", userClientIp);
}
std::string DescribeIpv4LocationRequest::getLang()const
{
return lang_;
}
void DescribeIpv4LocationRequest::setLang(const std::string& lang)
{
lang_ = lang;
setParameter("Lang", lang);
}

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.
*/
#include <alibabacloud/geoip/model/DescribeIpv4LocationResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Geoip;
using namespace AlibabaCloud::Geoip::Model;
DescribeIpv4LocationResult::DescribeIpv4LocationResult() :
ServiceResult()
{}
DescribeIpv4LocationResult::DescribeIpv4LocationResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DescribeIpv4LocationResult::~DescribeIpv4LocationResult()
{}
void DescribeIpv4LocationResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["Ip"].isNull())
ip_ = value["Ip"].asString();
if(!value["Country"].isNull())
country_ = value["Country"].asString();
if(!value["Province"].isNull())
province_ = value["Province"].asString();
if(!value["City"].isNull())
city_ = value["City"].asString();
if(!value["County"].isNull())
county_ = value["County"].asString();
if(!value["Isp"].isNull())
isp_ = value["Isp"].asString();
}
std::string DescribeIpv4LocationResult::getIp()const
{
return ip_;
}
std::string DescribeIpv4LocationResult::getIsp()const
{
return isp_;
}
std::string DescribeIpv4LocationResult::getCountry()const
{
return country_;
}
std::string DescribeIpv4LocationResult::getCity()const
{
return city_;
}
std::string DescribeIpv4LocationResult::getCounty()const
{
return county_;
}
std::string DescribeIpv4LocationResult::getProvince()const
{
return province_;
}