14ce098cfc1a54f0f0de74aa9cf60ca8274a693e
[arvados.git] / sdk / go / arvados / resource_list.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import "encoding/json"
8
9 // ResourceListParams expresses which results are requested in a
10 // list/index API.
11 type ResourceListParams struct {
12         Select             []string `json:"select,omitempty"`
13         Filters            []Filter `json:"filters,omitempty"`
14         IncludeTrash       bool     `json:"include_trash,omitempty"`
15         IncludeOldVersions bool     `json:"include_old_versions,omitempty"`
16         Limit              *int     `json:"limit,omitempty"`
17         Offset             int      `json:"offset,omitempty"`
18         Order              string   `json:"order,omitempty"`
19         Distinct           bool     `json:"distinct,omitempty"`
20         Count              string   `json:"count,omitempty"`
21 }
22
23 // A Filter restricts the set of records returned by a list/index API.
24 type Filter struct {
25         Attr     string
26         Operator string
27         Operand  interface{}
28 }
29
30 // MarshalJSON encodes a Filter in the form expected by the API.
31 func (f *Filter) MarshalJSON() ([]byte, error) {
32         return json.Marshal([]interface{}{f.Attr, f.Operator, f.Operand})
33 }