Skip to content

Commit

Permalink
client: add startswith filter to available params
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Oct 18, 2023
1 parent 5a4d12b commit ee1c6fa
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mpcontribs-client/mpcontribs/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,11 @@ def _get_future(
setattr(future, "track_id", track_id)
return future

def available_query_params(self, resource="contributions"):
def available_query_params(
self,
startswith: tuple = None,
resource: str = "contributions"
) -> list:
resources = self.swagger_spec.resources
resource_obj = resources.get(resource)
if not resource_obj:
Expand All @@ -962,7 +966,14 @@ def available_query_params(self, resource="contributions"):

op_key = f"query{resource.capitalize()}"
operation = resource_obj.operations[op_key]
return [param.name for param in operation.params.values()]
params = [param.name for param in operation.params.values()]
if not startswith:
return params

return [
param for param in params
if param.startswith(startswith)
]

def get_project(self, name: str = None, fields: list = None) -> Type[Dict]:
"""Retrieve a project entry
Expand Down

0 comments on commit ee1c6fa

Please sign in to comment.