Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Upload object with additional tags #99

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading