|
| 1 | +import enum |
| 2 | +from kagglesdk.common.types.common_types import KaggleEntityType |
| 3 | +from kagglesdk.kaggle_object import * |
| 4 | +from typing import Optional |
| 5 | + |
| 6 | +class ReportedDismissalType(enum.Enum): |
| 7 | + REPORTED_DISMISSAL_TYPE_UNSPECIFIED = 0 |
| 8 | + BANNER = 1 |
| 9 | + MODAL = 2 |
| 10 | + |
| 11 | +class AdminAllowlistEntityRequest(KaggleObject): |
| 12 | + r""" |
| 13 | + Attributes: |
| 14 | + entity_id (int) |
| 15 | + The entity ID to allowlist |
| 16 | + entity_type (KaggleEntityType) |
| 17 | + The entity type of the allowlisted entity |
| 18 | + """ |
| 19 | + |
| 20 | + def __init__(self): |
| 21 | + self._entity_id = 0 |
| 22 | + self._entity_type = KaggleEntityType.KAGGLE_ENTITY_TYPE_UNSPECIFIED |
| 23 | + self._freeze() |
| 24 | + |
| 25 | + @property |
| 26 | + def entity_id(self) -> int: |
| 27 | + """The entity ID to allowlist""" |
| 28 | + return self._entity_id |
| 29 | + |
| 30 | + @entity_id.setter |
| 31 | + def entity_id(self, entity_id: int): |
| 32 | + if entity_id is None: |
| 33 | + del self.entity_id |
| 34 | + return |
| 35 | + if not isinstance(entity_id, int): |
| 36 | + raise TypeError('entity_id must be of type int') |
| 37 | + self._entity_id = entity_id |
| 38 | + |
| 39 | + @property |
| 40 | + def entity_type(self) -> 'KaggleEntityType': |
| 41 | + """The entity type of the allowlisted entity""" |
| 42 | + return self._entity_type |
| 43 | + |
| 44 | + @entity_type.setter |
| 45 | + def entity_type(self, entity_type: 'KaggleEntityType'): |
| 46 | + if entity_type is None: |
| 47 | + del self.entity_type |
| 48 | + return |
| 49 | + if not isinstance(entity_type, KaggleEntityType): |
| 50 | + raise TypeError('entity_type must be of type KaggleEntityType') |
| 51 | + self._entity_type = entity_type |
| 52 | + |
| 53 | + |
| 54 | +class RemoveDatasetVersionQuarantineRequest(KaggleObject): |
| 55 | + r""" |
| 56 | + Attributes: |
| 57 | + dataset_version_id (int) |
| 58 | + The dataset version to unquarantine |
| 59 | + reason (str) |
| 60 | + Admin reasoning for the quarantine removal |
| 61 | + """ |
| 62 | + |
| 63 | + def __init__(self): |
| 64 | + self._dataset_version_id = 0 |
| 65 | + self._reason = None |
| 66 | + self._freeze() |
| 67 | + |
| 68 | + @property |
| 69 | + def dataset_version_id(self) -> int: |
| 70 | + """The dataset version to unquarantine""" |
| 71 | + return self._dataset_version_id |
| 72 | + |
| 73 | + @dataset_version_id.setter |
| 74 | + def dataset_version_id(self, dataset_version_id: int): |
| 75 | + if dataset_version_id is None: |
| 76 | + del self.dataset_version_id |
| 77 | + return |
| 78 | + if not isinstance(dataset_version_id, int): |
| 79 | + raise TypeError('dataset_version_id must be of type int') |
| 80 | + self._dataset_version_id = dataset_version_id |
| 81 | + |
| 82 | + @property |
| 83 | + def reason(self) -> str: |
| 84 | + """Admin reasoning for the quarantine removal""" |
| 85 | + return self._reason or "" |
| 86 | + |
| 87 | + @reason.setter |
| 88 | + def reason(self, reason: Optional[str]): |
| 89 | + if reason is None: |
| 90 | + del self.reason |
| 91 | + return |
| 92 | + if not isinstance(reason, str): |
| 93 | + raise TypeError('reason must be of type str') |
| 94 | + self._reason = reason |
| 95 | + |
| 96 | + |
| 97 | +class SetReportedDismissalRequest(KaggleObject): |
| 98 | + r""" |
| 99 | + Attributes: |
| 100 | + entity_id (int) |
| 101 | + The ID for the entity to dismiss |
| 102 | + entity_type (KaggleEntityType) |
| 103 | + The type for the entity to dismiss |
| 104 | + is_dismissed (bool) |
| 105 | + The value to set dismissal to |
| 106 | + dismissal_type (ReportedDismissalType) |
| 107 | + Whether we're dismissing a banner or a modal |
| 108 | + """ |
| 109 | + |
| 110 | + def __init__(self): |
| 111 | + self._entity_id = 0 |
| 112 | + self._entity_type = KaggleEntityType.KAGGLE_ENTITY_TYPE_UNSPECIFIED |
| 113 | + self._is_dismissed = False |
| 114 | + self._dismissal_type = ReportedDismissalType.REPORTED_DISMISSAL_TYPE_UNSPECIFIED |
| 115 | + self._freeze() |
| 116 | + |
| 117 | + @property |
| 118 | + def entity_id(self) -> int: |
| 119 | + """The ID for the entity to dismiss""" |
| 120 | + return self._entity_id |
| 121 | + |
| 122 | + @entity_id.setter |
| 123 | + def entity_id(self, entity_id: int): |
| 124 | + if entity_id is None: |
| 125 | + del self.entity_id |
| 126 | + return |
| 127 | + if not isinstance(entity_id, int): |
| 128 | + raise TypeError('entity_id must be of type int') |
| 129 | + self._entity_id = entity_id |
| 130 | + |
| 131 | + @property |
| 132 | + def entity_type(self) -> 'KaggleEntityType': |
| 133 | + """The type for the entity to dismiss""" |
| 134 | + return self._entity_type |
| 135 | + |
| 136 | + @entity_type.setter |
| 137 | + def entity_type(self, entity_type: 'KaggleEntityType'): |
| 138 | + if entity_type is None: |
| 139 | + del self.entity_type |
| 140 | + return |
| 141 | + if not isinstance(entity_type, KaggleEntityType): |
| 142 | + raise TypeError('entity_type must be of type KaggleEntityType') |
| 143 | + self._entity_type = entity_type |
| 144 | + |
| 145 | + @property |
| 146 | + def is_dismissed(self) -> bool: |
| 147 | + """The value to set dismissal to""" |
| 148 | + return self._is_dismissed |
| 149 | + |
| 150 | + @is_dismissed.setter |
| 151 | + def is_dismissed(self, is_dismissed: bool): |
| 152 | + if is_dismissed is None: |
| 153 | + del self.is_dismissed |
| 154 | + return |
| 155 | + if not isinstance(is_dismissed, bool): |
| 156 | + raise TypeError('is_dismissed must be of type bool') |
| 157 | + self._is_dismissed = is_dismissed |
| 158 | + |
| 159 | + @property |
| 160 | + def dismissal_type(self) -> 'ReportedDismissalType': |
| 161 | + """Whether we're dismissing a banner or a modal""" |
| 162 | + return self._dismissal_type |
| 163 | + |
| 164 | + @dismissal_type.setter |
| 165 | + def dismissal_type(self, dismissal_type: 'ReportedDismissalType'): |
| 166 | + if dismissal_type is None: |
| 167 | + del self.dismissal_type |
| 168 | + return |
| 169 | + if not isinstance(dismissal_type, ReportedDismissalType): |
| 170 | + raise TypeError('dismissal_type must be of type ReportedDismissalType') |
| 171 | + self._dismissal_type = dismissal_type |
| 172 | + |
| 173 | + |
| 174 | +AdminAllowlistEntityRequest._fields = [ |
| 175 | + FieldMetadata("entityId", "entity_id", "_entity_id", int, 0, PredefinedSerializer()), |
| 176 | + FieldMetadata("entityType", "entity_type", "_entity_type", KaggleEntityType, KaggleEntityType.KAGGLE_ENTITY_TYPE_UNSPECIFIED, EnumSerializer()), |
| 177 | +] |
| 178 | + |
| 179 | +RemoveDatasetVersionQuarantineRequest._fields = [ |
| 180 | + FieldMetadata("datasetVersionId", "dataset_version_id", "_dataset_version_id", int, 0, PredefinedSerializer()), |
| 181 | + FieldMetadata("reason", "reason", "_reason", str, None, PredefinedSerializer(), optional=True), |
| 182 | +] |
| 183 | + |
| 184 | +SetReportedDismissalRequest._fields = [ |
| 185 | + FieldMetadata("entityId", "entity_id", "_entity_id", int, 0, PredefinedSerializer()), |
| 186 | + FieldMetadata("entityType", "entity_type", "_entity_type", KaggleEntityType, KaggleEntityType.KAGGLE_ENTITY_TYPE_UNSPECIFIED, EnumSerializer()), |
| 187 | + FieldMetadata("isDismissed", "is_dismissed", "_is_dismissed", bool, False, PredefinedSerializer()), |
| 188 | + FieldMetadata("dismissalType", "dismissal_type", "_dismissal_type", ReportedDismissalType, ReportedDismissalType.REPORTED_DISMISSAL_TYPE_UNSPECIFIED, EnumSerializer()), |
| 189 | +] |
| 190 | + |
0 commit comments