Skip to content

Commit

Permalink
allocations,jobs: Add trailing underscore to filter not to conflict w…
Browse files Browse the repository at this point in the history
…ith builtin filter function
  • Loading branch information
Kamil Cukrowski committed Jan 16, 2023
1 parent 07102da commit 155225c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions nomad/api/allocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def __iter__(self):
response = self.get_allocations()
return iter(response)

def get_allocations( # pylint: disable=redefined-builtin,too-many-arguments
def get_allocations( # pylint: disable=too-many-arguments
self,
prefix: Optional[str] = None,
filter: Optional[str] = None,
filter_: Optional[str] = None,
namespace: Optional[str] = None,
resources: Optional[bool] = None,
task_states: Optional[bool] = None,
Expand All @@ -49,7 +49,8 @@ def get_allocations( # pylint: disable=redefined-builtin,too-many-arguments
arguments:
- prefix :(str) optional, specifies a string to filter allocations on based on an prefix.
This is specified as a querystring parameter.
- filter :(str) optional
- filter_ :(str) optional
Name has a trailing underscore not to conflict with builtin function.
- namespace :(str) optional, specifies the target namespace. Specifying * would return all jobs.
This is specified as a querystring parameter.
- resources :(bool) optional
Expand All @@ -61,7 +62,7 @@ def get_allocations( # pylint: disable=redefined-builtin,too-many-arguments
"""
params = {
"prefix": prefix,
"filter": filter,
"filter": filter_,
"namespace": namespace,
"resources": resources,
"task_states": task_states,
Expand Down
9 changes: 5 additions & 4 deletions nomad/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def __iter__(self):
jobs = self.get_jobs()
return iter(jobs)

def get_jobs( # pylint: disable=redefined-builtin
def get_jobs(
self,
prefix: Optional[str] = None,
namespace: Optional[str] = None,
filter: Optional[str] = None,
filter_: Optional[str] = None,
meta: Optional[bool] = None,
):
"""Lists all the jobs registered with Nomad.
Expand All @@ -78,7 +78,8 @@ def get_jobs( # pylint: disable=redefined-builtin
This is specified as a querystring parameter.
- namespace :(str) optional, specifies the target namespace. Specifying * would return all jobs.
This is specified as a querystring parameter.
- filter :(str) optional, specifies the expression used to filter the result.
- filter_ :(str) optional, specifies the expression used to filter the result.
Name has a trailing underscore not to conflict with builtin function.
- meta :(bool) optional, if set, jobs returned will include a meta field containing
key-value pairs provided in the job specification's meta block.
returns: list
Expand All @@ -89,7 +90,7 @@ def get_jobs( # pylint: disable=redefined-builtin
params = {
"prefix": prefix,
"namespace": namespace,
"filter": filter,
"filter": filter_,
"meta": meta,
}
return self.request(method="get", params=params).json()
Expand Down

0 comments on commit 155225c

Please sign in to comment.