Skip to content

Commit

Permalink
Merge pull request #493 from beer-garden/Current_Request_Function
Browse files Browse the repository at this point in the history
Add function to provide read-only of the current request
  • Loading branch information
TheBurchLog authored Jul 12, 2024
2 parents 923835f + a1b263c commit 0a76c85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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

0 comments on commit 0a76c85

Please sign in to comment.