Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
rdap.py docstring update (secynic#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
secynic committed Jul 25, 2017
1 parent e49b598 commit 89b8bf3
Showing 1 changed file with 78 additions and 44 deletions.
122 changes: 78 additions & 44 deletions ipwhois/rdap.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class _RDAPContact:
https://tools.ietf.org/html/rfc7095
Args:
vcard: The vcard list from an RDAP IP address query.
vcard (:obj:`list` of :obj:`list`): The vcard list from an RDAP IP
address query.
Raises:
InvalidEntityContactObject: vcard is not an RDAP entity contact
Expand Down Expand Up @@ -93,7 +94,7 @@ def _parse_name(self, val):
The function for parsing the vcard name.
Args:
val: The value to parse.
val (:obj:`list`): The value to parse.
"""

self.vars['name'] = val[3].strip()
Expand All @@ -103,7 +104,7 @@ def _parse_kind(self, val):
The function for parsing the vcard kind.
Args:
val: The value to parse.
val (:obj:`list`): The value to parse.
"""

self.vars['kind'] = val[3].strip()
Expand All @@ -113,7 +114,7 @@ def _parse_address(self, val):
The function for parsing the vcard address.
Args:
val: The value to parse.
val (:obj:`list`): The value to parse.
"""

ret = {
Expand Down Expand Up @@ -151,7 +152,7 @@ def _parse_phone(self, val):
The function for parsing the vcard phone numbers.
Args:
val: The value to parse.
val (:obj:`list`): The value to parse.
"""

ret = {
Expand Down Expand Up @@ -183,7 +184,7 @@ def _parse_email(self, val):
The function for parsing the vcard email addresses.
Args:
val: The value to parse.
val (:obj:`list`): The value to parse.
"""

ret = {
Expand Down Expand Up @@ -215,7 +216,7 @@ def _parse_role(self, val):
The function for parsing the vcard role.
Args:
val: The value to parse.
val (:obj:`list`): The value to parse.
"""

self.vars['role'] = val[3].strip()
Expand All @@ -225,7 +226,7 @@ def _parse_title(self, val):
The function for parsing the vcard title.
Args:
val: The value to parse.
val (:obj:`list`): The value to parse.
"""

self.vars['title'] = val[3].strip()
Expand Down Expand Up @@ -263,7 +264,7 @@ class _RDAPCommon:
https://tools.ietf.org/html/rfc7483#section-5
Args:
json_result: The JSON response from an RDAP query.
json_result (:obj:`dict`): The JSON response from an RDAP query.
Raises:
ValueError: vcard is not a known RDAP object.
Expand Down Expand Up @@ -292,10 +293,11 @@ def summarize_links(self, links_json):
https://tools.ietf.org/html/rfc7483#section-4.2
Args:
links_json: A json dictionary of links from RDAP results.
links_json (:obj:`dict`): A json mapping of links from RDAP
results.
Returns:
List: A unique list of found RDAP link dictionaries.
list of str: Unique RDAP links.
"""

ret = []
Expand All @@ -314,10 +316,20 @@ def summarize_notices(self, notices_json):
https://tools.ietf.org/html/rfc7483#section-4.3
Args:
notices_json: A json dictionary of notices from RDAP results.
notices_json (:obj:`dict`): A json mapping of notices from RDAP
results.
Returns:
List: A unique list of found RDAP notices dictionaries.
list of dict: Unique RDAP notices information:
::
[{
'title' (str) - The title/header of the notice.
'description' (str) - The description/body of the notice.
'links' (list) - Unique links returned by
:obj:`ipwhois.rdap._RDAPCommon.summarize_links()`.
}]
"""

ret = []
Expand Down Expand Up @@ -366,10 +378,20 @@ def summarize_events(self, events_json):
https://tools.ietf.org/html/rfc7483#section-4.5
Args:
events_json: A json dictionary of events from RDAP results.
events_json (:obj:`dict`): A json mapping of events from RDAP
results.
Returns:
List: A unique list of found RDAP events dictionaries.
list of dict: Unique RDAP events information:
::
[{
'action' (str) - The reason for an event.
'timestamp' (str) - The timestamp for when an event
occured.
'actor' (str) - The identifier for an event initiator.
}]
"""

ret = []
Expand Down Expand Up @@ -440,7 +462,8 @@ class _RDAPNetwork(_RDAPCommon):
https://tools.ietf.org/html/rfc7483#section-5.4
Args:
json_result: The JSON response from an RDAP IP address query.
json_result (:obj:`dict`): The JSON response from an RDAP IP address
query.
Raises:
InvalidNetworkObject: json_result is not an RDAP network object.
Expand Down Expand Up @@ -551,7 +574,7 @@ class _RDAPEntity(_RDAPCommon):
https://tools.ietf.org/html/rfc7483#section-5.1
Args:
json_result: The JSON response from an RDAP query.
json_result (:obj:`dict`): The JSON response from an RDAP query.
Raises:
InvalidEntityObject: json_result is not an RDAP entity object.
Expand Down Expand Up @@ -645,7 +668,7 @@ class RDAP:
https://www.arin.net/resources/rdap.html
Args:
net: A ipwhois.net.Net object.
net (:obj:`ipwhois.net.Net`): The network object.
Raises:
NetError: The parameter provided is not an instance of
Expand Down Expand Up @@ -673,34 +696,45 @@ def lookup(self, inc_raw=False, retry_count=3, asn_data=None, depth=0,
address via RDAP (HTTP).
Args:
inc_raw: Boolean for whether to include the raw results in the
returned dictionary.
retry_count: The number of times to retry in case socket errors,
timeouts, connection resets, etc. are encountered.
asn_data: Result dictionary from ipwhois.asn.IPASN.lookup().
Optional if the bootstrap parameter is True.
depth: How many levels deep to run queries when additional
referenced objects are found.
excluded_entities: A list of entity handles to not perform lookups.
response: Optional response object, this bypasses the RDAP lookup.
bootstrap: If True, performs lookups via ARIN bootstrap rather
than lookups based on ASN data.
rate_limit_timeout: The number of seconds to wait before retrying
when a rate limit notice is returned via rdap+json.
inc_raw (:obj:`bool`, optional): Whether to include the raw
results in the returned dictionary. Defaults to False.
retry_count (:obj:`int`): The number of times to retry in case
socket errors, timeouts, connection resets, etc. are
encountered. Defaults to 3.
asn_data (:obj:`dict`): Result from
:obj:`ipwhois.asn.IPASN.lookup`. Optional if the bootstrap
parameter is True.
depth (:obj:`int`): How many levels deep to run queries when
additional referenced objects are found. Defaults to 0.
excluded_entities (:obj:`list`): Entity handles to not perform
lookups. Defaults to None.
response (:obj:`str`): Optional response object, this bypasses the
RDAP lookup.
bootstrap (:obj:`bool`): If True, performs lookups via ARIN
bootstrap rather than lookups based on ASN data. Defaults to
False.
rate_limit_timeout (:obj:`int`): The number of seconds to wait
before retrying when a rate limit notice is returned via
rdap+json. Defaults to 120.
Returns:
Dictionary:
:query: The IP address (String)
:network: Dictionary of values returned by _RDAPNetwork. The raw
result is included for each entity if the inc_raw parameter is
True.
:entities: List of entity keys referenced by the top level IP
address query.
:objects: Dictionary of objects with the handles as keys, and the
dictionary returned by _RDAPEntity, etc as the values. The raw
result is included for each object if the inc_raw parameter is
True.
dict: The IP RDAP lookup results
::
{
'query' (str) - The IP address
'entities' (list) - Entity handles referred by the top
level query.
'network' (dict) - Network information which consists of
the fields listed in the ipwhois.rdap._RDAPNetwork
dict.
'objects' (dict) - Mapping of entity handle->entity dict
which consists of the fields listed in the
ipwhois.rdap._RDAPEntity dict. The raw result is
included for each object if the inc_raw parameter
is True.
}
"""

if not excluded_entities:
Expand Down

0 comments on commit 89b8bf3

Please sign in to comment.