add driveAlias to the graphAPI

This commit is contained in:
Michael Barz
2022-03-07 17:51:27 +01:00
parent b3a1a14740
commit 3a59c7ec4c
5 changed files with 24 additions and 14 deletions

View File

@@ -0,0 +1,5 @@
Enhancement: Add space aliases
Space aliases can be used to resolve spaceIDs in a client.
https://github.com/owncloud/ocis/pull/3283

2
go.mod
View File

@@ -22,7 +22,7 @@ require (
github.com/blevesearch/bleve/v2 v2.3.1
github.com/coreos/go-oidc/v3 v3.1.0
github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19
github.com/cs3org/reva/v2 v2.0.0-20220314085001-8e5b22a20a3f
github.com/cs3org/reva/v2 v2.0.0-20220315083752-d008faf40d48
github.com/disintegration/imaging v1.6.2
github.com/glauth/glauth/v2 v2.0.0-20211021011345-ef3151c28733
github.com/go-chi/chi/v5 v5.0.7

4
go.sum
View File

@@ -341,8 +341,8 @@ github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD9
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19 h1:1jqPH58jCxvbaJ9WLIJ7W2/m622bWS6ChptzljSG6IQ=
github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva/v2 v2.0.0-20220314085001-8e5b22a20a3f h1:tv7v6OjbFoDFNB2ikGC+LLaWEOIAJnrZjyO5LRTDL0g=
github.com/cs3org/reva/v2 v2.0.0-20220314085001-8e5b22a20a3f/go.mod h1:XNtK1HEClNzmz5vyQa2DUw4KH3oqBjQoEsV1LhAGlV0=
github.com/cs3org/reva/v2 v2.0.0-20220315083752-d008faf40d48 h1:BLaNoseOPNvE5Khyc0DnUBFb29oiRja1RRCLBQcrjOQ=
github.com/cs3org/reva/v2 v2.0.0-20220315083752-d008faf40d48/go.mod h1:XNtK1HEClNzmz5vyQa2DUw4KH3oqBjQoEsV1LhAGlV0=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=

View File

@@ -218,6 +218,10 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
csr.Opaque = utils.AppendPlainToOpaque(csr.Opaque, "description", *drive.Description)
}
if drive.DriveAlias != nil {
csr.Opaque = utils.AppendPlainToOpaque(csr.Opaque, "spaceAlias", *drive.DriveAlias)
}
resp, err := client.CreateStorageSpace(r.Context(), &csr)
if err != nil {
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())
@@ -303,24 +307,19 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) {
}
}
// Note: this is the Opaque prop of the space itself
opaque := make(map[string]*types.OpaqueEntry)
if drive.Description != nil {
opaque["description"] = &types.OpaqueEntry{
Decoder: "plain",
Value: []byte(*drive.Description),
}
updateSpaceRequest.StorageSpace.Opaque = utils.AppendPlainToOpaque(updateSpaceRequest.StorageSpace.Opaque, "description", *drive.Description)
}
if drive.DriveAlias != nil {
updateSpaceRequest.StorageSpace.Opaque = utils.AppendPlainToOpaque(updateSpaceRequest.StorageSpace.Opaque, "spaceAlias", *drive.DriveAlias)
}
for _, special := range drive.Special {
if special.Id != nil {
opaque[*special.SpecialFolder.Name] = &types.OpaqueEntry{
Decoder: "plain",
Value: []byte(*special.Id),
}
updateSpaceRequest.StorageSpace.Opaque = utils.AppendPlainToOpaque(updateSpaceRequest.StorageSpace.Opaque, *special.SpecialFolder.Name, *special.Id)
}
}
updateSpaceRequest.StorageSpace.Opaque = &types.Opaque{Map: opaque}
if drive.Name != nil {
updateSpaceRequest.StorageSpace.Name = *drive.Name
@@ -508,6 +507,10 @@ func (g Graph) cs3StorageSpaceToDrive(baseURL *url.URL, space *storageprovider.S
drive.Description = libregraph.PtrString(string(description.Value))
}
if alias, ok := space.Opaque.Map["spaceAlias"]; ok {
drive.DriveAlias = libregraph.PtrString(string(alias.Value))
}
if v, ok := space.Opaque.Map["trashed"]; ok {
deleted := &libregraph.Deleted{}
deleted.SetState(string(v.Value))

View File

@@ -15,6 +15,7 @@ Feature: List and create spaces
And the json responded should contain a space "Alice Hansen" with these key and value pairs:
| key | value |
| driveType | personal |
| driveAlias | personal/Alice |
| id | %space_id% |
| name | Alice Hansen |
| quota@@@state | normal |
@@ -61,6 +62,7 @@ Feature: List and create spaces
And the json responded should contain a space "Project Mars" with these key and value pairs:
| key | value |
| driveType | project |
| driveAlias | project/project-mars |
| name | Project Mars |
| quota@@@total | 1000000000 |
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |