module GoodData

GoodData Module

Copyright © 2010-2022 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.

Copyright © 2010-2018 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.

rubocop:disable Style/ClassVars

Copyright © 2010-2018 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.

Copyright © 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.

Define GoodData::CLI as GLI Wrapper

Define GoodData::CLI as GLI Wrapper

Copyright © 2010-2019 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.

Copyright © 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.

Copyright © 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.

Copyright © 2010-2021 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 2010-2019 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Migrate date dimension urn:gooddata:date or urn:custom:date to urn:custom_v2:date

Copyright © 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.

Copyright © 2010-2019 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.

© 2019-2022 GoodData Corporation

Copyright © 2010-2018 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.

Copyright © 2010-2019 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

See gist.github.com/ubermajestix/3644301

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 2010-2021 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 2010-2018 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 2010-2021 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.

Copyright © 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.

Copyright © 2022 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.

Copyright © 2010-2021 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.

GoodData Module

Copyright © 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.

Copyright © 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 containing classes that counter-part GoodData server-side meta-data elements, including the server-side data model.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

Copyright © 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.

GoodData Module

GoodData Module

Constants

BRICKS_VERSION
DEFAULT_LOGGER_CLASS
DEFAULT_LOG_LEVEL
DEFAULT_LOG_OUTPUT
DEFAULT_RESTLOGGER_CLASS
DEFAULT_RESTLOG_LEVEL
DEFAULT_RESTLOG_OUTPUT
DEFAULT_SPLUNKLOG_LEVEL
DEFAULT_SPLUNKLOG_OUTPUT
DEFAULT_SSO_OPTIONS
DisplayForm
VERSION

Attributes

gd_logger[RW]
logger[RW]
project[R]
rest_logger[RW]
stats[W]

Public Class Methods

bricks_version() click to toggle source

LCM bricks version @return brick version

# File lib/gooddata/version.rb, line 23
def bricks_version
  BRICKS_VERSION
end
client()
Alias for: connection
connect(options = nil, second_options = nil, third_options = {}) click to toggle source

Connect to the GoodData API

@param options @param second_options @param third_options

# File lib/gooddata/connection.rb, line 36
def connect(options = nil, second_options = nil, third_options = {})
  Rest::Client.connect(options, second_options, third_options)
end
connect_sso(login, provider, url = GoodData::Rest::Connection::DEFAULT_URL, opts = {}) click to toggle source

Connect to GoodData using SSO

This SSO implementation is custom implementation provided by GoodData that allows your application to sign in an existing GoodData user. The authentication is done not by username and password but by generating a session specific token using pair of PGP keys.

@see developer.gooddata.com/article/single-sign-on

@param [String] login Email address used for logging into gooddata @param [String] provider Name of SSO provider @return [GoodData::Rest::Client] Instance of REST client

# File lib/gooddata/connection.rb, line 118
def connect_sso(login, provider, url = GoodData::Rest::Connection::DEFAULT_URL, opts = {})
  url, params = sso_url(login, provider, url)

  RestClient::Request.execute(opts.merge(method: :post, url: url, payload: params)) do |response, _request, _result|
    return Rest::Client.connect_sso(
      opts.merge(
        headers:
           {
             x_gdc_authsst: response.cookies['GDCAuthSST'],
             x_gdc_authtt: response.cookies['GDCAuthTT']
           }
      )
    )
  end
end
connection() click to toggle source

Returns the active GoodData connection earlier initialized via GoodData.connect call

@see GoodData.connect

# File lib/gooddata/connection.rb, line 23
def connection
  # TODO: Remove this after successful rest-factory transition
  Rest::Client.connection # || fail('Please authenticate with GoodData.connect first')
end
Also aliased as: client
delete(path, options = {}) click to toggle source

Performs a HTTP DELETE request.

Retuns the JSON response formatted as a Hash object.

@param path The HTTP path on the GoodData server (must be prefixed with a forward slash)

### Examples

GoodData.delete '/gdc/project/1'
# File lib/gooddata/core/rest.rb, line 65
def delete(path, options = {})
  connection.delete path, options
end
disconnect() click to toggle source

Disconnect (logout) if logged in

# File lib/gooddata/connection.rb, line 41
def disconnect
  Rest::Client.disconnect
end
download_from_project_webdav(file, where, options = {}) click to toggle source

Download from project directory

