Skip to content

Commit 08ab2da

Browse files
committed
Merge pull request #9 from dyninc/reports
Adding unified module for TM report calls. Tagging as 1.0.2
2 parents 9f8743e + ebdf8c6 commit 08ab2da

File tree

6 files changed

+160
-4
lines changed

6 files changed

+160
-4
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Release History
22
---------------
3+
1.0.2 (2014-08-26)
4+
++++++++++++++++++
5+
6+
* Added reports module
7+
* Updated installation documentation.
8+
39
1.0.1 (2014-08-06)
410
++++++++++++++++++
511

docs/install.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ The first step to using any software package is getting it properly installed.
1010
Distribute & Pip
1111
----------------
1212

13-
Installing dyn is simple via `pip <http://www.pip-installer.org/>`_. Currently
14-
the dyn module is only available internally within Dyn, because of this it can
15-
only be downloaded while on Dyn's internal VPN::
13+
Installing dyn is simple via `pip <http://www.pip-installer.org/>`_.
1614

1715
$ pip install dyn
1816

docs/tm.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ this part of the documentation is for you.
2525
tm/accounts
2626
tm/records
2727
tm/services
28+
tm/reports
2829
tm/errors
2930

docs/tm/reports.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.. _tm-reports:
2+
3+
TM Reports
4+
==========
5+
The :mod:`~dyn.tm.reports` module contains interfaces for all of the various Report
6+
collection calls offered by the dyn.tm REST API
7+
8+
List Functions
9+
--------------
10+
11+
.. autofunction:: dyn.tm.reports.get_check_permission
12+
.. autofunction:: dyn.tm.reports.get_dnssec_timeline
13+
.. autofunction:: dyn.tm.reports.get_rttm_log
14+
.. autofunction:: dyn.tm.reports.get_rttm_rrset
15+
.. autofunction:: dyn.tm.reports.get_qps
16+
.. autofunction:: dyn.tm.reports.get_zone_notes
17+

