@@ -197,8 +197,10 @@ def index(self, request, **kwargs):
197197 # GET /v2.0/{obj_resource}/{obj_resource_id}/tags
198198 ctx = request .context
199199 rinfo = self ._get_resource_info (ctx , kwargs )
200- policy .enforce (ctx , f'get_{ rinfo .obj_type } _{ TAGS } ' ,
201- rinfo .obj )
200+ policy .enforce (
201+ ctx ,
202+ self ._get_policy_action ("get" , rinfo .obj_type ),
203+ rinfo .obj )
202204 return self .plugin .get_tags (ctx , rinfo .obj_type , rinfo .obj ['id' ])
203205
204206 def show (self , request , id , ** kwargs ):
@@ -207,8 +209,10 @@ def show(self, request, id, **kwargs):
207209 validate_tag (id )
208210 ctx = request .context
209211 rinfo = self ._get_resource_info (ctx , kwargs )
210- policy .enforce (ctx , f'get_{ rinfo .obj_type } :{ TAGS } ' ,
211- rinfo .obj )
212+ policy .enforce (
213+ ctx ,
214+ self ._get_policy_action ("get" , rinfo .obj_type ),
215+ rinfo .obj )
212216 return self .plugin .get_tag (ctx , rinfo .obj_type , rinfo .obj ['id' ], id )
213217
214218 def create (self , request , body , ** kwargs ):
@@ -217,8 +221,10 @@ def create(self, request, body, **kwargs):
217221 validate_tags (body )
218222 ctx = request .context
219223 rinfo = self ._get_resource_info (ctx , kwargs , tags = body [TAGS ])
220- policy .enforce (ctx , f'create_{ rinfo .obj_type } :{ TAGS } ' ,
221- rinfo .obj )
224+ policy .enforce (
225+ ctx ,
226+ self ._get_policy_action ("create" , rinfo .obj_type ),
227+ rinfo .obj )
222228 validate_tags_limit (rinfo .obj_type , body ['tags' ])
223229 notify_tag_action (ctx , 'create.start' , rinfo .obj_type ,
224230 rinfo .obj ['id' ], body ['tags' ])
@@ -234,8 +240,10 @@ def update(self, request, id, **kwargs):
234240 validate_tag (id )
235241 ctx = request .context
236242 rinfo = self ._get_resource_info (ctx , kwargs , tags = [id ])
237- policy .enforce (ctx , f'update_{ rinfo .obj_type } :{ TAGS } ' ,
238- rinfo .obj )
243+ policy .enforce (
244+ ctx ,
245+ self ._get_policy_action ("update" , rinfo .obj_type ),
246+ rinfo .obj )
239247 current_tags = self .plugin .get_tags (
240248 ctx , rinfo .obj_type , rinfo .obj ['id' ])['tags' ]
241249 new_tags = current_tags + [id ]
0 commit comments