def _create_action_resource_param(self, sources, destinations=None): action_resource_param = Object() action_resource_param._classname = 'ActionResourcesParam' # pylint: disable=protected-access action_resource_param.urls = [] for idx, source in enumerate(sources): param = Object() param._classname = 'SrcDstParam' # pylint: disable=protected-access param.src = self._services.file_browser_base_path + '/' + source if destinations: param.dest = self._services.file_browser_base_path + '/' + destinations[idx] else: param.dest = None action_resource_param.urls.append(param) return action_resource_param
def _create_filter(filter_type, field, restriction, value): query_filter = Object() query_filter._classname = filter_type # pylint: disable=protected-access query_filter.field = field query_filter.restriction = restriction query_filter.value = value return query_filter
def _fetch_resources_param(root, start): param = Object() param._classname = 'FetchResourcesParam' # pylint: disable=protected-access param.root = BaseCoreServicesFilesList.basepath + '/' + root param.depth = 1 param.start = start param.limit = 100 return param
def _get_dir_entry(self, name, include): param = Object() param._classname = 'DirEntry' # pylint: disable=protected-access param.name = name param.children = None param.displayName = self._display_name param.isIncluded = include return param
def _get_init_replication_param(replicate_from=None): params = Object() params._classname = 'SetReplicationParam' # pylint: disable=protected-access if replicate_from: params.enabledReplicationParam = Object() params.enabledReplicationParam._classname = 'EnabledReplicationParam' # pylint: disable=protected-access params.enabledReplicationParam.replicationOf = replicate_from params.enabledReplicationParam.restartDB = True return params
def default_settings(): settings = Object() settings._classname = 'SystemSettings' # pylint: disable=protected-access settings.smtpSettings = Object() settings.smtpSettings._classname = 'SMTPSettings' # pylint: disable=protected-access settings.smtpSettings.smtpHost = 'your.mail.server' settings.smtpSettings.smtpPort = 25 settings.smtpSettings.enableTls = False settings.defaultPortalSettings = Object() settings.defaultPortalSettings._classname = 'PortalSettings' # pylint: disable=protected-access settings.defaultPortalSettings.mailSettings = Object() settings.defaultPortalSettings.mailSettings._classname = 'MailSettings' # pylint: disable=protected-access settings.defaultPortalSettings.mailSettings.sender = '*****@*****.**' return settings
def _get_init_portal_param(self): params = Object() params._classname = 'InitParams' # pylint: disable=protected-access params.admin = Object() params.admin._classname = 'PortalAdmin' # pylint: disable=protected-access params.admin.name = self._admin_username params.admin.email = self._admin_email params.admin.firstName = self._admin_first_name params.admin.lastName = self._admin_last_name params.admin.password = self._admin_password params.settings = TestCoreSetup.default_settings() params.settings.dnsSuffix = self._domain return params
def _create_public_link_param(self, access_mode, expire_in): param = Object() param._classname = 'CreateShareParam' # pylint: disable=protected-access param.url = self._services.file_browser_base_path + '/' + self._path param.share = Object() param.share._classname = 'ShareConfig' # pylint: disable=protected-access param.share.accessMode = access_mode param.share.protectionLevel = 'publicLink' param.share.expiration = ( datetime.date.today() + datetime.timedelta(days=expire_in)).strftime('%Y-%m-%d') param.share.invitee = Object() param.share.invitee._classname = 'Collaborator' # pylint: disable=protected-access param.share.invitee.type = 'external' return param
def _get_init_server_params(mode, authentication_method=None, master_ipaddr=None, master_secret=None): params = Object() params._classname = 'InitServerParams' # pylint: disable=protected-access params.serverMode = mode if mode == ServerMode.Slave: params.slaveSettings = Object() params.slaveSettings._classname = 'SlaveServerSettings' # pylint: disable=protected-access if master_ipaddr: params.slaveSettings.masterIpAddr = master_ipaddr if authentication_method == SlaveAuthenticaionMethod.Password: params.slaveSettings.masterPassword = master_secret elif authentication_method == SlaveAuthenticaionMethod.PrivateKey: params.slaveSettings.masterKey = master_secret return params
def _get_add_folders_param(self): param = self._get_zone_param(zone_id=self._zone_id) param.delta.policyDelta = [] for cloud_folders in TestCoreZones._cloud_folders.values(): owner_id = None folder_ids = list() for folder_info in cloud_folders.values(): owner_id = re.search("[1-9][0-9]*", folder_info['owner']).group(0) folder_ids.append(folder_info['uid']) policyDelta = Object() policyDelta._classname = 'ZonePolicyDelta' # pylint: disable=protected-access policyDelta.userUid = owner_id policyDelta.foldersDelta = Object() policyDelta.foldersDelta._classname = 'ZoneFolderDelta' # pylint: disable=protected-access policyDelta.foldersDelta.added = folder_ids policyDelta.foldersDelta.removed = [] param.delta.policyDelta.append(policyDelta) return param
def _get_zone_param(self, policy_type=PolicyType.SELECT, description=None, zone_id=None): param = Object() param._classname = "SaveZoneParam" # pylint: disable=protected-access param.basicInfo = Object() param.basicInfo._classname = 'ZoneBasicInfo' # pylint: disable=protected-access param.basicInfo.name = self._zone_name param.basicInfo.policyType = policy_type param.basicInfo.description = description param.basicInfo.zoneId = zone_id param.delta = Object() param.delta._classname = 'ZoneDelta' # pylint: disable=protected-access param.delta.devicesDelta = Object() param.delta.devicesDelta._classname = 'ZoneDeviceDelta' # pylint: disable=protected-access param.delta.devicesDelta.added = [] param.delta.devicesDelta.removed = [] return param
def _create_query_params(include_classname=False, start_from=None, count_limit=None, include=None, filters=None, or_filter=None, all_portals=None, **kwargs): query_params = Object() if include_classname: query_params._classname = 'QueryParams' # pylint: disable=protected-access if start_from is not None: query_params.startFrom = start_from if count_limit is not None: query_params.countLimit = count_limit if include is not None: query_params.include = include if filters is not None: query_params.filters = filters if or_filter is not None: query_params.orFilter = or_filter if all_portals is not None: query_params.allPortals = all_portals for k, v in kwargs.items(): setattr(query_params, k, v) return query_params
def _get_portal_object(self, **kwargs): portal_object = Object() portal_object._classname = self._portal_class_name # pylint: disable=protected-access for key, value in kwargs.items(): setattr(portal_object, key, value) return portal_object
def _get_plan_object(self, **kwargs): param = Object() param._classname = self._plan_class_name # pylint: disable=protected-access for key, value in kwargs.items(): setattr(param, key, value) return param
def _get_user_object(self, **kwargs): user_object = Object() user_object._classname = self._user_class_name # pylint: disable=protected-access for key, value in kwargs.items(): setattr(user_object, key, value) return user_object
def _create_resource_info(path): resource_info = Object() resource_info._classname = 'ResourceInfo' # pylint: disable=protected-access resource_info.href = BaseCoreServicesFilesList.basepath + '/' + path return resource_info