Sha256: b8bd354343a63e0749deb2fde0efd2927bf3598d16b5aa09f023698d2f66283b

Contents?: true

Size: 1.44 KB

Versions: 34

Compression:

Stored size: 1.44 KB

Contents

module Fog
  module Storage
    class Google
      class Mock
        def put_bucket_acl(bucket_name, acl)
          Fog::Mock.not_implemented
        end
      end

      class Real
        # Change access control list for an Google Storage bucket
        def put_bucket_acl(bucket_name, acl)
          data = <<-DATA
<AccessControlList>
  <Owner>
    #{tag('ID', acl['Owner']['ID'])}
  </Owner>
  <Entries>
    #{entries_list(acl['AccessControlList'])}
  </Entries>
</AccessControlList>
DATA

          request({
            :body     => data,
            :expects  => 200,
            :headers  => {},
            :host     => "#{bucket_name}.#{@host}",
            :method   => 'PUT',
            :query    => {'acl' => nil}
          })
        end

        private

        def tag(name, value)
          "<#{name}>#{value}</#{name}>"
        end

        def scope_tag(scope)
          if %w(AllUsers AllAuthenticatedUsers).include?(scope['type'])
            "<Scope type='#{scope['type']}'/>"
          else
            "<Scope type='#{scope['type']}'>" +
              scope.to_a.select { |pair| pair[0] != 'type' }.map { |pair| tag(pair[0], pair[1]) }.join("\n") +
            "</Scope>"
          end
        end

        def entries_list(access_control_list)
          access_control_list.map do |entry|
            tag('Entry', scope_tag(entry['Scope']) + tag('Permission', entry['Permission']))
          end.join("\n")
        end
      end
    end
  end
end

Version data entries

34 entries across 32 versions & 6 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-google-0.1.0/lib/fog/google/requests/storage/put_bucket_acl.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-google-0.1.0/lib/fog/google/requests/storage/put_bucket_acl.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-google-0.1.0/lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.1.3 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.1.2 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.1.1 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.1.0 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.0.9 lib/fog/google/requests/storage/put_bucket_acl.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-google-0.0.7/lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.0.7 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.0.6 lib/fog/google/requests/storage/put_bucket_acl.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.0.5 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.0.4 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.0.3 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-google-0.0.2 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-1.29.0 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-1.28.0 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-1.27.0 lib/fog/google/requests/storage/put_bucket_acl.rb
fog-1.26.0 lib/fog/google/requests/storage/put_bucket_acl.rb