From a4a9ef72e23a1f9b6cf1dc2bc80a5b3af7b4501e Mon Sep 17 00:00:00 2001 From: Peichao Zhang Date: Mon, 9 Jul 2018 17:01:50 -0700 Subject: [PATCH] Fixed mappings of business API endpoints. --- dropbox/base.py | 65 ----------------------------------------- dropbox/base_team.py | 65 +++++++++++++++++++++++++++++++++++++++++ generate_base_client.py | 19 ++++++++++-- 3 files changed, 82 insertions(+), 67 deletions(-) diff --git a/dropbox/base.py b/dropbox/base.py index 5272e9ec..9bbebab5 100644 --- a/dropbox/base.py +++ b/dropbox/base.py @@ -4184,71 +4184,6 @@ def sharing_update_folder_policy(self, ) return r - # ------------------------------------------ - # Routes in team_log namespace - - def team_log_get_events(self, - limit=1000, - account_id=None, - time=None, - category=None): - """ - Retrieves team events. Events have a lifespan of two years. Events older - than two years will not be returned. Many attributes note 'may be - missing due to historical data gap'. Note that the file_operations - category and & analogous paper events are not available on all Dropbox - Business `plans `_. Use `features/get_values - `_ to - check for this feature. Permission : Team Auditing. - - :param long limit: Number of results to return per call. - :param Nullable account_id: Filter the events by account ID. Return ony - events with this account_id as either Actor, Context, or - Participants. - :param Nullable time: Filter by time range. - :param Nullable category: Filter the returned events to a single - category. - :rtype: :class:`dropbox.team_log.GetTeamEventsResult` - :raises: :class:`.exceptions.ApiError` - - If this raises, ApiError will contain: - :class:`dropbox.team_log.GetTeamEventsError` - """ - arg = team_log.GetTeamEventsArg(limit, - account_id, - time, - category) - r = self.request( - team_log.get_events, - 'team_log', - arg, - None, - ) - return r - - def team_log_get_events_continue(self, - cursor): - """ - Once a cursor has been retrieved from :meth:`team_log_get_events`, use - this to paginate through all events. Permission : Team Auditing. - - :param str cursor: Indicates from what point to get the next set of - events. - :rtype: :class:`dropbox.team_log.GetTeamEventsResult` - :raises: :class:`.exceptions.ApiError` - - If this raises, ApiError will contain: - :class:`dropbox.team_log.GetTeamEventsContinueError` - """ - arg = team_log.GetTeamEventsContinueArg(cursor) - r = self.request( - team_log.get_events_continue, - 'team_log', - arg, - None, - ) - return r - # ------------------------------------------ # Routes in users namespace diff --git a/dropbox/base_team.py b/dropbox/base_team.py index d5f9be1b..6fa9341c 100644 --- a/dropbox/base_team.py +++ b/dropbox/base_team.py @@ -1686,3 +1686,68 @@ def team_token_get_authenticated_admin(self): ) return r + # ------------------------------------------ + # Routes in team_log namespace + + def team_log_get_events(self, + limit=1000, + account_id=None, + time=None, + category=None): + """ + Retrieves team events. Events have a lifespan of two years. Events older + than two years will not be returned. Many attributes note 'may be + missing due to historical data gap'. Note that the file_operations + category and & analogous paper events are not available on all Dropbox + Business `plans `_. Use `features/get_values + `_ to + check for this feature. Permission : Team Auditing. + + :param long limit: Number of results to return per call. + :param Nullable account_id: Filter the events by account ID. Return ony + events with this account_id as either Actor, Context, or + Participants. + :param Nullable time: Filter by time range. + :param Nullable category: Filter the returned events to a single + category. + :rtype: :class:`dropbox.team_log.GetTeamEventsResult` + :raises: :class:`.exceptions.ApiError` + + If this raises, ApiError will contain: + :class:`dropbox.team_log.GetTeamEventsError` + """ + arg = team_log.GetTeamEventsArg(limit, + account_id, + time, + category) + r = self.request( + team_log.get_events, + 'team_log', + arg, + None, + ) + return r + + def team_log_get_events_continue(self, + cursor): + """ + Once a cursor has been retrieved from :meth:`team_log_get_events`, use + this to paginate through all events. Permission : Team Auditing. + + :param str cursor: Indicates from what point to get the next set of + events. + :rtype: :class:`dropbox.team_log.GetTeamEventsResult` + :raises: :class:`.exceptions.ApiError` + + If this raises, ApiError will contain: + :class:`dropbox.team_log.GetTeamEventsContinueError` + """ + arg = team_log.GetTeamEventsContinueArg(cursor) + r = self.request( + team_log.get_events_continue, + 'team_log', + arg, + None, + ) + return r + diff --git a/generate_base_client.py b/generate_base_client.py index 8d5d0d41..7bd3bcbd 100755 --- a/generate_base_client.py +++ b/generate_base_client.py @@ -31,6 +31,13 @@ help='Path to clone of stone repository.', ) +# List of namespaces for business endpoints +TEAM_NAMESPACES = [ + 'team', + 'team_common', + 'team_log', + 'team_policies', +] def main(): """The entry point for the program.""" @@ -66,16 +73,24 @@ def main(): if verbose: print('Generating Python client') + + blacklist_namespace_args = [] + for namespace in TEAM_NAMESPACES: + blacklist_namespace_args.extend(('-b', namespace)) o = subprocess.check_output( (['python', '-m', 'stone.cli', 'python_client', dropbox_pkg_path] + - specs + ['-a', 'host', '-a', 'style', '-b', 'team'] + + specs + ['-a', 'host', '-a', 'style'] + blacklist_namespace_args + ['--', '-m', 'base', '-c', 'DropboxBase', '-t', 'dropbox']), cwd=stone_path) if o: print('Output:', o) + + whitelist_namespace_args = [] + for namespace in TEAM_NAMESPACES: + whitelist_namespace_args.extend(('-w', namespace)) o = subprocess.check_output( (['python', '-m', 'stone.cli', 'python_client', dropbox_pkg_path] + - specs + ['-a', 'host', '-a', 'style', '-w', 'team'] + + specs + ['-a', 'host', '-a', 'style'] + whitelist_namespace_args + ['--', '-m', 'base_team', '-c', 'DropboxTeamBase', '-t', 'dropbox']), cwd=stone_path) if o: