Fix Rails package version calculation again.
[arvados.git] / sdk / go / arvados / api.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import (
8         "context"
9         "encoding/json"
10 )
11
12 type APIEndpoint struct {
13         Method string
14         Path   string
15         // "new attributes" key for create/update requests
16         AttrsKey string
17 }
18
19 var (
20         EndpointConfigGet                     = APIEndpoint{"GET", "arvados/v1/config", ""}
21         EndpointLogin                         = APIEndpoint{"GET", "login", ""}
22         EndpointCollectionCreate              = APIEndpoint{"POST", "arvados/v1/collections", "collection"}
23         EndpointCollectionUpdate              = APIEndpoint{"PATCH", "arvados/v1/collections/{uuid}", "collection"}
24         EndpointCollectionGet                 = APIEndpoint{"GET", "arvados/v1/collections/{uuid}", ""}
25         EndpointCollectionList                = APIEndpoint{"GET", "arvados/v1/collections", ""}
26         EndpointCollectionProvenance          = APIEndpoint{"GET", "arvados/v1/collections/{uuid}/provenance", ""}
27         EndpointCollectionUsedBy              = APIEndpoint{"GET", "arvados/v1/collections/{uuid}/used_by", ""}
28         EndpointCollectionDelete              = APIEndpoint{"DELETE", "arvados/v1/collections/{uuid}", ""}
29         EndpointCollectionTrash               = APIEndpoint{"POST", "arvados/v1/collections/{uuid}/trash", ""}
30         EndpointCollectionUntrash             = APIEndpoint{"POST", "arvados/v1/collections/{uuid}/untrash", ""}
31         EndpointSpecimenCreate                = APIEndpoint{"POST", "arvados/v1/specimens", "specimen"}
32         EndpointSpecimenUpdate                = APIEndpoint{"PATCH", "arvados/v1/specimens/{uuid}", "specimen"}
33         EndpointSpecimenGet                   = APIEndpoint{"GET", "arvados/v1/specimens/{uuid}", ""}
34         EndpointSpecimenList                  = APIEndpoint{"GET", "arvados/v1/specimens", ""}
35         EndpointSpecimenDelete                = APIEndpoint{"DELETE", "arvados/v1/specimens/{uuid}", ""}
36         EndpointContainerCreate               = APIEndpoint{"POST", "arvados/v1/containers", "container"}
37         EndpointContainerUpdate               = APIEndpoint{"PATCH", "arvados/v1/containers/{uuid}", "container"}
38         EndpointContainerGet                  = APIEndpoint{"GET", "arvados/v1/containers/{uuid}", ""}
39         EndpointContainerList                 = APIEndpoint{"GET", "arvados/v1/containers", ""}
40         EndpointContainerDelete               = APIEndpoint{"DELETE", "arvados/v1/containers/{uuid}", ""}
41         EndpointContainerLock                 = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/lock", ""}
42         EndpointContainerUnlock               = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/unlock", ""}
43         EndpointUserActivate                  = APIEndpoint{"POST", "arvados/v1/users/{uuid}/activate", ""}
44         EndpointUserCreate                    = APIEndpoint{"POST", "arvados/v1/users", "user"}
45         EndpointUserCurrent                   = APIEndpoint{"GET", "arvados/v1/users/current", ""}
46         EndpointUserDelete                    = APIEndpoint{"DELETE", "arvados/v1/users/{uuid}", ""}
47         EndpointUserGet                       = APIEndpoint{"GET", "arvados/v1/users/{uuid}", ""}
48         EndpointUserGetCurrent                = APIEndpoint{"GET", "arvados/v1/users/current", ""}
49         EndpointUserGetSystem                 = APIEndpoint{"GET", "arvados/v1/users/system", ""}
50         EndpointUserList                      = APIEndpoint{"GET", "arvados/v1/users", ""}
51         EndpointUserMerge                     = APIEndpoint{"POST", "arvados/v1/users/merge", ""}
52         EndpointUserSetup                     = APIEndpoint{"POST", "arvados/v1/users/setup", ""}
53         EndpointUserSystem                    = APIEndpoint{"GET", "arvados/v1/users/system", ""}
54         EndpointUserUnsetup                   = APIEndpoint{"POST", "arvados/v1/users/{uuid}/unsetup", ""}
55         EndpointUserUpdate                    = APIEndpoint{"PATCH", "arvados/v1/users/{uuid}", "user"}
56         EndpointUserUpdateUUID                = APIEndpoint{"POST", "arvados/v1/users/{uuid}/update_uuid", ""}
57         EndpointUserBatchUpdate               = APIEndpoint{"PATCH", "arvados/v1/users/batch", ""}
58         EndpointAPIClientAuthorizationCurrent = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/current", ""}
59 )
60
61 type GetOptions struct {
62         UUID         string   `json:"uuid"`
63         Select       []string `json:"select"`
64         IncludeTrash bool     `json:"include_trash"`
65 }
66
67 type UntrashOptions struct {
68         UUID             string `json:"uuid"`
69         EnsureUniqueName bool   `json:"ensure_unique_name"`
70 }
71
72 type ListOptions struct {
73         ClusterID          string                 `json:"cluster_id"`
74         Select             []string               `json:"select"`
75         Filters            []Filter               `json:"filters"`
76         Where              map[string]interface{} `json:"where"`
77         Limit              int                    `json:"limit"`
78         Offset             int                    `json:"offset"`
79         Order              []string               `json:"order"`
80         Distinct           bool                   `json:"distinct"`
81         Count              string                 `json:"count"`
82         IncludeTrash       bool                   `json:"include_trash"`
83         IncludeOldVersions bool                   `json:"include_old_versions"`
84 }
85
86 type CreateOptions struct {
87         ClusterID        string                 `json:"cluster_id"`
88         EnsureUniqueName bool                   `json:"ensure_unique_name"`
89         Select           []string               `json:"select"`
90         Attrs            map[string]interface{} `json:"attrs"`
91 }
92
93 type UpdateOptions struct {
94         UUID  string                 `json:"uuid"`
95         Attrs map[string]interface{} `json:"attrs"`
96 }
97
98 type UpdateUUIDOptions struct {
99         UUID    string `json:"uuid"`
100         NewUUID string `json:"new_uuid"`
101 }
102
103 type UserActivateOptions struct {
104         UUID string `json:"uuid"`
105 }
106
107 type UserSetupOptions struct {
108         UUID                  string                 `json:"uuid"`
109         Email                 string                 `json:"email"`
110         OpenIDPrefix          string                 `json:"openid_prefix"`
111         RepoName              string                 `json:"repo_name"`
112         VMUUID                string                 `json:"vm_uuid"`
113         SendNotificationEmail bool                   `json:"send_notification_email"`
114         Attrs                 map[string]interface{} `json:"attrs"`
115 }
116
117 type UserMergeOptions struct {
118         NewUserUUID  string `json:"new_user_uuid,omitempty"`
119         OldUserUUID  string `json:"old_user_uuid,omitempty"`
120         NewUserToken string `json:"new_user_token,omitempty"`
121 }
122
123 type UserBatchUpdateOptions struct {
124         Updates map[string]map[string]interface{} `json:"updates"`
125 }
126
127 type UserBatchUpdateResponse struct{}
128
129 type DeleteOptions struct {
130         UUID string `json:"uuid"`
131 }
132
133 type LoginOptions struct {
134         ReturnTo string `json:"return_to"`        // On success, redirect to this target with api_token=xxx query param
135         Remote   string `json:"remote,omitempty"` // Salt token for remote Cluster ID
136         Code     string `json:"code,omitempty"`   // OAuth2 callback code
137         State    string `json:"state,omitempty"`  // OAuth2 callback state
138 }
139
140 type API interface {
141         ConfigGet(ctx context.Context) (json.RawMessage, error)
142         Login(ctx context.Context, options LoginOptions) (LoginResponse, error)
143         CollectionCreate(ctx context.Context, options CreateOptions) (Collection, error)
144         CollectionUpdate(ctx context.Context, options UpdateOptions) (Collection, error)
145         CollectionGet(ctx context.Context, options GetOptions) (Collection, error)
146         CollectionList(ctx context.Context, options ListOptions) (CollectionList, error)
147         CollectionProvenance(ctx context.Context, options GetOptions) (map[string]interface{}, error)
148         CollectionUsedBy(ctx context.Context, options GetOptions) (map[string]interface{}, error)
149         CollectionDelete(ctx context.Context, options DeleteOptions) (Collection, error)
150         CollectionTrash(ctx context.Context, options DeleteOptions) (Collection, error)
151         CollectionUntrash(ctx context.Context, options UntrashOptions) (Collection, error)
152         ContainerCreate(ctx context.Context, options CreateOptions) (Container, error)
153         ContainerUpdate(ctx context.Context, options UpdateOptions) (Container, error)
154         ContainerGet(ctx context.Context, options GetOptions) (Container, error)
155         ContainerList(ctx context.Context, options ListOptions) (ContainerList, error)
156         ContainerDelete(ctx context.Context, options DeleteOptions) (Container, error)
157         ContainerLock(ctx context.Context, options GetOptions) (Container, error)
158         ContainerUnlock(ctx context.Context, options GetOptions) (Container, error)
159         SpecimenCreate(ctx context.Context, options CreateOptions) (Specimen, error)
160         SpecimenUpdate(ctx context.Context, options UpdateOptions) (Specimen, error)
161         SpecimenGet(ctx context.Context, options GetOptions) (Specimen, error)
162         SpecimenList(ctx context.Context, options ListOptions) (SpecimenList, error)
163         SpecimenDelete(ctx context.Context, options DeleteOptions) (Specimen, error)
164         UserCreate(ctx context.Context, options CreateOptions) (User, error)
165         UserUpdate(ctx context.Context, options UpdateOptions) (User, error)
166         UserUpdateUUID(ctx context.Context, options UpdateUUIDOptions) (User, error)
167         UserMerge(ctx context.Context, options UserMergeOptions) (User, error)
168         UserActivate(ctx context.Context, options UserActivateOptions) (User, error)
169         UserSetup(ctx context.Context, options UserSetupOptions) (map[string]interface{}, error)
170         UserUnsetup(ctx context.Context, options GetOptions) (User, error)
171         UserGet(ctx context.Context, options GetOptions) (User, error)
172         UserGetCurrent(ctx context.Context, options GetOptions) (User, error)
173         UserGetSystem(ctx context.Context, options GetOptions) (User, error)
174         UserList(ctx context.Context, options ListOptions) (UserList, error)
175         UserDelete(ctx context.Context, options DeleteOptions) (User, error)
176         UserBatchUpdate(context.Context, UserBatchUpdateOptions) (UserList, error)
177         APIClientAuthorizationCurrent(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
178 }