Class: RightAws::Sqs::Grantee
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#perms ⇒ Object
Returns the value of attribute perms.
-
#queue ⇒ Object
Returns the value of attribute queue.
Instance Method Summary collapse
-
#drop ⇒ Object
Revokes all permissions for this grantee.
-
#grant(permission = nil) ⇒ Object
Adds permissions for grantee.
-
#initialize(queue, email = nil, id = nil, name = nil, perms = []) ⇒ Grantee
constructor
Creates new Grantee instance.
-
#retrieve ⇒ Object
Retrieves security information for grantee identified by email.
-
#revoke(permission = 'FULLCONTROL') ⇒ Object
Revokes permissions for grantee.
Constructor Details
#initialize(queue, email = nil, id = nil, name = nil, perms = []) ⇒ Grantee
Creates new Grantee instance. To create new grantee for queue use:
grantee = Grantee.new(queue, [email protected])
grantee.grant('FULLCONTROL')
324 325 326 327 328 329 330 331 |
# File 'lib/sqs/right_sqs.rb', line 324 def initialize(queue, email=nil, id=nil, name=nil, perms=[]) @queue = queue @id = id @name = name @perms = perms @email = email retrieve unless id end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
316 317 318 |
# File 'lib/sqs/right_sqs.rb', line 316 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
316 317 318 |
# File 'lib/sqs/right_sqs.rb', line 316 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
316 317 318 |
# File 'lib/sqs/right_sqs.rb', line 316 def name @name end |
#perms ⇒ Object
Returns the value of attribute perms.
316 317 318 |
# File 'lib/sqs/right_sqs.rb', line 316 def perms @perms end |
#queue ⇒ Object
Returns the value of attribute queue.
316 317 318 |
# File 'lib/sqs/right_sqs.rb', line 316 def queue @queue end |
Instance Method Details
#drop ⇒ Object
Revokes all permissions for this grantee. Returns true
377 378 379 380 381 382 383 |
# File 'lib/sqs/right_sqs.rb', line 377 def drop @perms.each do || @queue.sqs.interface.remove_grant(@queue.url, @email || @id, ) end retrieve true end |
#grant(permission = nil) ⇒ Object
Adds permissions for grantee. Permission: ‘FULLCONTROL’ | ‘RECEIVEMESSAGE’ | ‘SENDMESSAGE’. The caller must have set the email instance variable.
354 355 356 357 358 |
# File 'lib/sqs/right_sqs.rb', line 354 def grant(=nil) raise "You can't grant permission without defining a grantee email address!" unless @email @queue.sqs.interface.add_grant(@queue.url, @email, ) retrieve end |
#retrieve ⇒ Object
Retrieves security information for grantee identified by email. Returns nil
if the named user has no privileges on this queue, or true
if perms updated successfully.
336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/sqs/right_sqs.rb', line 336 def retrieve # :nodoc: @id = nil @name = nil @perms = [] hash = @queue.sqs.interface.list_grants(@queue.url, @email) return nil if hash.empty? grantee = hash.shift @id = grantee[0] @name = grantee[1][:name] @perms = grantee[1][:perms] true end |
#revoke(permission = 'FULLCONTROL') ⇒ Object
Revokes permissions for grantee. Permission: ‘FULLCONTROL’ | ‘RECEIVEMESSAGE’ | ‘SENDMESSAGE’. Default value is ‘FULLCONTROL’. User must have @email or @id set. Returns true
.
365 366 367 368 369 370 371 372 373 |
# File 'lib/sqs/right_sqs.rb', line 365 def revoke(='FULLCONTROL') @queue.sqs.interface.remove_grant(@queue.url, @email || @id, ) unless @email # if email is unknown - just remove permission from local perms list... @perms.delete() else # ... else retrieve updated information from Amazon retrieve end true end |