Skip to content

Commit

Permalink
Drop: metakeys
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Dec 16, 2024
1 parent f4b7652 commit f99a6fd
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 951 deletions.
18 changes: 0 additions & 18 deletions mwdb/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@
)
from mwdb.resources.group import GroupListResource, GroupMemberResource, GroupResource
from mwdb.resources.karton import KartonAnalysisResource, KartonObjectResource
from mwdb.resources.metakey import (
MetakeyDefinitionManageResource,
MetakeyListDefinitionManageResource,
MetakeyListDefinitionResource,
MetakeyPermissionResource,
MetakeyResource,
)
from mwdb.resources.metrics import MetricsResource
from mwdb.resources.oauth import (
OpenIDAccountIdentitiesResource,
Expand Down Expand Up @@ -319,17 +312,6 @@ def apply_rate_limit():
api.add_resource(AttributeDefinitionResource, "/attribute/<key>")
api.add_resource(AttributePermissionResource, "/attribute/<key>/permissions")

# Attribute (metakey) deprecated endpoints
api.add_resource(MetakeyListDefinitionResource, "/meta/list/<any(read, set):access>")
api.add_resource(
MetakeyResource, "/<any(file, config, blob, object):type>/<hash64:identifier>/meta"
)
api.add_resource(MetakeyListDefinitionManageResource, "/meta/manage")
api.add_resource(MetakeyDefinitionManageResource, "/meta/manage/<key>")
api.add_resource(
MetakeyPermissionResource, "/meta/manage/<key>/permissions/<group_name>"
)

# Karton endpoints
api.add_resource(
KartonObjectResource,
Expand Down
8 changes: 0 additions & 8 deletions mwdb/core/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class DeprecatedFeature(Enum):
# API keys non-complaint with RFC7519
# Deprecated in v2.7.0
legacy_api_key_v2 = "legacy_api_key_v2"
# Legacy Metakey API
# Use Attribute API instead
# Deprecated in v2.6.0
legacy_metakey_api = "legacy_metakey_api"
# Legacy Metakey API
# Use Attribute API instead
# Deprecated in v2.6.0
legacy_metakeys_upload_option = "legacy_metakeys_upload_option"


def uses_deprecated_api(
Expand Down
37 changes: 5 additions & 32 deletions mwdb/model/object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
from collections import namedtuple
from typing import Any, Dict, Optional
from uuid import UUID

Expand Down Expand Up @@ -577,7 +576,6 @@ def get_attributes(
as_dict=False,
check_permissions=True,
show_hidden=False,
show_karton=False,
):
"""
Gets all object attributes
Expand All @@ -587,7 +585,6 @@ def get_attributes(
:param check_permissions: |
Filter results including current user permissions (default: True)
:param show_hidden: Show hidden attributes
:param show_karton: Show Karton attributes (for compatibility)
"""
attributes = (
db.session.query(Attribute)
Expand All @@ -611,19 +608,6 @@ def get_attributes(

attributes = attributes.order_by(Attribute.id).all()

if show_karton:
KartonAttribute = namedtuple("KartonAttribute", ["key", "value"])

attributes += [
KartonAttribute(key="karton", value=str(analysis.id))
for analysis in (
db.session.query(KartonAnalysis)
.filter(KartonAnalysis.objects.any(id=self.id))
.order_by(KartonAnalysis.creation_time)
.all()
)
]

if not as_dict:
return attributes

Expand All @@ -635,23 +619,12 @@ def get_attributes(
return dict_attributes

def add_attribute(
self, key, value, commit=True, check_permissions=True, include_karton=True
self,
key,
value,
commit=True,
check_permissions=True,
):
if include_karton and key == "karton":
karton_id = UUID(value)

if check_permissions and not g.auth_user.has_rights(
Capabilities.karton_assign
):
# User doesn't have permissions to assign analysis
return None

_, is_new = self.assign_analysis(karton_id, commit=False)

if commit:
db.session.commit()
return is_new

if check_permissions:
attribute_definition = AttributeDefinition.query_for_set(key).first()
else:
Expand Down
2 changes: 1 addition & 1 deletion mwdb/resources/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def post(self, type, identifier):

key = obj["key"]
value = obj["value"]
is_new = db_object.add_attribute(key, value, include_karton=False)
is_new = db_object.add_attribute(key, value)
if is_new is None:
raise NotFound(
f"Attribute '{key}' is not defined or you have "
Expand Down
Loading

0 comments on commit f99a6fd

Please sign in to comment.