# File lib/gooddata/core/rest.rb, line 92
def download_from_project_webdav(file, where, options = {})
  options = merge_options(options)
  url = project_webdav_path(options)
  connection.download(file, where, options.merge(:staging_url => url))
end
download_from_user_webdav(file, where, options = {}) click to toggle source

Download from user directory

# File lib/gooddata/core/rest.rb, line 106
def download_from_user_webdav(file, where, options = {})
  url = user_webdav_path({ :client => GoodData.client }.merge(options))
  connection.download(file, where, options.merge(:staging_url => url))
end
gem_version_string() click to toggle source

Identifier of gem version @return Formatted gem version

# File lib/gooddata/version.rb, line 29
def gem_version_string
  "gooddata-gem/#{VERSION}/#{RUBY_PLATFORM}/#{RUBY_VERSION}"
end
get(path, options = {}) click to toggle source

Performs a HTTP GET request.

Retuns the JSON response formatted as a Hash object.

@param path The HTTP path on the GoodData server (must be prefixed with a forward slash)

### Examples

GoodData.get '/gdc/projects'
# File lib/gooddata/core/rest.rb, line 19
def get(path, options = {})
  connection.get(path, options)
end
get_client(opts) click to toggle source
# File lib/gooddata/helpers/global_helpers.rb, line 288
def get_client(opts)
  client = opts[:client]
  fail ArgumentError, 'No :client specified' if client.nil?

  client
end
get_client_and_project(opts) click to toggle source
# File lib/gooddata/helpers/global_helpers.rb, line 295
def get_client_and_project(opts)
  client = opts[:client]
  fail ArgumentError, 'No :client specified' if client.nil?

  p = opts[:project]
  fail ArgumentError, 'No :project specified' if p.nil?

  project = GoodData::Project[p, opts]
  fail ArgumentError, 'Wrong :project specified' if project.nil?

  [client, project]
end
init_module() click to toggle source

Initializes required dynamically loaded classes

# File lib/gooddata/client.rb, line 46
def init_module
  # Metadata packages, such as report.rb, require this to be loaded first
  require_relative 'models/metadata.rb'

  # Load models from models folder
  Dir[File.dirname(__FILE__) + '/models/*.rb'].each { |file| require file }

  # Load collections
  Dir[File.dirname(__FILE__) + '/collections/*.rb'].each { |file| require file }
end
logging_http_off() click to toggle source
# File lib/gooddata/core/logging.rb, line 62
def logging_http_off
  @rest_logger = NilLogger.new
end
logging_http_on(level = DEFAULT_RESTLOG_LEVEL, output = DEFAULT_RESTLOG_OUTPUT, klass = DEFAULT_RESTLOGGER_CLASS) click to toggle source
# File lib/gooddata/core/logging.rb, line 56
def logging_http_on(level = DEFAULT_RESTLOG_LEVEL, output = DEFAULT_RESTLOG_OUTPUT, klass = DEFAULT_RESTLOGGER_CLASS)
  @rest_logger = klass.new(output)
  @rest_logger.level = level
  @rest_logger
end
logging_http_on?() click to toggle source
# File lib/gooddata/core/logging.rb, line 66
def logging_http_on?
  !@rest_logger.instance_of?(NilLogger)
end
logging_off() click to toggle source
# File lib/gooddata/core/logging.rb, line 48
def logging_off
  @logger = NilLogger.new
end
logging_on(level = DEFAULT_LOG_LEVEL, output = DEFAULT_LOG_OUTPUT, klass = DEFAULT_LOGGER_CLASS) click to toggle source

Turn logging on

### Example

# Turn of default logging
GoodData.logging_on

# Log only WARN and higher
GoodData.logging_on(Logger::WARN)

# Log DEBUG and above to file
GoodData.logging_on(Logger::DEBUG, 'log.txt')
# File lib/gooddata/core/logging.rb, line 42
def logging_on(level = DEFAULT_LOG_LEVEL, output = DEFAULT_LOG_OUTPUT, klass = DEFAULT_LOGGER_CLASS)
  @logger = klass.new(output)
  @logger.level = level
  @logger
end
logging_on?() click to toggle source
# File lib/gooddata/core/logging.rb, line 52
def logging_on?
  !@logger.instance_of?(NilLogger)
end
poll_on_code(link, options = {}) click to toggle source

