github.com/cyverse/go-irodsclient@v0.13.2/fs/fs_ticket.go (about) 1 package fs 2 3 import ( 4 "time" 5 6 irods_fs "github.com/cyverse/go-irodsclient/irods/fs" 7 "github.com/cyverse/go-irodsclient/irods/types" 8 "github.com/cyverse/go-irodsclient/irods/util" 9 ) 10 11 // GetTicketForAnonymousAccess gets ticket information for anonymous access 12 func (fs *FileSystem) GetTicketForAnonymousAccess(ticketName string) (*types.IRODSTicketForAnonymousAccess, error) { 13 conn, err := fs.metaSession.AcquireConnection() 14 if err != nil { 15 return nil, err 16 } 17 defer fs.metaSession.ReturnConnection(conn) 18 19 ticketInfo, err := irods_fs.GetTicketForAnonymousAccess(conn, ticketName) 20 if err != nil { 21 return nil, err 22 } 23 24 return ticketInfo, err 25 } 26 27 // GetTicket gets ticket information 28 func (fs *FileSystem) GetTicket(ticketName string) (*types.IRODSTicket, error) { 29 conn, err := fs.metaSession.AcquireConnection() 30 if err != nil { 31 return nil, err 32 } 33 defer fs.metaSession.ReturnConnection(conn) 34 35 ticketInfo, err := irods_fs.GetTicket(conn, ticketName) 36 if err != nil { 37 return nil, err 38 } 39 40 return ticketInfo, err 41 } 42 43 // ListTickets lists all available ticket information 44 func (fs *FileSystem) ListTickets() ([]*types.IRODSTicket, error) { 45 conn, err := fs.metaSession.AcquireConnection() 46 if err != nil { 47 return nil, err 48 } 49 defer fs.metaSession.ReturnConnection(conn) 50 51 tickets, err := irods_fs.ListTickets(conn) 52 if err != nil { 53 return nil, err 54 } 55 56 return tickets, err 57 } 58 59 // ListTicketsBasic lists all available basic ticket information 60 func (fs *FileSystem) ListTicketsBasic() ([]*types.IRODSTicket, error) { 61 conn, err := fs.metaSession.AcquireConnection() 62 if err != nil { 63 return nil, err 64 } 65 defer fs.metaSession.ReturnConnection(conn) 66 67 tickets, err := irods_fs.ListTicketsBasic(conn) 68 if err != nil { 69 return nil, err 70 } 71 72 return tickets, err 73 } 74 75 // GetTicketRestrictions gets all restriction info. for the given ticket 76 func (fs *FileSystem) GetTicketRestrictions(ticketID int64) (*IRODSTicketRestrictions, error) { 77 conn, err := fs.metaSession.AcquireConnection() 78 if err != nil { 79 return nil, err 80 } 81 defer fs.metaSession.ReturnConnection(conn) 82 83 hosts, err := irods_fs.ListTicketAllowedHosts(conn, ticketID) 84 if err != nil { 85 return nil, err 86 } 87 88 usernames, err := irods_fs.ListTicketAllowedUserNames(conn, ticketID) 89 if err != nil { 90 return nil, err 91 } 92 93 groupnames, err := irods_fs.ListTicketAllowedGroupNames(conn, ticketID) 94 if err != nil { 95 return nil, err 96 } 97 98 return &IRODSTicketRestrictions{ 99 AllowedHosts: hosts, 100 AllowedUserNames: usernames, 101 AllowedGroupNames: groupnames, 102 }, nil 103 } 104 105 // ListTicketHostRestrictions lists all host restrictions for the given ticket 106 func (fs *FileSystem) ListTicketHostRestrictions(ticketID int64) ([]string, error) { 107 conn, err := fs.metaSession.AcquireConnection() 108 if err != nil { 109 return nil, err 110 } 111 defer fs.metaSession.ReturnConnection(conn) 112 113 hosts, err := irods_fs.ListTicketAllowedHosts(conn, ticketID) 114 if err != nil { 115 return nil, err 116 } 117 118 return hosts, err 119 } 120 121 // ListTicketUserNameRestrictions lists all user name restrictions for the given ticket 122 func (fs *FileSystem) ListTicketUserNameRestrictions(ticketID int64) ([]string, error) { 123 conn, err := fs.metaSession.AcquireConnection() 124 if err != nil { 125 return nil, err 126 } 127 defer fs.metaSession.ReturnConnection(conn) 128 129 usernames, err := irods_fs.ListTicketAllowedUserNames(conn, ticketID) 130 if err != nil { 131 return nil, err 132 } 133 134 return usernames, err 135 } 136 137 // ListTicketUserGroupRestrictions lists all group name restrictions for the given ticket 138 func (fs *FileSystem) ListTicketUserGroupRestrictions(ticketID int64) ([]string, error) { 139 conn, err := fs.metaSession.AcquireConnection() 140 if err != nil { 141 return nil, err 142 } 143 defer fs.metaSession.ReturnConnection(conn) 144 145 groupnames, err := irods_fs.ListTicketAllowedGroupNames(conn, ticketID) 146 if err != nil { 147 return nil, err 148 } 149 150 return groupnames, err 151 } 152 153 // CreateTicket creates a new ticket 154 func (fs *FileSystem) CreateTicket(ticketName string, ticketType types.TicketType, path string) error { 155 irodsPath := util.GetCorrectIRODSPath(path) 156 157 conn, err := fs.metaSession.AcquireConnection() 158 if err != nil { 159 return err 160 } 161 defer fs.metaSession.ReturnConnection(conn) 162 163 err = irods_fs.CreateTicket(conn, ticketName, ticketType, irodsPath) 164 if err != nil { 165 return err 166 } 167 168 return nil 169 } 170 171 // DeleteTicket deletes the given ticket 172 func (fs *FileSystem) DeleteTicket(ticketName string) error { 173 conn, err := fs.metaSession.AcquireConnection() 174 if err != nil { 175 return err 176 } 177 defer fs.metaSession.ReturnConnection(conn) 178 179 err = irods_fs.DeleteTicket(conn, ticketName) 180 if err != nil { 181 return err 182 } 183 184 return nil 185 } 186 187 // ModifyTicketUseLimit modifies the use limit of the given ticket 188 func (fs *FileSystem) ModifyTicketUseLimit(ticketName string, uses int64) error { 189 conn, err := fs.metaSession.AcquireConnection() 190 if err != nil { 191 return err 192 } 193 defer fs.metaSession.ReturnConnection(conn) 194 195 err = irods_fs.ModifyTicketUseLimit(conn, ticketName, uses) 196 if err != nil { 197 return err 198 } 199 200 return nil 201 } 202 203 // ClearTicketUseLimit clears the use limit of the given ticket 204 func (fs *FileSystem) ClearTicketUseLimit(ticketName string) error { 205 conn, err := fs.metaSession.AcquireConnection() 206 if err != nil { 207 return err 208 } 209 defer fs.metaSession.ReturnConnection(conn) 210 211 err = irods_fs.ClearTicketUseLimit(conn, ticketName) 212 if err != nil { 213 return err 214 } 215 216 return nil 217 } 218 219 // ModifyTicketWriteFileLimit modifies the write file limit of the given ticket 220 func (fs *FileSystem) ModifyTicketWriteFileLimit(ticketName string, count int64) error { 221 conn, err := fs.metaSession.AcquireConnection() 222 if err != nil { 223 return err 224 } 225 defer fs.metaSession.ReturnConnection(conn) 226 227 err = irods_fs.ModifyTicketWriteFileLimit(conn, ticketName, count) 228 if err != nil { 229 return err 230 } 231 232 return nil 233 } 234 235 // ClearTicketWriteFileLimit clears the write file limit of the given ticket 236 func (fs *FileSystem) ClearTicketWriteFileLimit(ticketName string) error { 237 conn, err := fs.metaSession.AcquireConnection() 238 if err != nil { 239 return err 240 } 241 defer fs.metaSession.ReturnConnection(conn) 242 243 err = irods_fs.ClearTicketWriteFileLimit(conn, ticketName) 244 if err != nil { 245 return err 246 } 247 248 return nil 249 } 250 251 // ModifyTicketWriteByteLimit modifies the write byte limit of the given ticket 252 func (fs *FileSystem) ModifyTicketWriteByteLimit(ticketName string, bytes int64) error { 253 conn, err := fs.metaSession.AcquireConnection() 254 if err != nil { 255 return err 256 } 257 defer fs.metaSession.ReturnConnection(conn) 258 259 err = irods_fs.ModifyTicketWriteByteLimit(conn, ticketName, bytes) 260 if err != nil { 261 return err 262 } 263 264 return nil 265 } 266 267 // ClearTicketWriteByteLimit clears the write byte limit of the given ticket 268 func (fs *FileSystem) ClearTicketWriteByteLimit(ticketName string) error { 269 conn, err := fs.metaSession.AcquireConnection() 270 if err != nil { 271 return err 272 } 273 defer fs.metaSession.ReturnConnection(conn) 274 275 err = irods_fs.ClearTicketWriteByteLimit(conn, ticketName) 276 if err != nil { 277 return err 278 } 279 280 return nil 281 } 282 283 // AddTicketAllowedUser adds a user to the allowed user names list of the given ticket 284 func (fs *FileSystem) AddTicketAllowedUser(ticketName string, userName string) error { 285 conn, err := fs.metaSession.AcquireConnection() 286 if err != nil { 287 return err 288 } 289 defer fs.metaSession.ReturnConnection(conn) 290 291 err = irods_fs.AddTicketAllowedUser(conn, ticketName, userName) 292 if err != nil { 293 return err 294 } 295 296 return nil 297 } 298 299 // RemoveTicketAllowedUser removes the user from the allowed user names list of the given ticket 300 func (fs *FileSystem) RemoveTicketAllowedUser(ticketName string, userName string) error { 301 conn, err := fs.metaSession.AcquireConnection() 302 if err != nil { 303 return err 304 } 305 defer fs.metaSession.ReturnConnection(conn) 306 307 err = irods_fs.RemoveTicketAllowedUser(conn, ticketName, userName) 308 if err != nil { 309 return err 310 } 311 312 return nil 313 } 314 315 // AddTicketAllowedGroup adds a group to the allowed group names list of the given ticket 316 func (fs *FileSystem) AddTicketAllowedGroup(ticketName string, groupName string) error { 317 conn, err := fs.metaSession.AcquireConnection() 318 if err != nil { 319 return err 320 } 321 defer fs.metaSession.ReturnConnection(conn) 322 323 err = irods_fs.AddTicketAllowedGroup(conn, ticketName, groupName) 324 if err != nil { 325 return err 326 } 327 328 return nil 329 } 330 331 // RemoveTicketAllowedGroup removes the group from the allowed group names list of the given ticket 332 func (fs *FileSystem) RemoveTicketAllowedGroup(ticketName string, groupName string) error { 333 conn, err := fs.metaSession.AcquireConnection() 334 if err != nil { 335 return err 336 } 337 defer fs.metaSession.ReturnConnection(conn) 338 339 err = irods_fs.RemoveTicketAllowedGroup(conn, ticketName, groupName) 340 if err != nil { 341 return err 342 } 343 344 return nil 345 } 346 347 // AddTicketAllowedHost adds a host to the allowed hosts list of the given ticket 348 func (fs *FileSystem) AddTicketAllowedHost(ticketName string, host string) error { 349 conn, err := fs.metaSession.AcquireConnection() 350 if err != nil { 351 return err 352 } 353 defer fs.metaSession.ReturnConnection(conn) 354 355 err = irods_fs.AddTicketAllowedHost(conn, ticketName, host) 356 if err != nil { 357 return err 358 } 359 360 return nil 361 } 362 363 // RemoveTicketAllowedHost removes the host from the allowed hosts list of the given ticket 364 func (fs *FileSystem) RemoveTicketAllowedHost(ticketName string, host string) error { 365 conn, err := fs.metaSession.AcquireConnection() 366 if err != nil { 367 return err 368 } 369 defer fs.metaSession.ReturnConnection(conn) 370 371 err = irods_fs.RemoveTicketAllowedHost(conn, ticketName, host) 372 if err != nil { 373 return err 374 } 375 376 return nil 377 } 378 379 // ModifyTicketExpirationTime modifies the expiration time of the given ticket 380 func (fs *FileSystem) ModifyTicketExpirationTime(ticketName string, expirationTime time.Time) error { 381 conn, err := fs.metaSession.AcquireConnection() 382 if err != nil { 383 return err 384 } 385 defer fs.metaSession.ReturnConnection(conn) 386 387 err = irods_fs.ModifyTicketExpirationTime(conn, ticketName, expirationTime) 388 if err != nil { 389 return err 390 } 391 392 return nil 393 } 394 395 // ClearTicketExpirationTime clears the expiration time of the given ticket 396 func (fs *FileSystem) ClearTicketExpirationTime(ticketName string) error { 397 conn, err := fs.metaSession.AcquireConnection() 398 if err != nil { 399 return err 400 } 401 defer fs.metaSession.ReturnConnection(conn) 402 403 err = irods_fs.ClearTicketExpirationTime(conn, ticketName) 404 if err != nil { 405 return err 406 } 407 408 return nil 409 }