diff --git a/cmd/reva/ocm-share-create.go b/cmd/reva/ocm-share-create.go index b78bff48656..b073eeedbcc 100644 --- a/cmd/reva/ocm-share-create.go +++ b/cmd/reva/ocm-share-create.go @@ -110,6 +110,8 @@ func ocmShareCreateCommand() *command { Permissions: perm, Grantee: &provider.Grantee{ Type: gt, + // For now, we only support user shares. + // TODO (ishank011): To be updated once this is decided. Id: &provider.Grantee_UserId{UserId: &userpb.UserId{ Idp: *idp, OpaqueId: *grantee, diff --git a/cmd/reva/share-create.go b/cmd/reva/share-create.go index ac90374d5d0..198f54e8407 100644 --- a/cmd/reva/share-create.go +++ b/cmd/reva/share-create.go @@ -23,6 +23,7 @@ import ( "os" "time" + grouppb "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1" @@ -89,12 +90,22 @@ func shareCreateCommand() *command { }, Grantee: &provider.Grantee{ Type: gt, - Id: &provider.Grantee_UserId{UserId: &userpb.UserId{ - Idp: *idp, - OpaqueId: *grantee, - }}, }, } + if *grantType == "user" { + grant.Grantee.Id = &provider.Grantee_UserId{UserId: &userpb.UserId{ + Idp: *idp, + OpaqueId: *grantee, + }} + } else if *grantType == "group" { + grant.Grantee.Id = &provider.Grantee_GroupId{GroupId: &grouppb.GroupId{ + Idp: *idp, + OpaqueId: *grantee, + }} + } else { + return errors.New("Invalid grantee type argument: " + *grantType) + } + shareRequest := &collaboration.CreateShareRequest{ ResourceInfo: res.Info, Grant: grant, @@ -114,9 +125,15 @@ func shareCreateCommand() *command { t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Type", "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated"}) s := shareRes.Share + var idp, opaque string + if s.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER { + idp, opaque = s.Grantee.GetUserId().Idp, s.Grantee.GetUserId().OpaqueId + } else if s.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_GROUP { + idp, opaque = s.Grantee.GetGroupId().Idp, s.Grantee.GetGroupId().OpaqueId + } t.AppendRows([]table.Row{ {s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), - s.Grantee.Type.String(), s.Grantee.GetUserId().Idp, s.Grantee.GetUserId().OpaqueId, + s.Grantee.Type.String(), idp, opaque, time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)}, }) t.Render() diff --git a/cmd/reva/share-list-received.go b/cmd/reva/share-list-received.go index 57376f6c2f0..97c7d82b19b 100644 --- a/cmd/reva/share-list-received.go +++ b/cmd/reva/share-list-received.go @@ -26,6 +26,7 @@ import ( rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1" + provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" "github.com/jedib0t/go-pretty/table" ) @@ -57,10 +58,16 @@ func shareListReceivedCommand() *command { t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Type", "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated", "State"}) for _, s := range shareRes.Shares { + var idp, opaque string + if s.Share.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER { + idp, opaque = s.Share.Grantee.GetUserId().Idp, s.Share.Grantee.GetUserId().OpaqueId + } else if s.Share.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_GROUP { + idp, opaque = s.Share.Grantee.GetGroupId().Idp, s.Share.Grantee.GetGroupId().OpaqueId + } t.AppendRows([]table.Row{ {s.Share.Id.OpaqueId, s.Share.Owner.Idp, s.Share.Owner.OpaqueId, s.Share.ResourceId.String(), - s.Share.Permissions.String(), s.Share.Grantee.Type.String(), s.Share.Grantee.GetUserId().Idp, - s.Share.Grantee.GetUserId().OpaqueId, time.Unix(int64(s.Share.Ctime.Seconds), 0), + s.Share.Permissions.String(), s.Share.Grantee.Type.String(), idp, + opaque, time.Unix(int64(s.Share.Ctime.Seconds), 0), time.Unix(int64(s.Share.Mtime.Seconds), 0), s.State.String()}, }) } diff --git a/cmd/reva/share-list.go b/cmd/reva/share-list.go index 9ccc9f6fbe9..73b005d0cd0 100644 --- a/cmd/reva/share-list.go +++ b/cmd/reva/share-list.go @@ -86,9 +86,15 @@ func shareListCommand() *command { "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated"}) for _, s := range shareRes.Shares { + var idp, opaque string + if s.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER { + idp, opaque = s.Grantee.GetUserId().Idp, s.Grantee.GetUserId().OpaqueId + } else if s.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_GROUP { + idp, opaque = s.Grantee.GetGroupId().Idp, s.Grantee.GetGroupId().OpaqueId + } t.AppendRows([]table.Row{ {s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), - s.Grantee.Type.String(), s.Grantee.GetUserId().Idp, s.Grantee.GetUserId().OpaqueId, + s.Grantee.Type.String(), idp, opaque, time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)}, }) }