github.com/cs3org/reva/v2@v2.27.7/pkg/ocm/share/utils.go (about) 1 // Copyright 2018-2023 CERN 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // In applying this license, CERN does not waive the privileges and immunities 16 // granted to it by virtue of its status as an Intergovernmental Organization 17 // or submit itself to any jurisdiction. 18 19 package share 20 21 import ( 22 appprovider "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1" 23 ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1" 24 provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" 25 ) 26 27 // NewWebDAVProtocol is an abstraction for creating a WebDAV protocol. 28 func NewWebDAVProtocol(uri, shareSecred string, perms *ocm.SharePermissions) *ocm.Protocol { 29 return &ocm.Protocol{ 30 Term: &ocm.Protocol_WebdavOptions{ 31 WebdavOptions: &ocm.WebDAVProtocol{ 32 Uri: uri, 33 SharedSecret: shareSecred, 34 Permissions: perms, 35 }, 36 }, 37 } 38 } 39 40 // NewWebappProtocol is an abstraction for creating a Webapp protocol. 41 func NewWebappProtocol(uriTemplate string, viewMode appprovider.ViewMode) *ocm.Protocol { 42 return &ocm.Protocol{ 43 Term: &ocm.Protocol_WebappOptions{ 44 WebappOptions: &ocm.WebappProtocol{ 45 UriTemplate: uriTemplate, 46 ViewMode: viewMode, 47 }, 48 }, 49 } 50 } 51 52 // NewTransferProtocol is an abstraction for creating a Transfer protocol. 53 func NewTransferProtocol(sourceURI, sharedSecret string, size uint64) *ocm.Protocol { 54 return &ocm.Protocol{ 55 Term: &ocm.Protocol_TransferOptions{ 56 TransferOptions: &ocm.TransferProtocol{ 57 SourceUri: sourceURI, 58 SharedSecret: sharedSecret, 59 Size: size, 60 }, 61 }, 62 } 63 } 64 65 // NewWebDavAccessMethod is an abstraction for creating a WebDAV access method. 66 func NewWebDavAccessMethod(perms *provider.ResourcePermissions) *ocm.AccessMethod { 67 return &ocm.AccessMethod{ 68 Term: &ocm.AccessMethod_WebdavOptions{ 69 WebdavOptions: &ocm.WebDAVAccessMethod{ 70 Permissions: perms, 71 }, 72 }, 73 } 74 } 75 76 // NewWebappAccessMethod is an abstraction for creating a Webapp access method. 77 func NewWebappAccessMethod(mode appprovider.ViewMode) *ocm.AccessMethod { 78 return &ocm.AccessMethod{ 79 Term: &ocm.AccessMethod_WebappOptions{ 80 WebappOptions: &ocm.WebappAccessMethod{ 81 ViewMode: mode, 82 }, 83 }, 84 } 85 } 86 87 // NewTransferAccessMethod is an abstraction for creating a Transfer access method. 88 func NewTransferAccessMethod() *ocm.AccessMethod { 89 return &ocm.AccessMethod{ 90 Term: &ocm.AccessMethod_TransferOptions{ 91 TransferOptions: &ocm.TransferAccessMethod{}, 92 }, 93 } 94 }