You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::S3::BucketWebsite

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb

Defined Under Namespace

Classes: Collection

Actions collapse

Associations collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, options = {}) ⇒ BucketWebsite #initialize(options = {}) ⇒ BucketWebsite

Returns a new instance of BucketWebsite

Overloads:

  • #initialize(bucket_name, options = {}) ⇒ BucketWebsite

    Parameters:

    • bucket_name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ BucketWebsite

    Options Hash (options):

    • :bucket_name (required, String)
    • :client (Client)


19
20
21
22
23
24
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 19

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @bucket_name = extract_bucket_name(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#bucketBucket

Returns:



146
147
148
149
150
151
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 146

def bucket
  Bucket.new(
    name: @bucket_name,
    client: @client
  )
end

#bucket_nameString

Returns:

  • (String)


29
30
31
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 29

def bucket_name
  @bucket_name
end

#clientClient

Returns:



56
57
58
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 56

def client
  @client
end

#dataTypes::GetBucketWebsiteOutput

Returns the data for this Aws::S3::BucketWebsite. Calls Client#get_bucket_website if #data_loaded? is false.

Returns:



76
77
78
79
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 76

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



84
85
86
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 84

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


bucket_website.delete()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (EmptyStructure)


95
96
97
98
99
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 95

def delete(options = {})
  options = options.merge(bucket: @bucket_name)
  resp = @client.delete_bucket_website(options)
  resp.data
end

#error_documentTypes::ErrorDocument



44
45
46
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 44

def error_document
  data.error_document
end

#index_documentTypes::IndexDocument



39
40
41
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 39

def index_document
  data.index_document
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::S3::BucketWebsite. Returns self making it possible to chain methods.

bucket_website.reload.data

Returns:

  • (self)


66
67
68
69
70
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 66

def load
  resp = @client.get_bucket_website(bucket: @bucket_name)
  @data = resp.data
  self
end

#put(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


bucket_website.put({
  content_md5: "ContentMD5",
  website_configuration: { # required
    error_document: {
      key: "ObjectKey", # required
    },
    index_document: {
      suffix: "Suffix", # required
    },
    redirect_all_requests_to: {
      host_name: "HostName", # required
      protocol: "http", # accepts http, https
    },
    routing_rules: [
      {
        condition: {
          http_error_code_returned_equals: "HttpErrorCodeReturnedEquals",
          key_prefix_equals: "KeyPrefixEquals",
        },
        redirect: { # required
          host_name: "HostName",
          http_redirect_code: "HttpRedirectCode",
          protocol: "http", # accepts http, https
          replace_key_prefix_with: "ReplaceKeyPrefixWith",
          replace_key_with: "ReplaceKeyWith",
        },
      },
    ],
  },
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

Returns:

  • (EmptyStructure)


137
138
139
140
141
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 137

def put(options = {})
  options = options.merge(bucket: @bucket_name)
  resp = @client.put_bucket_website(options)
  resp.data
end

#redirect_all_requests_toTypes::RedirectAllRequestsTo



34
35
36
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 34

def redirect_all_requests_to
  data.redirect_all_requests_to
end

#routing_rulesArray<Types::RoutingRule>

Returns:



49
50
51
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/bucket_website.rb', line 49

def routing_rules
  data.routing_rules
end