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)
| 279 | |
| 280 | |
| 281 | def 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 | |
| 308 | def get_key_uids_for_user(user): |