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

Method get_all

st2api/st2api/controllers/v1/keyvalue.py:138–318  ·  view source on GitHub ↗

List all keys. Handles requests: GET /keys/

(
        self,
        requester_user,
        prefix=None,
        scope=None,
        user=None,
        decrypt=False,
        sort=None,
        offset=0,
        limit=None,
        **raw_filters,
    )

Source from the content-addressed store, hash-verified

136 return kvp_api
137
138 def get_all(
139 self,
140 requester_user,
141 prefix=None,
142 scope=None,
143 user=None,
144 decrypt=False,
145 sort=None,
146 offset=0,
147 limit=None,
148 **raw_filters,
149 ):
150 """
151 List all keys.
152
153 Handles requests:
154 GET /keys/
155 """
156 if not scope:
157 # Default to system scope
158 scope = FULL_SYSTEM_SCOPE
159
160 if user:
161 # Providing a user implies a user scope
162 scope = FULL_USER_SCOPE
163
164 if not requester_user:
165 requester_user = UserDB(name=cfg.CONF.system_user.user)
166
167 scope = get_datastore_full_scope(scope)
168
169 if scope not in [ALL_SCOPE] + ALLOWED_SCOPES:
170 raise ValueError("Invalid scope: %s" % (scope))
171
172 # User needs to be either admin or requesting items for themselves
173 self._validate_decrypt_query_parameter(
174 decrypt=decrypt, scope=scope, requester_user=requester_user
175 )
176
177 current_user = requester_user.name
178 user = user or requester_user.name
179
180 rbac_utils = get_rbac_backend().get_utils_class()
181
182 # Validate that the authenticated user is admin if user query param is provided
183 rbac_utils.assert_user_is_admin_if_user_query_param_is_provided(
184 user_db=requester_user, user=user, require_rbac=True
185 )
186
187 from_model_kwargs = {"mask_secrets": not decrypt}
188
189 if scope and scope not in ALL_SCOPE:
190 self._validate_scope(scope=scope)
191 raw_filters["scope"] = scope
192
193 # Check if user is granted one of the system roles.
194 has_system_role = rbac_utils.user_has_system_role(user_db=requester_user)
195

Callers

nothing calls this directly

Calls 14

_validate_scopeMethod · 0.95
UserDBClass · 0.90
get_datastore_full_scopeFunction · 0.90
get_rbac_backendFunction · 0.90
KeyValuePairDBClass · 0.90
get_key_referenceFunction · 0.90
get_utils_classMethod · 0.45
user_has_system_roleMethod · 0.45

Tested by

no test coverage detected