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

Add function to provide read-only of the current request #493

Merged
merged 6 commits into from
Jul 12, 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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Brewtils Changelog
------
TBD

- Exposed a read only feature to provide the current request that is being processed `from brewtils import get_current_request_read_only`
- Expand Job Export to include Job id

3.26.3
Expand Down
7 changes: 6 additions & 1 deletion brewtils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from brewtils.config import get_argument_parser, get_connection_info, load_config
from brewtils.decorators import client, command, parameter, subscribe, system
from brewtils.log import configure_logging
from brewtils.plugin import Plugin, RemotePlugin # noqa F401
from brewtils.plugin import (
get_current_request_read_only,
Plugin,
RemotePlugin,
) # noqa F401
from brewtils.rest import normalize_url_prefix
from brewtils.rest.easy_client import EasyClient, get_easy_client
from brewtils.rest.publish_client import PublishClient
Expand All @@ -28,6 +32,7 @@
"configure_logging",
"normalize_url_prefix",
"AutoDecorator",
"get_current_request_read_only",
]

# Aliased for compatibility
Expand Down
10 changes: 10 additions & 0 deletions brewtils/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import copy
import json
import logging
import logging.config
Expand Down Expand Up @@ -46,6 +47,15 @@
CONFIG = Box(default_box=True)


def get_current_request_read_only():
"""Read-Only instance of Current Request

Returns a copy of the current request, modifications to this object
do not impact the actual current request
"""
return copy.deepcopy(request_context.current_request)


class Plugin(object):
"""A Beer-garden Plugin

Expand Down
Loading