-
Notifications
You must be signed in to change notification settings - Fork 51
Adding unified module for TM report calls. #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,5 +25,6 @@ this part of the documentation is for you. | |
| tm/accounts | ||
| tm/records | ||
| tm/services | ||
| tm/reports | ||
| tm/errors | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| .. _tm-reports: | ||
|
|
||
| TM Reports | ||
| ========== | ||
| The :mod:`~dyn.tm.reports` module contains interfaces for all of the various Report | ||
| collection calls offered by the dyn.tm REST API | ||
|
|
||
| List Functions | ||
| -------------- | ||
|
|
||
| .. autofunction:: dyn.tm.reports.get_check_permission | ||
| .. autofunction:: dyn.tm.reports.get_dnssec_timeline | ||
| .. autofunction:: dyn.tm.reports.get_rttm_log | ||
| .. autofunction:: dyn.tm.reports.get_rttm_rrset | ||
| .. autofunction:: dyn.tm.reports.get_qps | ||
| .. autofunction:: dyn.tm.reports.get_zone_notes | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """This module contains interfaces for all Report generation features of the | ||
| REST API | ||
| """ | ||
| from .session import DynectSession | ||
|
|
||
| __author__ = 'elarochelle' | ||
| __all__ = ['get_check_permission', 'get_dnssec_timeline', 'get_qps', | ||
| 'get_rttm_log', 'get_rttm_rrset', 'get_zone_notes'] | ||
|
|
||
|
|
||
| def get_check_permission(permission, zone_name=None): | ||
| """Returns a list of allowed and forbidden permissions for the currently | ||
| logged in user based on the provided permissions array. | ||
|
|
||
| :param permission: A list of permissions to check for the current user. | ||
| :param zone_name: The zone to check for specific permissions. | ||
| :return: A :class:`dict` containing permission information. | ||
| """ | ||
| api_args = {'permission': permission} | ||
| if zone_name is not None: | ||
| api_args['zone_name'] = zone_name | ||
| response = DynectSession.get_session().execute('/CheckPermissionReport/', | ||
| 'POST', api_args) | ||
| return response['data'] | ||
|
|
||
|
|
||
| def get_dnssec_timeline(zone_name, start_ts=None, end_ts=None): | ||
| """Generates a report of events for the :class:`DNSSEC` service | ||
| attached to the specified zone has performed and has scheduled | ||
| to perform. | ||
|
|
||
| :param zone_name: The name of the zone with DNSSEC service | ||
| :param start_ts: UNIX timestamp identifying point in time for the | ||
| report | ||
| :param end_ts: UNIX timestamp indicating the end of the data range for | ||
| the report | ||
| :return: A :class:`dict` containing log report data | ||
| """ | ||
| api_args = {'zone': zone_name} | ||
| if start_ts is not None: | ||
| api_args['start_ts'] = start_ts | ||
| if end_ts is not None: | ||
| api_args['end_ts'] = end_ts | ||
| response = DynectSession.get_session().execute('/DNSSECTimelineReport/', | ||
| 'POST', api_args) | ||
| return response['data'] | ||
|
|
||
|
|
||
| def get_rttm_log(zone_name, fqdn, start_ts, end_ts): | ||
| """Generates a report with information about changes to an existing | ||
| RTTM service. | ||
|
|
||
| :param zone_name: The name of the zone | ||
| :param fqdn: The FQDN where RTTM is attached | ||
| :param start_ts: UNIX timestamp identifying point in time for the log | ||
| report | ||
| :param end_ts: UNIX timestamp indicating the end of the data range for | ||
| the report | ||
| :return: A :class:`dict` containing log report data | ||
| """ | ||
| api_args = {'zone': zone_name, | ||
| 'fqdn': fqdn, | ||
| 'start_ts': start_ts, | ||
| 'end_ts': end_ts} | ||
| response = DynectSession.get_session().execute('/RTTMLogReport/', | ||
| 'POST', api_args) | ||
| return response['data'] | ||
|
|
||
|
|
||
| def get_rttm_rrset(zone_name, fqdn, ts): | ||
| """Generates a report of regional response sets for this RTTM service | ||
| at a given point in time. | ||
|
|
||
| :param zone_name: The name of the zone | ||
| :param fqdn: The FQDN where RTTM is attached | ||
| :param ts: UNIX timestamp identifying point in time for the report | ||
| :return: A :class:`dict` containing rrset report data | ||
| """ | ||
| api_args = {'zone': zone_name, | ||
| 'fqdn': fqdn, | ||
| 'ts': ts} | ||
| response = DynectSession.get_session().execute('/RTTMRRSetReport/', | ||
| 'POST', api_args) | ||
| return response['data'] | ||
|
|
||
|
|
||
| def get_qps(start_ts, end_ts, breakdown=None, hosts=None, rrecs=None, | ||
| zones = None): | ||
| """Generates a report with information about Queries Per Second (QPS). | ||
|
|
||
| :param start_ts: UNIX timestamp identifying point in time for the QPS | ||
| report | ||
| :param end_ts: UNIX timestamp indicating the end of the data range for | ||
| the report | ||
| :param breakdown: By default, most data is aggregated together. | ||
| Valid values ('hosts', 'rrecs', 'zones'). | ||
| :param hosts: List of hosts to include in the report. | ||
| :param rrecs: List of record types to include in report. | ||
| :param zones: List of zones to include in report. | ||
| :return: A :class:`str` with CSV data | ||
| """ | ||
| api_args = {'start_ts': start_ts, | ||
| 'end_ts': end_ts} | ||
| if breakdown is not None: | ||
| api_args['breakdown'] = breakdown | ||
| if hosts is not None: | ||
| api_args['hosts'] = hosts | ||
| if rrecs is not None: | ||
| api_args['rrecs'] = rrecs | ||
| if zones is not None: | ||
| api_args['zones'] = zones | ||
| response = DynectSession.get_session().execute('/QPSReport/', | ||
| 'POST', api_args) | ||
| return response['data'] | ||
|
|
||
|
|
||
| def get_zone_notes(zone_name, offset=None, limit=None): | ||
| """Generates a report containing the Zone Notes for given zone. | ||
|
|
||
| :param zone_name: The name of the zone | ||
| :param offset: UNIX timestamp of the starting point at which to | ||
| retrieve the notes | ||
| :param limit: The maximum number of notes to be retrieved | ||
| :return: A :class:`list` of :class:`dict` containing Zone Notes | ||
| """ | ||
| api_args = {'zone': zone_name} | ||
| if offset: | ||
| api_args['offset'] = offset | ||
| if limit: | ||
| api_args['limit'] = limit | ||
| response = DynectSession.get_session().execute('/ZoneNoteReport/', | ||
| 'POST', api_args) | ||
| return response['data'] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming soon: A utlity function to convert Python datetime objects to UNIX timestamps. For now we can leave this alone, but we'll eventually be changing it to accept datetime objects. I'll make sure that that utliity makes it into the 1.1.0 release