Class: AWS::S3::AccessControlList::Grantee

Inherits:
Object
  • Object
show all
Includes:
AWS::S3::ACLObject
Defined in:
lib/aws/s3/access_control_list.rb

Overview

Represents a user who is granted some kind of permission through a Grant. There are three ways to specify a grantee:

  • You can specify the canonical user ID, for example. When you read an ACL from S3, all grantees will be identified this way, and the display_name attribute will also be provided.

    Grantee.new(:canonical_user_id => "8a6925ce4adf588a4f21c32aa379004fef")
    
  • You can specify the e-mail address of an AWS customer, for example:

    Grantee.new(:amazon_customer_email => '[email protected]')
    
  • You can specify a group URI, for example:

    Grantee.new(:group_uri => 'http://acs.amazonaws.com/groups/global/AllUsers')
    

    For more details about group URIs, see: docs.amazonwebservices.com/AmazonS3/latest/dev/ACLOverview.html

When constructing a grantee, you must provide a value for exactly one of the following attributes:

  • amazon_customer_email

  • canonical_user_id

  • group_uri

Constant Summary collapse

SIGNAL_ATTRIBUTES =
[:amazon_customer_email,
:canonical_user_id,
:group_uri]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AWS::S3::ACLObject

#body_xml, #element_name, included, #initialize, #to_s, #to_xml, #valid?, #validate_input

Instance Attribute Details

#amazon_customer_emailString

The e-mail address of an AWS customer.

Returns:

  • (String)

    the current value of amazon_customer_email



98
99
100
# File 'lib/aws/s3/access_control_list.rb', line 98

def amazon_customer_email
  @amazon_customer_email
end

#canonical_user_idString

The canonical user ID of an AWS customer.

Returns:

  • (String)

    the current value of canonical_user_id



98
99
100
# File 'lib/aws/s3/access_control_list.rb', line 98

def canonical_user_id
  @canonical_user_id
end

#display_nameString

The display name associated with the grantee. This is provided by S3 when reading an ACL.

Returns:

  • (String)

    the current value of display_name



98
99
100
# File 'lib/aws/s3/access_control_list.rb', line 98

def display_name
  @display_name
end

#group_uriString

A URI that identifies a particular group of users.

Returns:

  • (String)

    the current value of group_uri



98
99
100
# File 'lib/aws/s3/access_control_list.rb', line 98

def group_uri
  @group_uri
end

Instance Method Details

#signal_attributeObject



130
131
132
# File 'lib/aws/s3/access_control_list.rb', line 130

def signal_attribute
  SIGNAL_ATTRIBUTES.find { |att| send(att) }
end

#stagObject



120
121
122
123
124
125
126
127
# File 'lib/aws/s3/access_control_list.rb', line 120

def stag
  if attr = signal_attribute
    super + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
      " xsi:type=\"#{type_for_attr(attr)}\""
  else
    super
  end
end

#type_for_attr(attr) ⇒ Object



135
136
137
138
139
# File 'lib/aws/s3/access_control_list.rb', line 135

def type_for_attr(attr)
  { :amazon_customer_email => "AmazonCustomerByEmail",
    :canonical_user_id => "CanonicalUser",
    :group_uri => "Group" }[attr]
end

#validate!Object

Raises an exception unless this object is valid according to S3’s published ACL schema.



111
112
113
114
115
116
117
# File 'lib/aws/s3/access_control_list.rb', line 111

def validate!
  attr = signal_attribute
  raise "missing amazon_customer_email, canonical_user_id, "+
    "or group_uri" unless attr
  raise "display_name is invalid with #{attr}" if
    attr != :canonical_user_id and display_name
end