From 93a76a06e714bec0c432bf5a915ede74fb565fdf Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 23 Sep 2021 16:25:48 +0200 Subject: [PATCH] use space type from request --- changelog/unreleased/create-spaces-odata.md | 1 + go.mod | 2 +- go.sum | 4 ++-- graph/pkg/service/v0/drives.go | 14 +++++++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/changelog/unreleased/create-spaces-odata.md b/changelog/unreleased/create-spaces-odata.md index 44184dc68..af3cef5b1 100644 --- a/changelog/unreleased/create-spaces-odata.md +++ b/changelog/unreleased/create-spaces-odata.md @@ -3,4 +3,5 @@ Change: Make the drives create method odata compliant When creating a space on the graph API we now use the POST Body to provide the parameters. https://github.com/owncloud/ocis/pull/2531 +https://github.com/owncloud/ocis/pull/2535 https://www.odata.org/getting-started/basic-tutorial/#modifyData diff --git a/go.mod b/go.mod index fb33ed5a0..07c461daf 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/blevesearch/bleve/v2 v2.1.0 github.com/coreos/go-oidc/v3 v3.0.0 github.com/cs3org/go-cs3apis v0.0.0-20210922150613-cb9e3c99f8de - github.com/cs3org/reva v1.13.1-0.20211005112832-fc6a28e1c206 + github.com/cs3org/reva v1.13.1-0.20211006080436-67f39be571fa github.com/disintegration/imaging v1.6.2 github.com/glauth/glauth v1.1.3-0.20210729125545-b9aecdfcac31 github.com/go-chi/chi/v5 v5.0.4 diff --git a/go.sum b/go.sum index 638b89b2e..f3c9e54f6 100644 --- a/go.sum +++ b/go.sum @@ -291,8 +291,8 @@ github.com/crewjam/saml v0.4.5/go.mod h1:qCJQpUtZte9R1ZjUBcW8qtCNlinbO363ooNl02S github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= github.com/cs3org/go-cs3apis v0.0.0-20210922150613-cb9e3c99f8de h1:N+AI8wz7yhDDqHDuq9EGaqQoFhAOi9XW37xt0ormflw= github.com/cs3org/go-cs3apis v0.0.0-20210922150613-cb9e3c99f8de/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva v1.13.1-0.20211005112832-fc6a28e1c206 h1:JKVYnbtWYNunOzDx9++NEKevnUKygypAEA66TT4j5aQ= -github.com/cs3org/reva v1.13.1-0.20211005112832-fc6a28e1c206/go.mod h1:z1GjBB1gBv2olyqhWpTbL+JOobb2Q+GCSebR09x797A= +github.com/cs3org/reva v1.13.1-0.20211006080436-67f39be571fa h1:sKNIaZ7rZFi+32Wnv8Z8Tc+J4gh0AYrUjaxl0Uk8JCQ= +github.com/cs3org/reva v1.13.1-0.20211006080436-67f39be571fa/go.mod h1:z1GjBB1gBv2olyqhWpTbL+JOobb2Q+GCSebR09x797A= 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= diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index be8456ca9..3329a0a31 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -170,6 +170,18 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, fmt.Errorf("invalid name").Error()) return } + + var driveType string + if drive.DriveType != nil { + driveType = *drive.DriveType + } + switch driveType { + case "": + driveType = "project" + case "share": + errorcode.GeneralException.Render(w, r, http.StatusBadRequest, fmt.Errorf("drives of type share cannot be created via this api").Error()) + } + var quota uint64 if drive.Quota != nil && drive.Quota.Total != nil { quota = uint64(*drive.Quota.Total) @@ -179,7 +191,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) { csr := provider.CreateStorageSpaceRequest{ Owner: us, - Type: "share", + Type: driveType, Name: spaceName, Quota: &provider.Quota{ QuotaMaxBytes: quota,