1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
16 "git.arvados.org/arvados.git/sdk/go/arvados"
19 var ErrStubUnimplemented = errors.New("stub unimplemented")
22 // The error to return from every stubbed API method.
28 // BaseURL implements federation.backend
29 func (as *APIStub) BaseURL() url.URL {
30 return url.URL{Scheme: "https", Host: "apistub.example.com"}
32 func (as *APIStub) ConfigGet(ctx context.Context) (json.RawMessage, error) {
33 as.appendCall(ctx, as.ConfigGet, nil)
36 func (as *APIStub) Login(ctx context.Context, options arvados.LoginOptions) (arvados.LoginResponse, error) {
37 as.appendCall(ctx, as.Login, options)
38 return arvados.LoginResponse{}, as.Error
40 func (as *APIStub) Logout(ctx context.Context, options arvados.LogoutOptions) (arvados.LogoutResponse, error) {
41 as.appendCall(ctx, as.Logout, options)
42 return arvados.LogoutResponse{}, as.Error
44 func (as *APIStub) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
45 as.appendCall(ctx, as.CollectionCreate, options)
46 return arvados.Collection{}, as.Error
48 func (as *APIStub) CollectionUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Collection, error) {
49 as.appendCall(ctx, as.CollectionUpdate, options)
50 return arvados.Collection{}, as.Error
52 func (as *APIStub) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
53 as.appendCall(ctx, as.CollectionGet, options)
54 return arvados.Collection{}, as.Error
56 func (as *APIStub) CollectionList(ctx context.Context, options arvados.ListOptions) (arvados.CollectionList, error) {
57 as.appendCall(ctx, as.CollectionList, options)
58 return arvados.CollectionList{}, as.Error
60 func (as *APIStub) CollectionProvenance(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
61 as.appendCall(ctx, as.CollectionProvenance, options)
64 func (as *APIStub) CollectionUsedBy(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
65 as.appendCall(ctx, as.CollectionUsedBy, options)
68 func (as *APIStub) CollectionDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
69 as.appendCall(ctx, as.CollectionDelete, options)
70 return arvados.Collection{}, as.Error
72 func (as *APIStub) CollectionTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
73 as.appendCall(ctx, as.CollectionTrash, options)
74 return arvados.Collection{}, as.Error
76 func (as *APIStub) CollectionUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Collection, error) {
77 as.appendCall(ctx, as.CollectionUntrash, options)
78 return arvados.Collection{}, as.Error
80 func (as *APIStub) ContainerCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Container, error) {
81 as.appendCall(ctx, as.ContainerCreate, options)
82 return arvados.Container{}, as.Error
84 func (as *APIStub) ContainerUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Container, error) {
85 as.appendCall(ctx, as.ContainerUpdate, options)
86 return arvados.Container{}, as.Error
88 func (as *APIStub) ContainerGet(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
89 as.appendCall(ctx, as.ContainerGet, options)
90 return arvados.Container{}, as.Error
92 func (as *APIStub) ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) {
93 as.appendCall(ctx, as.ContainerList, options)
94 return arvados.ContainerList{}, as.Error
96 func (as *APIStub) ContainerDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Container, error) {
97 as.appendCall(ctx, as.ContainerDelete, options)
98 return arvados.Container{}, as.Error
100 func (as *APIStub) ContainerLock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
101 as.appendCall(ctx, as.ContainerLock, options)
102 return arvados.Container{}, as.Error
104 func (as *APIStub) ContainerUnlock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
105 as.appendCall(ctx, as.ContainerUnlock, options)
106 return arvados.Container{}, as.Error
108 func (as *APIStub) ContainerSSH(ctx context.Context, options arvados.ContainerSSHOptions) (arvados.ContainerSSHConnection, error) {
109 as.appendCall(ctx, as.ContainerSSH, options)
110 return arvados.ContainerSSHConnection{}, as.Error
112 func (as *APIStub) ContainerRequestCreate(ctx context.Context, options arvados.CreateOptions) (arvados.ContainerRequest, error) {
113 as.appendCall(ctx, as.ContainerRequestCreate, options)
114 return arvados.ContainerRequest{}, as.Error
116 func (as *APIStub) ContainerRequestUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.ContainerRequest, error) {
117 as.appendCall(ctx, as.ContainerRequestUpdate, options)
118 return arvados.ContainerRequest{}, as.Error
120 func (as *APIStub) ContainerRequestGet(ctx context.Context, options arvados.GetOptions) (arvados.ContainerRequest, error) {
121 as.appendCall(ctx, as.ContainerRequestGet, options)
122 return arvados.ContainerRequest{}, as.Error
124 func (as *APIStub) ContainerRequestList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerRequestList, error) {
125 as.appendCall(ctx, as.ContainerRequestList, options)
126 return arvados.ContainerRequestList{}, as.Error
128 func (as *APIStub) ContainerRequestDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.ContainerRequest, error) {
129 as.appendCall(ctx, as.ContainerRequestDelete, options)
130 return arvados.ContainerRequest{}, as.Error
132 func (as *APIStub) SpecimenCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Specimen, error) {
133 as.appendCall(ctx, as.SpecimenCreate, options)
134 return arvados.Specimen{}, as.Error
136 func (as *APIStub) SpecimenUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Specimen, error) {
137 as.appendCall(ctx, as.SpecimenUpdate, options)
138 return arvados.Specimen{}, as.Error
140 func (as *APIStub) SpecimenGet(ctx context.Context, options arvados.GetOptions) (arvados.Specimen, error) {
141 as.appendCall(ctx, as.SpecimenGet, options)
142 return arvados.Specimen{}, as.Error
144 func (as *APIStub) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
145 as.appendCall(ctx, as.SpecimenList, options)
146 return arvados.SpecimenList{}, as.Error
148 func (as *APIStub) SpecimenDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Specimen, error) {
149 as.appendCall(ctx, as.SpecimenDelete, options)
150 return arvados.Specimen{}, as.Error
152 func (as *APIStub) UserCreate(ctx context.Context, options arvados.CreateOptions) (arvados.User, error) {
153 as.appendCall(ctx, as.UserCreate, options)
154 return arvados.User{}, as.Error
156 func (as *APIStub) UserUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.User, error) {
157 as.appendCall(ctx, as.UserUpdate, options)
158 return arvados.User{}, as.Error
160 func (as *APIStub) UserUpdateUUID(ctx context.Context, options arvados.UpdateUUIDOptions) (arvados.User, error) {
161 as.appendCall(ctx, as.UserUpdateUUID, options)
162 return arvados.User{}, as.Error
164 func (as *APIStub) UserActivate(ctx context.Context, options arvados.UserActivateOptions) (arvados.User, error) {
165 as.appendCall(ctx, as.UserActivate, options)
166 return arvados.User{}, as.Error
168 func (as *APIStub) UserSetup(ctx context.Context, options arvados.UserSetupOptions) (map[string]interface{}, error) {
169 as.appendCall(ctx, as.UserSetup, options)
172 func (as *APIStub) UserUnsetup(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
173 as.appendCall(ctx, as.UserUnsetup, options)
174 return arvados.User{}, as.Error
176 func (as *APIStub) UserGet(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
177 as.appendCall(ctx, as.UserGet, options)
178 return arvados.User{}, as.Error
180 func (as *APIStub) UserGetCurrent(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
181 as.appendCall(ctx, as.UserGetCurrent, options)
182 return arvados.User{}, as.Error
184 func (as *APIStub) UserGetSystem(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
185 as.appendCall(ctx, as.UserGetSystem, options)
186 return arvados.User{}, as.Error
188 func (as *APIStub) UserList(ctx context.Context, options arvados.ListOptions) (arvados.UserList, error) {
189 as.appendCall(ctx, as.UserList, options)
190 return arvados.UserList{}, as.Error
192 func (as *APIStub) UserDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.User, error) {
193 as.appendCall(ctx, as.UserDelete, options)
194 return arvados.User{}, as.Error
196 func (as *APIStub) UserMerge(ctx context.Context, options arvados.UserMergeOptions) (arvados.User, error) {
197 as.appendCall(ctx, as.UserMerge, options)
198 return arvados.User{}, as.Error
200 func (as *APIStub) UserBatchUpdate(ctx context.Context, options arvados.UserBatchUpdateOptions) (arvados.UserList, error) {
201 as.appendCall(ctx, as.UserBatchUpdate, options)
202 return arvados.UserList{}, as.Error
204 func (as *APIStub) UserAuthenticate(ctx context.Context, options arvados.UserAuthenticateOptions) (arvados.APIClientAuthorization, error) {
205 as.appendCall(ctx, as.UserAuthenticate, options)
206 return arvados.APIClientAuthorization{}, as.Error
208 func (as *APIStub) APIClientAuthorizationCurrent(ctx context.Context, options arvados.GetOptions) (arvados.APIClientAuthorization, error) {
209 as.appendCall(ctx, as.APIClientAuthorizationCurrent, options)
210 return arvados.APIClientAuthorization{}, as.Error
213 func (as *APIStub) appendCall(ctx context.Context, method interface{}, options interface{}) {
215 defer as.mtx.Unlock()
216 as.calls = append(as.calls, APIStubCall{method, ctx, options})
219 func (as *APIStub) Calls(method interface{}) []APIStubCall {
221 defer as.mtx.Unlock()
222 var calls []APIStubCall
223 for _, call := range as.calls {
224 if method == nil || (runtime.FuncForPC(reflect.ValueOf(call.Method).Pointer()).Name() ==
225 runtime.FuncForPC(reflect.ValueOf(method).Pointer()).Name()) {
226 calls = append(calls, call)
232 type APIStubCall struct {
234 Context context.Context