Skip to content

Commit b1f61dc

Browse files
committed
Support upload only access when sharing public links or collaboration shares
1 parent 56b5c35 commit b1f61dc

5 files changed

Lines changed: 23 additions & 4 deletions

File tree

cterasdk/cio/core/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def _before_command(self):
703703
logger.info('Creating Public Link: %s', self.path)
704704

705705
def get_parameter(self):
706-
access = {'RO': 'ReadOnly', 'RW': 'ReadWrite', 'PO': 'PreviewOnly'}.get(self.access)
706+
access = {k: v for k, v in FileAccessMode.__dict__.items() if not k.startswith('_') and k != 'NA'}.get(self.access, None)
707707
expire_on = DateTimeUtils.get_expiration_date(self.expire_in).strftime('%Y-%m-%d')
708708
param = CreateShareParam.instance(path=self.path.absolute_encode, access=access, expire_on=expire_on)
709709
return param

cterasdk/cio/core/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class PortalVolume(Object):
314314
:ivar str name: Cloud Drive Folder Name
315315
:ivar int group: Folder Group ID
316316
:ivar bool protected: Passphrase-Protected
317-
:ivar cterasdk.core.types.VolumeOwner owner: Volume owner information.
317+
:ivar cterasdk.cio.core.types.VolumeOwner owner: Volume owner information.
318318
"""
319319
def __init__(self, i, name, group, protected, owner):
320320
super().__init__(id=i, name=name, group=group, protected=protected, owner=owner)

cterasdk/core/enum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class FileAccessMode:
176176
RW = "ReadWrite"
177177
RO = "ReadOnly"
178178
PO = "PreviewOnly"
179+
UO = "UploadOnly"
179180
NA = "None"
180181

181182

cterasdk/core/types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ def preview_only(self):
188188
self.access = FileAccessMode.PO
189189
return self
190190

191+
def upload_only(self):
192+
"""
193+
Grant upload only access
194+
"""
195+
self.access = FileAccessMode.UO
196+
return self
197+
191198
def no_access(self):
192199
"""
193200
Deny access

docs/source/UserGuides/Portal/Files.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,17 @@ This section describes the main objects used for managing collaboration shares.
376376
alice_rcpt = core_types.Collaborator.local_user(alice).expire_in(30).read_only()
377377
engineers_rcpt = core_types.Collaborator.local_group(engineers).read_write()
378378
379+
# Share with a local user with read-only access, expiring in 30 days
380+
# Share with a local group with read-write access and the default expiration date
379381
user.files.share('Codebase', [alice_rcpt, engineers_rcpt])
380382
381383
.. code-block:: python
382384
385+
# Share with an external user with view-only access, expiring in 10 days
383386
jsmith = core_types.Collaborator.external('jsmith@hotmail.com').expire_in(10).preview_only()
384387
user.files.share('My Files/Projects/2020/ProjectX', [jsmith])
385388
389+
# Share with an external user with read-only access, expiring in 5 days
386390
jsmith = core_types.Collaborator.external('jsmith@hotmail.com', True).expire_in(5).read_only()
387391
user.files.share('My Files/Projects/2020/ProjectX', [jsmith])
388392
@@ -394,13 +398,21 @@ This section describes the main objects used for managing collaboration shares.
394398
albany_rcpt = core_types.Collaborator.domain_group(albany_group).read_write()
395399
cleveland_rcpt = core_types.Collaborator.domain_group(cleveland_group).read_only()
396400
401+
# Share with two domain groups, with the default expiration date
397402
user.files.share('Cloud/Albany', [albany_rcpt, cleveland_rcpt])
398403
404+
.. code-block:: python
405+
406+
# Share with an external user with upload-only access, expiring in 15 days
407+
jsmith = core_types.Collaborator.external('jsmith@hotmail.com').expire_in(15).upload_only()
408+
user.files.share('My Files/Projects/2020/ProjectX', [jsmith])
409+
399410
.. automethod:: cterasdk.core.files.browser.CloudDrive.add_share_recipients
400411
:noindex:
401412

402413
.. code-block:: python
403414
415+
# Add a read-write local group share recepient
404416
engineering = core_types.GroupAccount('Engineering')
405417
engineering_rcpt = core_types.Collaborator.local_group(engineering).read_write()
406418
user.files.add_share_recipients('My Files/Projects/2020/ProjectX', [engineering_rcpt])
@@ -410,6 +422,7 @@ This section describes the main objects used for managing collaboration shares.
410422

411423
.. code-block:: python
412424
425+
# Remove a local user and group from a share
413426
alice = core_types.UserAccount('alice')
414427
engineering = core_types.GroupAccount('Engineering')
415428
user.files.remove_share_recipients('My Files/Projects/2020/ProjectX', [alice, engineering])
@@ -419,9 +432,7 @@ This section describes the main objects used for managing collaboration shares.
419432

420433
.. code-block:: python
421434
422-
user.files.unshare('Codebase')
423435
user.files.unshare('My Files/Projects/2020/ProjectX')
424-
user.files.unshare('Cloud/Albany')
425436
426437
Managing S3 Credentials
427438
-----------------------

0 commit comments

Comments
 (0)