Skip to content

Commit e99f396

Browse files
committed
Allow @fields to include protected properties, document @Protected
query param.
1 parent b174982 commit e99f396

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

doc/rest.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,10 @@ operation on ``https://.../rest/data/issue``.
414414
warnings about this below. Using this for collections is
415415
discouraged as it is slow and produces a lot of data.
416416
* - ``@fields=status,title``
417-
- will return the ``status`` and ``title`` fields for the issue displayed
418-
according to the @verbose parameter
417+
- will return the ``status`` and ``title`` fields for the
418+
displayed issues. It is added to the fields returned by the
419+
@verbose parameter. Protected properties
420+
can be included in the list and will be returned.
419421

420422
In addition collections support the ``@fields`` parameter which is a
421423
colon or comma separated list of fields to embed in the response. For
@@ -642,7 +644,13 @@ By default all (visible to the current user) attributes/properties are
642644
returned. You can limit this by using the ``@fields`` query parameter
643645
similar to how it is used in collections. This way you can only return
644646
the fields you are interested in reducing network load as well as
645-
memory and parsing time on the client side.
647+
memory and parsing time on the client side. By default protected
648+
properties (read only in the database) are not listed. Th
649+
is makes it easier to submit the attributes from a
650+
``@verbose=0`` query using PUT. To include protected properties
651+
in the output og a GET add the query parameter
652+
``@protected=true`` to the query and attributes like: actor,
653+
created, creator and activity will be include in the result.
646654

647655
Link and Multilink properties are displayed as a dictionary with a
648656
``link`` and an ``id`` property by default. This is controlled by the

roundup/rest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,10 @@ def get_collection(self, class_name, input):
656656
f = value.split(",")
657657
if len(f) == 1:
658658
f=value.split(":")
659+
allprops=class_obj.getprops(protected=True)
659660
for i in f:
660661
try:
661-
display_props[i] = class_obj.properties[i]
662+
display_props[i] = allprops[i]
662663
except KeyError as err:
663664
raise UsageError("Failed to find property '%s' "
664665
"for class %s."%(i, class_name))
@@ -821,9 +822,10 @@ def get_element(self, class_name, item_id, input):
821822
f=value.split(",")
822823
if len(f) == 1:
823824
f=value.split(":")
825+
allprops=class_obj.getprops(protected=True)
824826
for i in f:
825827
try:
826-
props[i] = class_obj.properties[i]
828+
props[i] = allprops[i]
827829
except KeyError as err:
828830
raise UsageError("Failed to find property '%s' for class %s."%(i, class_name))
829831
elif key == "@protected":

0 commit comments

Comments
 (0)