github.com/cyverse/go-irodsclient@v0.13.2/examples/list_ticket/list_ticket.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/cyverse/go-irodsclient/fs" 8 "github.com/cyverse/go-irodsclient/irods/types" 9 10 log "github.com/sirupsen/logrus" 11 ) 12 13 func main() { 14 logger := log.WithFields(log.Fields{ 15 "package": "main", 16 "function": "main", 17 }) 18 19 // Read account configuration from YAML file 20 yaml, err := os.ReadFile("account.yml") 21 if err != nil { 22 logger.Error(err) 23 panic(err) 24 } 25 26 account, err := types.CreateIRODSAccountFromYAML(yaml) 27 if err != nil { 28 logger.Error(err) 29 panic(err) 30 } 31 32 logger.Debugf("Account : %v", account.MaskSensitiveData()) 33 34 // Create a file system 35 appName := "list_ticket" 36 filesystem, err := fs.NewFileSystemWithDefault(account, appName) 37 if err != nil { 38 logger.Error(err) 39 panic(err) 40 } 41 42 defer filesystem.Release() 43 44 tickets, err := filesystem.ListTickets() 45 if err != nil { 46 logger.Error(err) 47 panic(err) 48 } 49 50 if len(tickets) == 0 { 51 fmt.Printf("Found no tickets\n") 52 } else { 53 for _, ticket := range tickets { 54 restrictions, err := filesystem.GetTicketRestrictions(ticket.ID) 55 if err != nil { 56 logger.Error(err) 57 panic(err) 58 } 59 60 fmt.Printf("> %d\n", ticket.ID) 61 fmt.Printf(" id: %d\n", ticket.ID) 62 fmt.Printf(" name: %s\n", ticket.Name) 63 fmt.Printf(" type: %s\n", ticket.Type) 64 fmt.Printf(" owner: %s\n", ticket.Owner) 65 fmt.Printf(" owner zone: %s\n", ticket.OwnerZone) 66 fmt.Printf(" object type: %s\n", ticket.ObjectType) 67 fmt.Printf(" path: %s\n", ticket.Path) 68 fmt.Printf(" expireTime: %s\n", ticket.ExpirationTime) 69 fmt.Printf(" uses limit: %d\n", ticket.UsesLimit) 70 fmt.Printf(" uses count: %d\n", ticket.UsesCount) 71 fmt.Printf(" write file limit: %d\n", ticket.WriteFileLimit) 72 fmt.Printf(" write file count: %d\n", ticket.WriteFileCount) 73 fmt.Printf(" write byte limit: %d\n", ticket.WriteByteLimit) 74 fmt.Printf(" write byte count: %d\n", ticket.WriteByteCount) 75 76 if len(restrictions.AllowedHosts) == 0 { 77 fmt.Printf(" No host restrictions\n") 78 } else { 79 for _, host := range restrictions.AllowedHosts { 80 fmt.Printf(" host restriction: %s\n", host) 81 } 82 } 83 84 if len(restrictions.AllowedUserNames) == 0 { 85 fmt.Printf(" No user restrictions\n") 86 } else { 87 for _, user := range restrictions.AllowedUserNames { 88 fmt.Printf(" user restriction: %s\n", user) 89 } 90 } 91 92 if len(restrictions.AllowedGroupNames) == 0 { 93 fmt.Printf(" No group restrictions\n") 94 } else { 95 for _, group := range restrictions.AllowedGroupNames { 96 fmt.Printf(" group restriction: %s\n", group) 97 } 98 } 99 } 100 } 101 }