Skip to content

Commit ac88a39

Browse files
committed
Added represented_country plus some doc updates to reduce verbosity.
1 parent e73291f commit ac88a39

File tree

1 file changed

+66
-32
lines changed

1 file changed

+66
-32
lines changed

geoip2/records.py

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ class City(PlaceRecord):
4848
4949
Attributes:
5050
51-
:ivar confidence: This returns a value from 0-100 indicating MaxMind's
51+
:ivar confidence: A value from 0-100 indicating MaxMind's
5252
confidence that the city is correct. This attribute is only available
5353
from the Omni end point.
54-
:ivar geoname_id: This returns a GeoName ID for the city. This attribute
54+
:ivar geoname_id: The GeoName ID for the city. This attribute
5555
is returned by all end points.
56-
:ivar name: Returns the name of the city based on the languages list
56+
:ivar name: The name of the city based on the languages list
5757
passed to the constructor. This attribute is returned by all end points.
58-
:ivar names: This returns a dictionary where the keys are language codes
58+
:ivar names: A dictionary where the keys are language codes
5959
and the values are names. This attribute is returned by all end points.
6060
6161
"""
@@ -72,14 +72,14 @@ class Continent(PlaceRecord):
7272
7373
Attributes:
7474
75-
:ivar continent_code: This returns a two character continent code
75+
:ivar continent_code: A two character continent code
7676
like "NA" (North America) or "OC" (Oceania). This attribute is returned
7777
by all end points.
78-
:ivar geoname_id: This returns a GeoName ID for the continent. This
78+
:ivar geoname_id: The GeoName ID for the continent. This
7979
attribute is returned by all end points.
8080
:ivar name: Returns the name of the continent based on the languages list
8181
passed to the constructor. This attribute is returned by all end points.
82-
:ivar names: This returns a dictionary where the keys are language codes
82+
:ivar names: A dictionary where the keys are language codes
8383
and the values are names. This attribute is returned by all end points.
8484
8585
"""
@@ -91,27 +91,61 @@ class Country(PlaceRecord):
9191
9292
This class contains the country-level data associated with an IP address.
9393
94-
This record is returned by all the end points except the Country end point.
94+
This record is returned by all the end points.
9595
9696
Attributes:
9797
98-
:ivar confidence: This returns a value from 0-100 indicating MaxMind's
99-
confidence that the country is correct. This attribute is only available
100-
from the Omni end point.
101-
:ivar geoname_id: This returns a GeoName ID for the country. This attribute
102-
is returned by all end points.
103-
:ivar iso_code: This returns the two-character ISO 3166-1
98+
:ivar confidence: A value from 0-100 indicating MaxMind's confidence that
99+
the country is correct. This attribute is only available from the Omni
100+
end point.
101+
:ivar geoname_id: The GeoName ID for the country. This attribute is
102+
returned by all end points.
103+
:ivar iso_code: The two-character ISO 3166-1
104104
(http://en.wikipedia.org/wiki/ISO_3166-1) alpha code for the country.
105105
This attribute is returned by all end points.
106-
:ivar name: Returns the name of the country based on the languages list
106+
:ivar name: The name of the country based on the languages list
107107
passed to the constructor. This attribute is returned by all end points.
108-
:ivar names: This returns a dictionary where the keys are language codes
109-
and the values are names. This attribute is returned by all end points.
108+
:ivar names: A dictionary where the keys are language codes and the values
109+
are names. This attribute is returned by all end points.
110110
111111
"""
112112
_valid_attributes = set(['confidence', 'geoname_id', 'iso_code', 'names'])
113113

114114

115+
class RepresentedCountry(Country):
116+
"""Contains data for the represented country associated with an IP address
117+
118+
This class contains the country-level data associated with an IP address for
119+
the IP's represented country. The represented country is the country
120+
represented by something like a military base or embassy.
121+
122+
This record is returned by all the end points.
123+
124+
Attributes:
125+
126+
:ivar confidence: A value from 0-100 indicating MaxMind's confidence that
127+
the country is correct. This attribute is only available from the Omni
128+
end point.
129+
:ivar geoname_id: The GeoName ID for the country. This attribute is
130+
returned by all end points.
131+
:ivar iso_code: The two-character ISO 3166-1
132+
(http://en.wikipedia.org/wiki/ISO_3166-1) alpha code for the country.
133+
This attribute is returned by all end points.
134+
:ivar name: The name of the country based on the languages list
135+
passed to the constructor. This attribute is returned by all end points.
136+
:ivar names: A dictionary where the keys are language codes and the values
137+
are names. This attribute is returned by all end points.
138+
:var type: A string indicating the type of entity that is representing the
139+
country. Currently we only return ``military`` but this could expand to
140+
include other types such as ``embassy`` in the future. Returned by all
141+
endpoints.
142+
143+
144+
145+
"""
146+
_valid_attributes = set(['confidence', 'geoname_id', 'iso_code', 'names', 'type'])
147+
148+
115149
class Location(Record):
116150
"""Contains data for the location record associated with an IP address
117151
@@ -121,22 +155,22 @@ class Location(Record):
121155
122156
Attributes:
123157
124-
:ivar accuracy_radius: This returns the radius in kilometers around the
158+
:ivar accuracy_radius: The radius in kilometers around the
125159
specified location where the IP address is likely to be. This attribute
126160
is only available from the Omni end point.
127-
:ivar latitude: This returns the latitude of the location as a floating
161+
:ivar latitude: The latitude of the location as a floating
128162
point number. This attribute is returned by all end points except the
129163
Country end point.
130-
:ivar longitude: This returns the longitude of the location as a
164+
:ivar longitude: The longitude of the location as a
131165
floating point number. This attribute is returned by all end points
132166
except the Country end point.
133-
:ivar metro_code: This returns the metro code of the location if the
167+
:ivar metro_code: The metro code of the location if the
134168
location is in the US. MaxMind returns the same metro codes as the
135169
Google AdWords API
136170
(https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions).
137171
This attribute is returned by all end points except the Country end
138172
point.
139-
:ivar time_zone: This returns the time zone associated with location, as
173+
:ivar time_zone: The time zone associated with location, as
140174
specified by the IANA Time Zone Database
141175
(http://www.iana.org/time-zones), e.g., "America/New_York". This
142176
attribute is returned by all end points except the Country end point.
@@ -156,11 +190,11 @@ class Postal(Record):
156190
157191
Attributes:
158192
159-
:ivar code: This returns the postal code of the location. Postal
193+
:ivar code: The postal code of the location. Postal
160194
codes are not available for all countries. In some countries, this will
161195
only contain part of the postal code. This attribute is returned by all
162196
end points except the Country end point.
163-
:ivar confidence: This returns a value from 0-100 indicating
197+
:ivar confidence: A value from 0-100 indicating
164198
MaxMind's confidence that the postal code is correct. This attribute is
165199
only available from the Omni end point.
166200
@@ -238,35 +272,35 @@ class Traits(Record):
238272
239273
This class has the following attributes:
240274
241-
:ivar autonomous_system_number: This returns the autonomous system
275+
:ivar autonomous_system_number: The autonomous system
242276
number (http://en.wikipedia.org/wiki/Autonomous_system_(Internet))
243277
associated with the IP address. This attribute is only available from
244278
the City/ISP/Org and Omni end points.
245-
:ivar autonomous_system_organization: This returns the organization
279+
:ivar autonomous_system_organization: The organization
246280
associated with the registered autonomous system number
247281
(http://en.wikipedia.org/wiki/Autonomous_system_(Internet)) for the IP
248282
address. This attribute is only available from the City/ISP/Org and
249283
Omni end points.
250-
:ivar domain: This returns the second level domain associated with the
284+
:ivar domain: The second level domain associated with the
251285
IP address. This will be something like "example.com" or
252286
"example.co.uk", not "foo.example.com". This attribute is only available
253287
from the City/ISP/Org and Omni end points.
254-
:ivar ip_address: This returns the IP address that the data in the model
288+
:ivar ip_address: The IP address that the data in the model
255289
is for. If you performed a "me" lookup against the web service, this
256290
will be the externally routable IP address for the system the code is
257291
running on. If the system is behind a NAT, this may differ from the IP
258292
address locally assigned to it. This attribute is returned by all end
259293
points.
260-
:ivar is_anonymous_proxy: This returns true if the IP is an anonymous
294+
:ivar is_anonymous_proxy: This is true if the IP is an anonymous
261295
proxy. See http://dev.maxmind.com/faq/geoip#anonproxy for further
262296
details. This attribute is returned by all end points.
263-
:ivar isp: This returns the name of the ISP associated the IP address.
297+
:ivar isp: The name of the ISP associated the IP address.
264298
This attribute is only available from the City/ISP/Org and Omni end
265299
points.
266-
:ivar organization: This returns the name of the organization associated
300+
:ivar organization: The name of the organization associated
267301
the IP address. This attribute is only available from the City/ISP/Org
268302
and Omni end points.
269-
:ivar user_type: This returns the user type associated with the IP
303+
:ivar user_type: The user type associated with the IP
270304
address. This can be one of the following values:
271305
272306
* business

0 commit comments

Comments
 (0)