File tree Expand file tree Collapse file tree 4 files changed +19
-1
lines changed
st2api/st2api/controllers Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ class ActionsController(resource.ContentPackResourceControler):
3939 'sort' : ['pack' , 'name' ]
4040 }
4141
42+ include_reference = True
43+
4244 @staticmethod
4345 def _get_by_id (action_id ):
4446 try :
Original file line number Diff line number Diff line change @@ -93,9 +93,21 @@ def _get_all(self, **kwargs):
9393
9494
9595class ContentPackResourceControler (ResourceController ):
96+ include_reference = False
97+
9698 @jsexpose ()
9799 def get_all (self , ** kwargs ):
98- return self ._get_all (** kwargs )
100+ result = self ._get_all (** kwargs )
101+ result = result or []
102+
103+ if self .include_reference :
104+ for item in result :
105+ pack = getattr (item , 'pack' , None )
106+ name = getattr (item , 'name' , None )
107+
108+ item .ref = ResourceReference (pack = pack , name = name ).ref
109+
110+ return result
99111
100112 def _get_all (self , ** kwargs ):
101113 kwargs = self ._get_filters (** kwargs )
Original file line number Diff line number Diff line change @@ -20,3 +20,5 @@ class SensorTypeController(resource.ContentPackResourceControler):
2020 options = {
2121 'sort' : ['pack' , 'name' ]
2222 }
23+
24+ include_reference = True
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ class TriggerTypeController(resource.ContentPackResourceControler):
3131 'sort' : ['pack' , 'name' ]
3232 }
3333
34+ include_reference = True
35+
3436 @jsexpose (body = TriggerTypeAPI , status_code = http_client .CREATED )
3537 def post (self , triggertype ):
3638 """
You can’t perform that action at this time.
0 commit comments