15720: Merge branch 'master' into 15720-fed-user-list
[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.curoverse.com/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                 cl, err := backend.ContainerList(ctx, options)
27                 if err != nil {
28                         return nil, err
29                 }
30                 mtx.Lock()
31                 defer mtx.Unlock()
32                 if len(merged.Items) == 0 {
33                         merged = cl
34                 } else if len(cl.Items) > 0 {
35                         merged.Items = append(merged.Items, cl.Items...)
36                         needSort.Store(true)
37                 }
38                 uuids := make([]string, 0, len(cl.Items))
39                 for _, item := range cl.Items {
40                         uuids = append(uuids, item.UUID)
41                 }
42                 return uuids, nil
43         })
44         if needSort.Load().(bool) {
45                 // Apply the default/implied order, "modified_at desc"
46                 sort.Slice(merged.Items, func(i, j int) bool {
47                         mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt
48                         return mj.Before(mi)
49                 })
50         }
51         if merged.Items == nil {
52                 // Return empty results as [], not null
53                 // (https://github.com/golang/go/issues/27589 might be
54                 // a better solution in the future)
55                 merged.Items = []arvados.Container{}
56         }
57         return merged, err
58 }
59
60 func (conn *Conn) generated_SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
61         var mtx sync.Mutex
62         var merged arvados.SpecimenList
63         var needSort atomic.Value
64         needSort.Store(false)
65         err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) {
66                 cl, err := backend.SpecimenList(ctx, options)
67                 if err != nil {
68                         return nil, err
69                 }
70                 mtx.Lock()
71                 defer mtx.Unlock()
72                 if len(merged.Items) == 0 {
73                         merged = cl
74                 } else if len(cl.Items) > 0 {
75                         merged.Items = append(merged.Items, cl.Items...)
76                         needSort.Store(true)
77                 }
78                 uuids := make([]string, 0, len(cl.Items))
79                 for _, item := range cl.Items {
80                         uuids = append(uuids, item.UUID)
81                 }
82                 return uuids, nil
83         })
84         if needSort.Load().(bool) {
85                 // Apply the default/implied order, "modified_at desc"
86                 sort.Slice(merged.Items, func(i, j int) bool {
87                         mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt
88                         return mj.Before(mi)
89                 })
90         }
91         if merged.Items == nil {
92                 // Return empty results as [], not null
93                 // (https://github.com/golang/go/issues/27589 might be
94                 // a better solution in the future)
95                 merged.Items = []arvados.Specimen{}
96         }
97         return merged, err
98 }
99
100 func (conn *Conn) generated_UserList(ctx context.Context, options arvados.ListOptions) (arvados.UserList, error) {
101         var mtx sync.Mutex
102         var merged arvados.UserList
103         err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) {
104                 cl, err := backend.UserList(ctx, options)
105                 if err != nil {
106                         return nil, err
107                 }
108                 mtx.Lock()
109                 defer mtx.Unlock()
110                 if len(merged.Items) == 0 {
111                         merged = cl
112                 } else {
113                         merged.Items = append(merged.Items, cl.Items...)
114                 }
115                 uuids := make([]string, 0, len(cl.Items))
116                 for _, item := range cl.Items {
117                         uuids = append(uuids, item.UUID)
118                 }
119                 return uuids, nil
120         })
121         sort.Slice(merged.Items, func(i, j int) bool { return merged.Items[i].UUID < merged.Items[j].UUID })
122         return merged, err
123 }