@@ -15,15 +15,37 @@ def run(self, endpoint_uri, http_verb, get_detail_route_eligible, fail_non_2xx,
1515 StackStorm action entry point.
1616 """
1717 if http_verb == "get" :
18- if kwargs .get ("id" , False ) and get_detail_route_eligible :
19- # modify the `endpoint_uri` to use the detail route
20- endpoint_uri = "{}{}/" .format (endpoint_uri , str (kwargs .pop ("id" )))
21- self .logger .debug (
22- "endpoint_uri transformed to {} because id was passed" .format (endpoint_uri )
23- )
18+ if get_detail_route_eligible and "id" in kwargs :
19+ id_param = kwargs ["id" ]
20+ # Scalar or 1-elem list -> detail route; multi-elem list -> list filter
21+ if isinstance (id_param , (list , tuple )):
22+ if len (id_param ) == 1 :
23+ detail_id = id_param [0 ]
24+ kwargs .pop ("id" )
25+ endpoint_uri = "{}{}/" .format (endpoint_uri , str (detail_id ))
26+ self .logger .debug (
27+ "endpoint_uri transformed to {} (single id from list)" .format (
28+ endpoint_uri
29+ )
30+ )
31+ # else: len > 1 -> keep id in kwargs for list filter, no endpoint change
32+ else :
33+ # scalar id -> detail route
34+ detail_id = kwargs .pop ("id" )
35+ endpoint_uri = "{}{}/" .format (endpoint_uri , str (detail_id ))
36+ self .logger .debug (
37+ "endpoint_uri transformed to {} because id was passed" .format (
38+ endpoint_uri
39+ )
40+ )
2441
25- if kwargs .get ("save_in_key_store" ) and not kwargs .get ("save_in_key_store_key_name" ):
26- return (False , "save_in_key_store_key_name MUST be used with save_in_key_store!" )
42+ if kwargs .get ("save_in_key_store" ) and not kwargs .get (
43+ "save_in_key_store_key_name"
44+ ):
45+ return (
46+ False ,
47+ "save_in_key_store_key_name MUST be used with save_in_key_store!" ,
48+ )
2749
2850 result = self .make_request (endpoint_uri , http_verb , ** kwargs )
2951
@@ -38,7 +60,9 @@ def run(self, endpoint_uri, http_verb, get_detail_route_eligible, fail_non_2xx,
3860 key_name = kwargs ["save_in_key_store_key_name" ]
3961 client .keys .update (
4062 KeyValuePair (
41- name = key_name , value = json .dumps (result ), ttl = kwargs ["save_in_key_store_ttl" ]
63+ name = key_name ,
64+ value = json .dumps (result ),
65+ ttl = kwargs ["save_in_key_store_ttl" ],
4266 )
4367 )
4468
0 commit comments