Skip to content

Commit

Permalink
Drop: metakeys API (#1006)
Browse files Browse the repository at this point in the history
* Drop: metakeys

* Remove metakey remnants
  • Loading branch information
psrok1 authored Dec 16, 2024
1 parent f4b7652 commit 4e11814
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 985 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
10 changes: 0 additions & 10 deletions mwdb/model/attribute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from string import Template

from flask import g
from sqlalchemy import cast, func
from sqlalchemy.dialects.postgresql import JSONB
Expand Down Expand Up @@ -35,14 +33,6 @@ class Attribute(db.Model):
value = db.Column(JSONB, nullable=False)
template = db.relationship("AttributeDefinition", lazy="joined")

@property
def url(self):
# deprecated, left for metakey compatibility
if self.template.url_template:
s = Template(self.template.url_template)
return s.safe_substitute(value=self.value)
return None

@property
def label(self):
return self.template.label
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
5 changes: 1 addition & 4 deletions mwdb/resources/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ def post(self):
content: "blob contents"
parent: null
upload_as: "*"
metakeys:
- key: string
value: string
attributes:
- key: string
value: string
Expand All @@ -164,7 +161,7 @@ def post(self):
403:
description: |
No permissions to perform additional operations
(e.g. adding metakeys)
(e.g. adding attributes)
404:
description: Specified group doesn't exist
409:
Expand Down
5 changes: 1 addition & 4 deletions mwdb/resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ def post(self):
config_type: static
parent: null
upload_as: "*"
metakeys:
- key: string
value: string
attributes:
- key: string
value: string
Expand All @@ -280,7 +277,7 @@ def post(self):
403:
description: |
No permissions to perform additional operations
(e.g. adding parent, metakeys)
(e.g. adding parent, attributes)
404:
description: |
One of attribute keys doesn't exist
Expand Down
4 changes: 0 additions & 4 deletions mwdb/resources/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ def post(self):
type: array
items:
$ref: '#/components/schemas/AttributeItemRequest'
metakeys:
type: array
items:
$ref: '#/components/schemas/MetakeyItemRequest'
tags:
type: array
items:
Expand Down
Loading

0 comments on commit 4e11814

Please sign in to comment.