14715: keepproxy.service checks for cluster config
[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         EndpointCollectionCreate              = APIEndpoint{"POST", "arvados/v1/collections", "collection"}
22         EndpointCollectionUpdate              = APIEndpoint{"PATCH", "arvados/v1/collections/:uuid", "collection"}
23         EndpointCollectionGet                 = APIEndpoint{"GET", "arvados/v1/collections/:uuid", ""}
24         EndpointCollectionList                = APIEndpoint{"GET", "arvados/v1/collections", ""}
25         EndpointCollectionProvenance          = APIEndpoint{"GET", "arvados/v1/collections/:uuid/provenance", ""}
26         EndpointCollectionUsedBy              = APIEndpoint{"GET", "arvados/v1/collections/:uuid/used_by", ""}
27         EndpointCollectionDelete              = APIEndpoint{"DELETE", "arvados/v1/collections/:uuid", ""}
28         EndpointCollectionTrash               = APIEndpoint{"POST", "arvados/v1/collections/:uuid/trash", ""}
29         EndpointCollectionUntrash             = APIEndpoint{"POST", "arvados/v1/collections/:uuid/untrash", ""}
30         EndpointSpecimenCreate                = APIEndpoint{"POST", "arvados/v1/specimens", "specimen"}
31         EndpointSpecimenUpdate                = APIEndpoint{"PATCH", "arvados/v1/specimens/:uuid", "specimen"}
32         EndpointSpecimenGet                   = APIEndpoint{"GET", "arvados/v1/specimens/:uuid", ""}
33         EndpointSpecimenList                  = APIEndpoint{"GET", "arvados/v1/specimens", ""}
34         EndpointSpecimenDelete                = APIEndpoint{"DELETE", "arvados/v1/specimens/:uuid", ""}
35         EndpointContainerCreate               = APIEndpoint{"POST", "arvados/v1/containers", "container"}
36         EndpointContainerUpdate               = APIEndpoint{"PATCH", "arvados/v1/containers/:uuid", "container"}
37         EndpointContainerGet                  = APIEndpoint{"GET", "arvados/v1/containers/:uuid", ""}
38         EndpointContainerList                 = APIEndpoint{"GET", "arvados/v1/containers", ""}
39         EndpointContainerDelete               = APIEndpoint{"DELETE", "arvados/v1/containers/:uuid", ""}
40         EndpointContainerLock                 = APIEndpoint{"POST", "arvados/v1/containers/:uuid/lock", ""}
41         EndpointContainerUnlock               = APIEndpoint{"POST", "arvados/v1/containers/:uuid/unlock", ""}
42         EndpointAPIClientAuthorizationCurrent = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/current", ""}
43 )
44
45 type GetOptions struct {
46         UUID         string   `json:"uuid"`
47         Select       []string `json:"select"`
48         IncludeTrash bool     `json:"include_trash"`
49 }
50
51 type UntrashOptions struct {
52         UUID             string `json:"uuid"`
53         EnsureUniqueName bool   `json:"ensure_unique_name"`
54 }
55
56 type ListOptions struct {
57         ClusterID          string                 `json:"cluster_id"`
58         Select             []string               `json:"select"`
59         Filters            []Filter               `json:"filters"`
60         Where              map[string]interface{} `json:"where"`
61         Limit              int                    `json:"limit"`
62         Offset             int                    `json:"offset"`
63         Order              []string               `json:"order"`
64         Distinct           bool                   `json:"distinct"`
65         Count              string                 `json:"count"`
66         IncludeTrash       bool                   `json:"include_trash"`
67         IncludeOldVersions bool                   `json:"include_old_versions"`
68 }
69
70 type CreateOptions struct {
71         ClusterID        string                 `json:"cluster_id"`
72         EnsureUniqueName bool                   `json:"ensure_unique_name"`
73         Select           []string               `json:"select"`
74         Attrs            map[string]interface{} `json:"attrs"`
75 }
76
77 type UpdateOptions struct {
78         UUID  string                 `json:"uuid"`
79         Attrs map[string]interface{} `json:"attrs"`
80 }
81
82 type DeleteOptions struct {
83         UUID string `json:"uuid"`
84 }
85
86 type API interface {
87         ConfigGet(ctx context.Context) (json.RawMessage, error)
88         CollectionCreate(ctx context.Context, options CreateOptions) (Collection, error)
89         CollectionUpdate(ctx context.Context, options UpdateOptions) (Collection, error)
90         CollectionGet(ctx context.Context, options GetOptions) (Collection, error)
91         CollectionList(ctx context.Context, options ListOptions) (CollectionList, error)
92         CollectionProvenance(ctx context.Context, options GetOptions) (map[string]interface{}, error)
93         CollectionUsedBy(ctx context.Context, options GetOptions) (map[string]interface{}, error)
94         CollectionDelete(ctx context.Context, options DeleteOptions) (Collection, error)
95         CollectionTrash(ctx context.Context, options DeleteOptions) (Collection, error)
96         CollectionUntrash(ctx context.Context, options UntrashOptions) (Collection, error)
97         ContainerCreate(ctx context.Context, options CreateOptions) (Container, error)
98         ContainerUpdate(ctx context.Context, options UpdateOptions) (Container, error)
99         ContainerGet(ctx context.Context, options GetOptions) (Container, error)
100         ContainerList(ctx context.Context, options ListOptions) (ContainerList, error)
101         ContainerDelete(ctx context.Context, options DeleteOptions) (Container, error)
102         ContainerLock(ctx context.Context, options GetOptions) (Container, error)
103         ContainerUnlock(ctx context.Context, options GetOptions) (Container, error)
104         SpecimenCreate(ctx context.Context, options CreateOptions) (Specimen, error)
105         SpecimenUpdate(ctx context.Context, options UpdateOptions) (Specimen, error)
106         SpecimenGet(ctx context.Context, options GetOptions) (Specimen, error)
107         SpecimenList(ctx context.Context, options ListOptions) (SpecimenList, error)
108         SpecimenDelete(ctx context.Context, options DeleteOptions) (Specimen, error)
109         APIClientAuthorizationCurrent(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
110 }