def delete(self, viewers): """ ================== ==================================================================== **Argument** **Description** ------------------ -------------------------------------------------------------------- viewers Required :class:`List` of :class:`String` or :class:`arcgis.gis.User`. The list of usernames/users to remove as Track Viewers. ================== ==================================================================== """ if isinstance(viewers, (str, arcgis.gis.User)): viewers = [viewers] if isinstance(viewers[0], str): if self._track_view._item['owner'] in viewers: raise LocationTrackingError( "Cannot remove track view owner from being a track viewer. Please try again without the owner included" ) else: if any(viewer.username == self._track_view._item['owner'] for viewer in viewers): raise LocationTrackingError( "Cannot remove track view owner from being a track viewer. Please try again without the owner included" ) max_add_per_call = 25 for i in range(0, math.ceil(len(viewers) / max_add_per_call)): self._track_view.group.remove_users( viewers[i * max_add_per_call:(i * max_add_per_call) + max_add_per_call])
def retention_period_units(self, value): self._validate_environment() if not isinstance(value, str): raise LocationTrackingError("Invalid Retention Policy Setting: '{}' expected HOURS, DAYS, MONTHS, or YEARS".format(value)) elif value.upper() not in ("HOURS", "DAYS", "MONTHS", "YEARS"): raise LocationTrackingError("Invalid Retention Policy Setting: '{}' expected HOURS, DAYS, MONTHS, or YEARS".format(value)) self.tracks_layer.manager.update_definition({ "tableMetadata": { "dataRetentionStrategyUnits": "{}".format(value) } })
def retention_period_enabled(self, value): self._validate_environment() if isinstance(value, str): if value.lower() not in ("false", "true"): raise LocationTrackingError("Invalid Retention Policy Setting: '{}' expected True or False".format(value)) elif not isinstance(value, bool): raise LocationTrackingError("Invalid Retention Policy Setting: '{}' expected True or False".format(value)) self.tracks_layer.manager.update_definition({ "tableMetadata": { "dataRetention": "{}".format(str(value).lower()) } })
def retention_period(self, value): self._validate_environment() if isinstance(value, str): if not value.isdigit(): raise LocationTrackingError("Invalid Retention Policy Setting: '{}' expected an integer greater than 0") elif isinstance(value, int): if value < 0: raise LocationTrackingError("Invalid Retention Policy Setting: '{}' expected an integer greater than 0") else: raise LocationTrackingError("Invalid Retention Policy Setting: '{}' expected an integer greater than 0") self.tracks_layer.manager.update_definition({ "tableMetadata": { "dataRetentionStrategy": "{}".format(value) } })
def list(self): """ Lists all of the Track Viewers :return: :class:`List` of :class:`String` representing usernames """ pattern = re.compile(self._VDQ_RE) match = pattern.match(self.view_definition_query) if match is None: raise LocationTrackingError("Unable to parse viewDefinitionQuery") return [username.strip()[1:-1] for username in match[1].split(',') if username.strip()[1:-1]]
def _validate_environment(self, location_tracking_enabled=True): if self._gis is None: raise LocationTrackingError("You must use a valid GIS") if float(self._gis.properties.get("currentVersion", "0")) < 7.1: raise LocationTrackingError("Location Tracking requires ArcGIS Enterprise 10.7+ or ArcGIS Online") if self._gis.users.me.role != "org_admin": raise LocationTrackingError("You must be an administrator to configure Location Tracking") if self._gis.properties.get("isPortal", False) and not self._gis.properties.get("hasSpatioTemporalArcGISDataStore", False): raise LocationTrackingError("Location Tracking requires the Spatiotemporal Big Data Store") if location_tracking_enabled and "locationTracking" not in self._gis.properties.helperServices: raise LocationTrackingError("Location Tracking is not enabled.") if not location_tracking_enabled and "locationTracking" in self._gis.properties.helperServices: raise LocationTrackingError("Location Tracking is already enabled.")
def __init__(self, item): if "Location Tracking View" not in item.typeKeywords: raise LocationTrackingError("Item is not a Track View") self._item = item self._gis = item._gis