MCPcopy Create free account
hub / github.com/StackStorm/st2 / get_key_reference

Function get_key_reference

st2common/st2common/services/keyvalues.py:281–305  ·  view source on GitHub ↗

Given a key name and user this method returns a new name (string ref) to address the key value pair in the context of that user. :param user: User to whom key belongs. :type user: ``str`` :param name: Original name of the key. :type name: ``str`` :rtype: ``str``

(scope, name, user=None)

Source from the content-addressed store, hash-verified

279
280
281def get_key_reference(scope, name, user=None):
282 """
283 Given a key name and user this method returns a new name (string ref)
284 to address the key value pair in the context of that user.
285
286 :param user: User to whom key belongs.
287 :type user: ``str``
288
289 :param name: Original name of the key.
290 :type name: ``str``
291
292 :rtype: ``str``
293 """
294 if scope == SYSTEM_SCOPE or scope == FULL_SYSTEM_SCOPE:
295 return name
296 elif scope == USER_SCOPE or scope == FULL_USER_SCOPE:
297 if not user:
298 raise InvalidUserException(
299 "A valid user must be specified for user key ref."
300 )
301 return UserKeyReference(name=name, user=user).ref
302 else:
303 raise InvalidScopeException(
304 'Scope "%s" is not valid. Allowed scopes are %s.' % (scope, ALLOWED_SCOPES)
305 )
306
307
308def get_key_uids_for_user(user):

Callers 7

get_oneMethod · 0.90
get_allMethod · 0.90
putMethod · 0.90
deleteMethod · 0.90

Calls 3

UserKeyReferenceClass · 0.90