Sha256: a984bf6e524abd5847242fc3c8da0e9c0e61253d231048cc5ad66dbddc3f9d03

Contents?: true

Size: 1.5 KB

Versions: 21

Compression:

Stored size: 1.5 KB

Contents

module Fog
  module Storage
    class GoogleXML
      class Mock
        def put_bucket_acl(_bucket_name, _acl)
          # :no-coverage:
          Fog::Mock.not_implemented
          # :no-coverage:
        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.reject { |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

21 entries across 21 versions & 2 rubygems

Version Path
fog-google-1.24.1 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.24.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.23.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.22.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.21.1 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.21.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.20.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.19.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.18.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.17.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.16.1 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.16.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.15.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.14.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
gitlab-fog-google-1.14.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.13.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
gitlab-fog-google-1.13.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.12.1 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.12.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb
fog-google-1.11.0 lib/fog/storage/google_xml/requests/put_bucket_acl.rb