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(as.ConfigGet, ctx, nil)
36 func (as *APIStub) Login(ctx context.Context, options arvados.LoginOptions) (arvados.LoginResponse, error) {
37 as.appendCall(as.Login, ctx, options)
38 return arvados.LoginResponse{}, as.Error
40 func (as *APIStub) Logout(ctx context.Context, options arvados.LogoutOptions) (arvados.LogoutResponse, error) {
41 as.appendCall(as.Logout, ctx, options)
42 return arvados.LogoutResponse{}, as.Error
44 func (as *APIStub) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
45 as.appendCall(as.CollectionCreate, ctx, options)
46 return arvados.Collection{}, as.Error
48 func (as *APIStub) CollectionUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Collection, error) {
49 as.appendCall(as.CollectionUpdate, ctx, options)
50 return arvados.Collection{}, as.Error
52 func (as *APIStub) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
53 as.appendCall(as.CollectionGet, ctx, options)
54 return arvados.Collection{}, as.Error
56 func (as *APIStub) CollectionList(ctx context.Context, options arvados.ListOptions) (arvados.CollectionList, error) {
57 as.appendCall(as.CollectionList, ctx, 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(as.CollectionProvenance, ctx, options)
64 func (as *APIStub) CollectionUsedBy(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
65 as.appendCall(as.CollectionUsedBy, ctx, options)
68 func (as *APIStub) CollectionDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
69 as.appendCall(as.CollectionDelete, ctx, options)
70 return arvados.Collection{}, as.Error
72 func (as *APIStub) CollectionTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
73 as.appendCall(as.CollectionTrash, ctx, options)
74 return arvados.Collection{}, as.Error
76 func (as *APIStub) CollectionUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Collection, error) {
77 as.appendCall(as.CollectionUntrash, ctx, options)
78 return arvados.Collection{}, as.Error
80 func (as *APIStub) ContainerCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Container, error) {
81 as.appendCall(as.ContainerCreate, ctx, options)
82 return arvados.Container{}, as.Error
84 func (as *APIStub) ContainerUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Container, error) {
85 as.appendCall(as.ContainerUpdate, ctx, options)
86 return arvados.Container{}, as.Error
88 func (as *APIStub) ContainerGet(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
89 as.appendCall(as.ContainerGet, ctx, options)
90 return arvados.Container{}, as.Error
92 func (as *APIStub) ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) {
93 as.appendCall(as.ContainerList, ctx, options)
94 return arvados.ContainerList{}, as.Error
96 func (as *APIStub) ContainerDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Container, error) {
97 as.appendCall(as.ContainerDelete, ctx, options)
98 return arvados.Container{}, as.Error
100 func (as *APIStub) ContainerLock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
101 as.appendCall(as.ContainerLock, ctx, options)
102 return arvados.Container{}, as.Error
104 func (as *APIStub) ContainerUnlock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
105 as.appendCall(as.ContainerUnlock, ctx, options)
106 return arvados.Container{}, as.Error
108 func (as *APIStub) SpecimenCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Specimen, error) {
109 as.appendCall(as.SpecimenCreate, ctx, options)
110 return arvados.Specimen{}, as.Error
112 func (as *APIStub) SpecimenUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Specimen, error) {
113 as.appendCall(as.SpecimenUpdate, ctx, options)
114 return arvados.Specimen{}, as.Error
116 func (as *APIStub) SpecimenGet(ctx context.Context, options arvados.GetOptions) (arvados.Specimen, error) {
117 as.appendCall(as.SpecimenGet, ctx, options)
118 return arvados.Specimen{}, as.Error
120 func (as *APIStub) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
121 as.appendCall(as.SpecimenList, ctx, options)
122 return arvados.SpecimenList{}, as.Error
124 func (as *APIStub) SpecimenDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Specimen, error) {
125 as.appendCall(as.SpecimenDelete, ctx, options)
126 return arvados.Specimen{}, as.Error
128 func (as *APIStub) UserCreate(ctx context.Context, options arvados.CreateOptions) (arvados.User, error) {
129 as.appendCall(as.UserCreate, ctx, options)
130 return arvados.User{}, as.Error
132 func (as *APIStub) UserUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.User, error) {
133 as.appendCall(as.UserUpdate, ctx, options)
134 return arvados.User{}, as.Error
136 func (as *APIStub) UserUpdateUUID(ctx context.Context, options arvados.UpdateUUIDOptions) (arvados.User, error) {
137 as.appendCall(as.UserUpdateUUID, ctx, options)
138 return arvados.User{}, as.Error
140 func (as *APIStub) UserActivate(ctx context.Context, options arvados.UserActivateOptions) (arvados.User, error) {
141 as.appendCall(as.UserActivate, ctx, options)
142 return arvados.User{}, as.Error
144 func (as *APIStub) UserSetup(ctx context.Context, options arvados.UserSetupOptions) (map[string]interface{}, error) {
145 as.appendCall(as.UserSetup, ctx, options)
148 func (as *APIStub) UserUnsetup(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
149 as.appendCall(as.UserUnsetup, ctx, options)
150 return arvados.User{}, as.Error
152 func (as *APIStub) UserGet(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
153 as.appendCall(as.UserGet, ctx, options)
154 return arvados.User{}, as.Error
156 func (as *APIStub) UserGetCurrent(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
157 as.appendCall(as.UserGetCurrent, ctx, options)
158 return arvados.User{}, as.Error
160 func (as *APIStub) UserGetSystem(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
161 as.appendCall(as.UserGetSystem, ctx, options)
162 return arvados.User{}, as.Error
164 func (as *APIStub) UserList(ctx context.Context, options arvados.ListOptions) (arvados.UserList, error) {
165 as.appendCall(as.UserList, ctx, options)
166 return arvados.UserList{}, as.Error
168 func (as *APIStub) UserDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.User, error) {
169 as.appendCall(as.UserDelete, ctx, options)
170 return arvados.User{}, as.Error
172 func (as *APIStub) UserMerge(ctx context.Context, options arvados.UserMergeOptions) (arvados.User, error) {
173 as.appendCall(as.UserMerge, ctx, options)
174 return arvados.User{}, as.Error
176 func (as *APIStub) UserBatchUpdate(ctx context.Context, options arvados.UserBatchUpdateOptions) (arvados.UserList, error) {
177 as.appendCall(as.UserBatchUpdate, ctx, options)
178 return arvados.UserList{}, as.Error
180 func (as *APIStub) UserAuthenticate(ctx context.Context, options arvados.UserAuthenticateOptions) (arvados.APIClientAuthorization, error) {
181 as.appendCall(as.UserAuthenticate, ctx, options)
182 return arvados.APIClientAuthorization{}, as.Error
184 func (as *APIStub) APIClientAuthorizationCurrent(ctx context.Context, options arvados.GetOptions) (arvados.APIClientAuthorization, error) {
185 as.appendCall(as.APIClientAuthorizationCurrent, ctx, options)
186 return arvados.APIClientAuthorization{}, as.Error
189 func (as *APIStub) appendCall(method interface{}, ctx context.Context, options interface{}) {
191 defer as.mtx.Unlock()
192 as.calls = append(as.calls, APIStubCall{method, ctx, options})
195 func (as *APIStub) Calls(method interface{}) []APIStubCall {
197 defer as.mtx.Unlock()
198 var calls []APIStubCall
199 for _, call := range as.calls {
200 if method == nil || (runtime.FuncForPC(reflect.ValueOf(call.Method).Pointer()).Name() ==
201 runtime.FuncForPC(reflect.ValueOf(method).Pointer()).Name()) {
202 calls = append(calls, call)
208 type APIStubCall struct {
210 Context context.Context