17119: First take: add groups endpoints to controller.
[arvados.git] / lib / controller / federation / generated.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package federation
6
7 import (
8         "context"
9         "sort"
10         "sync"
11         "sync/atomic"
12
13         "git.arvados.org/arvados.git/sdk/go/arvados"
14 )
15
16 //
17 // -- this file is auto-generated -- do not edit -- edit list.go and run "go generate" instead --
18 //
19
20 func (conn *Conn) generated_ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) {
21         var mtx sync.Mutex
22         var merged arvados.ContainerList
23         var needSort atomic.Value
24         needSort.Store(false)
25         err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) {
26                 options.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
27                 cl, err := backend.ContainerList(ctx, options)
28                 if err != nil {
29                         return nil, err
30                 }
31                 mtx.Lock()
32                 defer mtx.Unlock()
33                 if len(merged.Items) == 0 {
34                         merged = cl
35                 } else if len(cl.Items) > 0 {
36                         merged.Items = append(merged.Items, cl.Items...)
37                         needSort.Store(true)
38                 }
39                 uuids := make([]string, 0, len(cl.Items))
40                 for _, item := range cl.Items {
41                         uuids = append(uuids, item.UUID)
42                 }
43                 return uuids, nil
44         })
45         if needSort.Load().(bool) {
46                 // Apply the default/implied order, "modified_at desc"
47                 sort.Slice(merged.Items, func(i, j int) bool {
48                         mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt
49                         return mj.Before(mi)
50                 })
51         }
52         if merged.Items == nil {
53                 // Return empty results as [], not null
54                 // (https://github.com/golang/go/issues/27589 might be
55                 // a better solution in the future)
56                 merged.Items = []arvados.Container{}
57         }
58         return merged, err
59 }
60
61 func (conn *Conn) generated_ContainerRequestList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerRequestList, error) {
62         var mtx sync.Mutex
63         var merged arvados.ContainerRequestList
64         var needSort atomic.Value
65         needSort.Store(false)
66         err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) {
67                 options.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
68                 cl, err := backend.ContainerRequestList(ctx, options)
69                 if err != nil {
70                         return nil, err
71                 }
72                 mtx.Lock()
73                 defer mtx.Unlock()
74                 if len(merged.Items) == 0 {
75                         merged = cl
76                 } else if len(cl.Items) > 0 {
77                         merged.Items = append(merged.Items, cl.Items...)
78                         needSort.Store(true)
79                 }
80                 uuids := make([]string, 0, len(cl.Items))
81                 for _, item := range cl.Items {
82                         uuids = append(uuids, item.UUID)
83                 }
84                 return uuids, nil
85         })
86         if needSort.Load().(bool) {
87                 // Apply the default/implied order, "modified_at desc"
88                 sort.Slice(merged.Items, func(i, j int) bool {
89                         mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt
90                         return mj.Before(mi)
91                 })
92         }
93         if merged.Items == nil {
94                 // Return empty results as [], not null
95                 // (https://github.com/golang/go/issues/27589 might be
96                 // a better solution in the future)
97                 merged.Items = []arvados.ContainerRequest{}
98         }
99         return merged, err
100 }
101
102 func (conn *Conn) generated_GroupList(ctx context.Context, options arvados.ListOptions) (arvados.GroupList, error) {
103         var mtx sync.Mutex
104         var merged arvados.GroupList
105         var needSort atomic.Value
106         needSort.Store(false)
107         err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) {
108                 options.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
109                 cl, err := backend.GroupList(ctx, options)
110                 if err != nil {
111                         return nil, err
112                 }
113                 mtx.Lock()
114                 defer mtx.Unlock()
115                 if len(merged.Items) == 0 {
116                         merged = cl
117                 } else if len(cl.Items) > 0 {
118                         merged.Items = append(merged.Items, cl.Items...)
119                         needSort.Store(true)
120                 }
121                 uuids := make([]string, 0, len(cl.Items))
122                 for _, item := range cl.Items {
123                         uuids = append(uuids, item.UUID)
124                 }
125                 return uuids, nil
126         })
127         if needSort.Load().(bool) {
128                 // Apply the default/implied order, "modified_at desc"
129                 sort.Slice(merged.Items, func(i, j int) bool {
130                         mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt
131                         return mj.Before(mi)
132                 })
133         }
134         if merged.Items == nil {
135                 // Return empty results as [], not null
136                 // (https://github.com/golang/go/issues/27589 might be
137                 // a better solution in the future)
138                 merged.Items = []arvados.Group{}
139         }
140         return merged, err
141 }
142
143 func (conn *Conn) generated_SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
144         var mtx sync.Mutex
145         var merged arvados.SpecimenList
146         var needSort atomic.Value
147         needSort.Store(false)
148         err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) {
149                 options.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
150                 cl, err := backend.SpecimenList(ctx, options)
151                 if err != nil {
152                         return nil, err
153                 }
154                 mtx.Lock()
155                 defer mtx.Unlock()
156                 if len(merged.Items) == 0 {
157                         merged = cl
158                 } else if len(cl.Items) > 0 {
159                         merged.Items = append(merged.Items, cl.Items...)
160                         needSort.Store(true)
161                 }
162                 uuids := make([]string, 0, len(cl.Items))
163                 for _, item := range cl.Items {
164                         uuids = append(uuids, item.UUID)
165                 }
166                 return uuids, nil
167         })
168         if needSort.Load().(bool) {
169                 // Apply the default/implied order, "modified_at desc"
170                 sort.Slice(merged.Items, func(i, j int) bool {
171                         mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt
172                         return mj.Before(mi)
173                 })
174         }
175         if merged.Items == nil {
176                 // Return empty results as [], not null
177                 // (https://github.com/golang/go/issues/27589 might be
178                 // a better solution in the future)
179                 merged.Items = []arvados.Specimen{}
180         }
181         return merged, err
182 }
183
184 func (conn *Conn) generated_UserList(ctx context.Context, options arvados.ListOptions) (arvados.UserList, error) {
185         var mtx sync.Mutex
186         var merged arvados.UserList
187         var needSort atomic.Value
188         needSort.Store(false)
189         err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) {
190                 options.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
191                 cl, err := backend.UserList(ctx, options)
192                 if err != nil {
193                         return nil, err
194                 }
195                 mtx.Lock()
196                 defer mtx.Unlock()
197                 if len(merged.Items) == 0 {
198                         merged = cl
199                 } else if len(cl.Items) > 0 {
200                         merged.Items = append(merged.Items, cl.Items...)
201                         needSort.Store(true)
202                 }
203                 uuids := make([]string, 0, len(cl.Items))
204                 for _, item := range cl.Items {
205                         uuids = append(uuids, item.UUID)
206                 }
207                 return uuids, nil
208         })
209         if needSort.Load().(bool) {
210                 // Apply the default/implied order, "modified_at desc"
211                 sort.Slice(merged.Items, func(i, j int) bool {
212                         mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt
213                         return mj.Before(mi)
214                 })
215         }
216         if merged.Items == nil {
217                 // Return empty results as [], not null
218                 // (https://github.com/golang/go/issues/27589 might be
219                 // a better solution in the future)
220                 merged.Items = []arvados.User{}
221         }
222         return merged, err
223 }