/
base.py
5861 lines (5197 loc) · 223 KB
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
# Auto-generated by Stone, do not modify.
# flake8: noqa
# pylint: skip-file
from abc import ABCMeta, abstractmethod
import warnings
from dropbox import account
from dropbox import async_
from dropbox import auth
from dropbox import check
from dropbox import common
from dropbox import contacts
from dropbox import file_properties
from dropbox import file_requests
from dropbox import files
from dropbox import paper
from dropbox import secondary_emails
from dropbox import seen_state
from dropbox import sharing
from dropbox import team
from dropbox import team_common
from dropbox import team_log
from dropbox import team_policies
from dropbox import users
from dropbox import users_common
class DropboxBase(object):
__metaclass__ = ABCMeta
@abstractmethod
def request(self, route, namespace, arg, arg_binary=None):
pass
# ------------------------------------------
# Routes in account namespace
def account_set_profile_photo(self,
photo):
"""
Sets a user's profile photo.
Route attributes:
scope: account_info.write
:param photo: Image to set as the user's new profile photo.
:type photo: :class:`dropbox.account.PhotoSourceArg`
:rtype: :class:`dropbox.account.SetProfilePhotoResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.account.SetProfilePhotoError`
"""
arg = account.SetProfilePhotoArg(photo)
r = self.request(
account.set_profile_photo,
'account',
arg,
None,
)
return r
# ------------------------------------------
# Routes in auth namespace
def auth_token_from_oauth1(self,
oauth1_token,
oauth1_token_secret):
"""
Creates an OAuth 2.0 access token from the supplied OAuth 1.0 access
token.
:param str oauth1_token: The supplied OAuth 1.0 access token.
:param str oauth1_token_secret: The token secret associated with the
supplied access token.
:rtype: :class:`dropbox.auth.TokenFromOAuth1Result`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.auth.TokenFromOAuth1Error`
"""
arg = auth.TokenFromOAuth1Arg(oauth1_token,
oauth1_token_secret)
r = self.request(
auth.token_from_oauth1,
'auth',
arg,
None,
)
return r
def auth_token_revoke(self):
"""
Disables the access token used to authenticate the call. If there is a
corresponding refresh token for the access token, this disables that
refresh token, as well as any other access tokens for that refresh
token.
:rtype: None
"""
arg = None
r = self.request(
auth.token_revoke,
'auth',
arg,
None,
)
return None
# ------------------------------------------
# Routes in check namespace
def check_app(self,
query=''):
"""
This endpoint performs App Authentication, validating the supplied app
key and secret, and returns the supplied string, to allow you to test
your code and connection to the Dropbox API. It has no other effect. If
you receive an HTTP 200 response with the supplied query, it indicates
at least part of the Dropbox API infrastructure is working and that the
app key and secret valid.
:param str query: The string that you'd like to be echoed back to you.
:rtype: :class:`dropbox.check.EchoResult`
"""
arg = check.EchoArg(query)
r = self.request(
check.app,
'check',
arg,
None,
)
return r
def check_user(self,
query=''):
"""
This endpoint performs User Authentication, validating the supplied
access token, and returns the supplied string, to allow you to test your
code and connection to the Dropbox API. It has no other effect. If you
receive an HTTP 200 response with the supplied query, it indicates at
least part of the Dropbox API infrastructure is working and that the
access token is valid.
Route attributes:
scope: account_info.read
:param str query: The string that you'd like to be echoed back to you.
:rtype: :class:`dropbox.check.EchoResult`
"""
arg = check.EchoArg(query)
r = self.request(
check.user,
'check',
arg,
None,
)
return r
# ------------------------------------------
# Routes in contacts namespace
def contacts_delete_manual_contacts(self):
"""
Removes all manually added contacts. You'll still keep contacts who are
on your team or who you imported. New contacts will be added when you
share.
Route attributes:
scope: contacts.write
:rtype: None
"""
arg = None
r = self.request(
contacts.delete_manual_contacts,
'contacts',
arg,
None,
)
return None
def contacts_delete_manual_contacts_batch(self,
email_addresses):
"""
Removes manually added contacts from the given list.
Route attributes:
scope: contacts.write
:param List[str] email_addresses: List of manually added contacts to be
deleted.
:rtype: None
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.contacts.DeleteManualContactsError`
"""
arg = contacts.DeleteManualContactsArg(email_addresses)
r = self.request(
contacts.delete_manual_contacts_batch,
'contacts',
arg,
None,
)
return None
# ------------------------------------------
# Routes in file_properties namespace
def file_properties_properties_add(self,
path,
property_groups):
"""
Add property groups to a Dropbox file. See
:meth:`file_properties_templates_add_for_user` or
:meth:`file_properties_templates_add_for_team` to create new templates.
Route attributes:
scope: files.metadata.write
:param str path: A unique identifier for the file or folder.
:param List[:class:`dropbox.file_properties.PropertyGroup`]
property_groups: The property groups which are to be added to a
Dropbox file. No two groups in the input should refer to the same
template.
:rtype: None
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.AddPropertiesError`
"""
arg = file_properties.AddPropertiesArg(path,
property_groups)
r = self.request(
file_properties.properties_add,
'file_properties',
arg,
None,
)
return None
def file_properties_properties_overwrite(self,
path,
property_groups):
"""
Overwrite property groups associated with a file. This endpoint should
be used instead of :meth:`file_properties_properties_update` when
property groups are being updated via a "snapshot" instead of via a
"delta". In other words, this endpoint will delete all omitted fields
from a property group, whereas :meth:`file_properties_properties_update`
will only delete fields that are explicitly marked for deletion.
Route attributes:
scope: files.metadata.write
:param str path: A unique identifier for the file or folder.
:param List[:class:`dropbox.file_properties.PropertyGroup`]
property_groups: The property groups "snapshot" updates to force
apply. No two groups in the input should refer to the same
template.
:rtype: None
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.InvalidPropertyGroupError`
"""
arg = file_properties.OverwritePropertyGroupArg(path,
property_groups)
r = self.request(
file_properties.properties_overwrite,
'file_properties',
arg,
None,
)
return None
def file_properties_properties_remove(self,
path,
property_template_ids):
"""
Permanently removes the specified property group from the file. To
remove specific property field key value pairs, see
:meth:`file_properties_properties_update`. To update a template, see
:meth:`file_properties_templates_update_for_user` or
:meth:`file_properties_templates_update_for_team`. To remove a template,
see :meth:`file_properties_templates_remove_for_user` or
:meth:`file_properties_templates_remove_for_team`.
Route attributes:
scope: files.metadata.write
:param str path: A unique identifier for the file or folder.
:param List[str] property_template_ids: A list of identifiers for a
template created by :meth:`file_properties_templates_add_for_user`
or :meth:`file_properties_templates_add_for_team`.
:rtype: None
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.RemovePropertiesError`
"""
arg = file_properties.RemovePropertiesArg(path,
property_template_ids)
r = self.request(
file_properties.properties_remove,
'file_properties',
arg,
None,
)
return None
def file_properties_properties_search(self,
queries,
template_filter=file_properties.TemplateFilter.filter_none):
"""
Search across property templates for particular property field values.
Route attributes:
scope: files.metadata.read
:param List[:class:`dropbox.file_properties.PropertiesSearchQuery`]
queries: Queries to search.
:param template_filter: Filter results to contain only properties
associated with these template IDs.
:type template_filter: :class:`dropbox.file_properties.TemplateFilter`
:rtype: :class:`dropbox.file_properties.PropertiesSearchResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.PropertiesSearchError`
"""
arg = file_properties.PropertiesSearchArg(queries,
template_filter)
r = self.request(
file_properties.properties_search,
'file_properties',
arg,
None,
)
return r
def file_properties_properties_search_continue(self,
cursor):
"""
Once a cursor has been retrieved from
:meth:`file_properties_properties_search`, use this to paginate through
all search results.
Route attributes:
scope: files.metadata.read
:param str cursor: The cursor returned by your last call to
:meth:`file_properties_properties_search` or
:meth:`file_properties_properties_search_continue`.
:rtype: :class:`dropbox.file_properties.PropertiesSearchResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.PropertiesSearchContinueError`
"""
arg = file_properties.PropertiesSearchContinueArg(cursor)
r = self.request(
file_properties.properties_search_continue,
'file_properties',
arg,
None,
)
return r
def file_properties_properties_update(self,
path,
update_property_groups):
"""
Add, update or remove properties associated with the supplied file and
templates. This endpoint should be used instead of
:meth:`file_properties_properties_overwrite` when property groups are
being updated via a "delta" instead of via a "snapshot" . In other
words, this endpoint will not delete any omitted fields from a property
group, whereas :meth:`file_properties_properties_overwrite` will delete
any fields that are omitted from a property group.
Route attributes:
scope: files.metadata.write
:param str path: A unique identifier for the file or folder.
:param List[:class:`dropbox.file_properties.PropertyGroupUpdate`]
update_property_groups: The property groups "delta" updates to
apply.
:rtype: None
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.UpdatePropertiesError`
"""
arg = file_properties.UpdatePropertiesArg(path,
update_property_groups)
r = self.request(
file_properties.properties_update,
'file_properties',
arg,
None,
)
return None
def file_properties_templates_add_for_user(self,
name,
description,
fields):
"""
Add a template associated with a user. See
:meth:`file_properties_properties_add` to add properties to a file. This
endpoint can't be called on a team member or admin's behalf.
Route attributes:
scope: files.metadata.write
:rtype: :class:`dropbox.file_properties.AddTemplateResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.ModifyTemplateError`
"""
arg = file_properties.AddTemplateArg(name,
description,
fields)
r = self.request(
file_properties.templates_add_for_user,
'file_properties',
arg,
None,
)
return r
def file_properties_templates_get_for_user(self,
template_id):
"""
Get the schema for a specified template. This endpoint can't be called
on a team member or admin's behalf.
Route attributes:
scope: files.metadata.read
:param str template_id: An identifier for template added by route See
:meth:`file_properties_templates_add_for_user` or
:meth:`file_properties_templates_add_for_team`.
:rtype: :class:`dropbox.file_properties.GetTemplateResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.TemplateError`
"""
arg = file_properties.GetTemplateArg(template_id)
r = self.request(
file_properties.templates_get_for_user,
'file_properties',
arg,
None,
)
return r
def file_properties_templates_list_for_user(self):
"""
Get the template identifiers for a team. To get the schema of each
template use :meth:`file_properties_templates_get_for_user`. This
endpoint can't be called on a team member or admin's behalf.
Route attributes:
scope: files.metadata.read
:rtype: :class:`dropbox.file_properties.ListTemplateResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.TemplateError`
"""
arg = None
r = self.request(
file_properties.templates_list_for_user,
'file_properties',
arg,
None,
)
return r
def file_properties_templates_remove_for_user(self,
template_id):
"""
Permanently removes the specified template created from
:meth:`file_properties_templates_add_for_user`. All properties
associated with the template will also be removed. This action cannot be
undone.
Route attributes:
scope: files.metadata.write
:param str template_id: An identifier for a template created by
:meth:`file_properties_templates_add_for_user` or
:meth:`file_properties_templates_add_for_team`.
:rtype: None
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.TemplateError`
"""
arg = file_properties.RemoveTemplateArg(template_id)
r = self.request(
file_properties.templates_remove_for_user,
'file_properties',
arg,
None,
)
return None
def file_properties_templates_update_for_user(self,
template_id,
name=None,
description=None,
add_fields=None):
"""
Update a template associated with a user. This route can update the
template name, the template description and add optional properties to
templates. This endpoint can't be called on a team member or admin's
behalf.
Route attributes:
scope: files.metadata.write
:param str template_id: An identifier for template added by See
:meth:`file_properties_templates_add_for_user` or
:meth:`file_properties_templates_add_for_team`.
:param Nullable[str] name: A display name for the template. template
names can be up to 256 bytes.
:param Nullable[str] description: Description for the new template.
Template descriptions can be up to 1024 bytes.
:param
Nullable[List[:class:`dropbox.file_properties.PropertyFieldTemplate`]]
add_fields: Property field templates to be added to the group
template. There can be up to 32 properties in a single template.
:rtype: :class:`dropbox.file_properties.UpdateTemplateResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_properties.ModifyTemplateError`
"""
arg = file_properties.UpdateTemplateArg(template_id,
name,
description,
add_fields)
r = self.request(
file_properties.templates_update_for_user,
'file_properties',
arg,
None,
)
return r
# ------------------------------------------
# Routes in file_requests namespace
def file_requests_count(self):
"""
Returns the total number of file requests owned by this user. Includes
both open and closed file requests.
Route attributes:
scope: file_requests.read
:rtype: :class:`dropbox.file_requests.CountFileRequestsResult`
"""
arg = None
r = self.request(
file_requests.count,
'file_requests',
arg,
None,
)
return r
def file_requests_create(self,
title,
destination,
deadline=None,
open=True,
description=None):
"""
Creates a file request for this user.
Route attributes:
scope: file_requests.write
:param str title: The title of the file request. Must not be empty.
:param str destination: The path of the folder in the Dropbox where
uploaded files will be sent. For apps with the app folder
permission, this will be relative to the app folder.
:param Nullable[:class:`dropbox.file_requests.FileRequestDeadline`]
deadline: The deadline for the file request. Deadlines can only be
set by Professional and Business accounts.
:param bool open: Whether or not the file request should be open. If the
file request is closed, it will not accept any file submissions, but
it can be opened later.
:param Nullable[str] description: A description of the file request.
:rtype: :class:`dropbox.file_requests.FileRequest`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_requests.CreateFileRequestError`
"""
arg = file_requests.CreateFileRequestArgs(title,
destination,
deadline,
open,
description)
r = self.request(
file_requests.create,
'file_requests',
arg,
None,
)
return r
def file_requests_delete(self,
ids):
"""
Delete a batch of closed file requests.
Route attributes:
scope: file_requests.write
:param List[str] ids: List IDs of the file requests to delete.
:rtype: :class:`dropbox.file_requests.DeleteFileRequestsResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_requests.DeleteFileRequestError`
"""
arg = file_requests.DeleteFileRequestArgs(ids)
r = self.request(
file_requests.delete,
'file_requests',
arg,
None,
)
return r
def file_requests_delete_all_closed(self):
"""
Delete all closed file requests owned by this user.
Route attributes:
scope: file_requests.write
:rtype: :class:`dropbox.file_requests.DeleteAllClosedFileRequestsResult`
"""
arg = None
r = self.request(
file_requests.delete_all_closed,
'file_requests',
arg,
None,
)
return r
def file_requests_get(self,
id):
"""
Returns the specified file request.
Route attributes:
scope: file_requests.read
:param str id: The ID of the file request to retrieve.
:rtype: :class:`dropbox.file_requests.FileRequest`
"""
arg = file_requests.GetFileRequestArgs(id)
r = self.request(
file_requests.get,
'file_requests',
arg,
None,
)
return r
def file_requests_list_v2(self,
limit=1000):
"""
Returns a list of file requests owned by this user. For apps with the
app folder permission, this will only return file requests with
destinations in the app folder.
Route attributes:
scope: file_requests.read
:param int limit: The maximum number of file requests that should be
returned per request.
:rtype: :class:`dropbox.file_requests.ListFileRequestsV2Result`
"""
arg = file_requests.ListFileRequestsArg(limit)
r = self.request(
file_requests.list_v2,
'file_requests',
arg,
None,
)
return r
def file_requests_list(self):
"""
Returns a list of file requests owned by this user. For apps with the
app folder permission, this will only return file requests with
destinations in the app folder.
Route attributes:
scope: file_requests.read
:rtype: :class:`dropbox.file_requests.ListFileRequestsResult`
"""
arg = None
r = self.request(
file_requests.list,
'file_requests',
arg,
None,
)
return r
def file_requests_list_continue(self,
cursor):
"""
Once a cursor has been retrieved from :meth:`file_requests_list_v2`, use
this to paginate through all file requests. The cursor must come from a
previous call to :meth:`file_requests_list_v2` or
:meth:`file_requests_list_continue`.
Route attributes:
scope: file_requests.read
:param str cursor: The cursor returned by the previous API call
specified in the endpoint description.
:rtype: :class:`dropbox.file_requests.ListFileRequestsV2Result`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.file_requests.ListFileRequestsContinueError`
"""
arg = file_requests.ListFileRequestsContinueArg(cursor)
r = self.request(
file_requests.list_continue,
'file_requests',
arg,
None,
)
return r
def file_requests_update(self,
id,
title=None,
destination=None,
deadline=file_requests.UpdateFileRequestDeadline.no_update,
open=None,
description=None):
"""
Update a file request.
Route attributes:
scope: file_requests.write
:param str id: The ID of the file request to update.
:param Nullable[str] title: The new title of the file request. Must not
be empty.
:param Nullable[str] destination: The new path of the folder in the
Dropbox where uploaded files will be sent. For apps with the app
folder permission, this will be relative to the app folder.
:param deadline: The new deadline for the file request. Deadlines can
only be set by Professional and Business accounts.
:type deadline: :class:`dropbox.file_requests.UpdateFileRequestDeadline`
:param Nullable[bool] open: Whether to set this file request as open or
closed.
:param Nullable[str] description: The description of the file request.
:rtype: :class:`dropbox.file_requests.FileRequest`
"""
arg = file_requests.UpdateFileRequestArgs(id,
title,
destination,
deadline,
open,
description)
r = self.request(
file_requests.update,
'file_requests',
arg,
None,
)
return r
# ------------------------------------------
# Routes in files namespace
def files_alpha_get_metadata(self,
path,
include_media_info=False,
include_deleted=False,
include_has_explicit_shared_members=False,
include_property_groups=None,
include_property_templates=None):
"""
Returns the metadata for a file or folder. This is an alpha endpoint
compatible with the properties API. Note: Metadata for the root folder
is unsupported.
Route attributes:
scope: files.metadata.read
:param Nullable[List[str]] include_property_templates: If set to a valid
list of template IDs, ``FileMetadata.property_groups`` is set for
files with custom properties.
:rtype: :class:`dropbox.files.Metadata`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.files.AlphaGetMetadataError`
"""
warnings.warn(
'alpha/get_metadata is deprecated. Use get_metadata.',
DeprecationWarning,
)
arg = files.AlphaGetMetadataArg(path,
include_media_info,
include_deleted,
include_has_explicit_shared_members,
include_property_groups,
include_property_templates)
r = self.request(
files.alpha_get_metadata,
'files',
arg,
None,
)
return r
def files_alpha_upload(self,
f,
path,
mode=files.WriteMode.add,
autorename=False,
client_modified=None,
mute=False,
property_groups=None,
strict_conflict=False,
content_hash=None):
"""
Create a new file with the contents provided in the request. Note that
the behavior of this alpha endpoint is unstable and subject to change.
Do not use this to upload a file larger than 150 MB. Instead, create an
upload session with :meth:`files_upload_session_start`.
Route attributes:
scope: files.content.write
:param bytes f: Contents to upload.
:param Nullable[str] content_hash: A hash of the file content uploaded
in this call. If provided and the uploaded content does not match
this hash, an error will be returned. For more information see our
`Content hash
<https://www.dropbox.com/developers/reference/content-hash>`_ page.
:rtype: :class:`dropbox.files.FileMetadata`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.files.UploadError`
"""
warnings.warn(
'alpha/upload is deprecated. Use upload.',
DeprecationWarning,
)
arg = files.UploadArg(path,
mode,
autorename,
client_modified,
mute,
property_groups,
strict_conflict,
content_hash)
r = self.request(
files.alpha_upload,
'files',
arg,
f,
)
return r
def files_copy_v2(self,
from_path,
to_path,
allow_shared_folder=False,
autorename=False,
allow_ownership_transfer=False):
"""
Copy a file or folder to a different location in the user's Dropbox. If
the source path is a folder all its contents will be copied.
Route attributes:
scope: files.content.write
:param bool allow_shared_folder: This flag has no effect.
:param bool autorename: If there's a conflict, have the Dropbox server
try to autorename the file to avoid the conflict.
:param bool allow_ownership_transfer: Allow moves by owner even if it
would result in an ownership transfer for the content being moved.
This does not apply to copies.
:rtype: :class:`dropbox.files.RelocationResult`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.files.RelocationError`
"""
arg = files.RelocationArg(from_path,
to_path,
allow_shared_folder,
autorename,
allow_ownership_transfer)
r = self.request(
files.copy_v2,
'files',
arg,
None,
)
return r
def files_copy(self,
from_path,
to_path,
allow_shared_folder=False,
autorename=False,
allow_ownership_transfer=False):
"""
Copy a file or folder to a different location in the user's Dropbox. If
the source path is a folder all its contents will be copied.
Route attributes:
scope: files.content.write
:param bool allow_shared_folder: This flag has no effect.
:param bool autorename: If there's a conflict, have the Dropbox server
try to autorename the file to avoid the conflict.
:param bool allow_ownership_transfer: Allow moves by owner even if it
would result in an ownership transfer for the content being moved.
This does not apply to copies.
:rtype: :class:`dropbox.files.Metadata`
:raises: :class:`.exceptions.ApiError`
If this raises, ApiError will contain:
:class:`dropbox.files.RelocationError`
"""
warnings.warn(
'copy is deprecated. Use copy.',
DeprecationWarning,
)
arg = files.RelocationArg(from_path,
to_path,
allow_shared_folder,
autorename,
allow_ownership_transfer)
r = self.request(
files.copy,
'files',
arg,
None,
)
return r
def files_copy_batch_v2(self,
entries,
autorename=False):
"""
Copy multiple files or folders to different locations at once in the
user's Dropbox. This route will replace :meth:`files_copy_batch`. The
main difference is this route will return status for each entry, while
:meth:`files_copy_batch` raises failure if any entry fails. This route
will either finish synchronously, or return a job ID and do the async
copy job in background. Please use :meth:`files_copy_batch_check_v2` to
check the job status.
Route attributes:
scope: files.content.write
:param List[:class:`dropbox.files.RelocationPath`] entries: List of
entries to be moved or copied. Each entry is
:class:`dropbox.files.RelocationPath`.
:param bool autorename: If there's a conflict with any file, have the
Dropbox server try to autorename that file to avoid the conflict.
:rtype: :class:`dropbox.files.RelocationBatchV2Launch`
"""
arg = files.RelocationBatchArgBase(entries,
autorename)
r = self.request(
files.copy_batch_v2,
'files',