X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/231a86fd3f7e30e9f66d71d92ad7c26578637e37..9a0172e4aa5ef715db657a6d0d2cadbf6a54344e:/sdk/go/arvados/api.go diff --git a/sdk/go/arvados/api.go b/sdk/go/arvados/api.go index 71265756da..5a2cfb8800 100644 --- a/sdk/go/arvados/api.go +++ b/sdk/go/arvados/api.go @@ -4,7 +4,10 @@ package arvados -import "context" +import ( + "context" + "encoding/json" +) type APIEndpoint struct { Method string @@ -14,34 +17,55 @@ type APIEndpoint struct { } var ( + EndpointConfigGet = APIEndpoint{"GET", "arvados/v1/config", ""} + EndpointLogin = APIEndpoint{"GET", "login", ""} + EndpointLogout = APIEndpoint{"GET", "logout", ""} EndpointCollectionCreate = APIEndpoint{"POST", "arvados/v1/collections", "collection"} - EndpointCollectionUpdate = APIEndpoint{"PATCH", "arvados/v1/collections/:uuid", "collection"} - EndpointCollectionGet = APIEndpoint{"GET", "arvados/v1/collections/:uuid", ""} + EndpointCollectionUpdate = APIEndpoint{"PATCH", "arvados/v1/collections/{uuid}", "collection"} + EndpointCollectionGet = APIEndpoint{"GET", "arvados/v1/collections/{uuid}", ""} EndpointCollectionList = APIEndpoint{"GET", "arvados/v1/collections", ""} - EndpointCollectionProvenance = APIEndpoint{"GET", "arvados/v1/collections/:uuid/provenance", ""} - EndpointCollectionUsedBy = APIEndpoint{"GET", "arvados/v1/collections/:uuid/used_by", ""} - EndpointCollectionDelete = APIEndpoint{"DELETE", "arvados/v1/collections/:uuid", ""} - EndpointCollectionTrash = APIEndpoint{"POST", "arvados/v1/collections/:uuid/trash", ""} - EndpointCollectionUntrash = APIEndpoint{"POST", "arvados/v1/collections/:uuid/untrash", ""} + EndpointCollectionProvenance = APIEndpoint{"GET", "arvados/v1/collections/{uuid}/provenance", ""} + EndpointCollectionUsedBy = APIEndpoint{"GET", "arvados/v1/collections/{uuid}/used_by", ""} + EndpointCollectionDelete = APIEndpoint{"DELETE", "arvados/v1/collections/{uuid}", ""} + EndpointCollectionTrash = APIEndpoint{"POST", "arvados/v1/collections/{uuid}/trash", ""} + EndpointCollectionUntrash = APIEndpoint{"POST", "arvados/v1/collections/{uuid}/untrash", ""} EndpointSpecimenCreate = APIEndpoint{"POST", "arvados/v1/specimens", "specimen"} - EndpointSpecimenUpdate = APIEndpoint{"PATCH", "arvados/v1/specimens/:uuid", "specimen"} - EndpointSpecimenGet = APIEndpoint{"GET", "arvados/v1/specimens/:uuid", ""} + EndpointSpecimenUpdate = APIEndpoint{"PATCH", "arvados/v1/specimens/{uuid}", "specimen"} + EndpointSpecimenGet = APIEndpoint{"GET", "arvados/v1/specimens/{uuid}", ""} EndpointSpecimenList = APIEndpoint{"GET", "arvados/v1/specimens", ""} - EndpointSpecimenDelete = APIEndpoint{"DELETE", "arvados/v1/specimens/:uuid", ""} + EndpointSpecimenDelete = APIEndpoint{"DELETE", "arvados/v1/specimens/{uuid}", ""} EndpointContainerCreate = APIEndpoint{"POST", "arvados/v1/containers", "container"} - EndpointContainerUpdate = APIEndpoint{"PATCH", "arvados/v1/containers/:uuid", "container"} - EndpointContainerGet = APIEndpoint{"GET", "arvados/v1/containers/:uuid", ""} + EndpointContainerUpdate = APIEndpoint{"PATCH", "arvados/v1/containers/{uuid}", "container"} + EndpointContainerGet = APIEndpoint{"GET", "arvados/v1/containers/{uuid}", ""} EndpointContainerList = APIEndpoint{"GET", "arvados/v1/containers", ""} - 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", ""} + EndpointUserActivate = APIEndpoint{"POST", "arvados/v1/users/{uuid}/activate", ""} + EndpointUserCreate = APIEndpoint{"POST", "arvados/v1/users", "user"} + EndpointUserCurrent = APIEndpoint{"GET", "arvados/v1/users/current", ""} + EndpointUserDelete = APIEndpoint{"DELETE", "arvados/v1/users/{uuid}", ""} + EndpointUserGet = APIEndpoint{"GET", "arvados/v1/users/{uuid}", ""} + EndpointUserGetCurrent = APIEndpoint{"GET", "arvados/v1/users/current", ""} + EndpointUserGetSystem = APIEndpoint{"GET", "arvados/v1/users/system", ""} + EndpointUserList = APIEndpoint{"GET", "arvados/v1/users", ""} + EndpointUserMerge = APIEndpoint{"POST", "arvados/v1/users/merge", ""} + EndpointUserSetup = APIEndpoint{"POST", "arvados/v1/users/setup", "user"} + EndpointUserSystem = APIEndpoint{"GET", "arvados/v1/users/system", ""} + 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_update", ""} + EndpointUserAuthenticate = APIEndpoint{"POST", "arvados/v1/users/authenticate", ""} EndpointAPIClientAuthorizationCurrent = APIEndpoint{"GET", "arvados/v1/api_client_authorizations/current", ""} ) type GetOptions struct { - UUID string `json:"uuid"` + UUID string `json:"uuid,omitempty"` Select []string `json:"select"` IncludeTrash bool `json:"include_trash"` + ForwardedFor string `json:"forwarded_for,omitempty"` + Remote string `json:"remote,omitempty"` } type UntrashOptions struct { @@ -54,13 +78,15 @@ type ListOptions struct { 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"` + BypassFederation bool `json:"bypass_federation"` + ForwardedFor string `json:"forwarded_for,omitempty"` } type CreateOptions struct { @@ -71,15 +97,68 @@ type CreateOptions 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 UpdateUUIDOptions struct { + UUID string `json:"uuid"` + NewUUID string `json:"new_uuid"` +} + +type UserActivateOptions struct { + UUID string `json:"uuid"` +} + +type UserSetupOptions struct { + UUID string `json:"uuid,omitempty"` + Email string `json:"email,omitempty"` + OpenIDPrefix string `json:"openid_prefix,omitempty"` + RepoName string `json:"repo_name,omitempty"` + VMUUID string `json:"vm_uuid,omitempty"` + SendNotificationEmail bool `json:"send_notification_email,omitempty"` + Attrs map[string]interface{} `json:"attrs"` +} + +type UserMergeOptions struct { + NewUserUUID string `json:"new_user_uuid,omitempty"` + OldUserUUID string `json:"old_user_uuid,omitempty"` + NewOwnerUUID string `json:"new_owner_uuid,omitempty"` + NewUserToken string `json:"new_user_token,omitempty"` + RedirectToNewUser bool `json:"redirect_to_new_user"` +} + +type UserBatchUpdateOptions struct { + Updates map[string]map[string]interface{} `json:"updates"` } +type UserBatchUpdateResponse struct{} + type DeleteOptions struct { UUID string `json:"uuid"` } +type LoginOptions struct { + ReturnTo string `json:"return_to"` // On success, redirect to this target with api_token=xxx query param + Remote string `json:"remote,omitempty"` // Salt token for remote Cluster ID + Code string `json:"code,omitempty"` // OAuth2 callback code + 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 API interface { + ConfigGet(ctx context.Context) (json.RawMessage, 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) CollectionUpdate(ctx context.Context, options UpdateOptions) (Collection, error) CollectionGet(ctx context.Context, options GetOptions) (Collection, error) @@ -101,5 +180,19 @@ type API interface { SpecimenGet(ctx context.Context, options GetOptions) (Specimen, error) SpecimenList(ctx context.Context, options ListOptions) (SpecimenList, error) SpecimenDelete(ctx context.Context, options DeleteOptions) (Specimen, error) + UserCreate(ctx context.Context, options CreateOptions) (User, error) + UserUpdate(ctx context.Context, options UpdateOptions) (User, error) + UserUpdateUUID(ctx context.Context, options UpdateUUIDOptions) (User, error) + UserMerge(ctx context.Context, options UserMergeOptions) (User, error) + UserActivate(ctx context.Context, options UserActivateOptions) (User, error) + UserSetup(ctx context.Context, options UserSetupOptions) (map[string]interface{}, error) + UserUnsetup(ctx context.Context, options GetOptions) (User, error) + UserGet(ctx context.Context, options GetOptions) (User, error) + UserGetCurrent(ctx context.Context, options GetOptions) (User, error) + UserGetSystem(ctx context.Context, options GetOptions) (User, 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) }