dyn/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Requires Python 2.6 or higher, or the "simplejson" package.
77
"""
8-
version_info = (1, 0, 1)
8+
version_info = (1, 0, 2)
99
__name__ = 'dyn'
1010
__doc__ = 'A python wrapper for the DynDNS and DynEmail APIs'
1111
__author__ = 'Jonathan Nappi, Cole Tuininga'

dyn/tm/reports.py

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# -*- coding: utf-8 -*-
2+
"""This module contains interfaces for all Report generation features of the
3+
REST API
4+
"""
5+
from .session import DynectSession
6+
7+
__author__ = 'elarochelle'
8+
__all__ = ['get_check_permission', 'get_dnssec_timeline', 'get_qps',
9+
'get_rttm_log', 'get_rttm_rrset', 'get_zone_notes']
10+
11+
12+
def get_check_permission(permission, zone_name=None):
13+
"""Returns a list of allowed and forbidden permissions for the currently
14+
logged in user based on the provided permissions array.
15+
16+
:param permission: A list of permissions to check for the current user.
17+
:param zone_name: The zone to check for specific permissions.
18+
:return: A :class:`dict` containing permission information.
19+
"""
20+
api_args = {'permission': permission}
21+
if zone_name is not None:
22+
api_args['zone_name'] = zone_name
23+
response = DynectSession.get_session().execute('/CheckPermissionReport/',
24+
'POST', api_args)
25+
return response['data']
26+
27+
28+
def get_dnssec_timeline(zone_name, start_ts=None, end_ts=None):
29+
"""Generates a report of events for the :class:`DNSSEC` service
30+
attached to the specified zone has performed and has scheduled
31+
to perform.
32+
33+
:param zone_name: The name of the zone with DNSSEC service
34+
:param start_ts: UNIX timestamp identifying point in time for the
35+
report
36+
:param end_ts: UNIX timestamp indicating the end of the data range for
37+
the report
38+
:return: A :class:`dict` containing log report data
39+
"""
40+
api_args = {'zone': zone_name}
41+
if start_ts is not None:
42+
api_args['start_ts'] = start_ts
43+
if end_ts is not None:
44+
api_args['end_ts'] = end_ts
45+
response = DynectSession.get_session().execute('/DNSSECTimelineReport/',
46+
'POST', api_args)
47+
return response['data']
48+
49+
50+
def get_rttm_log(zone_name, fqdn, start_ts, end_ts):
51+
"""Generates a report with information about changes to an existing
52+
RTTM service.
53+
54+
:param zone_name: The name of the zone
55+
:param fqdn: The FQDN where RTTM is attached
56+
:param start_ts: UNIX timestamp identifying point in time for the log
57+
report
58+
:param end_ts: UNIX timestamp indicating the end of the data range for
59+
the report
60+
:return: A :class:`dict` containing log report data
61+
"""
62+
api_args = {'zone': zone_name,
63+
'fqdn': fqdn,
64+
'start_ts': start_ts,
65+
'end_ts': end_ts}
66+
response = DynectSession.get_session().execute('/RTTMLogReport/',
67+
'POST', api_args)
68+
return response['data']
69+
70+
71+
def get_rttm_rrset(zone_name, fqdn, ts):
72+
"""Generates a report of regional response sets for this RTTM service
73+
at a given point in time.
74+
75+
:param zone_name: The name of the zone
76+
:param fqdn: The FQDN where RTTM is attached
77+
:param ts: UNIX timestamp identifying point in time for the report
78+
:return: A :class:`dict` containing rrset report data
79+
"""
80+
api_args = {'zone': zone_name,
81+
'fqdn': fqdn,
82+
'ts': ts}
83+
response = DynectSession.get_session().execute('/RTTMRRSetReport/',
84+
'POST', api_args)
85+
return response['data']
86+
87+
88+
def get_qps(start_ts, end_ts, breakdown=None, hosts=None, rrecs=None,
89+
zones = None):
90+
"""Generates a report with information about Queries Per Second (QPS).
91+
92+
:param start_ts: UNIX timestamp identifying point in time for the QPS
93+
report
94+
:param end_ts: UNIX timestamp indicating the end of the data range for
95+
the report
96+
:param breakdown: By default, most data is aggregated together.
97+
Valid values ('hosts', 'rrecs', 'zones').
98+
:param hosts: List of hosts to include in the report.
99+
:param rrecs: List of record types to include in report.
100+
:param zones: List of zones to include in report.
101+
:return: A :class:`str` with CSV data
102+
"""
103+
api_args = {'start_ts': start_ts,
104+
'end_ts': end_ts}
105+
if breakdown is not None:
106+
api_args['breakdown'] = breakdown
107+
if hosts is not None:
108+
api_args['hosts'] = hosts
109+
if rrecs is not None:
110+
api_args['rrecs'] = rrecs
111+
if zones is not None:
112+
api_args['zones'] = zones
113+
response = DynectSession.get_session().execute('/QPSReport/',
114+
'POST', api_args)
115+
return response['data']
116+
117+
118+
def get_zone_notes(zone_name, offset=None, limit=None):
119+
"""Generates a report containing the Zone Notes for given zone.
120+
121+
:param zone_name: The name of the zone
122+
:param offset: UNIX timestamp of the starting point at which to
123+
retrieve the notes
124+
:param limit: The maximum number of notes to be retrieved
125+
:return: A :class:`list` of :class:`dict` containing Zone Notes
126+
"""
127+
api_args = {'zone': zone_name}
128+
if offset:
129+
api_args['offset'] = offset
130+
if limit:
131+
api_args['limit'] = limit
132+
response = DynectSession.get_session().execute('/ZoneNoteReport/',
133+
'POST', api_args)
134+
return response['data']

0 commit comments

Comments
 (0)