From b33ac87b135d930db01231dc7c1b0489d04ee908 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Mon, 7 Mar 2022 17:51:27 +0100 Subject: [PATCH] add driveAlias to the graphAPI --- go.mod | 2 +- go.sum | 2 ++ graph/pkg/service/v0/drives.go | 25 ++++++++++++++----------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 448427b6854..f4e0c061bfc 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.18.1 - github.com/owncloud/libre-graph-api-go v0.11.0 + github.com/owncloud/libre-graph-api-go v0.12.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.12.1 github.com/rs/zerolog v1.26.1 diff --git a/go.sum b/go.sum index bd91fd53286..759ad2d8e4e 100644 --- a/go.sum +++ b/go.sum @@ -1164,6 +1164,8 @@ github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CF github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA= github.com/owncloud/libre-graph-api-go v0.11.0 h1:E260P0EJQvtdkUHYk/l2GeKoDxcbsazAqY9MnAQxUt8= github.com/owncloud/libre-graph-api-go v0.11.0/go.mod h1:579sFrPP7aP24LZXGPopLfvE+hAka/2DYHk0+Ij+w+U= +github.com/owncloud/libre-graph-api-go v0.12.0 h1:2EzBEzs2r5wP3PYss2woNhTl/0/NZfMOzFe/bvtdsEU= +github.com/owncloud/libre-graph-api-go v0.12.0/go.mod h1:579sFrPP7aP24LZXGPopLfvE+hAka/2DYHk0+Ij+w+U= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index e3e16186164..a82f284223c 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -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))