ethyca-fides 2.63.1b0__py2.py3-none-any.whl → 2.63.1b3__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ethyca_fides-2.63.1b0.dist-info → ethyca_fides-2.63.1b3.dist-info}/METADATA +1 -1
- {ethyca_fides-2.63.1b0.dist-info → ethyca_fides-2.63.1b3.dist-info}/RECORD +124 -112
- fides/_version.py +3 -3
- fides/api/alembic/migrations/versions/5efcdf18438e_add_manual_task_tables.py +160 -0
- fides/api/alembic/migrations/versions/bf713b5a021d_staged_resource_ancestor_link_data_.py +20 -11
- fides/api/db/base.py +2 -0
- fides/api/migrations/post_upgrade_index_creation.py +3 -3
- fides/api/models/attachment.py +36 -23
- fides/api/models/manual_tasks/__init__.py +8 -0
- fides/api/models/manual_tasks/manual_task.py +110 -0
- fides/api/models/manual_tasks/manual_task_log.py +100 -0
- fides/api/schemas/manual_tasks/__init__.py +0 -0
- fides/api/schemas/manual_tasks/manual_task_schemas.py +79 -0
- fides/api/schemas/manual_tasks/manual_task_status.py +151 -0
- fides/api/service/privacy_request/attachment_handling.py +132 -0
- fides/api/service/privacy_request/dsr_package/dsr_report_builder.py +264 -46
- fides/api/service/privacy_request/dsr_package/templates/attachments_index.html +33 -0
- fides/api/service/privacy_request/dsr_package/templates/collection_index.html +34 -9
- fides/api/service/privacy_request/dsr_package/templates/main.css +45 -2
- fides/api/service/privacy_request/dsr_package/templates/welcome.html +12 -8
- fides/api/service/privacy_request/request_runner_service.py +258 -139
- fides/api/service/storage/gcs.py +15 -3
- fides/api/service/storage/s3.py +28 -14
- fides/api/service/storage/util.py +45 -7
- fides/api/tasks/csv_utils.py +170 -0
- fides/api/tasks/encryption_utils.py +42 -0
- fides/api/tasks/storage.py +85 -91
- fides/api/util/cache.py +77 -1
- fides/config/redis_settings.py +99 -8
- fides/service/manual_tasks/__init__.py +0 -0
- fides/service/manual_tasks/manual_task_service.py +150 -0
- fides/service/messaging/aws_ses_service.py +5 -1
- fides/ui-build/static/admin/404.html +1 -1
- fides/ui-build/static/admin/add-systems/manual.html +1 -1
- fides/ui-build/static/admin/add-systems/multiple.html +1 -1
- fides/ui-build/static/admin/add-systems.html +1 -1
- fides/ui-build/static/admin/consent/configure/add-vendors.html +1 -1
- fides/ui-build/static/admin/consent/configure.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices.html +1 -1
- fides/ui-build/static/admin/consent/properties.html +1 -1
- fides/ui-build/static/admin/consent/reporting.html +1 -1
- fides/ui-build/static/admin/consent.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn]/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources.html +1 -1
- fides/ui-build/static/admin/data-catalog.html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId]/[systemId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center.html +1 -1
- fides/ui-build/static/admin/data-discovery/activity.html +1 -1
- fides/ui-build/static/admin/data-discovery/detection/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/detection.html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery.html +1 -1
- fides/ui-build/static/admin/datamap.html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName]/[...subfieldNames].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId].html +1 -1
- fides/ui-build/static/admin/dataset/new.html +1 -1
- fides/ui-build/static/admin/dataset.html +1 -1
- fides/ui-build/static/admin/datastore-connection/[id].html +1 -1
- fides/ui-build/static/admin/datastore-connection/new.html +1 -1
- fides/ui-build/static/admin/datastore-connection.html +1 -1
- fides/ui-build/static/admin/index.html +1 -1
- fides/ui-build/static/admin/integrations/[id].html +1 -1
- fides/ui-build/static/admin/integrations.html +1 -1
- fides/ui-build/static/admin/lib/fides-ext-gpp.js +1 -1
- fides/ui-build/static/admin/lib/fides-headless.js +1 -1
- fides/ui-build/static/admin/lib/fides-preview.js +1 -1
- fides/ui-build/static/admin/lib/fides-tcf.js +2 -2
- fides/ui-build/static/admin/lib/fides.js +2 -2
- fides/ui-build/static/admin/login/[provider].html +1 -1
- fides/ui-build/static/admin/login.html +1 -1
- fides/ui-build/static/admin/messaging/[id].html +1 -1
- fides/ui-build/static/admin/messaging/add-template.html +1 -1
- fides/ui-build/static/admin/messaging.html +1 -1
- fides/ui-build/static/admin/poc/ant-components.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/AntForm.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikAntFormItem.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikControlled.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikField.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikSpreadField.html +1 -1
- fides/ui-build/static/admin/poc/forms.html +1 -1
- fides/ui-build/static/admin/poc/table-migration.html +1 -1
- fides/ui-build/static/admin/privacy-requests/[id].html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/messaging.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/storage.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure.html +1 -1
- fides/ui-build/static/admin/privacy-requests.html +1 -1
- fides/ui-build/static/admin/properties/[id].html +1 -1
- fides/ui-build/static/admin/properties/add-property.html +1 -1
- fides/ui-build/static/admin/properties.html +1 -1
- fides/ui-build/static/admin/reporting/datamap.html +1 -1
- fides/ui-build/static/admin/settings/about/alpha.html +1 -1
- fides/ui-build/static/admin/settings/about.html +1 -1
- fides/ui-build/static/admin/settings/consent/[configuration_id]/[purpose_id].html +1 -1
- fides/ui-build/static/admin/settings/consent.html +1 -1
- fides/ui-build/static/admin/settings/custom-fields.html +1 -1
- fides/ui-build/static/admin/settings/domain-records.html +1 -1
- fides/ui-build/static/admin/settings/domains.html +1 -1
- fides/ui-build/static/admin/settings/email-templates.html +1 -1
- fides/ui-build/static/admin/settings/locations.html +1 -1
- fides/ui-build/static/admin/settings/organization.html +1 -1
- fides/ui-build/static/admin/settings/regulations.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id]/test-datasets.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id].html +1 -1
- fides/ui-build/static/admin/systems.html +1 -1
- fides/ui-build/static/admin/taxonomy.html +1 -1
- fides/ui-build/static/admin/user-management/new.html +1 -1
- fides/ui-build/static/admin/user-management/profile/[id].html +1 -1
- fides/ui-build/static/admin/user-management.html +1 -1
- fides/api/service/privacy_request/dsr_package/templates/item.html +0 -37
- {ethyca_fides-2.63.1b0.dist-info → ethyca_fides-2.63.1b3.dist-info}/WHEEL +0 -0
- {ethyca_fides-2.63.1b0.dist-info → ethyca_fides-2.63.1b3.dist-info}/entry_points.txt +0 -0
- {ethyca_fides-2.63.1b0.dist-info → ethyca_fides-2.63.1b3.dist-info}/licenses/LICENSE +0 -0
- {ethyca_fides-2.63.1b0.dist-info → ethyca_fides-2.63.1b3.dist-info}/top_level.txt +0 -0
- /fides/ui-build/static/admin/_next/static/{j0v5qPG9TaezfK2WMkHhI → ycPcko8qnif6BlkQ6MN4D}/_buildManifest.js +0 -0
- /fides/ui-build/static/admin/_next/static/{j0v5qPG9TaezfK2WMkHhI → ycPcko8qnif6BlkQ6MN4D}/_ssgManifest.js +0 -0
@@ -74,6 +74,11 @@ def upgrade():
|
|
74
74
|
children = result.children
|
75
75
|
if children:
|
76
76
|
resource_children[urn] = children
|
77
|
+
else:
|
78
|
+
# even if no children, we still add the resource to the map
|
79
|
+
# so that we maintain a record of all resources and can
|
80
|
+
# check for orphaned descendant records later
|
81
|
+
resource_children[urn] = []
|
77
82
|
|
78
83
|
# Build list of ancestor-descendant pairs
|
79
84
|
ancestor_links = []
|
@@ -86,17 +91,21 @@ def upgrade():
|
|
86
91
|
for child_urn in children:
|
87
92
|
if child_urn not in visited:
|
88
93
|
visited.add(child_urn)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
94
|
+
if child_urn not in resource_children:
|
95
|
+
logger.warning(
|
96
|
+
f"Found orphaned descendant URN: {child_urn}, not adding ancestor link"
|
97
|
+
)
|
98
|
+
else:
|
99
|
+
# Add direct ancestor link
|
100
|
+
ancestor_links.append(
|
101
|
+
{
|
102
|
+
"id": f"srl_{uuid.uuid4()}",
|
103
|
+
"ancestor_urn": ancestor_urn,
|
104
|
+
"descendant_urn": child_urn,
|
105
|
+
}
|
106
|
+
)
|
107
|
+
|
108
|
+
# Recursively process this child's children
|
100
109
|
process_children(
|
101
110
|
ancestor_urn, resource_children[child_urn], visited
|
102
111
|
)
|
fides/api/db/base.py
CHANGED
@@ -27,6 +27,8 @@ from fides.api.models.fides_user_respondent_email_verification import (
|
|
27
27
|
)
|
28
28
|
from fides.api.models.identity_salt import IdentitySalt
|
29
29
|
from fides.api.models.location_regulation_selections import LocationRegulationSelections
|
30
|
+
from fides.api.models.manual_tasks.manual_task import ManualTask, ManualTaskReference
|
31
|
+
from fides.api.models.manual_tasks.manual_task_log import ManualTaskLog
|
30
32
|
from fides.api.models.manual_webhook import AccessManualWebhook
|
31
33
|
from fides.api.models.messaging import MessagingConfig
|
32
34
|
from fides.api.models.messaging_template import MessagingTemplate
|
@@ -182,7 +182,7 @@ def create_object(db: Session, object_statement: str, object_name: str) -> None:
|
|
182
182
|
def check_and_create_objects(
|
183
183
|
db: Session, table_object_map: Dict[str, List[Dict[str, str]]], lock: Lock
|
184
184
|
) -> Dict[str, str]:
|
185
|
-
"""Returns a dictionary of any indices or constraints that
|
185
|
+
"""Returns a dictionary of any indices or constraints that were created."""
|
186
186
|
object_info: Dict[str, str] = {}
|
187
187
|
for _, objects in table_object_map.items():
|
188
188
|
for object_data in objects:
|
@@ -203,7 +203,7 @@ def check_and_create_objects(
|
|
203
203
|
continue
|
204
204
|
|
205
205
|
create_object(db, object_statement, object_name)
|
206
|
-
object_info[object_name] = "
|
206
|
+
object_info[object_name] = "created"
|
207
207
|
else:
|
208
208
|
logger.debug(
|
209
209
|
f"Object {object_name} already exists, skipping index/constraint creation"
|
@@ -248,7 +248,7 @@ def post_upgrade_index_creation_task() -> None:
|
|
248
248
|
f"Post upgrade index creation output: {json.dumps(object_info)}"
|
249
249
|
)
|
250
250
|
else:
|
251
|
-
logger.debug("All indices and constraints created")
|
251
|
+
logger.debug("All indices and constraints already created")
|
252
252
|
|
253
253
|
|
254
254
|
def initiate_post_upgrade_index_creation() -> None:
|
fides/api/models/attachment.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
from enum import Enum as EnumType
|
3
|
+
from io import BytesIO
|
3
4
|
from typing import IO, TYPE_CHECKING, Any, Tuple
|
4
5
|
|
5
6
|
from fideslang.validation import AnyHttpUrlString
|
@@ -19,7 +20,6 @@ from fides.api.service.storage.s3 import (
|
|
19
20
|
generic_upload_to_s3,
|
20
21
|
)
|
21
22
|
from fides.api.service.storage.util import AllowedFileType, get_local_filename
|
22
|
-
from fides.config import CONFIG
|
23
23
|
|
24
24
|
if TYPE_CHECKING:
|
25
25
|
from fides.api.models.comment import Comment
|
@@ -28,6 +28,11 @@ if TYPE_CHECKING:
|
|
28
28
|
from fides.api.models.storage import StorageConfig
|
29
29
|
|
30
30
|
|
31
|
+
# This is 7 days in seconds and is currently the max allowed
|
32
|
+
# configurable expiration time for presigned URLs for both s3 and gcs.
|
33
|
+
MAX_TTL_SECONDS = 604800
|
34
|
+
|
35
|
+
|
31
36
|
class AttachmentType(str, EnumType):
|
32
37
|
"""
|
33
38
|
Enum for attachment types. Indicates attachment usage.
|
@@ -122,6 +127,11 @@ class Attachment(Base):
|
|
122
127
|
"""Returns the content type of the attachment."""
|
123
128
|
return AllowedFileType[self.file_name.split(".")[-1]].value
|
124
129
|
|
130
|
+
@property
|
131
|
+
def file_key(self) -> str:
|
132
|
+
"""Returns the file key of the attachment."""
|
133
|
+
return f"{self.id}/{self.file_name}"
|
134
|
+
|
125
135
|
def upload(self, attachment: IO[bytes]) -> None:
|
126
136
|
"""Uploads an attachment to S3, GCS, or local storage."""
|
127
137
|
if self.config.type == StorageType.s3:
|
@@ -130,7 +140,7 @@ class Attachment(Base):
|
|
130
140
|
generic_upload_to_s3(
|
131
141
|
storage_secrets=self.config.secrets,
|
132
142
|
bucket_name=bucket_name,
|
133
|
-
file_key=
|
143
|
+
file_key=self.file_key,
|
134
144
|
document=attachment,
|
135
145
|
auth_method=auth_method,
|
136
146
|
)
|
@@ -142,7 +152,7 @@ class Attachment(Base):
|
|
142
152
|
auth_method = self.config.details[StorageDetails.AUTH_METHOD.value]
|
143
153
|
storage_client = get_gcs_client(auth_method, self.config.secrets)
|
144
154
|
bucket = storage_client.bucket(bucket_name)
|
145
|
-
blob = bucket.blob(
|
155
|
+
blob = bucket.blob(self.file_key)
|
146
156
|
|
147
157
|
# Reset the file pointer to the beginning
|
148
158
|
try:
|
@@ -155,7 +165,7 @@ class Attachment(Base):
|
|
155
165
|
return
|
156
166
|
|
157
167
|
if self.config.type == StorageType.local:
|
158
|
-
filename = get_local_filename(
|
168
|
+
filename = get_local_filename(self.file_key)
|
159
169
|
|
160
170
|
# Validate that attachment is a file-like object
|
161
171
|
if not hasattr(attachment, "read"):
|
@@ -205,9 +215,10 @@ class Attachment(Base):
|
|
205
215
|
size, url = generic_retrieve_from_s3(
|
206
216
|
storage_secrets=self.config.secrets,
|
207
217
|
bucket_name=bucket_name,
|
208
|
-
file_key=
|
218
|
+
file_key=self.file_key,
|
209
219
|
auth_method=auth_method,
|
210
220
|
get_content=False,
|
221
|
+
ttl_seconds=MAX_TTL_SECONDS,
|
211
222
|
)
|
212
223
|
return size, url
|
213
224
|
|
@@ -216,19 +227,20 @@ class Attachment(Base):
|
|
216
227
|
auth_method = self.config.details[StorageDetails.AUTH_METHOD.value]
|
217
228
|
storage_client = get_gcs_client(auth_method, self.config.secrets)
|
218
229
|
bucket = storage_client.bucket(bucket_name)
|
219
|
-
blob = bucket.blob(
|
230
|
+
blob = bucket.blob(self.file_key)
|
220
231
|
|
221
232
|
# Ensure we have the blob metadata
|
222
233
|
blob.reload()
|
234
|
+
# Expiration is set to 7 days
|
223
235
|
url = blob.generate_signed_url(
|
224
236
|
version="v4",
|
225
|
-
expiration=
|
237
|
+
expiration=MAX_TTL_SECONDS,
|
226
238
|
method="GET",
|
227
239
|
)
|
228
240
|
return blob.size, url
|
229
241
|
|
230
242
|
if self.config.type == StorageType.local:
|
231
|
-
filename = get_local_filename(
|
243
|
+
filename = get_local_filename(self.file_key)
|
232
244
|
size = os.path.getsize(filename)
|
233
245
|
return size, filename
|
234
246
|
|
@@ -236,7 +248,7 @@ class Attachment(Base):
|
|
236
248
|
|
237
249
|
def retrieve_attachment_content(
|
238
250
|
self,
|
239
|
-
) -> Tuple[int, bytes]:
|
251
|
+
) -> Tuple[int, IO[bytes]]:
|
240
252
|
"""
|
241
253
|
Retrieves the size of the attachment and its actual content.
|
242
254
|
- For s3:
|
@@ -252,30 +264,33 @@ class Attachment(Base):
|
|
252
264
|
if self.config.type == StorageType.s3:
|
253
265
|
bucket_name = f"{self.config.details[StorageDetails.BUCKET.value]}"
|
254
266
|
auth_method = self.config.details[StorageDetails.AUTH_METHOD.value]
|
255
|
-
size,
|
267
|
+
size, fileobj = generic_retrieve_from_s3(
|
256
268
|
storage_secrets=self.config.secrets,
|
257
269
|
bucket_name=bucket_name,
|
258
|
-
file_key=
|
270
|
+
file_key=self.file_key,
|
259
271
|
auth_method=auth_method,
|
260
272
|
get_content=True,
|
261
273
|
)
|
262
|
-
return size,
|
274
|
+
return size, fileobj
|
263
275
|
|
264
276
|
if self.config.type == StorageType.gcs:
|
265
277
|
bucket_name = f"{self.config.details[StorageDetails.BUCKET.value]}"
|
266
278
|
auth_method = self.config.details[StorageDetails.AUTH_METHOD.value]
|
267
279
|
storage_client = get_gcs_client(auth_method, self.config.secrets)
|
268
280
|
bucket = storage_client.bucket(bucket_name)
|
269
|
-
blob = bucket.blob(
|
281
|
+
blob = bucket.blob(self.file_key)
|
270
282
|
|
271
|
-
|
272
|
-
|
283
|
+
fileobj = BytesIO()
|
284
|
+
blob.download_to_file(fileobj)
|
285
|
+
fileobj.seek(0) # Reset pointer to beginning after download
|
286
|
+
return blob.size, fileobj
|
273
287
|
|
274
288
|
if self.config.type == StorageType.local:
|
275
|
-
filename = get_local_filename(
|
276
|
-
|
277
|
-
|
278
|
-
|
289
|
+
filename = get_local_filename(self.file_key)
|
290
|
+
size = os.path.getsize(filename)
|
291
|
+
with open(filename, "rb") as fileobj:
|
292
|
+
content = BytesIO(fileobj.read())
|
293
|
+
content.seek(0) # Reset pointer to beginning
|
279
294
|
return size, content
|
280
295
|
|
281
296
|
raise ValueError(f"Unsupported storage type: {self.config.type}")
|
@@ -288,7 +303,7 @@ class Attachment(Base):
|
|
288
303
|
generic_delete_from_s3(
|
289
304
|
storage_secrets=self.config.secrets,
|
290
305
|
bucket_name=bucket_name,
|
291
|
-
file_key=
|
306
|
+
file_key=self.file_key,
|
292
307
|
auth_method=auth_method,
|
293
308
|
)
|
294
309
|
return
|
@@ -307,9 +322,7 @@ class Attachment(Base):
|
|
307
322
|
return
|
308
323
|
|
309
324
|
if self.config.type == StorageType.local:
|
310
|
-
folder_path = os.path.dirname(
|
311
|
-
get_local_filename(f"{self.id}/{self.file_name}")
|
312
|
-
)
|
325
|
+
folder_path = os.path.dirname(get_local_filename(self.file_key))
|
313
326
|
if os.path.exists(folder_path):
|
314
327
|
import shutil
|
315
328
|
|
@@ -0,0 +1,110 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
from sqlalchemy import Column, DateTime, ForeignKey, String
|
4
|
+
from sqlalchemy.ext.declarative import declared_attr
|
5
|
+
from sqlalchemy.orm import Session, relationship
|
6
|
+
|
7
|
+
from fides.api.db.base_class import Base
|
8
|
+
from fides.api.db.util import EnumColumn
|
9
|
+
from fides.api.models.manual_tasks.manual_task_log import ManualTaskLog
|
10
|
+
from fides.api.schemas.manual_tasks.manual_task_schemas import (
|
11
|
+
ManualTaskLogStatus,
|
12
|
+
ManualTaskParentEntityType,
|
13
|
+
ManualTaskReferenceType,
|
14
|
+
ManualTaskType,
|
15
|
+
)
|
16
|
+
|
17
|
+
|
18
|
+
class ManualTask(Base):
|
19
|
+
"""Model for storing manual tasks.
|
20
|
+
|
21
|
+
This model can be used for both privacy request tasks and general tasks.
|
22
|
+
For privacy requests, it replaces the functionality of manual webhooks.
|
23
|
+
For other use cases, it provides a flexible task management system.
|
24
|
+
|
25
|
+
There can only be one ManualTask per parent entity.
|
26
|
+
You can create multiple Configs for the same ManualTask.
|
27
|
+
"""
|
28
|
+
|
29
|
+
@declared_attr
|
30
|
+
def __tablename__(cls) -> str:
|
31
|
+
"""Overriding base class method to set the table name."""
|
32
|
+
return "manual_task"
|
33
|
+
|
34
|
+
# Database columns
|
35
|
+
task_type = Column(
|
36
|
+
EnumColumn(ManualTaskType),
|
37
|
+
nullable=False,
|
38
|
+
default=ManualTaskType.privacy_request,
|
39
|
+
)
|
40
|
+
parent_entity_id = Column(String, nullable=False)
|
41
|
+
parent_entity_type = Column(
|
42
|
+
EnumColumn(ManualTaskParentEntityType),
|
43
|
+
nullable=False,
|
44
|
+
default=ManualTaskParentEntityType.connection_config,
|
45
|
+
)
|
46
|
+
due_date = Column(DateTime, nullable=True)
|
47
|
+
|
48
|
+
# Relationships
|
49
|
+
references = relationship(
|
50
|
+
"ManualTaskReference",
|
51
|
+
back_populates="task",
|
52
|
+
uselist=True,
|
53
|
+
cascade="all, delete-orphan",
|
54
|
+
)
|
55
|
+
logs = relationship(
|
56
|
+
"ManualTaskLog",
|
57
|
+
back_populates="task",
|
58
|
+
primaryjoin="and_(ManualTask.id == ManualTaskLog.task_id)",
|
59
|
+
viewonly=True,
|
60
|
+
order_by="ManualTaskLog.created_at",
|
61
|
+
)
|
62
|
+
|
63
|
+
# Properties
|
64
|
+
@property
|
65
|
+
def assigned_users(self) -> list[str]:
|
66
|
+
"""Get all users assigned to this task."""
|
67
|
+
if not self.references:
|
68
|
+
return []
|
69
|
+
return [
|
70
|
+
ref.reference_id
|
71
|
+
for ref in self.references
|
72
|
+
if ref.reference_type == ManualTaskReferenceType.assigned_user
|
73
|
+
]
|
74
|
+
|
75
|
+
# CRUD Operations
|
76
|
+
@classmethod
|
77
|
+
def create(
|
78
|
+
cls, db: Session, *, data: dict[str, Any], check_name: bool = True
|
79
|
+
) -> "ManualTask":
|
80
|
+
"""Create a new manual task."""
|
81
|
+
task = super().create(db=db, data=data, check_name=check_name)
|
82
|
+
ManualTaskLog.create_log(
|
83
|
+
db=db,
|
84
|
+
task_id=task.id,
|
85
|
+
status=ManualTaskLogStatus.created,
|
86
|
+
message=f"Created manual task for {data['task_type']}",
|
87
|
+
)
|
88
|
+
return task
|
89
|
+
|
90
|
+
|
91
|
+
class ManualTaskReference(Base):
|
92
|
+
"""Join table to associate manual tasks with multiple references.
|
93
|
+
|
94
|
+
A single task may have many references including privacy requests, configurations, and assigned users.
|
95
|
+
"""
|
96
|
+
|
97
|
+
@declared_attr
|
98
|
+
def __tablename__(cls) -> str:
|
99
|
+
"""Overriding base class method to set the table name."""
|
100
|
+
return "manual_task_reference"
|
101
|
+
|
102
|
+
# Database columns
|
103
|
+
task_id = Column(
|
104
|
+
String, ForeignKey("manual_task.id", ondelete="CASCADE"), nullable=False
|
105
|
+
)
|
106
|
+
reference_id = Column(String, nullable=False)
|
107
|
+
reference_type = Column(EnumColumn(ManualTaskReferenceType), nullable=False)
|
108
|
+
|
109
|
+
# Relationships
|
110
|
+
task = relationship("ManualTask", back_populates="references")
|
@@ -0,0 +1,100 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Any, Optional
|
2
|
+
|
3
|
+
from sqlalchemy import Column, ForeignKey, String
|
4
|
+
from sqlalchemy.dialects.postgresql import JSONB
|
5
|
+
from sqlalchemy.ext.declarative import declared_attr
|
6
|
+
from sqlalchemy.orm import Session, relationship
|
7
|
+
|
8
|
+
from fides.api.db.base_class import Base
|
9
|
+
from fides.api.schemas.manual_tasks.manual_task_schemas import ManualTaskLogStatus
|
10
|
+
|
11
|
+
if TYPE_CHECKING:
|
12
|
+
from fides.api.models.manual_tasks.manual_task import ManualTask
|
13
|
+
|
14
|
+
|
15
|
+
class ManualTaskLog(Base):
|
16
|
+
"""Model for storing manual task execution logs."""
|
17
|
+
|
18
|
+
@declared_attr
|
19
|
+
def __tablename__(cls) -> str:
|
20
|
+
"""Overriding base class method to set the table name."""
|
21
|
+
return "manual_task_log"
|
22
|
+
|
23
|
+
task_id = Column(
|
24
|
+
String, ForeignKey("manual_task.id", ondelete="CASCADE"), nullable=False
|
25
|
+
)
|
26
|
+
# TODO: Add foreign key constraints when config and instance are implemented
|
27
|
+
config_id = Column(String, nullable=True)
|
28
|
+
instance_id = Column(String, nullable=True)
|
29
|
+
status = Column(String, nullable=False)
|
30
|
+
message = Column(String, nullable=True)
|
31
|
+
details = Column(JSONB, nullable=True)
|
32
|
+
|
33
|
+
# Relationships - using string references to avoid circular imports
|
34
|
+
task = relationship("ManualTask", back_populates="logs", foreign_keys=[task_id])
|
35
|
+
# TODO: Add config and instance relationships when they are implemented
|
36
|
+
# config = relationship("ManualTaskConfig", back_populates="logs")
|
37
|
+
# instance = relationship("ManualTaskInstance", back_populates="logs")
|
38
|
+
|
39
|
+
@classmethod
|
40
|
+
def create_log(
|
41
|
+
cls,
|
42
|
+
db: Session,
|
43
|
+
status: ManualTaskLogStatus,
|
44
|
+
task_id: str,
|
45
|
+
config_id: Optional[str] = None,
|
46
|
+
instance_id: Optional[str] = None,
|
47
|
+
message: Optional[str] = None,
|
48
|
+
details: Optional[dict[str, Any]] = None,
|
49
|
+
) -> "ManualTaskLog":
|
50
|
+
"""Create a new task log entry.
|
51
|
+
|
52
|
+
Args:
|
53
|
+
db: Database session
|
54
|
+
task_id: ID of the task
|
55
|
+
status: Status of the log entry
|
56
|
+
message: Optional message describing the event
|
57
|
+
details: Optional additional details about the event
|
58
|
+
"""
|
59
|
+
data = {
|
60
|
+
"task_id": task_id,
|
61
|
+
"config_id": config_id,
|
62
|
+
"instance_id": instance_id,
|
63
|
+
"status": status,
|
64
|
+
"message": message,
|
65
|
+
"details": details,
|
66
|
+
}
|
67
|
+
return cls.create(db=db, data=data)
|
68
|
+
|
69
|
+
@classmethod
|
70
|
+
def create_error_log(
|
71
|
+
cls,
|
72
|
+
db: Session,
|
73
|
+
task_id: str,
|
74
|
+
message: str,
|
75
|
+
config_id: Optional[str] = None,
|
76
|
+
instance_id: Optional[str] = None,
|
77
|
+
details: Optional[dict[str, Any]] = None,
|
78
|
+
) -> "ManualTaskLog":
|
79
|
+
"""Create a new error log entry.
|
80
|
+
|
81
|
+
Args:
|
82
|
+
db: Database session
|
83
|
+
task_id: ID of the task
|
84
|
+
message: Error message describing what went wrong
|
85
|
+
config_id: Optional ID of the configuration
|
86
|
+
instance_id: Optional ID of the instance
|
87
|
+
details: Optional additional details about the error
|
88
|
+
|
89
|
+
Returns:
|
90
|
+
The created error log entry
|
91
|
+
"""
|
92
|
+
return cls.create_log(
|
93
|
+
db=db,
|
94
|
+
status=ManualTaskLogStatus.error,
|
95
|
+
task_id=task_id,
|
96
|
+
config_id=config_id,
|
97
|
+
instance_id=instance_id,
|
98
|
+
message=message,
|
99
|
+
details=details,
|
100
|
+
)
|
File without changes
|
@@ -0,0 +1,79 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from enum import Enum
|
3
|
+
from typing import Annotated, Any, Optional
|
4
|
+
|
5
|
+
from pydantic import ConfigDict, Field
|
6
|
+
|
7
|
+
from fides.api.schemas.base_class import FidesSchema
|
8
|
+
|
9
|
+
|
10
|
+
class ManualTaskType(str, Enum):
|
11
|
+
"""Enum for manual task types."""
|
12
|
+
|
13
|
+
privacy_request = "privacy_request"
|
14
|
+
# Add more task types as needed
|
15
|
+
|
16
|
+
|
17
|
+
class ManualTaskParentEntityType(str, Enum):
|
18
|
+
"""Enum for manual task parent entity types."""
|
19
|
+
|
20
|
+
connection_config = (
|
21
|
+
"connection_config" # used for access and erasure privacy requests
|
22
|
+
)
|
23
|
+
# Add more parent entity types as needed
|
24
|
+
|
25
|
+
|
26
|
+
class ManualTaskReferenceType(str, Enum):
|
27
|
+
"""Enum for manual task reference types."""
|
28
|
+
|
29
|
+
privacy_request = "privacy_request"
|
30
|
+
connection_config = "connection_config"
|
31
|
+
manual_task_config = "manual_task_config"
|
32
|
+
assigned_user = "assigned_user" # Reference to the user assigned to the task
|
33
|
+
# Add more reference types as needed
|
34
|
+
|
35
|
+
|
36
|
+
class ManualTaskLogStatus(str, Enum):
|
37
|
+
"""Enum for manual task log status."""
|
38
|
+
|
39
|
+
created = "created"
|
40
|
+
updated = "updated"
|
41
|
+
in_processing = "in_processing"
|
42
|
+
complete = "complete"
|
43
|
+
error = "error"
|
44
|
+
retrying = "retrying"
|
45
|
+
paused = "paused"
|
46
|
+
awaiting_input = "awaiting_input"
|
47
|
+
|
48
|
+
|
49
|
+
class ManualTaskLogCreate(FidesSchema):
|
50
|
+
"""Schema for creating a manual task log entry."""
|
51
|
+
|
52
|
+
model_config = ConfigDict(extra="forbid")
|
53
|
+
|
54
|
+
task_id: Annotated[str, Field(..., description="ID of the task")]
|
55
|
+
status: Annotated[ManualTaskLogStatus, Field(..., description="Log status")]
|
56
|
+
message: Annotated[Optional[str], Field(None, description="Log message")]
|
57
|
+
details: Annotated[
|
58
|
+
Optional[dict[str, Any]], Field(None, description="Additional details")
|
59
|
+
]
|
60
|
+
config_id: Annotated[Optional[str], Field(None, description="Configuration ID")]
|
61
|
+
instance_id: Annotated[Optional[str], Field(None, description="Instance ID")]
|
62
|
+
|
63
|
+
|
64
|
+
class ManualTaskLogResponse(FidesSchema):
|
65
|
+
"""Schema for manual task log response."""
|
66
|
+
|
67
|
+
model_config = ConfigDict(extra="forbid")
|
68
|
+
|
69
|
+
id: Annotated[str, Field(..., description="Log ID")]
|
70
|
+
task_id: Annotated[str, Field(..., description="Task ID")]
|
71
|
+
status: Annotated[ManualTaskLogStatus, Field(..., description="Log status")]
|
72
|
+
message: Annotated[Optional[str], Field(None, description="Log message")]
|
73
|
+
details: Annotated[
|
74
|
+
Optional[dict[str, Any]], Field(None, description="Additional details")
|
75
|
+
]
|
76
|
+
config_id: Annotated[Optional[str], Field(None, description="Configuration ID")]
|
77
|
+
instance_id: Annotated[Optional[str], Field(None, description="Instance ID")]
|
78
|
+
created_at: Annotated[datetime, Field(..., description="Creation timestamp")]
|
79
|
+
updated_at: Annotated[datetime, Field(..., description="Last update timestamp")]
|