Skip to content

Commit c21462c

Browse files
Milan Ghatakstarforever
authored andcommitted
Generate clients with multiple auth modes in stone (#153)
1 parent b2357a1 commit c21462c

File tree

3 files changed

+164
-151
lines changed

3 files changed

+164
-151
lines changed

dropbox/base.py

Lines changed: 6 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -250,32 +250,6 @@ def file_properties_properties_update(self,
250250
)
251251
return None
252252

253-
def file_properties_templates_add_for_team(self,
254-
name,
255-
description,
256-
fields):
257-
"""
258-
Add a template associated with a team. See
259-
:meth:`file_properties_properties_add` to add properties to a file or
260-
folder. Note: this endpoint will create team-owned templates.
261-
262-
:rtype: :class:`dropbox.file_properties.AddTemplateResult`
263-
:raises: :class:`.exceptions.ApiError`
264-
265-
If this raises, ApiError will contain:
266-
:class:`dropbox.file_properties.ModifyTemplateError`
267-
"""
268-
arg = file_properties.AddTemplateArg(name,
269-
description,
270-
fields)
271-
r = self.request(
272-
file_properties.templates_add_for_team,
273-
'file_properties',
274-
arg,
275-
None,
276-
)
277-
return r
278-
279253
def file_properties_templates_add_for_user(self,
280254
name,
281255
description,
@@ -302,29 +276,6 @@ def file_properties_templates_add_for_user(self,
302276
)
303277
return r
304278

305-
def file_properties_templates_get_for_team(self,
306-
template_id):
307-
"""
308-
Get the schema for a specified template.
309-
310-
:param str template_id: An identifier for template added by route See
311-
:meth:`file_properties_templates_add_for_user` or
312-
:meth:`file_properties_templates_add_for_team`.
313-
:rtype: :class:`dropbox.file_properties.GetTemplateResult`
314-
:raises: :class:`.exceptions.ApiError`
315-
316-
If this raises, ApiError will contain:
317-
:class:`dropbox.file_properties.TemplateError`
318-
"""
319-
arg = file_properties.GetTemplateArg(template_id)
320-
r = self.request(
321-
file_properties.templates_get_for_team,
322-
'file_properties',
323-
arg,
324-
None,
325-
)
326-
return r
327-
328279
def file_properties_templates_get_for_user(self,
329280
template_id):
330281
"""
@@ -349,26 +300,6 @@ def file_properties_templates_get_for_user(self,
349300
)
350301
return r
351302

352-
def file_properties_templates_list_for_team(self):
353-
"""
354-
Get the template identifiers for a team. To get the schema of each
355-
template use :meth:`file_properties_templates_get_for_team`.
356-
357-
:rtype: :class:`dropbox.file_properties.ListTemplateResult`
358-
:raises: :class:`.exceptions.ApiError`
359-
360-
If this raises, ApiError will contain:
361-
:class:`dropbox.file_properties.TemplateError`
362-
"""
363-
arg = None
364-
r = self.request(
365-
file_properties.templates_list_for_team,
366-
'file_properties',
367-
arg,
368-
None,
369-
)
370-
return r
371-
372303
def file_properties_templates_list_for_user(self):
373304
"""
374305
Get the template identifiers for a team. To get the schema of each
@@ -390,32 +321,6 @@ def file_properties_templates_list_for_user(self):
390321
)
391322
return r
392323

393-
def file_properties_templates_remove_for_team(self,
394-
template_id):
395-
"""
396-
Permanently removes the specified template created from
397-
:meth:`file_properties_templates_add_for_user`. All properties
398-
associated with the template will also be removed. This action cannot be
399-
undone.
400-
401-
:param str template_id: An identifier for a template created by
402-
:meth:`file_properties_templates_add_for_user` or
403-
:meth:`file_properties_templates_add_for_team`.
404-
:rtype: None
405-
:raises: :class:`.exceptions.ApiError`
406-
407-
If this raises, ApiError will contain:
408-
:class:`dropbox.file_properties.TemplateError`
409-
"""
410-
arg = file_properties.RemoveTemplateArg(template_id)
411-
r = self.request(
412-
file_properties.templates_remove_for_team,
413-
'file_properties',
414-
arg,
415-
None,
416-
)
417-
return None
418-
419324
def file_properties_templates_remove_for_user(self,
420325
template_id):
421326
"""
@@ -442,44 +347,6 @@ def file_properties_templates_remove_for_user(self,
442347
)
443348
return None
444349

445-
def file_properties_templates_update_for_team(self,
446-
template_id,
447-
name=None,
448-
description=None,
449-
add_fields=None):
450-
"""
451-
Update a template associated with a team. This route can update the
452-
template name, the template description and add optional properties to
453-
templates.
454-
455-
:param str template_id: An identifier for template added by See
456-
:meth:`file_properties_templates_add_for_user` or
457-
:meth:`file_properties_templates_add_for_team`.
458-
:param Nullable name: A display name for the template. template names
459-
can be up to 256 bytes.
460-
:param Nullable description: Description for the new template. Template
461-
descriptions can be up to 1024 bytes.
462-
:param Nullable add_fields: Property field templates to be added to the
463-
group template. There can be up to 32 properties in a single
464-
template.
465-
:rtype: :class:`dropbox.file_properties.UpdateTemplateResult`
466-
:raises: :class:`.exceptions.ApiError`
467-
468-
If this raises, ApiError will contain:
469-
:class:`dropbox.file_properties.ModifyTemplateError`
470-
"""
471-
arg = file_properties.UpdateTemplateArg(template_id,
472-
name,
473-
description,
474-
add_fields)
475-
r = self.request(
476-
file_properties.templates_update_for_team,
477-
'file_properties',
478-
arg,
479-
None,
480-
)
481-
return r
482-
483350
def file_properties_templates_update_for_user(self,
484351
template_id,
485352
name=None,
@@ -4278,6 +4145,12 @@ def sharing_update_folder_policy(self,
42784145
)
42794146
return r
42804147

4148+
# ------------------------------------------
4149+
# Routes in team namespace
4150+
4151+
# ------------------------------------------
4152+
# Routes in team_log namespace
4153+
42814154
# ------------------------------------------
42824155
# Routes in users namespace
42834156

dropbox/base_team.py

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,157 @@ class DropboxTeamBase(object):
3232
def request(self, route, namespace, arg, arg_binary=None):
3333
pass
3434

35+
# ------------------------------------------
36+
# Routes in auth namespace
37+
38+
# ------------------------------------------
39+
# Routes in file_properties namespace
40+
41+
def file_properties_templates_add_for_team(self,
42+
name,
43+
description,
44+
fields):
45+
"""
46+
Add a template associated with a team. See
47+
:meth:`file_properties_properties_add` to add properties to a file or
48+
folder. Note: this endpoint will create team-owned templates.
49+
50+
:rtype: :class:`dropbox.file_properties.AddTemplateResult`
51+
:raises: :class:`.exceptions.ApiError`
52+
53+
If this raises, ApiError will contain:
54+
:class:`dropbox.file_properties.ModifyTemplateError`
55+
"""
56+
arg = file_properties.AddTemplateArg(name,
57+
description,
58+
fields)
59+
r = self.request(
60+
file_properties.templates_add_for_team,
61+
'file_properties',
62+
arg,
63+
None,
64+
)
65+
return r
66+
67+
def file_properties_templates_get_for_team(self,
68+
template_id):
69+
"""
70+
Get the schema for a specified template.
71+
72+
:param str template_id: An identifier for template added by route See
73+
:meth:`file_properties_templates_add_for_user` or
74+
:meth:`file_properties_templates_add_for_team`.
75+
:rtype: :class:`dropbox.file_properties.GetTemplateResult`
76+
:raises: :class:`.exceptions.ApiError`
77+
78+
If this raises, ApiError will contain:
79+
:class:`dropbox.file_properties.TemplateError`
80+
"""
81+
arg = file_properties.GetTemplateArg(template_id)
82+
r = self.request(
83+
file_properties.templates_get_for_team,
84+
'file_properties',
85+
arg,
86+
None,
87+
)
88+
return r
89+
90+
def file_properties_templates_list_for_team(self):
91+
"""
92+
Get the template identifiers for a team. To get the schema of each
93+
template use :meth:`file_properties_templates_get_for_team`.
94+
95+
:rtype: :class:`dropbox.file_properties.ListTemplateResult`
96+
:raises: :class:`.exceptions.ApiError`
97+
98+
If this raises, ApiError will contain:
99+
:class:`dropbox.file_properties.TemplateError`
100+
"""
101+
arg = None
102+
r = self.request(
103+
file_properties.templates_list_for_team,
104+
'file_properties',
105+
arg,
106+
None,
107+
)
108+
return r
109+
110+
def file_properties_templates_remove_for_team(self,
111+
template_id):
112+
"""
113+
Permanently removes the specified template created from
114+
:meth:`file_properties_templates_add_for_user`. All properties
115+
associated with the template will also be removed. This action cannot be
116+
undone.
117+
118+
:param str template_id: An identifier for a template created by
119+
:meth:`file_properties_templates_add_for_user` or
120+
:meth:`file_properties_templates_add_for_team`.
121+
:rtype: None
122+
:raises: :class:`.exceptions.ApiError`
123+
124+
If this raises, ApiError will contain:
125+
:class:`dropbox.file_properties.TemplateError`
126+
"""
127+
arg = file_properties.RemoveTemplateArg(template_id)
128+
r = self.request(
129+
file_properties.templates_remove_for_team,
130+
'file_properties',
131+
arg,
132+
None,
133+
)
134+
return None
135+
136+
def file_properties_templates_update_for_team(self,
137+
template_id,
138+
name=None,
139+
description=None,
140+
add_fields=None):
141+
"""
142+
Update a template associated with a team. This route can update the
143+
template name, the template description and add optional properties to
144+
templates.
145+
146+
:param str template_id: An identifier for template added by See
147+
:meth:`file_properties_templates_add_for_user` or
148+
:meth:`file_properties_templates_add_for_team`.
149+
:param Nullable name: A display name for the template. template names
150+
can be up to 256 bytes.
151+
:param Nullable description: Description for the new template. Template
152+
descriptions can be up to 1024 bytes.
153+
:param Nullable add_fields: Property field templates to be added to the
154+
group template. There can be up to 32 properties in a single
155+
template.
156+
:rtype: :class:`dropbox.file_properties.UpdateTemplateResult`
157+
:raises: :class:`.exceptions.ApiError`
158+
159+
If this raises, ApiError will contain:
160+
:class:`dropbox.file_properties.ModifyTemplateError`
161+
"""
162+
arg = file_properties.UpdateTemplateArg(template_id,
163+
name,
164+
description,
165+
add_fields)
166+
r = self.request(
167+
file_properties.templates_update_for_team,
168+
'file_properties',
169+
arg,
170+
None,
171+
)
172+
return r
173+
174+
# ------------------------------------------
175+
# Routes in file_requests namespace
176+
177+
# ------------------------------------------
178+
# Routes in files namespace
179+
180+
# ------------------------------------------
181+
# Routes in paper namespace
182+
183+
# ------------------------------------------
184+
# Routes in sharing namespace
185+
35186
# ------------------------------------------
36187
# Routes in team namespace
37188

@@ -1811,3 +1962,6 @@ def team_log_get_events_continue(self,
18111962
)
18121963
return r
18131964

1965+
# ------------------------------------------
1966+
# Routes in users namespace
1967+

generate_base_client.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@
3131
help='Path to clone of stone repository.',
3232
)
3333

34-
# List of namespaces for business endpoints
35-
TEAM_NAMESPACES = [
36-
'team',
37-
'team_common',
38-
'team_log',
39-
'team_policies',
40-
]
41-
4234
def main():
4335
"""The entry point for the program."""
4436

@@ -74,24 +66,18 @@ def main():
7466
if verbose:
7567
print('Generating Python client')
7668

77-
blacklist_namespace_args = []
78-
for namespace in TEAM_NAMESPACES:
79-
blacklist_namespace_args.extend(('-b', namespace))
8069
o = subprocess.check_output(
8170
(['python', '-m', 'stone.cli', 'python_client', dropbox_pkg_path] +
82-
specs + ['-a', 'host', '-a', 'style'] + blacklist_namespace_args +
83-
['--', '-m', 'base', '-c', 'DropboxBase', '-t', 'dropbox']),
71+
specs + ['-a', 'host', '-a', 'style', '-a', 'auth'] +
72+
['--', '-w', 'user,app,noauth', '-m', 'base', '-c', 'DropboxBase', '-t', 'dropbox']),
8473
cwd=stone_path)
8574
if o:
8675
print('Output:', o)
8776

88-
whitelist_namespace_args = []
89-
for namespace in TEAM_NAMESPACES:
90-
whitelist_namespace_args.extend(('-w', namespace))
9177
o = subprocess.check_output(
9278
(['python', '-m', 'stone.cli', 'python_client', dropbox_pkg_path] +
93-
specs + ['-a', 'host', '-a', 'style'] + whitelist_namespace_args +
94-
['--', '-m', 'base_team', '-c', 'DropboxTeamBase', '-t', 'dropbox']),
79+
specs + ['-a', 'host', '-a', 'style', '-a', 'auth'] +
80+
['--', '-w', 'team', '-m', 'base_team', '-c', 'DropboxTeamBase', '-t', 'dropbox']),
9581
cwd=stone_path)
9682
if o:
9783
print('Output:', o)

0 commit comments

Comments
 (0)