Module: GoodData
- Defined in:
- lib/gooddata.rb,
lib/gooddata/client.rb,
lib/gooddata/app/app.rb,
lib/gooddata/cli/cli.rb,
lib/gooddata/extract.rb,
lib/gooddata/lcm/lcm.rb,
lib/gooddata/version.rb,
lib/gooddata/lcm/lcm2.rb,
lib/gooddata/core/rest.rb,
lib/gooddata/core/user.rb,
lib/gooddata/rest/rest.rb,
lib/gooddata/cli/shared.rb,
lib/gooddata/connection.rb,
lib/gooddata/lcm/dsl/dsl.rb,
lib/gooddata/rest/client.rb,
lib/gooddata/rest/object.rb,
lib/gooddata/bricks/brick.rb,
lib/gooddata/bricks/utils.rb,
lib/gooddata/cli/terminal.rb,
lib/gooddata/commands/api.rb,
lib/gooddata/core/logging.rb,
lib/gooddata/core/project.rb,
lib/gooddata/data/guesser.rb,
lib/gooddata/mixins/links.rb,
lib/gooddata/models/links.rb,
lib/gooddata/models/model.rb,
lib/gooddata/commands/auth.rb,
lib/gooddata/commands/base.rb,
lib/gooddata/commands/role.rb,
lib/gooddata/commands/user.rb,
lib/gooddata/mixins/author.rb,
lib/gooddata/mixins/obj_id.rb,
lib/gooddata/models/client.rb,
lib/gooddata/models/domain.rb,
lib/gooddata/rest/resource.rb,
lib/gooddata/mixins/is_fact.rb,
lib/gooddata/mixins/md_json.rb,
lib/gooddata/mixins/md_lock.rb,
lib/gooddata/mixins/to_json.rb,
lib/gooddata/models/process.rb,
lib/gooddata/models/profile.rb,
lib/gooddata/models/segment.rb,
lib/gooddata/bricks/pipeline.rb,
lib/gooddata/commands/domain.rb,
lib/gooddata/core/nil_logger.rb,
lib/gooddata/lcm/types/param.rb,
lib/gooddata/mixins/is_label.rb,
lib/gooddata/mixins/not_fact.rb,
lib/gooddata/models/metadata.rb,
lib/gooddata/models/schedule.rb,
lib/gooddata/rest/connection.rb,
lib/gooddata/commands/process.rb,
lib/gooddata/commands/project.rb,
lib/gooddata/commands/runners.rb,
lib/gooddata/lcm/dsl/type_dsl.rb,
lib/gooddata/mixins/inspector.rb,
lib/gooddata/mixins/is_folder.rb,
lib/gooddata/mixins/not_group.rb,
lib/gooddata/mixins/not_label.rb,
lib/gooddata/models/execution.rb,
lib/gooddata/models/from_wire.rb,
lib/gooddata/commands/datasets.rb,
lib/gooddata/commands/projects.rb,
lib/gooddata/commands/scaffold.rb,
lib/gooddata/mixins/md_finders.rb,
lib/gooddata/mixins/not_metric.rb,
lib/gooddata/mixins/timestamps.rb,
lib/gooddata/mixins/uri_getter.rb,
lib/gooddata/models/invitation.rb,
lib/gooddata/models/membership.rb,
lib/gooddata/models/user_group.rb,
lib/gooddata/helpers/csv_helper.rb,
lib/gooddata/helpers/erb_helper.rb,
lib/gooddata/lcm/dsl/params_dsl.rb,
lib/gooddata/mixins/contributor.rb,
lib/gooddata/mixins/data_getter.rb,
lib/gooddata/mixins/md_grantees.rb,
lib/gooddata/mixins/meta_getter.rb,
lib/gooddata/models/tab_builder.rb,
lib/gooddata/goodzilla/goodzilla.rb,
lib/gooddata/helpers/data_helper.rb,
lib/gooddata/lcm/types/base_type.rb,
lib/gooddata/mixins/is_attribute.rb,
lib/gooddata/mixins/is_dimension.rb,
lib/gooddata/mixins/md_id_to_uri.rb,
lib/gooddata/mixins/md_object_id.rb,
lib/gooddata/mixins/md_relations.rb,
lib/gooddata/mixins/rest_getters.rb,
lib/gooddata/models/project_role.rb,
lib/gooddata/models/subscription.rb,
lib/gooddata/rest/object_factory.rb,
lib/gooddata/helpers/auth_helpers.rb,
lib/gooddata/mixins/not_attribute.rb,
lib/gooddata/mixins/rest_resource.rb,
lib/gooddata/models/datawarehouse.rb,
lib/gooddata/models/metadata/fact.rb,
lib/gooddata/models/style_setting.rb,
lib/gooddata/cli/commands/auth_cmd.rb,
lib/gooddata/lcm/types/class/class.rb,
lib/gooddata/lcm/types/scalar/bool.rb,
lib/gooddata/lcm/types/scalar/hash.rb,
lib/gooddata/mixins/content_getter.rb,
lib/gooddata/mixins/not_exportable.rb,
lib/gooddata/models/metadata/label.rb,
lib/gooddata/bricks/base_downloader.rb,
lib/gooddata/commands/datawarehouse.rb,
lib/gooddata/helpers/global_helpers.rb,
lib/gooddata/lcm/types/special/enum.rb,
lib/gooddata/mixins/md_object_query.rb,
lib/gooddata/mixins/root_key_getter.rb,
lib/gooddata/mixins/root_key_setter.rb,
lib/gooddata/models/metadata/folder.rb,
lib/gooddata/models/metadata/metric.rb,
lib/gooddata/models/metadata/report.rb,
lib/gooddata/models/project_creator.rb,
lib/gooddata/cli/commands/domain_cmd.rb,
lib/gooddata/exceptions/export_clone.rb,
lib/gooddata/exceptions/import_clone.rb,
lib/gooddata/lcm/actions/base_action.rb,
lib/gooddata/lcm/actions/hello_world.rb,
lib/gooddata/lcm/actions/print_modes.rb,
lib/gooddata/lcm/actions/print_types.rb,
lib/gooddata/lcm/types/scalar/object.rb,
lib/gooddata/lcm/types/scalar/string.rb,
lib/gooddata/lcm/types/special/array.rb,
lib/gooddata/models/ads_output_stage.rb,
lib/gooddata/models/execution_detail.rb,
lib/gooddata/models/metadata/dataset.rb,
lib/gooddata/models/module_constants.rb,
lib/gooddata/models/project_metadata.rb,
lib/gooddata/cli/commands/project_cmd.rb,
lib/gooddata/lcm/helpers/check_helper.rb,
lib/gooddata/lcm/types/complex/tokens.rb,
lib/gooddata/lcm/types/scalar/integer.rb,
lib/gooddata/mixins/md_object_indexer.rb,
lib/gooddata/models/blueprint/to_wire.rb,
lib/gooddata/models/metadata/variable.rb,
lib/gooddata/models/notification_rule.rb,
lib/gooddata/exceptions/command_failed.rb,
lib/gooddata/exceptions/malformed_user.rb,
lib/gooddata/exceptions/maql_execution.rb,
lib/gooddata/lcm/actions/print_actions.rb,
lib/gooddata/lcm/actions/purge_clients.rb,
lib/gooddata/lcm/types/class/gd_client.rb,
lib/gooddata/lcm/types/complex/complex.rb,
lib/gooddata/lcm/types/complex/segment.rb,
lib/gooddata/models/metadata/attribute.rb,
lib/gooddata/models/metadata/dashboard.rb,
lib/gooddata/models/metadata/dimension.rb,
lib/gooddata/models/report_data_result.rb,
lib/gooddata/lcm/types/class/ads_client.rb,
lib/gooddata/exceptions/no_project_error.rb,
lib/gooddata/exceptions/object_migration.rb,
lib/gooddata/exceptions/validation_error.rb,
lib/gooddata/lcm/actions/collect_clients.rb,
lib/gooddata/lcm/actions/ensure_segments.rb,
lib/gooddata/lcm/actions/segments_filter.rb,
lib/gooddata/lcm/actions/synchronize_ldm.rb,
lib/gooddata/mixins/data_property_reader.rb,
lib/gooddata/mixins/data_property_writer.rb,
lib/gooddata/mixins/meta_property_reader.rb,
lib/gooddata/mixins/meta_property_writer.rb,
lib/gooddata/models/blueprint/fact_field.rb,
lib/gooddata/exceptions/project_not_found.rb,
lib/gooddata/exceptions/segment_not_empty.rb,
lib/gooddata/lcm/actions/collect_segments.rb,
lib/gooddata/lcm/actions/synchronize_meta.rb,
lib/gooddata/models/blueprint/label_field.rb,
lib/gooddata/models/blueprint/to_manifest.rb,
lib/gooddata/models/channel_configuration.rb,
lib/gooddata/models/project_log_formatter.rb,
lib/gooddata/exceptions/filter_maqlization.rb,
lib/gooddata/helpers/global_helpers_params.rb,
lib/gooddata/lcm/actions/apply_custom_maql.rb,
lib/gooddata/lcm/actions/associate_clients.rb,
lib/gooddata/lcm/actions/provision_clients.rb,
lib/gooddata/models/blueprint/anchor_field.rb,
lib/gooddata/models/metadata/dashboard_tab.rb,
lib/gooddata/exceptions/uncomputable_report.rb,
lib/gooddata/mixins/content_property_reader.rb,
lib/gooddata/mixins/content_property_writer.rb,
lib/gooddata/models/metadata/scheduled_mail.rb,
lib/gooddata/lcm/actions/synchronize_clients.rb,
lib/gooddata/lcm/types/complex/release_query.rb,
lib/gooddata/models/blueprint/date_dimension.rb,
lib/gooddata/models/blueprint/schema_builder.rb,
lib/gooddata/models/user_filters/user_filter.rb,
lib/gooddata/bricks/middleware/aws_middleware.rb,
lib/gooddata/bricks/middleware/dwh_middleware.rb,
lib/gooddata/lcm/actions/ensure_release_table.rb,
lib/gooddata/lcm/actions/update_release_table.rb,
lib/gooddata/models/blueprint/attribute_field.rb,
lib/gooddata/models/blueprint/blueprint_field.rb,
lib/gooddata/models/blueprint/project_builder.rb,
lib/gooddata/models/blueprint/reference_field.rb,
lib/gooddata/bricks/middleware/base_middleware.rb,
lib/gooddata/exceptions/attr_element_not_found.rb,
lib/gooddata/lcm/actions/synchronize_processes.rb,
lib/gooddata/lcm/actions/synchronize_schedules.rb,
lib/gooddata/models/blueprint/schema_blueprint.rb,
lib/gooddata/models/metadata/report_definition.rb,
lib/gooddata/bricks/middleware/bench_middleware.rb,
lib/gooddata/lcm/actions/create_segment_masters.rb,
lib/gooddata/models/automated_data_distribution.rb,
lib/gooddata/models/blueprint/dashboard_builder.rb,
lib/gooddata/models/blueprint/dataset_blueprint.rb,
lib/gooddata/models/blueprint/project_blueprint.rb,
lib/gooddata/bricks/middleware/logger_middleware.rb,
lib/gooddata/bricks/middleware/stdout_middleware.rb,
lib/gooddata/exceptions/execution_limit_exceeded.rb,
lib/gooddata/exceptions/user_in_different_domain.rb,
lib/gooddata/lcm/actions/collect_segment_clients.rb,
lib/gooddata/lcm/actions/synchronize_label_types.rb,
lib/gooddata/lcm/types/complex/update_preference.rb,
lib/gooddata/models/metadata/dashboard/text_item.rb,
lib/gooddata/bricks/middleware/twitter_middleware.rb,
lib/gooddata/lcm/actions/synchronize_new_segments.rb,
lib/gooddata/models/client_synchronization_result.rb,
lib/gooddata/bricks/middleware/gooddata_middleware.rb,
lib/gooddata/lcm/actions/synchronize_color_palette.rb,
lib/gooddata/models/metadata/dashboard/filter_item.rb,
lib/gooddata/models/metadata/dashboard/iframe_item.rb,
lib/gooddata/models/metadata/dashboard/report_item.rb,
lib/gooddata/bricks/middleware/fs_upload_middleware.rb,
lib/gooddata/bricks/middleware/restforce_middleware.rb,
lib/gooddata/lcm/types/complex/synchronization_info.rb,
lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb,
lib/gooddata/models/metadata/dashboard/headline_item.rb,
lib/gooddata/models/user_filters/user_filter_builder.rb,
lib/gooddata/bricks/middleware/fs_download_middleware.rb,
lib/gooddata/models/metadata/dashboard/dashboard_item.rb,
lib/gooddata/models/metadata/dashboard/geo_chart_item.rb,
lib/gooddata/models/user_filters/variable_user_filter.rb,
lib/gooddata/bricks/middleware/undot_params_middleware.rb,
lib/gooddata/lcm/actions/ensure_technical_users_domain.rb,
lib/gooddata/models/user_filters/mandatory_user_filter.rb,
lib/gooddata/bricks/middleware/decode_params_middleware.rb,
lib/gooddata/lcm/actions/ensure_technical_users_project.rb,
lib/gooddata/bricks/middleware/params_inspect_middleware.rb,
lib/gooddata/models/metadata/dashboard/filter_apply_item.rb,
lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb,
lib/gooddata/lcm/actions/synchronize_attribute_drillpaths.rb,
lib/gooddata/models/client_synchronization_result_details.rb,
lib/gooddata/models/metadata/scheduled_mail/report_attachment.rb,
lib/gooddata/models/metadata/scheduled_mail/dashboard_attachment.rb
Overview
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.
Defined Under Namespace
Modules: Bricks, CLI, Command, Data, Extract, Helpers, LCM, LCM2, Mixin, Model, Rest, SmallGoodZilla, UserFilterBuilder Classes: AdsOutputStage, App, Attribute, AttributeElementNotFound, AutomatedDataDistribution, ChannelConfiguration, Client, ClientSynchronizationResult, ClientSynchronizationResultDetails, CommandFailed, Dashboard, DashboardAttachment, DashboardItem, DashboardTab, DataWarehouse, Dataset, Dimension, Domain, Execution, ExecutionDetail, ExecutionLimitExceeded, ExportCloneError, Fact, FilterApplyItem, FilterItem, FilterMaqlizationError, Folder, GeoChartItem, HeadlineItem, IframeItem, ImportCloneError, Invitation, Label, Links, MalformedUserError, MandatoryUserFilter, MaqlExecutionError, MdObject, Membership, Metric, NilLogger, NoProjectError, NotificationRule, ObjectsExportError, ObjectsImportError, ObjectsMigrationError, Process, Profile, ProjectLogFormatter, ProjectMetadata, ProjectNotFound, ProjectRole, Report, ReportAttachment, ReportDataResult, ReportDefinition, ReportItem, Schedule, ScheduledMail, Segment, SegmentNotEmpty, StyleSetting, Subscription, TextItem, UncomputableReport, UserFilter, UserGroup, UserInDifferentDomainError, ValidationError, Variable, VariableUserFilter
Constant Summary collapse
- RELEASE_INFO_PATH =
'/gdc/releaseInfo'- VERSION =
'0.6.51'- DEFAULT_SSO_OPTIONS =
{ :url => '/gdc/app/account/bootstrap', :valid => 24 * 60 * 60 }
- DEFAULT_LOG_LEVEL =
Logger::INFO
- DEFAULT_LOG_OUTPUT =
STDOUT- DEFAULT_LOGGER_CLASS =
Logger- DEFAULT_RESTLOG_LEVEL =
Logger::DEBUG
- DEFAULT_RESTLOG_OUTPUT =
STDOUT- DEFAULT_RESTLOGGER_CLASS =
Logger- DisplayForm =
GoodData::Label
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.project ⇒ Object
Returns the value of attribute project.
-
.rest_logger ⇒ Object
Returns the value of attribute rest_logger.
-
.stats ⇒ Object
writeonly
Sets the attribute stats.
Class Method Summary collapse
-
.connect(options = nil, second_options = nil, third_options = {}) ⇒ Object
Connect to the GoodData API.
-
.connect_sso(login, provider) ⇒ GoodData::Rest::Client
Connect to GoodData using SSO.
-
.connection ⇒ Object
(also: client)
Returns the active GoodData connection earlier initialized via GoodData.connect call.
-
.delete(path, options = {}) ⇒ Object
Performs a HTTP DELETE request.
-
.disconnect ⇒ Object
Disconnect (logout) if logged in.
-
.download_from_project_webdav(file, where, options = {}) ⇒ Object
Download from project directory.
-
.download_from_user_webdav(file, where, options = {}) ⇒ Object
Download from user directory.
-
.gem_version_string ⇒ Object
Identifier of gem version.
-
.get(path, options = {}) ⇒ Object
Performs a HTTP GET request.
- .get_client(opts) ⇒ Object
- .get_client_and_project(opts) ⇒ Object
-
.init_module ⇒ Object
Initializes required dynamically loaded classes.
-
.logging_http_off ⇒ Object
Turn logging on.
-
.logging_http_on(level = DEFAULT_RESTLOG_LEVEL, output = DEFAULT_RESTLOG_OUTPUT, klass = DEFAULT_RESTLOGGER_CLASS) ⇒ Object
Turn logging on with HTTP included.
- .logging_http_on? ⇒ Boolean
-
.logging_off ⇒ Object
Turn logging on.
-
.logging_on(level = DEFAULT_LOG_LEVEL, output = DEFAULT_LOG_OUTPUT, klass = DEFAULT_LOGGER_CLASS) ⇒ Object
Turn logging on.
- .logging_on? ⇒ Boolean
-
.poll_on_code(link, options = {}) ⇒ Hash
Generalizaton of poller.
-
.poll_on_response(link, options = {}, &bl) ⇒ Hash
Generalizaton of poller.
-
.post(path, data = {}, options = {}) ⇒ Object
Performs a HTTP POST request.
-
.project_webdav_path(options = {}) ⇒ String
Get WebDav directory for project data.
-
.put(path, data, options = {}) ⇒ Object
Performs a HTTP PUT request.
-
.release_info ⇒ Object
Returns information about the GoodData API as a Hash (e.g. version, release time etc.).
-
.sso_url(login, provider, opts = DEFAULT_SSO_OPTIONS) ⇒ String
Generates SSO URL.
- .stats_off ⇒ Object
- .stats_on ⇒ Object
- .stats_on? ⇒ Boolean
-
.upload_to_project_webdav(file, options = {}) ⇒ Object
Upload to project directory.
-
.upload_to_user_webdav(file, options = {}) ⇒ String
Upload to user directory.
-
.user ⇒ GoodData::Profile
(also: profile)
Gets currently logged user.
-
.user_webdav_path(options = {}) ⇒ String
Get WebDav directory for user data.
-
.version ⇒ Object
Version.
- .with_connection(options = nil, second_options = nil, third_options = {}, &bl) ⇒ Object
-
.with_project(project, opts = { :client => GoodData.connection }, &bl) ⇒ Object
Perform block in context of another project than currently set.
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
21 22 23 |
# File 'lib/gooddata/core/logging.rb', line 21 def logger @logger end |
.project ⇒ Object
Returns the value of attribute project.
44 45 46 |
# File 'lib/gooddata/core/project.rb', line 44 def project @project end |
.rest_logger ⇒ Object
Returns the value of attribute rest_logger.
21 22 23 |
# File 'lib/gooddata/core/logging.rb', line 21 def rest_logger @rest_logger end |
.stats=(value) ⇒ Object (writeonly)
Sets the attribute stats
22 23 24 |
# File 'lib/gooddata/core/logging.rb', line 22 def stats=(value) @stats = value end |
Class Method Details
.connect(options = nil, second_options = nil, third_options = {}) ⇒ Object
Connect to the GoodData API
36 37 38 |
# File 'lib/gooddata/connection.rb', line 36 def connect( = nil, = nil, = {}) Rest::Client.connect(, , ) end |
.connect_sso(login, provider) ⇒ GoodData::Rest::Client
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.
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/gooddata/connection.rb', line 115 def connect_sso(login, provider) url = sso_url(login, provider) params = { :x_gdc_request => "#{GoodData::Rest::Connection.generate_string}:#{GoodData::Rest::Connection.generate_string}" } RestClient.get url, params do |response, _request, _result| Rest::Client.connect_sso(:sst_token => URI.decode(response.['GDCAuthSST'])) end end |
.connection ⇒ Object Also known as: client
Returns the active GoodData connection earlier initialized via GoodData.connect call
23 24 25 26 |
# 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 |
.delete(path, options = {}) ⇒ Object
Performs a HTTP DELETE request.
Retuns the JSON response formatted as a Hash object.
Examples
GoodData.delete '/gdc/project/1'
65 66 67 |
# File 'lib/gooddata/core/rest.rb', line 65 def delete(path, = {}) connection.delete path, end |
.disconnect ⇒ Object
Disconnect (logout) if logged in
41 42 43 |
# File 'lib/gooddata/connection.rb', line 41 def disconnect Rest::Client.disconnect end |
.download_from_project_webdav(file, where, options = {}) ⇒ Object
Download from project directory
92 93 94 95 96 |
# File 'lib/gooddata/core/rest.rb', line 92 def download_from_project_webdav(file, where, = {}) = () url = project_webdav_path() connection.download(file, where, .merge(:staging_url => url)) end |
.download_from_user_webdav(file, where, options = {}) ⇒ Object
Download from user directory
106 107 108 109 |
# File 'lib/gooddata/core/rest.rb', line 106 def download_from_user_webdav(file, where, = {}) url = user_webdav_path({ :client => GoodData.client }.merge()) connection.download(file, where, .merge(:staging_url => url)) end |
.gem_version_string ⇒ Object
Identifier of gem version
19 20 21 |
# File 'lib/gooddata/version.rb', line 19 def gem_version_string "gooddata-gem/#{VERSION}/#{RUBY_PLATFORM}/#{RUBY_VERSION}" end |
.get(path, options = {}) ⇒ Object
Performs a HTTP GET request.
Retuns the JSON response formatted as a Hash object.
Examples
GoodData.get '/gdc/projects'
19 20 21 |
# File 'lib/gooddata/core/rest.rb', line 19 def get(path, = {}) connection.get(path, ) end |
.get_client(opts) ⇒ Object
246 247 248 249 250 251 |
# File 'lib/gooddata/helpers/global_helpers.rb', line 246 def get_client(opts) client = opts[:client] fail ArgumentError, 'No :client specified' if client.nil? client end |
.get_client_and_project(opts) ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/gooddata/helpers/global_helpers.rb', line 253 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 ⇒ Object
Initializes required dynamically loaded classes
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gooddata/client.rb', line 48 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 ⇒ Object
75 76 77 |
# File 'lib/gooddata/core/logging.rb', line 75 def logging_http_off @rest_logger = NilLogger.new end |
.logging_http_on(level = DEFAULT_RESTLOG_LEVEL, output = DEFAULT_RESTLOG_OUTPUT, klass = DEFAULT_RESTLOGGER_CLASS) ⇒ Object
63 64 65 66 67 |
# File 'lib/gooddata/core/logging.rb', line 63 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? ⇒ Boolean
79 80 81 |
# File 'lib/gooddata/core/logging.rb', line 79 def logging_http_on? !@rest_logger.instance_of?(NilLogger) end |
.logging_off ⇒ Object
49 50 51 |
# File 'lib/gooddata/core/logging.rb', line 49 def logging_off @logger = NilLogger.new end |
.logging_on(level = DEFAULT_LOG_LEVEL, output = DEFAULT_LOG_OUTPUT, klass = DEFAULT_LOGGER_CLASS) ⇒ Object
37 38 39 40 41 |
# File 'lib/gooddata/core/logging.rb', line 37 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? ⇒ Boolean
53 54 55 |
# File 'lib/gooddata/core/logging.rb', line 53 def logging_on? !@logger.instance_of?(NilLogger) end |
.poll_on_code(link, options = {}) ⇒ Hash
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.
120 121 122 123 124 |
# File 'lib/gooddata/core/rest.rb', line 120 def poll_on_code(link, = {}) client = [:client] fail ArgumentError, 'No :client specified' if client.nil? client.poll_on_code(link, ) end |
.poll_on_response(link, options = {}, &bl) ⇒ Hash
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
135 136 137 138 139 |
# File 'lib/gooddata/core/rest.rb', line 135 def poll_on_response(link, = {}, &bl) client = [:client] fail ArgumentError, 'No :client specified' if client.nil? client.poll_on_response(link, , &bl) end |
.post(path, data = {}, options = {}) ⇒ Object
Performs a HTTP POST request.
Retuns the JSON response formatted as a Hash object.
Examples
client.post '/gdc/projects', { ... }
34 35 36 |
# File 'lib/gooddata/core/rest.rb', line 34 def post(path, data = {}, = {}) connection.post path, data, end |
.project_webdav_path(options = {}) ⇒ String
Get WebDav directory for project data
78 79 80 81 82 |
# File 'lib/gooddata/core/rest.rb', line 78 def project_webdav_path( = {}) = () project = [:project] project.project_webdav_path end |
.put(path, data, options = {}) ⇒ Object
Performs a HTTP PUT request.
Retuns the JSON response formatted as a Hash object.
Parameters
Examples
client.put '/gdc/projects', { ... }
51 52 53 |
# File 'lib/gooddata/core/rest.rb', line 51 def put(path, data, = {}) connection.put path, data, end |
.release_info ⇒ Object
Returns information about the GoodData API as a Hash (e.g. version, release time etc.)
60 61 62 |
# File 'lib/gooddata/client.rb', line 60 def release_info @release_info ||= @connection.get(RELEASE_INFO_PATH)['release'] end |
.sso_url(login, provider, opts = DEFAULT_SSO_OPTIONS) ⇒ String
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.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/gooddata/connection.rb', line 69 def sso_url(login, provider, 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 --no-tty --armor --yes -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') cmd = "gpg --yes --no-tty --trust-model always --armor --output #{file_final.path} --encrypt --recipient [email protected] #{file_signed.path}" res = system(cmd) fail 'Unable to encrypt json' unless res file_final.rewind final = file_final.read "#{GoodData::Helpers::AuthHelper.read_server}/gdc/account/customerlogin?sessionId=#{CGI.escape(final)}&serverURL=#{CGI.escape(provider)}&targetURL=#{CGI.escape(opts[:url])}" end |
.stats_off ⇒ Object
91 92 93 |
# File 'lib/gooddata/core/logging.rb', line 91 def stats_off @stats = false end |
.stats_on ⇒ Object
83 84 85 |
# File 'lib/gooddata/core/logging.rb', line 83 def stats_on @stats = true end |
.stats_on? ⇒ Boolean
87 88 89 |
# File 'lib/gooddata/core/logging.rb', line 87 def stats_on? @stats end |
.upload_to_project_webdav(file, options = {}) ⇒ Object
Upload to project directory
85 86 87 88 89 |
# File 'lib/gooddata/core/rest.rb', line 85 def upload_to_project_webdav(file, = {}) = () url = project_webdav_path() connection.upload(file, .merge(:staging_url => url)) end |
.upload_to_user_webdav(file, options = {}) ⇒ String
Upload to user directory
71 72 73 74 |
# File 'lib/gooddata/core/rest.rb', line 71 def upload_to_user_webdav(file, = {}) url = user_webdav_path({ :client => GoodData.client }.merge()) connection.upload(file, .merge(staging_url: url)) end |
.user ⇒ GoodData::Profile Also known as: profile
Gets currently logged user
14 15 16 |
# File 'lib/gooddata/core/user.rb', line 14 def user GoodData::Profile.current end |
.user_webdav_path(options = {}) ⇒ String
Get WebDav directory for user data
100 101 102 103 |
# File 'lib/gooddata/core/rest.rb', line 100 def user_webdav_path( = {}) client = GoodData::Rest::Object.client({ :client => GoodData.client }.merge()) client.user_webdav_path end |
.version ⇒ Object
Version
13 14 15 |
# File 'lib/gooddata/version.rb', line 13 def version VERSION end |
.with_connection(options = nil, second_options = nil, third_options = {}, &bl) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/gooddata/connection.rb', line 45 def with_connection( = nil, = nil, = {}, &bl) connection = connect(, , ) bl.call(connection) rescue Exception => e # rubocop:disable RescueException puts e. raise e ensure disconnect end |
.with_project(project, opts = { :client => GoodData.connection }, &bl) ⇒ Object
Perform block in context of another project than currently set
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# 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 |