Merge branch '8784-dir-listings'
[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         Limit        *int     `json:"limit,omitempty"`
16         Offset       int      `json:"offset,omitempty"`
17         Order        string   `json:"order,omitempty"`
18         Distinct     bool     `json:"distinct,omitempty"`
19         Count        string   `json:"count,omitempty"`
20 }
21
22 // A Filter restricts the set of records returned by a list/index API.
23 type Filter struct {
24         Attr     string
25         Operator string
26         Operand  interface{}
27 }
28
29 // MarshalJSON encodes a Filter in the form expected by the API.
30 func (f *Filter) MarshalJSON() ([]byte, error) {
31         return json.Marshal([]interface{}{f.Attr, f.Operator, f.Operand})
32 }