55from .base_command import BaseCommand
66from . import query , devices
77from .enum import ListFilter , PolicyType
8- from .types import ComplianceSettingsBuilder , ExtendedAttributesBuilder
8+ from .types import ArchiveSettingsBuilder , ComplianceSettingsBuilder , ExtendedAttributesBuilder
99from ..common import union , Object
1010from ..exceptions import CTERAException , ObjectNotFoundException
1111
@@ -151,35 +151,70 @@ def __init__(self, core):
151151 def _get_entire_object (self , name , owner ):
152152 return self ._core .api .get (f'{ self .find (name , owner , include = ["baseObjectRef" ]).baseObjectRef } ' )
153153
154- def add (self , name , group , owner , winacls = True , description = None , # pylint: disable=too-many-arguments
155- quota = None , compliance_settings = None , xattrs = None , gfl = False , lock_extensions = None ):
154+ def add (self , name , group = None , owner = None , winacls = True , description = None , # pylint: disable=too-many-arguments, too-many-locals
155+ quota = None , archive_settings = None , compliance_settings = None , native_format_settings = None ,
156+ xattrs = None , gfl = False , lock_extensions = None ):
156157 """
157158 Create a new Cloud Drive Folder (Cloud Volume)
158159
159- :param str name: Name of the new folder
160- :param str group: Folder Group to assign this folder to
160+ :param str name: Name of the new cloud folder
161+ :param str group,optional : Folder Group to assign this folder to
161162 :param cterasdk.core.types.UserAccount owner: User account, the owner of the new folder
162163 :param bool,optional winacls: Use Windows ACLs, defaults to True
163164 :param str,optional description: Cloud drive folder description
164165 :param str,optional quota: Cloud drive folder quota in GB
166+ :param cterasdk.common.object.Object,optional archive_settings: Archive settings.
167+ Use :func:`cterasdk.core.types.ArchiveSettingsBuilder` to build the archive settings object
165168 :param cterasdk.common.object.Object,optional compliance_settings: Compliance settings, defaults to disabled.
166169 Use :func:`cterasdk.core.types.ComplianceSettingsBuilder` to build the compliance settings object
170+ :param cterasdk.common.object.Object,optional native_format_settings: Native format settings, defaults to disabled.
171+ Use :func:`cterasdk.core.types.NativeFormatSettingsBuilder` to build the native format settings object
167172 :param cterasdk.common.object.Object,optional xattrs: Extended attributes, defaults to MacOS.
168173 Use :func:`cterasdk.core.types.ExtendedAttributesBuilder` to build the extended attributes object
169174 :param bool,optional gfl: Enable global file locking
170175 :param list[str],optional lock_extensions: List of file extensions (without leading dot) for which global file locking is enforced.
171176 :returns: Path to the Cloud Drive folder
172177 :rtype: str
173178 """
174- param = Object ()
179+ param = Object (owner = self ._core .users .get (owner , ['baseObjectRef' ]).baseObjectRef )
180+
181+ self ._configure_native_or_encrypted (param , group , native_format_settings )
182+
183+ CloudDrives ._configure_attributes (param , name , winacls , quota , description , xattrs )
184+
185+ CloudDrives ._configure_archive (param , archive_settings )
186+
187+ CloudDrives ._configure_compliance (param , compliance_settings )
188+
189+ if gfl :
190+ CloudDrives ._configure_locking (param , lock_extensions )
191+
192+ try :
193+ response = self ._core .api .execute ('' , 'addCloudDrive' , param )
194+ logger .info ('Cloud drive folder created. %s' ,
195+ {'name' : name , 'owner' : param .owner , 'folder_group' : group , 'winacls' : winacls })
196+ return re .search (r'/Users\/(.+)' , response ).group ()
197+ except CTERAException as error :
198+ logger .error ('Cloud drive folder creation failed. %s' ,
199+ {'name' : name , 'folder_group' : group , 'owner' : str (owner ), 'win_acls' : winacls })
200+ raise error
201+
202+ def _configure_native_or_encrypted (self , param , group , native_format_settings ):
203+ if native_format_settings :
204+ param .openStorageEnabled = True
205+ param .openFabricSettings = native_format_settings
206+ param .group = None
207+ else :
208+ param .group = self ._core .cloudfs .groups .get (group , ['baseObjectRef' ]).baseObjectRef
209+
210+ @staticmethod
211+ def _configure_attributes (param , name , winacls , quota , description , xattrs ):
175212 param .name = name
176- param .owner = self ._core .users .get (owner , ['baseObjectRef' ]).baseObjectRef
177- param .group = self ._core .cloudfs .groups .get (group , ['baseObjectRef' ]).baseObjectRef
178213 param .enableSyncWinNtExtendedAttributes = winacls
179214 param .folderQuota = quota
180215 if description :
181216 param .description = description
182- param . wormSettings = compliance_settings if compliance_settings else ComplianceSettingsBuilder . default (). build ()
217+
183218 if xattrs :
184219 param .extendedAttributes = xattrs
185220 elif not winacls : # Only override default when winacls is False
@@ -193,31 +228,27 @@ def add(self, name, group, owner, winacls=True, description=None, # pylint: dis
193228 else :
194229 param .extendedAttributes = ExtendedAttributesBuilder .default ().build ()
195230
196- if gfl :
197- param .globalFileLockSettings = Object ()
198- param .globalFileLockSettings ._classname = 'GlobalFileLockSettings' # pylint: disable=protected-access
199- param .globalFileLockSettings .enabled = True
200- param .globalFileLockSettings .globalFileLockExtensions = (
201- lock_extensions if lock_extensions else CloudDrives .default_extensions
202- )
231+ @staticmethod
232+ def _configure_archive (param , archive_settings ):
233+ param .archiveSettings = archive_settings if archive_settings else ArchiveSettingsBuilder .default ().build ()
203234
204- try :
205- response = self ._core .api .execute ('' , 'addCloudDrive' , param )
206- logger .info (
207- 'Cloud drive folder created. %s' ,
208- {'name' : name , 'owner' : param .owner , 'folder_group' : group , 'winacls' : winacls }
209- )
210- return re .search (r'/Users\/(.+)' , response ).group ()
211- except CTERAException as error :
212- logger .error (
213- 'Cloud drive folder creation failed. %s' ,
214- {'name' : name , 'folder_group' : group , 'owner' : str (owner ), 'win_acls' : winacls }
215- )
216- raise error
235+ @staticmethod
236+ def _configure_compliance (param , compliance_settings ):
237+ param .wormSettings = compliance_settings if compliance_settings else ComplianceSettingsBuilder .default ().build ()
217238
218- def modify (self , current_name , owner , new_name = None , # pylint: disable=too-many-arguments, too-many-locals
219- new_owner = None , new_group = None , description = None , winacls = None , quota = None , compliance_settings = None , xattrs = None ,
220- gfl = None , lock_extensions = None ):
239+ @staticmethod
240+ def _configure_locking (param , lock_extensions ):
241+ param .globalFileLockSettings = Object ()
242+ param .globalFileLockSettings ._classname = 'GlobalFileLockSettings' # pylint: disable=protected-access
243+ param .globalFileLockSettings .enabled = True
244+ param .globalFileLockSettings .globalFileLockExtensions = (
245+ lock_extensions if lock_extensions else CloudDrives .default_extensions
246+ )
247+
248+ def modify (self , current_name , owner , new_name = None , # pylint: disable=too-many-arguments, too-many-locals, too-many-branches
249+ new_owner = None , new_group = None , description = None , winacls = None , quota = None ,
250+ archive_settings = None , compliance_settings = None , native_format_settings = None ,
251+ xattrs = None , gfl = None , lock_extensions = None ):
221252 """
222253 Modify a Cloud Drive Folder (Cloud Volume)
223254
@@ -229,8 +260,12 @@ def modify(self, current_name, owner, new_name=None, # pylint: disable=too-many
229260 :param str,optional description: Folder description
230261 :param bool,optional winacls: Enable or disable Windows ACLs
231262 :param str,optional quota: Folder quota in GB
263+ :param cterasdk.common.object.Object,optional archive_settings: Archive settings.
264+ Use :func:`cterasdk.core.types.ArchiveSettingsBuilder` to build the archive settings object
232265 :param cterasdk.common.object.Object,optional compliance_settings: Compliance settings.
233266 Use :func:`cterasdk.core.types.ComplianceSettingsBuilder` to build the compliance settings object
267+ :param cterasdk.common.object.Object,optional native_format_settings: Native format settings.
268+ Use :func:`cterasdk.core.types.NativeFormatSettingsBuilder` to build the native format settings object
234269 :param cterasdk.common.object.Object,optional xattrs: Extended attributes.
235270 Use :func:`cterasdk.core.types.ExtendedAttributesBuilder` to build the extended attributes object
236271 :param bool,optional gfl: Enable global file locking
@@ -249,8 +284,12 @@ def modify(self, current_name, owner, new_name=None, # pylint: disable=too-many
249284 param .enableSyncWinNtExtendedAttributes = winacls
250285 if quota :
251286 param .folderQuota = quota
287+ if archive_settings :
288+ param .archiveSettings = archive_settings
252289 if compliance_settings :
253290 param .wormSettings = compliance_settings
291+ if native_format_settings :
292+ param .openFabricSettings = native_format_settings
254293 if xattrs :
255294 param .extendedAttributes = xattrs
256295 if gfl is not None :
0 commit comments