Generalizaton of poller. Since we have quite a variation of how async proceses are handled this is a helper that should help you with resources where the information about “Are we done” is the http code of response. By default we repeat as long as the code == 202. You can change the code if necessary. It expects the URI as an input where it can poll. It returns the value of last poll. In majority of cases these are the data that you need.

@param link [String] Link for polling @param options [Hash] Options @return [Hash] Result of polling

# File lib/gooddata/core/rest.rb, line 120
def poll_on_code(link, options = {})
  client = options[:client]
  fail ArgumentError, 'No :client specified' if client.nil?
  client.poll_on_code(link, options)
end
poll_on_response(link, options = {}, &bl) click to toggle source

Generalizaton of poller. Since we have quite a variation of how async proceses are handled this is a helper that should help you with resources where the information about “Are we done” is inside the response. It expects the URI as an input where it can poll and a block that should return either false -> ‘meaning we are done’ or true -> meaning sleep and repeat. It returns the value of last poll. In majority of cases these are the data that you need

@param link [String] Link for polling @param options [Hash] Options @return [Hash] Result of polling

# File lib/gooddata/core/rest.rb, line 135
def poll_on_response(link, options = {}, &bl)
  client = options[:client]
  fail ArgumentError, 'No :client specified' if client.nil?
  client.poll_on_response(link, options, &bl)
end
post(path, data = {}, options = {}) click to toggle source

Performs a HTTP POST request.

Retuns the JSON response formatted as a Hash object.

@param path The HTTP path on the GoodData server (must be prefixed with a forward slash) @param data The payload data in the format of a Hash object

### Examples

client.post '/gdc/projects', { ... }
# File lib/gooddata/core/rest.rb, line 34
def post(path, data = {}, options = {})
  connection.post path, data, options
end
profile()
Alias for: user
project=(project, opts = { :client => GoodData.connection }) click to toggle source

Sets the active project

@param project A project identifier

### Examples

The following calls are equivalent

# Assign project ID
GoodData.project = 'afawtv356b6usdfsdf34vt'

# Use project ID
GoodData.use 'afawtv356b6usdfsdf34vt'

# Use project URL
GoodData.use '/gdc/projects/afawtv356b6usdfsdf34vt'

# Select project using indexer on GoodData::Project class
GoodData.project = Project['afawtv356b6usdfsdf34vt']

Assigns global/default GoodData project

# File lib/gooddata/core/project.rb, line 31
def project=(project, opts = { :client => GoodData.connection })
  if project.is_a? Project
    @project = project
  elsif project.nil?
    @project = nil
  else
    @project = Project[project, opts]
  end
  @project
end
Also aliased as: use
project_webdav_path(options = {}) click to toggle source

Get WebDav directory for project data @return [String]

# File lib/gooddata/core/rest.rb, line 78
def project_webdav_path(options = {})
  options = merge_options(options)
  project = options[:project]
  project.project_webdav_path
end
put(path, data, options = {}) click to toggle source

Performs a HTTP PUT request.

Retuns the JSON response formatted as a Hash object.

### Parameters

@param path The HTTP path on the GoodData server (must be prefixed with a forward slash) @param data The payload data in the format of a Hash object

### Examples

client.put '/gdc/projects', { ... }
# File lib/gooddata/core/rest.rb, line 51
def put(path, data, options = {})
  connection.put path, data, options
end
release_info() click to toggle source

Returns information about the GoodData API as a Hash (e.g. version, release time etc.) @deprecated The release info endpoint has been deprecated without a replacement.

# File lib/gooddata/client.rb, line 59
def release_info
  fail 'The release info endpoint has been deprecated without a replacement.'
end
sdk_version()
Alias for: version
splunk_logging_off() click to toggle source
# File lib/gooddata/core/logging.rb, line 74
def splunk_logging_off
  gd_logger.logging_off :splunk
end
splunk_logging_on(logger) click to toggle source
# File lib/gooddata/core/logging.rb, line 70
def splunk_logging_on(logger)
  gd_logger.logging_on :splunk, logger
end
splunk_logging_on?() click to toggle source
# File lib/gooddata/core/logging.rb, line 78
def splunk_logging_on?
  gd_logger.logging_on? :splunk
end
sso_url(login, provider, url, opts = DEFAULT_SSO_OPTIONS) click to toggle source

Generates SSO URL

This SSO implementation is custom implementation provided by GoodData that allows your application to sign in an existing GoodData user. The authentication is done not by username and password but by generating a session specific token using pair of PGP keys.

