    # File lib/fog/aws/requests/storage/put_bucket_lifecycle.rb, line 29
            def put_bucket_lifecycle(bucket_name, lifecycle)
              builder = Nokogiri::XML::Builder.new do
                LifecycleConfiguration {
                  lifecycle['Rules'].each do |rule|
                    Rule {
                      ID rule['ID']
                      Prefix rule['Prefix']
                      Status rule['Enabled'] ? 'Enabled' : 'Disabled'
                      unless (rule['Expiration'] or rule['Transition'])
                        Expiration { Days rule['Days'] }
                      else
                        if rule['Expiration']
                          if rule['Expiration']['Days']
                            Expiration { Days rule['Expiration']['Days'] }
                          elsif rule['Expiration']['Date']
                            Expiration { Date rule['Expiration']['Date'].is_a?(Time) ? rule['Expiration']['Date'].utc.iso8601 : Time.parse(rule['Expiration']['Date']).utc.iso8601 }
                          end
                        end
                        if rule['Transition']
                          Transition {
                            if rule['Transition']['Days']
                              Days rule['Transition']['Days']
                            elsif rule['Transition']['Date']
                              Date rule['Transition']['Date'].is_a?(Time) ? time.utc.iso8601 : Time.parse(time).utc.iso8601
                            end
                            StorageClass rule['Transition']['StorageClass'].nil? ? 'GLACIER' : rule['Transition']['StorageClass']
                          }
                        end
                      end
                    }
                  end
                }
              end
              body = builder.to_xml
              body.gsub! /<([^<>]+)\/>/, '<\1></\1>'
              request({
                        :body     => body,
                        :expects  => 200,
                        :headers  => {'Content-MD5' => Base64.encode64(Digest::MD5.digest(body)).chomp!,
                          'Content-Type' => 'application/xml'},
                        :host     => "#{bucket_name}.#{@host}",
                        :method   => 'PUT',
                        :query    => {'lifecycle' => nil}
                      })
            end