Sha256: e24e00c78b723069be80a6337b51154bdf3d4285767749ebf82ee89f59406a85

Contents?: true

Size: 1.3 KB

Versions: 77

Compression:

Stored size: 1.3 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 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

77 entries across 77 versions & 1 rubygems

Version Path
gooddata-1.2.1-java lib/gooddata/mixins/md_grantees.rb
gooddata-1.2.1 lib/gooddata/mixins/md_grantees.rb
gooddata-1.2.0-java lib/gooddata/mixins/md_grantees.rb
gooddata-1.2.0 lib/gooddata/mixins/md_grantees.rb
gooddata-1.1.0-java lib/gooddata/mixins/md_grantees.rb
gooddata-1.1.0 lib/gooddata/mixins/md_grantees.rb
gooddata-1.0.2-java lib/gooddata/mixins/md_grantees.rb
gooddata-1.0.2 lib/gooddata/mixins/md_grantees.rb
gooddata-1.0.1 lib/gooddata/mixins/md_grantees.rb
gooddata-1.0.1-java lib/gooddata/mixins/md_grantees.rb
gooddata-1.0.0-java lib/gooddata/mixins/md_grantees.rb
gooddata-1.0.0 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.54 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.53 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.52 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.51 lib/gooddata/mixins/md_grantees.rb
gooddata-0.6.50 lib/gooddata/mixins/md_grantees.rb