Sha256: 1ed169d0bbde2b6714424818d7cee8ce3f0f55eb4080c6a31ae686ffe85b2cc5
Contents?: true
Size: 1.48 KB
Versions: 38
Compression:
Stored size: 1.48 KB
Contents
module Fog module Storage class AWS class Real # Change tag set for an S3 bucket # # @param bucket_name [String] name of bucket to modify # @param tags [Hash]: # * Key [String]: tag key # * Value [String]: tag value # # @see http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTtagging.html def put_bucket_tagging(bucket_name, tags) tagging = tags.map do |k,v| "<Tag><Key>#{k}</Key><Value>#{v}</Value></Tag>" end.join("\n") data = <<-DATA <Tagging xmlns="http://doc.s3.amazonaws.com/2006-03-01" > <TagSet> #{tagging} </TagSet> </Tagging> DATA request({ :body => data, :expects => 204, :headers => {'Content-MD5' => Base64.encode64(Digest::MD5.digest(data)).chomp!, 'Content-Type' => 'application/xml'}, :bucket_name => bucket_name, :method => 'PUT', :query => {'tagging' => nil} }) end end class Mock # :nodoc:all def put_bucket_tagging(bucket_name, tags) response = Excon::Response.new if self.data[:buckets][bucket_name] self.data[:bucket_tagging][bucket_name] = tags response.status = 204 else response.status = 404 raise(Excon::Errors.status_error({:expects => 204}, response)) end response end end end end end
Version data entries
38 entries across 38 versions & 2 rubygems