Skip to content

Commit

Permalink
go api: add resources option to allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
robinovitch61 committed Nov 13, 2023
1 parent 1c9c75c commit 9202785
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ type QueryOptions struct {
// Currently only supported by specific endpoints.
Reverse bool

// Resources specifies whether to include the AllocatedResources
// field in the response.
Resources bool

// ctx is an optional context pass through to the underlying HTTP
// request layer. Use Context() and WithContext() to manage this.
ctx context.Context
Expand Down Expand Up @@ -713,6 +717,9 @@ func (r *request) setQueryOptions(q *QueryOptions) {
if q.Reverse {
r.params.Set("reverse", "true")
}
if q.Resources {
r.params.Set("resources", "true")
}
for k, v := range q.Params {
r.params.Set(k, v)
}
Expand Down
2 changes: 2 additions & 0 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func TestSetQueryOptions(t *testing.T) {
WaitTime: 100 * time.Second,
AuthToken: "foobar",
Reverse: true,
Resources: true,
}
r.setQueryOptions(q)

Expand All @@ -185,6 +186,7 @@ func TestSetQueryOptions(t *testing.T) {
try("index", "1000")
try("wait", "100000ms")
try("reverse", "true")
try("resources", "true")
}

func TestQueryOptionsContext(t *testing.T) {
Expand Down

0 comments on commit 9202785

Please sign in to comment.