github.com/cyverse/go-irodsclient@v0.13.2/irods/types/meta.go (about) 1 package types 2 3 import ( 4 "fmt" 5 6 "golang.org/x/xerrors" 7 ) 8 9 // IRODSMetaItemType describes a type to set metadata on 10 type IRODSMetaItemType string 11 12 const ( 13 // IRODSDataObjectMetaItemType is a type for data object meta 14 IRODSDataObjectMetaItemType IRODSMetaItemType = "-d" 15 // IRODSCollectionMetaItemType is a type for collection meta 16 IRODSCollectionMetaItemType IRODSMetaItemType = "-C" 17 // IRODSResourceMetaItemType is a type for resource meta 18 IRODSResourceMetaItemType IRODSMetaItemType = "-R" 19 // IRODSUserMetaItemType is a type for user meta 20 IRODSUserMetaItemType IRODSMetaItemType = "-u" 21 ) 22 23 // GetIRODSMetaItemType gets the irods metadata item type from an object. 24 func GetIRODSMetaItemType(data interface{}) (IRODSMetaItemType, error) { 25 switch data.(type) { 26 case IRODSDataObject: 27 return IRODSDataObjectMetaItemType, nil 28 case IRODSCollection: 29 return IRODSCollectionMetaItemType, nil 30 case IRODSUser: 31 return IRODSUserMetaItemType, nil 32 default: 33 return "", xerrors.Errorf("unknown irods metadata item type") 34 } 35 } 36 37 // IRODSMeta contains irods metadata 38 type IRODSMeta struct { 39 AVUID int64 // is ignored on metadata operations (set, add, mod, rm) 40 Name string 41 Value string 42 Units string 43 } 44 45 // ToString stringifies the object 46 func (meta *IRODSMeta) ToString() string { 47 return fmt.Sprintf("<IRODSMeta %d %s %s %s>", meta.AVUID, meta.Name, meta.Value, meta.Units) 48 } 49 50 // IRODSMetaCollection contains irods data object information 51 type IRODSMetaCollection struct { 52 Path string 53 } 54 55 // ToString stringifies the object 56 func (meta *IRODSMetaCollection) ToString() string { 57 return fmt.Sprintf("<IRODSMetaCollection %s>", meta.Path) 58 }