Skip to content

Commit

Permalink
CLI: Upload object with additional tags (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored Nov 15, 2024
1 parent 1d0d259 commit faaa0f4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# -- Project information -----------------------------------------------------

project = 'mwdblib'
copyright = '2022, CERT Polska'
copyright = '2024, CERT Polska'
author = 'CERT Polska'

# The full version, including alpha/beta/rc tags
Expand Down
2 changes: 1 addition & 1 deletion mwdblib/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.5.0"
__version__ = "4.6.0"
25 changes: 22 additions & 3 deletions mwdblib/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def upload_params(fn):
@click.option(
"--share-with", default=None, help="Share object with specified group"
)
@click.option(
"--tag",
multiple=True,
help="Add specified tag to the object",
default=[],
)
@functools.wraps(fn)
def upload_wrapped_command(*args, **kwargs):
if (
Expand Down Expand Up @@ -66,7 +72,7 @@ def upload_wrapped_command(*args, **kwargs):
@upload_params
@confirm_action
@pass_mwdb
def upload_file(mwdb, file, name, parent, private, public, share_with):
def upload_file(mwdb, file, name, parent, private, public, share_with, tag):
"""Upload file object"""
with click.open_file(file, "rb") as f:
content = f.read()
Expand All @@ -78,6 +84,7 @@ def upload_file(mwdb, file, name, parent, private, public, share_with):
private=private,
public=public,
share_with=share_with,
tags=tag,
)
return dict(message="Uploaded file {object_id}", object_id=obj.id)

Expand All @@ -90,7 +97,15 @@ def upload_file(mwdb, file, name, parent, private, public, share_with):
@confirm_action
@pass_mwdb
def upload_config(
mwdb, family, config_file, config_type, parent, private, public, share_with
mwdb,
family,
config_file,
config_type,
parent,
private,
public,
share_with,
tag,
):
"""Upload config object"""
import json
Expand All @@ -105,6 +120,7 @@ def upload_config(
private=private,
public=public,
share_with=share_with,
tags=tag,
)
return dict(message="Uploaded config {object_id}", object_id=obj.id)

Expand All @@ -120,7 +136,9 @@ def upload_config(
@upload_params
@confirm_action
@pass_mwdb
def upload_blob(mwdb, blob_type, blob_file, name, parent, private, public, share_with):
def upload_blob(
mwdb, blob_type, blob_file, name, parent, private, public, share_with, tag
):
"""Upload blob object"""
with click.open_file(blob_file, "rb") as f:
content = f.read()
Expand All @@ -133,5 +151,6 @@ def upload_blob(mwdb, blob_type, blob_file, name, parent, private, public, share
private=private,
public=public,
share_with=share_with,
tags=tag,
)
return dict(message="Uploaded blob {object_id}", object_id=obj.id)

0 comments on commit faaa0f4

Please sign in to comment.