github.com/cyverse/go-irodsclient@v0.13.2/irods/types/user.go (about)

     1  package types
     2  
     3  import "fmt"
     4  
     5  // IRODSUserType is a type of iRODS User
     6  type IRODSUserType string
     7  
     8  const (
     9  	// IRODSUserRodsGroup is for a group
    10  	IRODSUserRodsGroup IRODSUserType = "rodsgroup"
    11  	// IRODSUserRodsUser is for a user
    12  	IRODSUserRodsUser IRODSUserType = "rodsuser"
    13  	// IRODSUserRodsAdmin is for an admin user
    14  	IRODSUserRodsAdmin IRODSUserType = "rodsadmin"
    15  	// IRODSUserGroupAdmin is for an admin group
    16  	IRODSUserGroupAdmin IRODSUserType = "groupadmin"
    17  )
    18  
    19  // IRODSUser contains irods user information
    20  type IRODSUser struct {
    21  	ID   int64
    22  	Name string
    23  	Zone string
    24  	Type IRODSUserType
    25  }
    26  
    27  // IsGroup returns true if type is IRODSUserRodsGroup
    28  func (user *IRODSUser) IsGroup() bool {
    29  	return user.Type == IRODSUserRodsGroup
    30  }
    31  
    32  // IsUser returns true if type is IRODSUserRodsUser
    33  func (user *IRODSUser) IsUser() bool {
    34  	return user.Type == IRODSUserRodsUser
    35  }
    36  
    37  // IsAdminGroup returns true if type is IRODSUserGroupAdmin
    38  func (user *IRODSUser) IsAdminGroup() bool {
    39  	return user.Type == IRODSUserGroupAdmin
    40  }
    41  
    42  // IsAdminUser returns true if type is IRODSUserRodsAdmin
    43  func (user *IRODSUser) IsAdminUser() bool {
    44  	return user.Type == IRODSUserRodsAdmin
    45  }
    46  
    47  // ToString stringifies the object
    48  func (user *IRODSUser) ToString() string {
    49  	return fmt.Sprintf("<IRODSUser %d %s %s %s>", user.ID, user.Name, user.Zone, string(user.Type))
    50  }