1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
16 "git.curoverse.com/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) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
41 as.appendCall(as.CollectionCreate, ctx, options)
42 return arvados.Collection{}, as.Error
44 func (as *APIStub) CollectionUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Collection, error) {
45 as.appendCall(as.CollectionUpdate, ctx, options)
46 return arvados.Collection{}, as.Error
48 func (as *APIStub) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
49 as.appendCall(as.CollectionGet, ctx, options)
50 return arvados.Collection{}, as.Error
52 func (as *APIStub) CollectionList(ctx context.Context, options arvados.ListOptions) (arvados.CollectionList, error) {
53 as.appendCall(as.CollectionList, ctx, options)
54 return arvados.CollectionList{}, as.Error
56 func (as *APIStub) CollectionProvenance(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
57 as.appendCall(as.CollectionProvenance, ctx, options)
60 func (as *APIStub) CollectionUsedBy(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
61 as.appendCall(as.CollectionUsedBy, ctx, options)
64 func (as *APIStub) CollectionDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
65 as.appendCall(as.CollectionDelete, ctx, options)
66 return arvados.Collection{}, as.Error
68 func (as *APIStub) CollectionTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
69 as.appendCall(as.CollectionTrash, ctx, options)
70 return arvados.Collection{}, as.Error
72 func (as *APIStub) CollectionUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Collection, error) {
73 as.appendCall(as.CollectionUntrash, ctx, options)
74 return arvados.Collection{}, as.Error
76 func (as *APIStub) ContainerCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Container, error) {
77 as.appendCall(as.ContainerCreate, ctx, options)
78 return arvados.Container{}, as.Error
80 func (as *APIStub) ContainerUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Container, error) {
81 as.appendCall(as.ContainerUpdate, ctx, options)
82 return arvados.Container{}, as.Error
84 func (as *APIStub) ContainerGet(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
85 as.appendCall(as.ContainerGet, ctx, options)
86 return arvados.Container{}, as.Error
88 func (as *APIStub) ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) {
89 as.appendCall(as.ContainerList, ctx, options)
90 return arvados.ContainerList{}, as.Error
92 func (as *APIStub) ContainerDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Container, error) {
93 as.appendCall(as.ContainerDelete, ctx, options)
94 return arvados.Container{}, as.Error
96 func (as *APIStub) ContainerLock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
97 as.appendCall(as.ContainerLock, ctx, options)
98 return arvados.Container{}, as.Error
100 func (as *APIStub) ContainerUnlock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
101 as.appendCall(as.ContainerUnlock, ctx, options)
102 return arvados.Container{}, as.Error
104 func (as *APIStub) SpecimenCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Specimen, error) {
105 as.appendCall(as.SpecimenCreate, ctx, options)
106 return arvados.Specimen{}, as.Error
108 func (as *APIStub) SpecimenUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Specimen, error) {
109 as.appendCall(as.SpecimenUpdate, ctx, options)
110 return arvados.Specimen{}, as.Error
112 func (as *APIStub) SpecimenGet(ctx context.Context, options arvados.GetOptions) (arvados.Specimen, error) {
113 as.appendCall(as.SpecimenGet, ctx, options)
114 return arvados.Specimen{}, as.Error
116 func (as *APIStub) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
117 as.appendCall(as.SpecimenList, ctx, options)
118 return arvados.SpecimenList{}, as.Error
120 func (as *APIStub) SpecimenDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Specimen, error) {
121 as.appendCall(as.SpecimenDelete, ctx, options)
122 return arvados.Specimen{}, as.Error
124 func (as *APIStub) APIClientAuthorizationCurrent(ctx context.Context, options arvados.GetOptions) (arvados.APIClientAuthorization, error) {
125 as.appendCall(as.APIClientAuthorizationCurrent, ctx, options)
126 return arvados.APIClientAuthorization{}, as.Error
129 func (as *APIStub) appendCall(method interface{}, ctx context.Context, options interface{}) {
131 defer as.mtx.Unlock()
132 as.calls = append(as.calls, APIStubCall{method, ctx, options})
135 func (as *APIStub) Calls(method interface{}) []APIStubCall {
137 defer as.mtx.Unlock()
138 var calls []APIStubCall
139 for _, call := range as.calls {
141 if method == nil || (runtime.FuncForPC(reflect.ValueOf(call.Method).Pointer()).Name() ==
142 runtime.FuncForPC(reflect.ValueOf(method).Pointer()).Name()) {
143 calls = append(calls, call)
149 type APIStubCall struct {
151 Context context.Context