19166: Set up tunnel for container gateway requests
[arvados.git] / sdk / go / arvados / api.go
index b429e800841eb7e4935c63ebb56560ec93f556eb..1b303ffb414c893d0f6ada0622e12af3d34f75bb 100644 (file)
@@ -23,6 +23,7 @@ type APIEndpoint struct {
 
 var (
        EndpointConfigGet                     = APIEndpoint{"GET", "arvados/v1/config", ""}
+       EndpointVocabularyGet                 = APIEndpoint{"GET", "arvados/v1/vocabulary", ""}
        EndpointLogin                         = APIEndpoint{"GET", "login", ""}
        EndpointLogout                        = APIEndpoint{"GET", "logout", ""}
        EndpointCollectionCreate              = APIEndpoint{"POST", "arvados/v1/collections", "collection"}
@@ -46,7 +47,8 @@ var (
        EndpointContainerDelete               = APIEndpoint{"DELETE", "arvados/v1/containers/{uuid}", ""}
        EndpointContainerLock                 = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/lock", ""}
        EndpointContainerUnlock               = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/unlock", ""}
-       EndpointContainerSSH                  = APIEndpoint{"GET", "arvados/v1/connect/{uuid}/ssh", ""} // move to /containers after #17014 fixes routing
+       EndpointContainerSSH                  = APIEndpoint{"POST", "arvados/v1/connect/{uuid}/ssh", ""}            // move to /containers after #17014 fixes routing
+       EndpointContainerGatewayTunnel        = APIEndpoint{"POST", "arvados/v1/connect/{uuid}/gateway_tunnel", ""} // move to /containers after #17014 fixes routing
        EndpointContainerRequestCreate        = APIEndpoint{"POST", "arvados/v1/container_requests", "container_request"}
        EndpointContainerRequestUpdate        = APIEndpoint{"PATCH", "arvados/v1/container_requests/{uuid}", "container_request"}
        EndpointContainerRequestGet           = APIEndpoint{"GET", "arvados/v1/container_requests/{uuid}", ""}
@@ -62,6 +64,12 @@ var (
        EndpointGroupDelete                   = APIEndpoint{"DELETE", "arvados/v1/groups/{uuid}", ""}
        EndpointGroupTrash                    = APIEndpoint{"POST", "arvados/v1/groups/{uuid}/trash", ""}
        EndpointGroupUntrash                  = APIEndpoint{"POST", "arvados/v1/groups/{uuid}/untrash", ""}
+       EndpointLinkCreate                    = APIEndpoint{"POST", "arvados/v1/links", "link"}
+       EndpointLinkUpdate                    = APIEndpoint{"PATCH", "arvados/v1/links/{uuid}", "link"}
+       EndpointLinkGet                       = APIEndpoint{"GET", "arvados/v1/links/{uuid}", ""}
+       EndpointLinkList                      = APIEndpoint{"GET", "arvados/v1/links", ""}
+       EndpointLinkDelete                    = APIEndpoint{"DELETE", "arvados/v1/links/{uuid}", ""}
+       EndpointSysTrashSweep                 = APIEndpoint{"POST", "sys/trash_sweep", ""}
        EndpointUserActivate                  = APIEndpoint{"POST", "arvados/v1/users/{uuid}/activate", ""}
        EndpointUserCreate                    = APIEndpoint{"POST", "arvados/v1/users", "user"}
        EndpointUserCurrent                   = APIEndpoint{"GET", "arvados/v1/users/current", ""}
@@ -78,6 +86,11 @@ var (
        EndpointUserBatchUpdate               = APIEndpoint{"PATCH", "arvados/v1/users/batch_update", ""}
        EndpointUserAuthenticate              = APIEndpoint{"POST", "arvados/v1/users/authenticate", ""}
        EndpointAPIClientAuthorizationCurrent = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/current", ""}
+       EndpointAPIClientAuthorizationCreate  = APIEndpoint{"POST", "arvados/v1/api_client_authorizations", "api_client_authorization"}
+       EndpointAPIClientAuthorizationUpdate  = APIEndpoint{"PUT", "arvados/v1/api_client_authorizations/{uuid}", "api_client_authorization"}
+       EndpointAPIClientAuthorizationList    = APIEndpoint{"GET", "arvados/v1/api_client_authorizations", ""}
+       EndpointAPIClientAuthorizationDelete  = APIEndpoint{"DELETE", "arvados/v1/api_client_authorizations/{uuid}", ""}
+       EndpointAPIClientAuthorizationGet     = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/{uuid}", ""}
 )
 
 type ContainerSSHOptions struct {
@@ -86,10 +99,18 @@ type ContainerSSHOptions struct {
        LoginUsername string `json:"login_username"`
 }
 
-type ContainerSSHConnection struct {
-       Conn   net.Conn           `json:"-"`
-       Bufrw  *bufio.ReadWriter  `json:"-"`
-       Logger logrus.FieldLogger `json:"-"`
+type ContainerSSHConnection ConnectionResponse
+
+type ConnectionResponse struct {
+       Conn          net.Conn           `json:"-"`
+       Bufrw         *bufio.ReadWriter  `json:"-"`
+       Logger        logrus.FieldLogger `json:"-"`
+       UpgradeHeader string             `json:"-"`
+}
+
+type ContainerGatewayTunnelOptions struct {
+       UUID       string `json:"uuid"`
+       AuthSecret string `json:"auth_secret"`
 }
 
 type GetOptions struct {
@@ -127,6 +148,8 @@ type CreateOptions struct {
        EnsureUniqueName bool                   `json:"ensure_unique_name"`
        Select           []string               `json:"select"`
        Attrs            map[string]interface{} `json:"attrs"`
+       // ReplaceFiles only applies when creating a collection.
+       ReplaceFiles map[string]string `json:"replace_files"`
 }
 
 type UpdateOptions struct {
@@ -134,6 +157,8 @@ type UpdateOptions struct {
        Attrs            map[string]interface{} `json:"attrs"`
        Select           []string               `json:"select"`
        BypassFederation bool                   `json:"bypass_federation"`
+       // ReplaceFiles only applies when updating a collection.
+       ReplaceFiles map[string]string `json:"replace_files"`
 }
 
 type GroupContentsOptions struct {
@@ -219,6 +244,7 @@ type BlockWriteResponse struct {
 
 type API interface {
        ConfigGet(ctx context.Context) (json.RawMessage, error)
+       VocabularyGet(ctx context.Context) (Vocabulary, error)
        Login(ctx context.Context, options LoginOptions) (LoginResponse, error)
        Logout(ctx context.Context, options LogoutOptions) (LogoutResponse, error)
        CollectionCreate(ctx context.Context, options CreateOptions) (Collection, error)
@@ -238,6 +264,7 @@ type API interface {
        ContainerLock(ctx context.Context, options GetOptions) (Container, error)
        ContainerUnlock(ctx context.Context, options GetOptions) (Container, error)
        ContainerSSH(ctx context.Context, options ContainerSSHOptions) (ContainerSSHConnection, error)
+       ContainerGatewayTunnel(ctx context.Context, options ContainerGatewayTunnelOptions) (ConnectionResponse, error)
        ContainerRequestCreate(ctx context.Context, options CreateOptions) (ContainerRequest, error)
        ContainerRequestUpdate(ctx context.Context, options UpdateOptions) (ContainerRequest, error)
        ContainerRequestGet(ctx context.Context, options GetOptions) (ContainerRequest, error)
@@ -252,11 +279,17 @@ type API interface {
        GroupDelete(ctx context.Context, options DeleteOptions) (Group, error)
        GroupTrash(ctx context.Context, options DeleteOptions) (Group, error)
        GroupUntrash(ctx context.Context, options UntrashOptions) (Group, error)
+       LinkCreate(ctx context.Context, options CreateOptions) (Link, error)
+       LinkUpdate(ctx context.Context, options UpdateOptions) (Link, error)
+       LinkGet(ctx context.Context, options GetOptions) (Link, error)
+       LinkList(ctx context.Context, options ListOptions) (LinkList, error)
+       LinkDelete(ctx context.Context, options DeleteOptions) (Link, error)
        SpecimenCreate(ctx context.Context, options CreateOptions) (Specimen, error)
        SpecimenUpdate(ctx context.Context, options UpdateOptions) (Specimen, error)
        SpecimenGet(ctx context.Context, options GetOptions) (Specimen, error)
        SpecimenList(ctx context.Context, options ListOptions) (SpecimenList, error)
        SpecimenDelete(ctx context.Context, options DeleteOptions) (Specimen, error)
+       SysTrashSweep(ctx context.Context, options struct{}) (struct{}, error)
        UserCreate(ctx context.Context, options CreateOptions) (User, error)
        UserUpdate(ctx context.Context, options UpdateOptions) (User, error)
        UserMerge(ctx context.Context, options UserMergeOptions) (User, error)
@@ -271,4 +304,9 @@ type API interface {
        UserBatchUpdate(context.Context, UserBatchUpdateOptions) (UserList, error)
        UserAuthenticate(ctx context.Context, options UserAuthenticateOptions) (APIClientAuthorization, error)
        APIClientAuthorizationCurrent(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
+       APIClientAuthorizationCreate(ctx context.Context, options CreateOptions) (APIClientAuthorization, error)
+       APIClientAuthorizationList(ctx context.Context, options ListOptions) (APIClientAuthorizationList, error)
+       APIClientAuthorizationDelete(ctx context.Context, options DeleteOptions) (APIClientAuthorization, error)
+       APIClientAuthorizationUpdate(ctx context.Context, options UpdateOptions) (APIClientAuthorization, error)
+       APIClientAuthorizationGet(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
 }