1
1
import json
2
2
3
- from typing import TYPE_CHECKING , Any , Union
3
+ from typing import TYPE_CHECKING , Any , Union , Optional
4
4
5
5
from .base_object import BaseObject
6
6
from ..exception import BoxValueError
15
15
class BaseItem (BaseObject ):
16
16
17
17
@api_call
18
- def copy (self , parent_folder : 'Folder' , name : str = None ) -> 'BaseItem' :
18
+ def copy (self , parent_folder : 'Folder' , name : str = None , ** _kwargs ) -> 'BaseItem' :
19
19
"""Copy the item to the given folder.
20
20
21
21
:param parent_folder:
@@ -68,23 +68,50 @@ def rename(self, name: str) -> 'BaseItem':
68
68
return self .update_info (data )
69
69
70
70
@api_call
71
- def create_shared_link (self , ** kwargs : Any ) -> Any :
71
+ def create_shared_link (
72
+ self ,
73
+ access : Optional [str ] = None ,
74
+ unshared_at : Optional [str ] = SDK_VALUE_NOT_SET ,
75
+ password : Optional [str ] = None ,
76
+ vanity_name : Optional [str ] = None ,
77
+ ** kwargs : Any ) -> Any :
72
78
"""
73
79
Create a shared link for the item with the given access permissions.
74
80
81
+ :param access:
82
+ Determines who can access the shared link. May be open, company, or collaborators. If no access is
83
+ specified, the default access will be used.
84
+ :param unshared_at:
85
+ The date on which this link should be disabled. May only be set if the current user is not a free user
86
+ and has permission to set expiration dates. Takes an RFC3339-formatted string, e.g.
87
+ '2018-10-31T23:59:59-07:00' for 11:59:59 PM on October 31, 2018 in the America/Los_Angeles timezone.
88
+ The time portion can be omitted, which defaults to midnight (00:00:00) on that date.
89
+ :param password:
90
+ The password required to view this link. If no password is specified then no password will be set.
91
+ Please notice that this is a premium feature, which might not be available to your app.
92
+ :param vanity_name:
93
+ Defines a custom vanity name to use in the shared link URL, eg. https://app.box.com/v/my-custom-vanity-name.
94
+ If this parameter is None, the standard shared link URL will be used.
75
95
:param kwargs:
76
96
Keyword arguments passed from overriding method used to build request properties.
77
97
:return:
78
98
The updated object with shared link.
79
99
Returns a new object of the same type, without modifying the original object passed as self.
80
100
"""
101
+
81
102
shared_link = {}
82
103
83
- if kwargs .get ('access' ) is not None :
84
- shared_link ['access' ] = kwargs .get ('access' )
104
+ if access is not None :
105
+ shared_link ['access' ] = access
106
+
107
+ if unshared_at is not SDK_VALUE_NOT_SET :
108
+ shared_link ['unshared_at' ] = unshared_at
109
+
110
+ if password is not None :
111
+ shared_link ['password' ] = password
85
112
86
- if kwargs . get ( 'unshared_at' ) is not SDK_VALUE_NOT_SET :
87
- shared_link ['unshared_at ' ] = kwargs . get ( 'unshared_at' )
113
+ if vanity_name is not None :
114
+ shared_link ['vanity_name ' ] = vanity_name
88
115
89
116
if kwargs .get ('allow_download' ) is not None or kwargs .get ('allow_preview' ) is not None :
90
117
shared_link ['permissions' ] = {}
@@ -93,29 +120,45 @@ def create_shared_link(self, **kwargs: Any) -> Any:
93
120
if kwargs .get ('allow_preview' ) is not None :
94
121
shared_link ['permissions' ]['can_preview' ] = kwargs .get ('allow_preview' )
95
122
96
- if kwargs .get ('password' ) is not None :
97
- shared_link ['password' ] = kwargs .get ('password' )
98
-
99
- if kwargs .get ('vanity_name' ) is not None :
100
- shared_link ['vanity_name' ] = kwargs .get ('vanity_name' )
101
-
102
123
data = {'shared_link' : shared_link }
103
124
update_info_kwargs = {'etag' : kwargs .get ('etag' )} if kwargs .get ('etag' ) is not None else {}
104
125
105
126
return self .update_info (data , ** update_info_kwargs )
106
127
107
128
@api_call
108
- def get_shared_link (self , ** kwargs : Any ) -> str :
129
+ def get_shared_link (
130
+ self ,
131
+ access : Optional [str ] = None ,
132
+ unshared_at : Optional [str ] = SDK_VALUE_NOT_SET ,
133
+ password : Optional [str ] = None ,
134
+ vanity_name : Optional [str ] = None ,
135
+ ** kwargs : Any ) -> str :
109
136
"""
110
137
Get a shared link for the item with the given access permissions.
111
138
This url leads to a Box.com shared link page, where the item can be previewed, downloaded, etc.
112
139
140
+ :param access:
141
+ Determines who can access the shared link. May be open, company, or collaborators. If no access is
142
+ specified, the default access will be used.
143
+ :param unshared_at:
144
+ The date on which this link should be disabled. May only be set if the current user is not a free user
145
+ and has permission to set expiration dates. Takes an RFC3339-formatted string, e.g.
146
+ '2018-10-31T23:59:59-07:00' for 11:59:59 PM on October 31, 2018 in the America/Los_Angeles timezone.
147
+ The time portion can be omitted, which defaults to midnight (00:00:00) on that date.
148
+ :param password:
149
+ The password required to view this link. If no password is specified then no password will be set.
150
+ Please notice that this is a premium feature, which might not be available to your app.
151
+ :param vanity_name:
152
+ Defines a custom vanity name to use in the shared link URL, eg. https://app.box.com/v/my-custom-vanity-name.
153
+ If this parameter is None, the standard shared link URL will be used.
113
154
:param kwargs:
114
155
Keyword arguments passed from overriding method used to create a new shared link.
115
156
:returns:
116
157
The URL of the shared link.
117
158
"""
118
- item = self .create_shared_link (** kwargs )
159
+ item = self .create_shared_link (
160
+ access = access , unshared_at = unshared_at , password = password , vanity_name = vanity_name , ** kwargs
161
+ )
119
162
return item .shared_link ['url' ] # pylint:disable=no-member
120
163
121
164
@api_call
0 commit comments