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

Method get_one

st2api/st2api/controllers/v1/auth.py:58–90  ·  view source on GitHub ↗

List api keys. Handle: GET /apikeys/1

(self, api_key_id_or_key, requester_user, show_secrets=None)

Source from the content-addressed store, hash-verified

56 self.get_one_db_method = ApiKey.get_by_key_or_id
57
58 def get_one(self, api_key_id_or_key, requester_user, show_secrets=None):
59 """
60 List api keys.
61
62 Handle:
63 GET /apikeys/1
64 """
65 api_key_db = None
66 try:
67 api_key_db = ApiKey.get_by_key_or_id(api_key_id_or_key)
68 except ApiKeyNotFoundError:
69 msg = "ApiKey matching %s for reference and id not found." % (
70 api_key_id_or_key
71 )
72 LOG.exception(msg)
73 abort(http_client.NOT_FOUND, msg)
74
75 permission_type = PermissionType.API_KEY_VIEW
76 rbac_utils = get_rbac_backend().get_utils_class()
77 rbac_utils.assert_user_has_resource_db_permission(
78 user_db=requester_user,
79 resource_db=api_key_db,
80 permission_type=permission_type,
81 )
82
83 try:
84 mask_secrets = self._get_mask_secrets(
85 show_secrets=show_secrets, requester_user=requester_user
86 )
87 return ApiKeyAPI.from_model(api_key_db, mask_secrets=mask_secrets)
88 except (ValidationError, ValueError) as e:
89 LOG.exception("Failed to serialize API key.")
90 abort(http_client.INTERNAL_SERVER_ERROR, six.text_type(e))
91
92 @property
93 def max_limit(self):

Callers

nothing calls this directly

Calls 7

abortFunction · 0.90
get_rbac_backendFunction · 0.90
get_by_key_or_idMethod · 0.80
_get_mask_secretsMethod · 0.80
get_utils_classMethod · 0.45
from_modelMethod · 0.45

Tested by

no test coverage detected