github.com/cs3org/reva/v2@v2.27.7/pkg/events/spaces.go (about)

     1  // Copyright 2018-2022 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 events
    20  
    21  import (
    22  	"encoding/json"
    23  	"time"
    24  
    25  	group "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
    26  	user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
    27  	provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
    28  	types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
    29  )
    30  
    31  // SpaceCreated is emitted when a space is created
    32  type SpaceCreated struct {
    33  	Executant *user.UserId
    34  	ID        *provider.StorageSpaceId
    35  	Owner     *user.UserId
    36  	Root      *provider.ResourceId
    37  	Name      string
    38  	Type      string
    39  	Quota     *provider.Quota
    40  	MTime     *types.Timestamp
    41  }
    42  
    43  // Unmarshal to fulfill umarshaller interface
    44  func (SpaceCreated) Unmarshal(v []byte) (interface{}, error) {
    45  	e := SpaceCreated{}
    46  	err := json.Unmarshal(v, &e)
    47  	return e, err
    48  }
    49  
    50  // SpaceRenamed is emitted when a space is renamed
    51  type SpaceRenamed struct {
    52  	Executant *user.UserId
    53  	ID        *provider.StorageSpaceId
    54  	Owner     *user.UserId
    55  	Name      string
    56  	Timestamp *types.Timestamp
    57  }
    58  
    59  // Unmarshal to fulfill umarshaller interface
    60  func (SpaceRenamed) Unmarshal(v []byte) (interface{}, error) {
    61  	e := SpaceRenamed{}
    62  	err := json.Unmarshal(v, &e)
    63  	return e, err
    64  }
    65  
    66  // SpaceDisabled is emitted when a space is disabled
    67  type SpaceDisabled struct {
    68  	Executant *user.UserId
    69  	ID        *provider.StorageSpaceId
    70  	Timestamp time.Time
    71  }
    72  
    73  // Unmarshal to fulfill umarshaller interface
    74  func (SpaceDisabled) Unmarshal(v []byte) (interface{}, error) {
    75  	e := SpaceDisabled{}
    76  	err := json.Unmarshal(v, &e)
    77  	return e, err
    78  }
    79  
    80  // SpaceEnabled is emitted when a space is (re-)enabled
    81  type SpaceEnabled struct {
    82  	Executant *user.UserId
    83  	ID        *provider.StorageSpaceId
    84  	Owner     *user.UserId
    85  	Timestamp *types.Timestamp
    86  }
    87  
    88  // Unmarshal to fulfill umarshaller interface
    89  func (SpaceEnabled) Unmarshal(v []byte) (interface{}, error) {
    90  	e := SpaceEnabled{}
    91  	err := json.Unmarshal(v, &e)
    92  	return e, err
    93  }
    94  
    95  // SpaceDeleted is emitted when a space is deleted
    96  type SpaceDeleted struct {
    97  	Executant    *user.UserId
    98  	ID           *provider.StorageSpaceId
    99  	SpaceName    string
   100  	FinalMembers map[string]provider.ResourcePermissions
   101  	Timestamp    time.Time
   102  }
   103  
   104  // Unmarshal to fulfill umarshaller interface
   105  func (SpaceDeleted) Unmarshal(v []byte) (interface{}, error) {
   106  	e := SpaceDeleted{}
   107  	err := json.Unmarshal(v, &e)
   108  	return e, err
   109  }
   110  
   111  // SpaceShared is emitted when a space is shared
   112  type SpaceShared struct {
   113  	Executant      *user.UserId
   114  	GranteeUserID  *user.UserId
   115  	GranteeGroupID *group.GroupId
   116  	Creator        *user.UserId
   117  	ID             *provider.StorageSpaceId
   118  	Timestamp      time.Time
   119  }
   120  
   121  // Unmarshal to fulfill umarshaller interface
   122  func (SpaceShared) Unmarshal(v []byte) (interface{}, error) {
   123  	e := SpaceShared{}
   124  	err := json.Unmarshal(v, &e)
   125  	return e, err
   126  }
   127  
   128  // SpaceShareUpdated is emitted when a space share is updated
   129  type SpaceShareUpdated struct {
   130  	Executant      *user.UserId
   131  	GranteeUserID  *user.UserId
   132  	GranteeGroupID *group.GroupId
   133  	ID             *provider.StorageSpaceId
   134  	Timestamp      time.Time
   135  }
   136  
   137  // Unmarshal to fulfill umarshaller interface
   138  func (SpaceShareUpdated) Unmarshal(v []byte) (interface{}, error) {
   139  	ev := SpaceShareUpdated{}
   140  	err := json.Unmarshal(v, &ev)
   141  	return ev, err
   142  }
   143  
   144  // SpaceUnshared is emitted when a space is unshared
   145  type SpaceUnshared struct {
   146  	Executant      *user.UserId
   147  	GranteeUserID  *user.UserId
   148  	GranteeGroupID *group.GroupId
   149  	ID             *provider.StorageSpaceId
   150  	Timestamp      time.Time
   151  }
   152  
   153  // Unmarshal to fulfill umarshaller interface
   154  func (SpaceUnshared) Unmarshal(v []byte) (interface{}, error) {
   155  	e := SpaceUnshared{}
   156  	err := json.Unmarshal(v, &e)
   157  	return e, err
   158  }
   159  
   160  // SpaceUpdated is emitted when a space is updated
   161  type SpaceUpdated struct {
   162  	Executant *user.UserId
   163  	ID        *provider.StorageSpaceId
   164  	Space     *provider.StorageSpace
   165  	Timestamp *types.Timestamp
   166  }
   167  
   168  // Unmarshal to fulfill umarshaller interface
   169  func (SpaceUpdated) Unmarshal(v []byte) (interface{}, error) {
   170  	e := SpaceUpdated{}
   171  	err := json.Unmarshal(v, &e)
   172  	return e, err
   173  }
   174  
   175  // SpaceMembershipExpired is emitted when a space membership expires
   176  type SpaceMembershipExpired struct {
   177  	SpaceOwner *user.UserId
   178  	SpaceID    *provider.StorageSpaceId
   179  	SpaceName  string
   180  	ExpiredAt  time.Time
   181  	// split the protobuf Grantee oneof so we can use stdlib encoding/json
   182  	GranteeUserID  *user.UserId
   183  	GranteeGroupID *group.GroupId
   184  	Timestamp      *types.Timestamp
   185  }
   186  
   187  // Unmarshal to fulfill umarshaller interface
   188  func (SpaceMembershipExpired) Unmarshal(v []byte) (interface{}, error) {
   189  	e := SpaceMembershipExpired{}
   190  	err := json.Unmarshal(v, &e)
   191  	return e, err
   192  }