def create(cls, cli, storage_resource, name=None, description=None, is_auto_delete=None, retention_duration=None, is_read_only=None, fs_access_type=None): FilesystemSnapAccessTypeEnum.verify(fs_access_type) sr_clz = storops.unity.resource.storage_resource.UnityStorageResource sr = sr_clz.get(cli, storage_resource) resp = cli.post(cls().resource_class, storageResource=sr, name=name, description=description, isAutoDelete=is_auto_delete, retentionDuration=retention_duration, isReadOnly=is_read_only, filesystemAccessType=fs_access_type) resp.raise_if_err() return cls(_id=resp.resource_id, cli=cli)
def to_embedded(schedule_type, minute=None, hours=None, days_of_week=None, days_of_month=None, interval=None, is_auto_delete=None, retention_time=None, access_type=None): """ Constructs a `SnapScheduleRule` embedded instance. The rule created depends on the value of `schedule_type`. Its value could be: 0. `N_HOURS_AT_MM`, snap every `interval` hours, at `minute` past the hour. Supported parameters: `interval` (required), `minute` (optional, default 0). 1. `DAY_AT_HHMM`, specify `hours` as a list of `hour[,...]` to snap one or more times each day at `minute` past the hour. Supported parameters: `hours` (at least one required), `minute` (optional). 2. `N_DAYS_AT_HHMM`, snap every `interval` days at the time `hours`:`minute`. Supported Parameters: `interval` (required), `hours` (optional, exactly one), `minute` (optional). 3. `SELDAYS_AT_HHMM`, snap on the selected `days_of_week`, at the time `hours`:`minute`. Supported parameters: `days_of_week` (at least one required), `hours` (optional, default 0), `minute` (optional, default 0). 4. `NTH_DAYOFMONTH_AT_HHMM`, snap on the selected `days_of_month`, at the time `hours`:`minute`. Supported parameters: `days_of_month` (at least one required), `hours` (optional, default 0), `minute` (optional, default 0). 5. `UNSUPPORTED`. :param schedule_type: Type of snapshot schedule rule. Value is ScheduleTypeEnum. :param minute: Minute frequency for the snapshot schedule rule. Value should be [0, 59]. :param hours: Hourly frequency for the snapshot schedule rule. Each value should be [0, 23]. :param days_of_week: Days of the week for which the snapshot schedule rule applies. Each value is DayOfWeekEnum. :param days_of_month: Days of the month for which the snapshot schedule rule applies. Each value should be [1, 31]. :param interval: Number of days or hours between snaps, depending on the rule type. :param is_auto_delete: Indicates whether the system can automatically delete the snapshot based on pool automatic-deletion thresholds. Values are: true - System can delete the snapshot based on pool automatic-deletion thresholds. false - System cannot delete the snapshot based on pool automatic-deletion thresholds. :param retention_time: (Applies when the value of the is_auto_delete attribute is false.) Period of time in seconds for which to keep the snapshot. :param access_type: For a file system or VMware NFS datastore snapshot schedule, indicates whether the snapshot created by the schedule has checkpoint or protocol type access. Value is FilesystemSnapAccessTypeEnum. :return: constructed embedded instance in a dict. """ ScheduleTypeEnum.verify(schedule_type, allow_none=False) if minute is not None and (minute < 0 or minute > 59): raise ValueError( 'minute in UnitySnapScheduleRule should be [0, 59].') if hours is not None: if not isinstance(hours, list) or not hours: raise ValueError( 'hours in UnitySnapScheduleRule should be a list ' 'and not an empty list.') if any([(hour < 0 or hour > 23) for hour in hours]): raise ValueError( 'each value of hours in UnitySnapScheduleRule should be ' '[0, 23].') if days_of_week is not None: if not isinstance(days_of_week, list) or not days_of_week: raise ValueError( 'days_of_week in UnitySnapScheduleRule should be a list ' 'and not an empty list.') for day_of_week in days_of_week: DayOfWeekEnum.verify(day_of_week, allow_none=False) if days_of_month is not None: if not isinstance(days_of_month, list) or not days_of_month: raise ValueError( 'days_of_month in UnitySnapScheduleRule should be a list ' 'and not an empty list.') if any([(day < 1 or day > 31) for day in days_of_month]): raise ValueError( 'each value of days_of_month in UnitySnapScheduleRule ' 'should be [1, 31].') FilesystemSnapAccessTypeEnum.verify(access_type) return { 'type': schedule_type, 'minute': minute, 'hours': hours, 'daysOfWeek': days_of_week, 'daysOfMonth': days_of_month, 'interval': interval, 'isAutoDelete': is_auto_delete, 'retentionTime': retention_time, 'accessType': access_type, }