Skip to content

Commit 16eb891

Browse files
committed
Merge pull request #18 from maxmind/greg/ws-v2.1
Greg/ws v2.1
2 parents f7182fd + 4cbc8b8 commit 16eb891

21 files changed

+207
-154
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
CHANGELOG
22
=========
33

4+
0.8.0 (2014-07-XX)
5+
------------------
6+
7+
* The web service client API has been updated for the v2.1 release of the web
8+
service. In particular, the `cityIspOrg` and `omni` methods on
9+
`WebServiceClient` have been deprecated. The `city` method now provides all
10+
of the data formerly provided by `cityIspOrg`, and the `omni` method has
11+
been replaced by the `insights` method.
12+
413
0.7.2 (2014-06-02)
514
------------------
615

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ website](http://www.maxmind.com/en/geoip2_beta).
1212

1313
## Description ##
1414

15-
This distribution provides an API for the GeoIP2 [web services]
15+
This distribution provides an API for the GeoIP2 [Precision web services]
1616
(http://dev.maxmind.com/geoip/geoip2/web-services) and [databases]
1717
(http://dev.maxmind.com/geoip/geoip2/downloadable). The API also works with
1818
the free [GeoLite2 databases](http://dev.maxmind.com/geoip/geoip2/geolite2/).
@@ -28,7 +28,7 @@ To do this, add the dependency to your pom.xml:
2828
<dependency>
2929
<groupId>com.maxmind.geoip2</groupId>
3030
<artifactId>geoip2</artifactId>
31-
<version>0.7.2</version>
31+
<version>0.8.0-SNAPSHOT</version>
3232
</dependency>
3333
```
3434

@@ -56,9 +56,9 @@ See the API documentation for more details.
5656
// Replace "42" with your user ID and "license_key" with your license key.
5757
WebServiceClient client = new WebServiceClient.Builder(42, "license_key").build();
5858

59-
// Replace "omni" with the method corresponding to the web service that
60-
// you are using, e.g., "country", "cityIspOrg", "city".
61-
OmniResponse response = client.omni(InetAddress.getByName("128.101.101.101"));
59+
// Replace "city" with the method corresponding to the web service that
60+
// you are using, e.g., "country" or "insights".
61+
CityResponse response = client.city(InetAddress.getByName("128.101.101.101"));
6262

6363
System.out.println(response.getCountry().getIsoCode()); // 'US'
6464
System.out.println(response.getCountry().getName()); // 'United States'
@@ -87,7 +87,7 @@ appropriate method (e.g., `city`) for your database, passing it the IP address
8787
you want to look up.
8888

8989
If the lookup succeeds, the method call will return a response class for the
90-
GeoIP lookup. The class in turn contains multiple record classes, each of
90+
GeoIP2 lookup. The class in turn contains multiple record classes, each of
9191
which represents part of the data returned by the database.
9292

9393
We recommend reusing the `DatabaseReader` object rather than creating a new
@@ -192,7 +192,8 @@ System.out.println(response.getOrganization()); // 'University of Minnesota'
192192
## Exceptions ##
193193

194194
For details on the possible errors returned by the web service itself, [see
195-
the GeoIP2 web service documentation](http://dev.maxmind.com/geoip2/geoip/web-services).
195+
the GeoIP2 Precision web service
196+
documentation](http://dev.maxmind.com/geoip2/geoip/web-services).
196197

197198
If the web service returns an explicit error document, this is thrown as an
198199
`AddressNotFoundException`, an `AuthenticationException`, an

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.maxmind.geoip2</groupId>
55
<artifactId>geoip2</artifactId>
6-
<version>0.7.3-SNAPSHOT</version>
6+
<version>0.8.0-SNAPSHOT</version>
77
<packaging>jar</packaging>
88
<name>MaxMind GeoIP2 API</name>
9-
<description>API for accessing MaxMind's GeoIP2 web service</description>
9+
<description>GeoIP2 webservice client and database reader</description>
1010
<url>http://dev.maxmind.com/geoip/geoip2/web-services</url>
1111
<licenses>
1212
<license>

src/main/java/com/maxmind/geoip2/DatabaseReader.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616
import com.maxmind.db.Reader.FileMode;
1717
import com.maxmind.geoip2.exception.AddressNotFoundException;
1818
import com.maxmind.geoip2.exception.GeoIp2Exception;
19-
import com.maxmind.geoip2.model.CityIspOrgResponse;
20-
import com.maxmind.geoip2.model.CityResponse;
21-
import com.maxmind.geoip2.model.ConnectionTypeResponse;
22-
import com.maxmind.geoip2.model.CountryResponse;
23-
import com.maxmind.geoip2.model.DomainResponse;
24-
import com.maxmind.geoip2.model.IspResponse;
25-
import com.maxmind.geoip2.model.OmniResponse;
19+
import com.maxmind.geoip2.model.*;
2620

2721
/**
2822
* Instances of this class provide a reader for the GeoIP2 database format. IP
@@ -193,18 +187,28 @@ public CityResponse city(InetAddress ipAddress) throws IOException,
193187
return this.get(ipAddress, CityResponse.class);
194188
}
195189

190+
191+
@SuppressWarnings("deprecation")
196192
@Override
193+
@Deprecated
197194
public CityIspOrgResponse cityIspOrg(InetAddress ipAddress)
198195
throws IOException, GeoIp2Exception {
199196
return this.get(ipAddress, CityIspOrgResponse.class);
200197
}
201198

199+
@SuppressWarnings("deprecation")
202200
@Override
201+
@Deprecated
203202
public OmniResponse omni(InetAddress ipAddress) throws IOException,
204203
GeoIp2Exception {
205204
return this.get(ipAddress, OmniResponse.class);
206205
}
207206

207+
public InsightsResponse insights(InetAddress ipAddress) throws IOException,
208+
GeoIp2Exception {
209+
return this.get(ipAddress, InsightsResponse.class);
210+
}
211+
208212
public ConnectionTypeResponse connectionType(InetAddress ipAddress)
209213
throws IOException, GeoIp2Exception {
210214
return this.get(ipAddress, ConnectionTypeResponse.class, false);

src/main/java/com/maxmind/geoip2/GeoIp2Provider.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.maxmind.geoip2.model.CountryResponse;
1010
import com.maxmind.geoip2.model.OmniResponse;
1111

12+
@SuppressWarnings("deprecation")
1213
public interface GeoIp2Provider {
1314

1415
/**
@@ -43,7 +44,10 @@ public CityResponse city(InetAddress ipAddress) throws IOException,
4344
* if there is an error looking up the IP
4445
* @throws IOException
4546
* if there is an IO error
47+
*
48+
* @deprecated As of 0.8.0, this has been replaced by {@link #city(InetAddress)}.
4649
*/
50+
@Deprecated
4751
public CityIspOrgResponse cityIspOrg(InetAddress ipAddress)
4852
throws IOException, GeoIp2Exception;
4953

@@ -55,7 +59,10 @@ public CityIspOrgResponse cityIspOrg(InetAddress ipAddress)
5559
* if there is an error looking up the IP
5660
* @throws IOException
5761
* if there is an IO error
62+
*
63+
* @deprecated As of 0.8.0, use {@link WebServiceClient#insights(InetAddress)} instead.
5864
*/
65+
@Deprecated
5966
public OmniResponse omni(InetAddress ipAddress) throws IOException,
6067
GeoIp2Exception;
6168
}

src/main/java/com/maxmind/geoip2/WebServiceClient.java

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,17 @@
1111
import com.fasterxml.jackson.databind.DeserializationFeature;
1212
import com.fasterxml.jackson.databind.InjectableValues;
1313
import com.fasterxml.jackson.databind.ObjectMapper;
14-
import com.google.api.client.http.GenericUrl;
15-
import com.google.api.client.http.HttpHeaders;
16-
import com.google.api.client.http.HttpRequest;
17-
import com.google.api.client.http.HttpRequestFactory;
18-
import com.google.api.client.http.HttpResponse;
19-
import com.google.api.client.http.HttpResponseException;
20-
import com.google.api.client.http.HttpTransport;
14+
import com.google.api.client.http.*;
2115
import com.google.api.client.http.javanet.NetHttpTransport;
22-
import com.maxmind.geoip2.exception.AddressNotFoundException;
23-
import com.maxmind.geoip2.exception.AuthenticationException;
24-
import com.maxmind.geoip2.exception.GeoIp2Exception;
25-
import com.maxmind.geoip2.exception.HttpException;
26-
import com.maxmind.geoip2.exception.InvalidRequestException;
27-
import com.maxmind.geoip2.exception.OutOfQueriesException;
28-
import com.maxmind.geoip2.model.CityIspOrgResponse;
29-
import com.maxmind.geoip2.model.CityResponse;
30-
import com.maxmind.geoip2.model.CountryResponse;
31-
import com.maxmind.geoip2.model.OmniResponse;
16+
import com.maxmind.geoip2.exception.*;
17+
import com.maxmind.geoip2.model.*;
3218

3319
/**
3420
* <p>
35-
* This class provides a client API for all the GeoIP2 web service's end points.
36-
* The end points are Country, City, City/ISP/Org, and Omni. Each end point
21+
* This class provides a client API for all the GeoIP2 Precision web service end points.
22+
* The end points are Country and Insights. Each end point
3723
* returns a different set of data about an IP address, with Country returning
38-
* the least data and Omni the most.
24+
* the least data and Insights the most.
3925
* </p>
4026
*
4127
* <p>
@@ -241,33 +227,71 @@ public CityResponse city(InetAddress ipAddress) throws IOException,
241227
* if there is an error from the web service
242228
* @throws IOException
243229
* if an IO error happens during the request
230+
*
231+
* @deprecated As of 0.8.0, use {@link #city()} instead.
244232
*/
233+
@SuppressWarnings("deprecation")
234+
@Deprecated
245235
public CityIspOrgResponse cityIspOrg() throws IOException, GeoIp2Exception {
246236
return this.cityIspOrg(null);
247237
}
248238

239+
@SuppressWarnings("deprecation")
240+
@Deprecated
249241
@Override
250242
public CityIspOrgResponse cityIspOrg(InetAddress ipAddress)
251243
throws IOException, GeoIp2Exception {
252-
return this.responseFor("city_isp_org", ipAddress,
244+
return this.responseFor("city", ipAddress,
253245
CityIspOrgResponse.class);
254246
}
255247

248+
/**
249+
* @return An Insights model for the requesting IP address
250+
* @throws GeoIp2Exception
251+
* if there is an error from the web service
252+
* @throws IOException
253+
* if an IO error happens during the request
254+
*/
255+
public InsightsResponse insights() throws IOException, GeoIp2Exception {
256+
return this.insights(null);
257+
}
258+
259+
260+
/**
261+
* @param ipAddress
262+
* IPv4 or IPv6 address to lookup.
263+
* @return A Insight model for the requested IP address.
264+
* @throws GeoIp2Exception
265+
* if there is an error looking up the IP
266+
* @throws IOException
267+
* if there is an IO error
268+
*/
269+
public InsightsResponse insights(InetAddress ipAddress) throws IOException,
270+
GeoIp2Exception {
271+
return this.responseFor("insights", ipAddress, InsightsResponse.class);
272+
}
273+
256274
/**
257275
* @return An Omni model for the requesting IP address
258276
* @throws GeoIp2Exception
259277
* if there is an error from the web service
260278
* @throws IOException
261279
* if an IO error happens during the request
280+
*
281+
* @deprecated As of 0.8.0, use {@link #insights()} instead.
262282
*/
283+
@SuppressWarnings("deprecation")
284+
@Deprecated
263285
public OmniResponse omni() throws IOException, GeoIp2Exception {
264286
return this.omni(null);
265287
}
266288

289+
@SuppressWarnings("deprecation")
290+
@Deprecated
267291
@Override
268292
public OmniResponse omni(InetAddress ipAddress) throws IOException,
269293
GeoIp2Exception {
270-
return this.responseFor("omni", ipAddress, OmniResponse.class);
294+
return this.responseFor("insights", ipAddress, OmniResponse.class);
271295
}
272296

273297
private <T> T responseFor(String path, InetAddress ipAddress, Class<T> cls)
@@ -408,7 +432,7 @@ private static void handleErrorWithJsonBody(Map<String, String> content,
408432
}
409433

410434
private GenericUrl createUri(String path, InetAddress ipAddress) {
411-
return new GenericUrl("https://" + this.host + "/geoip/v2.0/" + path
435+
return new GenericUrl("https://" + this.host + "/geoip/v2.1/" + path
412436
+ "/" + (ipAddress == null ? "me" : ipAddress.getHostAddress()));
413437

414438
}

src/main/java/com/maxmind/geoip2/model/CityIspOrgResponse.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package com.maxmind.geoip2.model;
22

33
/**
4-
* This class provides a model for the data returned by the GeoIP2 City/ISP/Org
5-
* end point.
4+
* This class provides a model for the data returned by the GeoIP2 Precision:
5+
* City end point.
66
*
7-
* The only difference between the City, City/ISP/Org, and Omni model classes is
7+
* The only difference between the City and Insights model classes is
88
* which fields in each record may be populated.
99
*
1010
* @see <a href="http://dev.maxmind.com/geoip/geoip2/web-services">GeoIP2 Web
1111
* Services</a>
12+
*
13+
* @deprecated As of 0.8.0, this has been replaced by {@link CityResponse}.
1214
*/
15+
@Deprecated
1316
final public class CityIspOrgResponse extends AbstractCityResponse {
1417
public CityIspOrgResponse() {
1518
}

src/main/java/com/maxmind/geoip2/model/CityResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.maxmind.geoip2.model;
22

33
/**
4-
* This class provides a model for the data returned by the GeoIP2 City end
5-
* point.
4+
* This class provides a model for the data returned by the GeoIP2 Precision:
5+
* City end point.
66
*
7-
* The only difference between the City, City/ISP/Org, and Omni model classes is
7+
* The only difference between the City and Insights model classes is
88
* which fields in each record may be populated.
99
*
1010
* @see <a href="http://dev.maxmind.com/geoip/geoip2/web-services">GeoIP2 Web

src/main/java/com/maxmind/geoip2/model/CountryResponse.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.maxmind.geoip2.model;
22

33
/**
4-
* This class provides a model for the data returned by the GeoIP2 Country end
5-
* point.
6-
*
7-
* The only difference between the City, City/ISP/Org, and Omni model classes is
8-
* which fields in each record may be populated.
4+
* This class provides a model for the data returned by the GeoIP2 Precision:
5+
* Country end point.
96
*
107
* @see <a href="http://dev.maxmind.com/geoip/geoip2/web-services">GeoIP2 Web
118
* Services</a>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.maxmind.geoip2.model;
2+
3+
/**
4+
* This class provides a model for the data returned by the GeoIP2 Precision:
5+
* Insights end point.
6+
*
7+
* The only difference between the City and Insights model classes is
8+
* which fields in each record may be populated.
9+
*
10+
* @see <a href="http://dev.maxmind.com/geoip/geoip2/web-services">GeoIP2 Web
11+
* Services</a>
12+
*/
13+
final public class InsightsResponse extends AbstractCityResponse {
14+
public InsightsResponse() {
15+
}
16+
}

0 commit comments

Comments
 (0)