17119: fix options and response type of the groups/shared and
[arvados.git] / sdk / go / arvados / api.go
index 0c5d32e8b7e1e96bdab9bbf45b25962963297829..9aaa3205b7d0515960b90da8b09d7e64b197c778 100644 (file)
@@ -5,8 +5,12 @@
 package arvados
 
 import (
 package arvados
 
 import (
+       "bufio"
        "context"
        "encoding/json"
        "context"
        "encoding/json"
+       "net"
+
+       "github.com/sirupsen/logrus"
 )
 
 type APIEndpoint struct {
 )
 
 type APIEndpoint struct {
@@ -41,6 +45,21 @@ var (
        EndpointContainerDelete               = APIEndpoint{"DELETE", "arvados/v1/containers/{uuid}", ""}
        EndpointContainerLock                 = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/lock", ""}
        EndpointContainerUnlock               = APIEndpoint{"POST", "arvados/v1/containers/{uuid}/unlock", ""}
        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
+       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}", ""}
+       EndpointContainerRequestList          = APIEndpoint{"GET", "arvados/v1/container_requests", ""}
+       EndpointContainerRequestDelete        = APIEndpoint{"DELETE", "arvados/v1/container_requests/{uuid}", ""}
+       EndpointGroupCreate                   = APIEndpoint{"POST", "arvados/v1/groups", "group"}
+       EndpointGroupUpdate                   = APIEndpoint{"PATCH", "arvados/v1/groups/{uuid}", "group"}
+       EndpointGroupGet                      = APIEndpoint{"GET", "arvados/v1/groups/{uuid}", ""}
+       EndpointGroupList                     = APIEndpoint{"GET", "arvados/v1/groups", ""}
+       EndpointGroupContents                 = APIEndpoint{"GET", "arvados/v1/groups/contents", ""}
+       EndpointGroupContents2                = APIEndpoint{"GET", "arvados/v1/groups/{uuid}/contents", ""}
+       EndpointGroupShared                   = APIEndpoint{"GET", "arvados/v1/groups/shared", ""}
+       EndpointGroupDelete                   = APIEndpoint{"DELETE", "arvados/v1/groups/{uuid}", ""}
+       EndpointGroupUntrash                  = APIEndpoint{"POST", "arvados/v1/groups/{uuid}/untrash", ""}
        EndpointUserActivate                  = APIEndpoint{"POST", "arvados/v1/users/{uuid}/activate", ""}
        EndpointUserCreate                    = APIEndpoint{"POST", "arvados/v1/users", "user"}
        EndpointUserCurrent                   = APIEndpoint{"GET", "arvados/v1/users/current", ""}
        EndpointUserActivate                  = APIEndpoint{"POST", "arvados/v1/users/{uuid}/activate", ""}
        EndpointUserCreate                    = APIEndpoint{"POST", "arvados/v1/users", "user"}
        EndpointUserCurrent                   = APIEndpoint{"GET", "arvados/v1/users/current", ""}
@@ -55,16 +74,29 @@ var (
        EndpointUserUnsetup                   = APIEndpoint{"POST", "arvados/v1/users/{uuid}/unsetup", ""}
        EndpointUserUpdate                    = APIEndpoint{"PATCH", "arvados/v1/users/{uuid}", "user"}
        EndpointUserUpdateUUID                = APIEndpoint{"POST", "arvados/v1/users/{uuid}/update_uuid", ""}
        EndpointUserUnsetup                   = APIEndpoint{"POST", "arvados/v1/users/{uuid}/unsetup", ""}
        EndpointUserUpdate                    = APIEndpoint{"PATCH", "arvados/v1/users/{uuid}", "user"}
        EndpointUserUpdateUUID                = APIEndpoint{"POST", "arvados/v1/users/{uuid}/update_uuid", ""}
-       EndpointUserBatchUpdate               = APIEndpoint{"PATCH", "arvados/v1/users/batch", ""}
+       EndpointUserBatchUpdate               = APIEndpoint{"PATCH", "arvados/v1/users/batch_update", ""}
+       EndpointUserAuthenticate              = APIEndpoint{"POST", "arvados/v1/users/authenticate", ""}
        EndpointAPIClientAuthorizationCurrent = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/current", ""}
 )
 
        EndpointAPIClientAuthorizationCurrent = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/current", ""}
 )
 
+type ContainerSSHOptions struct {
+       UUID          string `json:"uuid"`
+       DetachKeys    string `json:"detach_keys"`
+       LoginUsername string `json:"login_username"`
+}
+
+type ContainerSSHConnection struct {
+       Conn   net.Conn           `json:"-"`
+       Bufrw  *bufio.ReadWriter  `json:"-"`
+       Logger logrus.FieldLogger `json:"-"`
+}
+
 type GetOptions struct {
 type GetOptions struct {
-       UUID         string   `json:"uuid"`
+       UUID         string   `json:"uuid,omitempty"`
        Select       []string `json:"select"`
        IncludeTrash bool     `json:"include_trash"`
        Select       []string `json:"select"`
        IncludeTrash bool     `json:"include_trash"`
-       ForwardedFor string   `json:"forwarded_for"`
-       Remote       string   `json:"remote"`
+       ForwardedFor string   `json:"forwarded_for,omitempty"`
+       Remote       string   `json:"remote,omitempty"`
 }
 
 type UntrashOptions struct {
 }
 
 type UntrashOptions struct {
@@ -77,13 +109,15 @@ type ListOptions struct {
        Select             []string               `json:"select"`
        Filters            []Filter               `json:"filters"`
        Where              map[string]interface{} `json:"where"`
        Select             []string               `json:"select"`
        Filters            []Filter               `json:"filters"`
        Where              map[string]interface{} `json:"where"`
-       Limit              int                    `json:"limit"`
-       Offset             int                    `json:"offset"`
+       Limit              int64                  `json:"limit"`
+       Offset             int64                  `json:"offset"`
        Order              []string               `json:"order"`
        Distinct           bool                   `json:"distinct"`
        Count              string                 `json:"count"`
        IncludeTrash       bool                   `json:"include_trash"`
        IncludeOldVersions bool                   `json:"include_old_versions"`
        Order              []string               `json:"order"`
        Distinct           bool                   `json:"distinct"`
        Count              string                 `json:"count"`
        IncludeTrash       bool                   `json:"include_trash"`
        IncludeOldVersions bool                   `json:"include_old_versions"`
+       BypassFederation   bool                   `json:"bypass_federation"`
+       ForwardedFor       string                 `json:"forwarded_for,omitempty"`
 }
 
 type CreateOptions struct {
 }
 
 type CreateOptions struct {
@@ -94,8 +128,32 @@ type CreateOptions struct {
 }
 
 type UpdateOptions struct {
 }
 
 type UpdateOptions struct {
-       UUID  string                 `json:"uuid"`
-       Attrs map[string]interface{} `json:"attrs"`
+       UUID             string                 `json:"uuid"`
+       Attrs            map[string]interface{} `json:"attrs"`
+       BypassFederation bool                   `json:"bypass_federation"`
+}
+
+type ContentsOptions struct {
+       UUID               string   `json:"uuid,omitempty"`
+       Select             []string `json:"select"`
+       Filters            []Filter `json:"filters"`
+       Limit              int64    `json:"limit"`
+       Offset             int64    `json:"offset"`
+       Order              []string `json:"order"`
+       Include            string   `json:"include"`
+       Recursive          bool     `json:"recursive"`
+       ExcludeHomeProject bool     `json:"exclude_home_project"`
+}
+
+type SharedOptions struct {
+       UUID    string   `json:"uuid,omitempty"`
+       Select  []string `json:"select"`
+       Filters []Filter `json:"filters"`
+       Limit   int64    `json:"limit"`
+       Offset  int64    `json:"offset"`
+       Count   string   `json:"count"`
+       Order   []string `json:"order"`
+       Include string   `json:"include"`
 }
 
 type UpdateUUIDOptions struct {
 }
 
 type UpdateUUIDOptions struct {
@@ -142,6 +200,11 @@ type LoginOptions struct {
        State    string `json:"state,omitempty"`  // OAuth2 callback state
 }
 
        State    string `json:"state,omitempty"`  // OAuth2 callback state
 }
 
+type UserAuthenticateOptions struct {
+       Username string `json:"username,omitempty"` // PAM username
+       Password string `json:"password,omitempty"` // PAM password
+}
+
 type LogoutOptions struct {
        ReturnTo string `json:"return_to"` // Redirect to this URL after logging out
 }
 type LogoutOptions struct {
        ReturnTo string `json:"return_to"` // Redirect to this URL after logging out
 }
@@ -166,6 +229,20 @@ type API interface {
        ContainerDelete(ctx context.Context, options DeleteOptions) (Container, error)
        ContainerLock(ctx context.Context, options GetOptions) (Container, error)
        ContainerUnlock(ctx context.Context, options GetOptions) (Container, error)
        ContainerDelete(ctx context.Context, options DeleteOptions) (Container, error)
        ContainerLock(ctx context.Context, options GetOptions) (Container, error)
        ContainerUnlock(ctx context.Context, options GetOptions) (Container, error)
+       ContainerSSH(ctx context.Context, options ContainerSSHOptions) (ContainerSSHConnection, 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)
+       ContainerRequestList(ctx context.Context, options ListOptions) (ContainerRequestList, error)
+       ContainerRequestDelete(ctx context.Context, options DeleteOptions) (ContainerRequest, error)
+       GroupCreate(ctx context.Context, options CreateOptions) (Group, error)
+       GroupUpdate(ctx context.Context, options UpdateOptions) (Group, error)
+       GroupGet(ctx context.Context, options GetOptions) (Group, error)
+       GroupList(ctx context.Context, options ListOptions) (GroupList, error)
+       GroupContents(ctx context.Context, options ContentsOptions) (ObjectList, error)
+       GroupShared(ctx context.Context, options SharedOptions) (SharedGroupList, error)
+       GroupDelete(ctx context.Context, options DeleteOptions) (Group, error)
+       GroupUntrash(ctx context.Context, options UntrashOptions) (Group, 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)
        SpecimenCreate(ctx context.Context, options CreateOptions) (Specimen, error)
        SpecimenUpdate(ctx context.Context, options UpdateOptions) (Specimen, error)
        SpecimenGet(ctx context.Context, options GetOptions) (Specimen, error)
@@ -184,5 +261,6 @@ type API interface {
        UserList(ctx context.Context, options ListOptions) (UserList, error)
        UserDelete(ctx context.Context, options DeleteOptions) (User, error)
        UserBatchUpdate(context.Context, UserBatchUpdateOptions) (UserList, error)
        UserList(ctx context.Context, options ListOptions) (UserList, error)
        UserDelete(ctx context.Context, options DeleteOptions) (User, error)
        UserBatchUpdate(context.Context, UserBatchUpdateOptions) (UserList, error)
+       UserAuthenticate(ctx context.Context, options UserAuthenticateOptions) (APIClientAuthorization, error)
        APIClientAuthorizationCurrent(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
 }
        APIClientAuthorizationCurrent(ctx context.Context, options GetOptions) (APIClientAuthorization, error)
 }