mirror of
https://github.com/openkmip/pykmip
synced 2025-12-21 18:53:15 +00:00
Add ModifyAttribute support to the client
This change adds ModifyAttribute support to the ProxyKmipClient, leveraging the new generic request capability in the underlying KMIPProxy client. New unit tests have been added to cover the new client additions. Partially implements #547
This commit is contained in:
committed by
Peter Hamilton
parent
2d283e128c
commit
53308c346b
@@ -472,6 +472,44 @@ class ProxyKmipClient(object):
|
||||
|
||||
return response_payload.unique_identifier
|
||||
|
||||
@is_connected
|
||||
def modify_attribute(self, unique_identifier=None, **kwargs):
|
||||
"""
|
||||
Set an attribute on a KMIP managed object.
|
||||
|
||||
Args:
|
||||
unique_identifier (string): The ID of the managed object.
|
||||
**kwargs (various): A placeholder for attribute values used to
|
||||
identify the attribute to modify. For KMIP 1.0 - 1.4, the
|
||||
supported parameters are:
|
||||
attribute (struct): An Attribute object containing the
|
||||
name and index of the existing attribute and the
|
||||
new value for that attribute.
|
||||
For KMIP 2.0+, the supported parameters are:
|
||||
current_attribute (struct): A CurrentAttribute object
|
||||
containing the attribute to modify. Required if the
|
||||
attribute is multivalued.
|
||||
attribute_reference (struct): A NewAttribute object
|
||||
containing the new attribute value. Required.
|
||||
|
||||
Returns:
|
||||
string: The ID of the managed object the attribute was modified on.
|
||||
struct: An Attribute object representing the newly modified
|
||||
attribute. Only returned if used for KMIP 1.0 - 1.4 messages.
|
||||
"""
|
||||
request_payload = payloads.ModifyAttributeRequestPayload(
|
||||
unique_identifier=unique_identifier,
|
||||
attribute=kwargs.get("attribute"),
|
||||
current_attribute=kwargs.get("current_attribute"),
|
||||
new_attribute=kwargs.get("new_attribute")
|
||||
)
|
||||
response_payload = self.proxy.send_request_payload(
|
||||
enums.Operation.MODIFY_ATTRIBUTE,
|
||||
request_payload
|
||||
)
|
||||
|
||||
return response_payload.unique_identifier, response_payload.attribute
|
||||
|
||||
@is_connected
|
||||
def register(self, managed_object):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user