@see developer.gooddata.com/article/single-sign-on

@param [String] login Email address used for logging into gooddata @param [String] provider Name of SSO provider @param [Hash] opts Additional options @option opts [Fixnum] :validity Validity in seconds from ‘now’ @return [String] URL which can be used for SSO logging in

# File lib/gooddata/connection.rb, line 66
def sso_url(login, provider, url, opts = DEFAULT_SSO_OPTIONS)
  opts = DEFAULT_SSO_OPTIONS.merge(opts)

  ts = DateTime.now.strftime('%s').to_i + opts[:valid]
  obj = {
    'email' => login,
    'validity' => ts
  }

  json_data = JSON.pretty_generate(obj) + "\n"

  file_json = Tempfile.new('gooddata-sso-json')
  file_json.write(json_data)

  file_json.rewind
  file_signed = Tempfile.new('gooddata-sso-signed')

  cmd = "gpg --yes --no-tty --armor -u #{login} --output #{file_signed.path} --sign #{file_json.path}"
  res = system(cmd)
  fail 'Unable to sign json' unless res

  file_signed.rewind
  file_final = Tempfile.new('gooddata-sso-final')

  recipient = url == GoodData::Rest::Connection::DEFAULT_URL ? 'secure@gooddata.com' : 'test@gooddata.com'
  cmd = "gpg --yes --no-tty --trust-model always --armor --output #{file_final.path} --encrypt --recipient #{recipient} #{file_signed.path}"
  res = system(cmd)
  fail 'Unable to encrypt json' unless res

  file_final.rewind
  final = file_final.read

  params = {
    targetUrl: opts[:url],
    ssoProvider: provider,
    encryptedClaims: final
  }
  [url + '/gdc/account/customerlogin', params]
end
upload_to_project_webdav(file, options = {}) click to toggle source

Upload to project directory

# File lib/gooddata/core/rest.rb, line 85
def upload_to_project_webdav(file, options = {})
  options = merge_options(options)
  url = project_webdav_path(options)
  connection.upload(file, options.merge(:staging_url => url))
end
upload_to_user_webdav(file, options = {}) click to toggle source

Upload to user directory @return [String]

# File lib/gooddata/core/rest.rb, line 71
def upload_to_user_webdav(file, options = {})
  url = user_webdav_path({ :client => GoodData.client }.merge(options))
  connection.upload(file, options.merge(staging_url: url))
end
use(project, opts = { :client => GoodData.connection })
Alias for: project=
user() click to toggle source

Gets currently logged user

@return [GoodData::Profile] User Profile

# File lib/gooddata/core/user.rb, line 14
def user
  GoodData::Profile.current
end
Also aliased as: profile
user_webdav_path(options = {}) click to toggle source

Get WebDav directory for user data @return [String]

# File lib/gooddata/core/rest.rb, line 100
def user_webdav_path(options = {})
  client = GoodData::Rest::Object.client({ :client => GoodData.client }.merge(options))
  client.user_webdav_path
end
version() click to toggle source

SDK version @return SDK version

# File lib/gooddata/version.rb, line 15
def version
  VERSION
end
Also aliased as: sdk_version
with_connection(options = nil, second_options = nil, third_options = {}, &block) click to toggle source
# File lib/gooddata/connection.rb, line 45
def with_connection(options = nil, second_options = nil, third_options = {}, &block)
  client = connect(options, second_options, third_options)
  block.call(client)
ensure
  disconnect
end
with_project(project, opts = { :client => GoodData.connection }, &bl) click to toggle source

Perform block in context of another project than currently set

@param project Project to use @param bl Block to be performed

# File lib/gooddata/core/project.rb, line 56
def with_project(project, opts = { :client => GoodData.connection }, &bl)
  fail 'You have to specify a project when using with_project' if project.nil? || (project.is_a?(String) && project.empty?)
  fail 'You have to specify block' unless bl
  old_project = GoodData.project

  begin
    GoodData.use(project, opts)
    res = bl.call(GoodData.project)
  rescue RestClient::ResourceNotFound
    GoodData.project = old_project
    raise(GoodData::ProjectNotFound, 'Project was not found')
  end

  GoodData.project = old_project

  res
end

Private Class Methods

merge_options(opts) click to toggle source
# File lib/gooddata/core/rest.rb, line 143
def merge_options(opts)
  {
    :project => GoodData.project
  }.merge(opts)
end