in uamqp/session.py [0:0]
def mgmt_request(self, message, operation, op_type=None, node=b'$management', **kwargs):
"""Run a request/response operation. These are frequently used for management
tasks against a $management node, however any node name can be specified
and the available options will depend on the target service.
:param message: The message to send in the management request.
:type message: ~uamqp.message.Message
:param operation: The type of operation to be performed. This value will
be service-specific, but common values include READ, CREATE and UPDATE.
This value will be added as an application property on the message.
:type operation: bytes
:param op_type: The type on which to carry out the operation. This will
be specific to the entities of the service. This value will be added as
an application property on the message.
:type op_type: bytes
:param node: The target node. Default is `b"$management"`.
:type node: bytes
:param timeout: Provide an optional timeout in milliseconds within which a response
to the management request must be received.
:type timeout: float
:param status_code_field: Provide an alternate name for the status code in the
response body which can vary between services due to the spec still being in draft.
The default is `b"statusCode"`.
:type status_code_field: bytes
:param description_fields: Provide an alternate name for the description in the
response body which can vary between services due to the spec still being in draft.
The default is `b"statusDescription"`.
:type description_fields: bytes
:param encoding: The encoding to use for parameters supplied as strings.
Default is 'UTF-8'
:type encoding: str
:rtype: ~uamqp.message.Message
"""
timeout = kwargs.pop('timeout', None) or 0
parse_response = kwargs.pop('callback', None)
try:
mgmt_link = self._mgmt_links[node]
except KeyError:
mgmt_link = mgmt_operation.MgmtOperation(self, target=node, **kwargs)
self._mgmt_links[node] = mgmt_link
while not mgmt_link.open and not mgmt_link.mgmt_error:
self._connection.work()
if mgmt_link.mgmt_error:
raise mgmt_link.mgmt_error
if mgmt_link.open != constants.MgmtOpenStatus.Ok:
raise errors.AMQPConnectionError("Failed to open mgmt link: {}".format(mgmt_link.open))
op_type = op_type or b'empty'
status, response, description = mgmt_link.execute(operation, op_type, message, timeout=timeout)
if parse_response:
return parse_response(status, response, description)
return response