Sha256: 660fed544bee1f0103bdaa072cf62316e87e69d767dc69e75d12ada9370e22b4

Contents?: true

Size: 1.3 KB

Versions: 26

Compression:

Stored size: 1.3 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

module GoodData
  module Mixin
    module MdGrantees
      def grantees(opts = {})
        permission = opts[:permission]
        params = permission ? { permission: permission } : {}
        client.get(uri + '/grantees', params: params)
      end

      def grant(opts = {})
        change_permission(opts.merge(operation: :add))
      end

      def revoke(opts = {})
        change_permission(opts.merge(operation: :remove))
      end

      def change_permission(opts)
        permission = opts[:permission]
        member = opts[:member]
        op = opts[:operation]
        klasses = [GoodData::Profile, GoodData::UserGroup, GoodData::Membership]
        fail "Permission has to be set. Current value '#{permission}'" unless permission
        fail 'Member has to be either user or group' unless klasses.any? { |c| member.is_a?(c) }
        payload = {
          granteeURIs: {
            items: [
              { aclEntryURI: { permission: permission, grantee: member.uri } }
            ]
          }
        }
        client.post(uri + '/grantees/' + op.to_s, payload)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
gooddata-edge-0.6.27.edge lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.49 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.48 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.47 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.46 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.45 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.44 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.43 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.42 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.41 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.40 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.39 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.38 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.37 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.36 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.35 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.34 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.33 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.32 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.31 lib/gooddata/mixins/md_grantees.rb