Sha256: 9ebcd5af013497460c22d98a4efef90f51e82c989192f0bf38dc145dfbfe2737

Contents?: true

Size: 1.09 KB

Versions: 73

Compression:

Stored size: 1.09 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 MdIdToUri
      IDENTIFIERS_CFG = 'instance-identifiers'

      def identifier_to_uri(opts = { :client => GoodData.connection, :project => GoodData.project }, *ids)
        client, project = GoodData.get_client_and_project(opts)

        response = nil
        begin
          uri = project.md[IDENTIFIERS_CFG]
          response = client.post(uri, 'identifierToUri' => ids)
        rescue => ex
          raise ex
        end

        if response['identifiers'].empty?
          nil
        else
          identifiers = response['identifiers']
          ids_lookup = identifiers.reduce({}) do |a, e|
            a[e['identifier']] = e['uri']
            a
          end
          uris = ids.map { |x| ids_lookup[x] }
          uris.count == 1 ? uris.first : uris
        end
      end

      alias_method :id_to_uri, :identifier_to_uri
    end
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.3.1 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.3.0-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.3.0 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.2.0-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.2.0 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.19-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.19 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.17-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.17 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.15-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.15 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.14-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.14 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.13-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.13 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.12-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.12 lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.11-java lib/gooddata/mixins/md_id_to_uri.rb
gooddata-2.1.11 lib/gooddata/mixins/md_id_to_uri.rb