mirror of
https://github.com/openkmip/pykmip
synced 2026-01-03 09:03:16 +00:00
Add offset and maximum item filtering for the Locate operation
This change updates Locate operation support in the PyKMIP server, allowing users to filter objects using the offset and maximum item constraints. The offset constraint tells the server how many matching items should be skipped before results are returned. The maximum items constraint tells the server how many matching items should be returned. Unit tests and integration tests have been added to test and verify the correctness of this feature. Additionally, the Locate demo scripts have also been updated to support offset and maximum item filtering. Simply use the "--offset-items" and "--maximum-items" flags to specify offset and maximum item values for the Locate script to filter on. Fixes #562
This commit is contained in:
committed by
Peter Hamilton
parent
4938f82772
commit
4a6a2eccc1
@@ -661,7 +661,7 @@ class ProxyKmipClient(object):
|
||||
|
||||
@is_connected
|
||||
def locate(self, maximum_items=None, storage_status_mask=None,
|
||||
object_group_member=None, attributes=None):
|
||||
object_group_member=None, attributes=None, offset_items=None):
|
||||
"""
|
||||
Search for managed objects, depending on the attributes specified in
|
||||
the request.
|
||||
@@ -669,6 +669,8 @@ class ProxyKmipClient(object):
|
||||
Args:
|
||||
maximum_items (integer): Maximum number of object identifiers the
|
||||
server MAY return.
|
||||
offset_items (integer): Number of object identifiers the server
|
||||
should skip before returning results.
|
||||
storage_status_mask (integer): A bit mask that indicates whether
|
||||
on-line or archived objects are to be searched.
|
||||
object_group_member (ObjectGroupMember): An enumeration that
|
||||
@@ -688,6 +690,9 @@ class ProxyKmipClient(object):
|
||||
if maximum_items is not None:
|
||||
if not isinstance(maximum_items, six.integer_types):
|
||||
raise TypeError("maximum_items must be an integer")
|
||||
if offset_items is not None:
|
||||
if not isinstance(offset_items, six.integer_types):
|
||||
raise TypeError("offset items must be an integer")
|
||||
if storage_status_mask is not None:
|
||||
if not isinstance(storage_status_mask, six.integer_types):
|
||||
raise TypeError("storage_status_mask must be an integer")
|
||||
@@ -705,8 +710,12 @@ class ProxyKmipClient(object):
|
||||
|
||||
# Search for managed objects and handle the results
|
||||
result = self.proxy.locate(
|
||||
maximum_items, storage_status_mask,
|
||||
object_group_member, attributes)
|
||||
maximum_items=maximum_items,
|
||||
offset_items=offset_items,
|
||||
storage_status_mask=storage_status_mask,
|
||||
object_group_member=object_group_member,
|
||||
attributes=attributes
|
||||
)
|
||||
|
||||
status = result.result_status.value
|
||||
if status == enums.ResultStatus.SUCCESS:
|
||||
|
||||
Reference in New Issue
Block a user