Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 57 additions & 16 deletions cterasdk/asynchronous/core/files/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def public_link(self, path, access='RO', expire_in=30):
"""
return await Link(io.public_link, self._core, path, access, expire_in).a_execute()

async def copy(self, *paths, destination=None, resolver=None, cursor=None, wait=False):
async def copy(self, *paths, destination=None, resolver=None, cursor=None, wait=False, strict_permission=False):
"""
Copy one or more files or folders.

Expand All @@ -156,7 +156,16 @@ async def copy(self, *paths, destination=None, resolver=None, cursor=None, wait=
:raises cterasdk.exceptions.io.core.CopyError: Raised on failure copying resources.
"""
try:
return await Copy(io.copy, self._core, wait, *paths, destination=destination, resolver=resolver, cursor=cursor).a_execute()
return await Copy(
io.copy,
self._core,
wait,
*paths,
destination=destination,
resolver=resolver,
cursor=cursor,
strict_permission=strict_permission
).a_execute()
except ValueError:
raise ValueError('Copy destination was not specified.')

Expand All @@ -175,7 +184,7 @@ async def permalink(self, path):
class CloudDrive(FileBrowser):
"""Async CloudDrive API with upload and sharing functionality."""

async def upload(self, destination, handle, name=None, size=None):
async def upload(self, destination, handle, name=None, size=None, strict_permission=False):
"""
Upload from file handle.

Expand All @@ -187,9 +196,18 @@ async def upload(self, destination, handle, name=None, size=None):
:rtype: str
:raises cterasdk.exceptions.io.core.UploadError: Raised on upload failure.
"""
return await Upload(io.upload, self._core, io.listdir, destination, handle, name, size).a_execute()
return await Upload(
io.upload,
self._core,
io.listdir,
destination,
handle,
name,
size,
strict_permission=strict_permission
).a_execute()

async def upload_file(self, path, destination):
async def upload_file(self, path, destination, strict_permission=False):
"""
Upload a file.

Expand All @@ -201,9 +219,15 @@ async def upload_file(self, path, destination):
"""
_, name = commonfs.split_file_directory(path)
with open(path, 'rb') as handle:
return await self.upload(destination, handle, name, commonfs.properties(path)['size'])
return await self.upload(
destination,
handle,
name,
commonfs.properties(path)['size'],
strict_permission=strict_permission
)

async def mkdir(self, path):
async def mkdir(self, path, strict_permission=False):
"""
Create a directory.

Expand All @@ -212,9 +236,9 @@ async def mkdir(self, path):
:rtype: str
:raises cterasdk.exceptions.io.core.CreateDirectoryError: Raised on error creating directory.
"""
return await CreateDirectory(io.mkdir, self._core, path).a_execute()
return await CreateDirectory(io.mkdir, self._core, path, strict_permission=strict_permission).a_execute()

async def makedirs(self, path):
async def makedirs(self, path, strict_permission=False):
"""
Recursively create a directory.

Expand All @@ -223,9 +247,9 @@ async def makedirs(self, path):
:rtype: str
:raises cterasdk.exceptions.io.core.CreateDirectoryError: Raised on error creating directory.
"""
return await CreateDirectory(io.mkdir, self._core, path, True).a_execute()
return await CreateDirectory(io.mkdir, self._core, path, True, strict_permission=strict_permission).a_execute()

async def rename(self, path, name, *, resolver=None, wait=False):
async def rename(self, path, name, *, resolver=None, wait=False, strict_permission=False):
"""
Rename a file or folder.

Expand All @@ -237,9 +261,17 @@ async def rename(self, path, name, *, resolver=None, wait=False):
:rtype: cterasdk.common.object.Object or :class:`cterasdk.lib.tasks.AwaitablePortalTask`
:raises cterasdk.exceptions.io.core.RenameError: Raised on error renaming object.
"""
return await Rename(io.move, self._core, wait, path, name, resolver).a_execute()
return await Rename(
io.move,
self._core,
wait,
path,
name,
resolver,
strict_permission=strict_permission
).a_execute()

async def delete(self, *paths, wait=False):
async def delete(self, *paths, wait=False, strict_permission=False):
"""
Delete one or more files or folders.

Expand All @@ -249,7 +281,7 @@ async def delete(self, *paths, wait=False):
:rtype: cterasdk.common.object.Object or :class:`cterasdk.lib.tasks.AwaitablePortalTask`
:raises cterasdk.exceptions.io.core.DeleteError: Raised on error deleting resources.
"""
return await Delete(io.delete, self._core, wait, *paths).a_execute()
return await Delete(io.delete, self._core, wait, *paths, strict_permission=strict_permission).a_execute()

async def undelete(self, *paths, wait=False):
"""
Expand All @@ -263,7 +295,7 @@ async def undelete(self, *paths, wait=False):
"""
return await Recover(io.undelete, self._core, wait, *paths).a_execute()

async def move(self, *paths, destination=None, resolver=None, cursor=None, wait=False):
async def move(self, *paths, destination=None, resolver=None, cursor=None, wait=False, strict_permission=False):
"""
Move one or more files or folders.

Expand All @@ -277,7 +309,16 @@ async def move(self, *paths, destination=None, resolver=None, cursor=None, wait=
:raises cterasdk.exceptions.io.core.MoveError: Raised on error moving resources.
"""
try:
return await Move(io.move, self._core, wait, *paths, destination=destination, resolver=resolver, cursor=cursor).a_execute()
return await Move(
io.move,
self._core,
wait,
*paths,
destination=destination,
resolver=resolver,
cursor=cursor,
strict_permission=strict_permission
).a_execute()
except ValueError:
raise ValueError('Move destination was not specified.')

Expand Down
Loading