gooddata 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/.rubocop.yml +23 -0
- data/.travis.yml +9 -4
- data/CLI.md +439 -0
- data/Gemfile +0 -1
- data/README.md +2 -2
- data/Rakefile +60 -8
- data/doc/templates/default/module/setup.rb +1 -1
- data/examples.rb +2 -0
- data/gooddata +2 -0
- data/gooddata.gemspec +12 -8
- data/lib/gooddata.rb +0 -2
- data/lib/gooddata/bricks/base_downloader.rb +52 -47
- data/lib/gooddata/bricks/brick.rb +20 -31
- data/lib/gooddata/bricks/bricks.rb +1 -1
- data/lib/gooddata/bricks/middleware/base_middleware.rb +9 -7
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +12 -10
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +28 -28
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +20 -16
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +21 -19
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +10 -8
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +36 -34
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +11 -9
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +14 -12
- data/lib/gooddata/bricks/pipeline.rb +28 -0
- data/lib/gooddata/bricks/utils.rb +10 -8
- data/lib/gooddata/cli/cli.rb +1 -6
- data/lib/gooddata/cli/commands/auth_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/console_cmd.rb +7 -5
- data/lib/gooddata/cli/commands/domain_cmd.rb +45 -0
- data/lib/gooddata/cli/commands/process_cmd.rb +42 -5
- data/lib/gooddata/cli/commands/project_cmd.rb +96 -36
- data/lib/gooddata/cli/commands/projects_cmd.rb +21 -0
- data/lib/gooddata/cli/commands/role_cmd.rb +28 -0
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +5 -5
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/{profile_cmd.rb → user_cmd.rb} +7 -9
- data/lib/gooddata/cli/shared.rb +3 -2
- data/lib/gooddata/client.rb +16 -304
- data/lib/gooddata/commands/api.rb +13 -5
- data/lib/gooddata/commands/auth.rb +47 -40
- data/lib/gooddata/commands/base.rb +4 -2
- data/lib/gooddata/commands/commands.rb +1 -1
- data/lib/gooddata/commands/datasets.rb +20 -7
- data/lib/gooddata/commands/domain.rb +23 -0
- data/lib/gooddata/commands/process.rb +23 -117
- data/lib/gooddata/commands/project.rb +147 -0
- data/lib/gooddata/commands/projects.rb +8 -102
- data/lib/gooddata/commands/role.rb +26 -0
- data/lib/gooddata/commands/runners.rb +41 -38
- data/lib/gooddata/commands/scaffold.rb +46 -43
- data/lib/gooddata/commands/user.rb +33 -0
- data/lib/gooddata/connection.rb +43 -353
- data/lib/gooddata/core/connection.rb +389 -0
- data/lib/gooddata/core/core.rb +5 -4
- data/lib/gooddata/core/logging.rb +48 -0
- data/lib/gooddata/core/nil_logger.rb +13 -0
- data/lib/gooddata/core/project.rb +70 -0
- data/lib/gooddata/core/rest.rb +120 -0
- data/lib/gooddata/core/threaded.rb +14 -0
- data/lib/gooddata/core/user.rb +19 -0
- data/lib/gooddata/data/data.rb +2 -1
- data/lib/gooddata/data/guesser.rb +16 -12
- data/lib/gooddata/exceptions/command_failed.rb +1 -1
- data/lib/gooddata/exceptions/exceptions.rb +2 -1
- data/lib/gooddata/exceptions/no_project_error.rb +11 -0
- data/lib/gooddata/exceptions/project_not_found.rb +1 -1
- data/lib/gooddata/extensions/big_decimal.rb +6 -2
- data/lib/gooddata/extract.rb +10 -8
- data/lib/gooddata/goodzilla/goodzilla.rb +61 -59
- data/lib/gooddata/helpers.rb +15 -9
- data/lib/gooddata/models/account_settings.rb +124 -0
- data/lib/gooddata/models/attributes/anchor.rb +37 -0
- data/lib/gooddata/models/attributes/attributes.rb +8 -0
- data/lib/gooddata/models/attributes/date_attribute.rb +25 -0
- data/lib/gooddata/models/attributes/time_attribute.rb +24 -0
- data/lib/gooddata/models/columns/attribute.rb +71 -0
- data/lib/gooddata/models/columns/columns.rb +8 -0
- data/lib/gooddata/models/columns/date_column.rb +63 -0
- data/lib/gooddata/models/columns/fact_model.rb +54 -0
- data/lib/gooddata/models/columns/label.rb +55 -0
- data/lib/gooddata/models/columns/reference.rb +57 -0
- data/lib/gooddata/models/dashboard_builder.rb +26 -0
- data/lib/gooddata/models/data_result.rb +10 -9
- data/lib/gooddata/models/domain.rb +131 -0
- data/lib/gooddata/models/empty_result.rb +5 -8
- data/lib/gooddata/models/facts/facts.rb +8 -0
- data/lib/gooddata/models/facts/time_fact.rb +20 -0
- data/lib/gooddata/models/folders/attribute_folder.rb +20 -0
- data/lib/gooddata/models/folders/fact_folder.rb +20 -0
- data/lib/gooddata/models/folders/folders.rb +8 -0
- data/lib/gooddata/models/invitation.rb +78 -0
- data/lib/gooddata/models/links.rb +6 -6
- data/lib/gooddata/models/md_object.rb +25 -0
- data/lib/gooddata/models/metadata.rb +160 -62
- data/lib/gooddata/models/metadata/attribute.rb +81 -0
- data/lib/gooddata/models/metadata/column.rb +61 -0
- data/lib/gooddata/models/{dashboard.rb → metadata/dashboard.rb} +12 -7
- data/lib/gooddata/models/{data_set.rb → metadata/data_set.rb} +5 -4
- data/lib/gooddata/models/metadata/date_dimension.rb +26 -0
- data/lib/gooddata/models/metadata/display_form.rb +61 -0
- data/lib/gooddata/models/metadata/fact.rb +36 -0
- data/lib/gooddata/models/metadata/folder.rb +24 -0
- data/lib/gooddata/models/metadata/metadata.rb +8 -0
- data/lib/gooddata/models/metadata/metric.rb +197 -0
- data/lib/gooddata/models/metadata/report.rb +115 -0
- data/lib/gooddata/models/{report_definition.rb → metadata/report_definition.rb} +16 -10
- data/lib/gooddata/models/metadata/schema.rb +227 -0
- data/lib/gooddata/models/model.rb +38 -1339
- data/lib/gooddata/models/models.rb +5 -2
- data/lib/gooddata/models/module_constants.rb +29 -0
- data/lib/gooddata/models/process.rb +142 -13
- data/lib/gooddata/models/profile.rb +4 -6
- data/lib/gooddata/models/project.rb +406 -136
- data/lib/gooddata/models/project_blueprint.rb +221 -0
- data/lib/gooddata/models/project_builder.rb +136 -0
- data/lib/gooddata/models/project_creator.rb +138 -0
- data/lib/gooddata/models/project_metadata.rb +11 -10
- data/lib/gooddata/models/project_role.rb +92 -0
- data/lib/gooddata/models/references/date_reference.rb +44 -0
- data/lib/gooddata/models/references/references.rb +8 -0
- data/lib/gooddata/models/references/time_reference.rb +13 -0
- data/lib/gooddata/models/report_data_result.rb +11 -11
- data/lib/gooddata/models/schedule.rb +284 -0
- data/lib/gooddata/models/schema_blueprint.rb +158 -0
- data/lib/gooddata/models/schema_builder.rb +81 -0
- data/lib/gooddata/models/tab_builder.rb +23 -0
- data/lib/gooddata/models/user.rb +165 -0
- data/lib/gooddata/version.rb +1 -1
- data/lib/templates/project/data/devs.csv +1 -1
- data/lib/templates/project/data/repos.csv +1 -1
- data/lib/templates/project/model/model.rb.erb +7 -11
- data/spec/bricks/bricks_spec.rb +2 -0
- data/spec/data/test-ci-data.csv +2 -0
- data/spec/data/test_project_model_spec.json +7 -27
- data/spec/helpers/blueprint_helper.rb +2 -0
- data/spec/helpers/cli_helper.rb +2 -0
- data/spec/helpers/connection_helper.rb +14 -1
- data/spec/helpers/project_helper.rb +16 -0
- data/spec/helpers/schema_helper.rb +16 -0
- data/spec/integration/command_projects_spec.rb +7 -7
- data/spec/integration/create_from_template_spec.rb +2 -2
- data/spec/integration/full_project_spec.rb +160 -7
- data/spec/integration/partial_md_export_import_spec.rb +3 -3
- data/spec/logging_in_logging_out_spec.rb +2 -1
- data/spec/spec_helper.rb +26 -4
- data/spec/unit/bricks/bricks_spec.rb +15 -7
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +2 -0
- data/spec/unit/cli/cli_spec.rb +2 -0
- data/spec/unit/cli/commands/cmd_api_spec.rb +23 -15
- data/spec/unit/cli/commands/cmd_auth_spec.rb +8 -4
- data/spec/unit/cli/commands/cmd_domain_spec.rb +82 -0
- data/spec/unit/cli/commands/cmd_process_spec.rb +29 -13
- data/spec/unit/cli/commands/cmd_project_spec.rb +51 -30
- data/spec/unit/cli/commands/cmd_role_spec.rb +44 -0
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +8 -4
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +48 -11
- data/spec/unit/cli/commands/cmd_user_spec.rb +29 -0
- data/spec/unit/commands/command_api_spec.rb +1 -1
- data/spec/unit/commands/command_auth_spec.rb +100 -18
- data/spec/unit/commands/command_dataset_spec.rb +4 -0
- data/spec/unit/commands/command_process_spec.rb +9 -4
- data/spec/unit/commands/command_projects_spec.rb +10 -6
- data/spec/unit/commands/command_scaffold_spec.rb +5 -1
- data/spec/unit/commands/command_user_spec.rb +22 -0
- data/spec/unit/core/connection_spec.rb +35 -6
- data/spec/unit/core/logging_spec.rb +65 -0
- data/spec/unit/core/nil_logger_spec.rb +9 -0
- data/spec/unit/core/project_spec.rb +51 -0
- data/spec/unit/core/rest_spec.rb +33 -0
- data/spec/unit/data/guesser_spec.rb +5 -0
- data/spec/unit/godzilla/goodzilla_spec.rb +2 -0
- data/spec/unit/models/account_settings_spec.rb +28 -0
- data/spec/unit/models/anchor_spec.rb +32 -0
- data/spec/unit/models/attribute_column_spec.rb +7 -0
- data/spec/unit/models/domain_spec.rb +45 -0
- data/spec/unit/models/invitation_spec.rb +13 -0
- data/spec/unit/models/md_object_spec.rb +47 -0
- data/spec/unit/models/metric.rb +92 -0
- data/spec/unit/{model → models}/model_spec.rb +9 -7
- data/spec/unit/models/project_blueprint_spec.rb +202 -0
- data/spec/unit/models/project_creator.rb +73 -0
- data/spec/unit/models/project_role_spec.rb +90 -0
- data/spec/unit/models/project_spec.rb +143 -0
- data/spec/unit/models/schedule_spec.rb +491 -0
- data/spec/unit/{model → models}/schema_builder_spec.rb +2 -0
- data/spec/unit/{model → models}/tools_spec.rb +13 -7
- data/spec/unit/models/user_spec.rb +16 -0
- data/test/test_upload.rb +2 -0
- metadata +189 -86
- data/lib/gooddata/commands/profile.rb +0 -11
- data/lib/gooddata/models/attribute.rb +0 -29
- data/lib/gooddata/models/display_form.rb +0 -9
- data/lib/gooddata/models/fact.rb +0 -19
- data/lib/gooddata/models/metric.rb +0 -99
- data/lib/gooddata/models/report.rb +0 -89
- data/spec/data/blueprint_valid.json +0 -37
- data/spec/unit/cli/commands/cmd_profile_spec.rb +0 -16
- data/spec/unit/commands/command_profile_spec.rb +0 -18
- data/spec/unit/core/core_spec.rb +0 -7
- data/spec/unit/model/blueprint_spec.rb +0 -132
- data/spec/unit/model/project_blueprint_spec.rb +0 -44
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative '../metadata/column'
|
|
4
|
+
|
|
5
|
+
module GoodData
|
|
6
|
+
module Model
|
|
7
|
+
##
|
|
8
|
+
# GoodData display form abstraction. Represents a default representation
|
|
9
|
+
# of an attribute column or an additional representation defined in a LABEL
|
|
10
|
+
# field
|
|
11
|
+
#
|
|
12
|
+
class Label < Column
|
|
13
|
+
attr_accessor :attribute
|
|
14
|
+
|
|
15
|
+
def type_prefix
|
|
16
|
+
'label'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# def initialize(hash, schema)
|
|
20
|
+
def initialize(hash, attribute, schema)
|
|
21
|
+
super hash, schema
|
|
22
|
+
attribute = attribute.nil? ? schema.fields.find { |field| field.name == hash[:reference] } : attribute
|
|
23
|
+
@attribute = attribute
|
|
24
|
+
attribute.labels << self
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def identifier
|
|
28
|
+
@identifier ||= @attribute.name == name ? super : "#{type_prefix}.#{@schema.name}.#{@attribute.name}.#{name}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_maql_create
|
|
32
|
+
"# LABEL FROM LABEL\nALTER ATTRIBUTE {#{@attribute.identifier}} ADD LABELS {#{identifier}}" \
|
|
33
|
+
+ " VISUAL (TITLE #{title.inspect}) AS {#{column}};\n"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def to_manifest_part(mode)
|
|
37
|
+
{
|
|
38
|
+
'populates' => [identifier],
|
|
39
|
+
'mode' => mode,
|
|
40
|
+
'columnName' => name
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def column
|
|
45
|
+
"#{@attribute.table}.#{LABEL_COLUMN_PREFIX}#{name}"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
alias_method :inspect_orig, :inspect
|
|
49
|
+
|
|
50
|
+
def inspect
|
|
51
|
+
inspect_orig.sub(/>$/, " @attribute=#{@attribute.to_s.sub(/>$/, " @name=#{@attribute.name}")}>")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative '../metadata/column'
|
|
4
|
+
|
|
5
|
+
module GoodData
|
|
6
|
+
module Model
|
|
7
|
+
##
|
|
8
|
+
# Reference to another data set
|
|
9
|
+
#
|
|
10
|
+
class Reference < Column
|
|
11
|
+
attr_accessor :reference, :schema_ref
|
|
12
|
+
|
|
13
|
+
def initialize(column, schema)
|
|
14
|
+
super column, schema
|
|
15
|
+
# pp column
|
|
16
|
+
@name = column[:name]
|
|
17
|
+
@reference = column[:reference]
|
|
18
|
+
@schema_ref = column[:dataset]
|
|
19
|
+
@schema = schema
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
##
|
|
23
|
+
# Generates an identifier of the referencing attribute using the
|
|
24
|
+
# schema name derived from schemaReference and column name derived
|
|
25
|
+
# from the reference key.
|
|
26
|
+
#
|
|
27
|
+
def identifier
|
|
28
|
+
@identifier ||= "#{ATTRIBUTE_PREFIX}.#{@schema_ref}.#{@reference}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def key
|
|
32
|
+
"#{@name}_id"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def label_column
|
|
36
|
+
"#{LABEL_PREFIX}.#{@schema_ref}.#{@reference}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def to_maql_create
|
|
40
|
+
"ALTER ATTRIBUTE {#{identifier}} ADD KEYS {#{@schema.table}.#{key}};\n"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def to_maql_drop
|
|
44
|
+
"ALTER ATTRIBUTE {#{identifier} DROP KEYS {#{@schema.table}.#{key}};\n"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def to_manifest_part(mode)
|
|
48
|
+
{
|
|
49
|
+
'populates' => [label_column],
|
|
50
|
+
'mode' => mode,
|
|
51
|
+
'columnName' => name,
|
|
52
|
+
'referenceKey' => 1
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module GoodData
|
|
4
|
+
module Model
|
|
5
|
+
class DashboardBuilder
|
|
6
|
+
def initialize(title)
|
|
7
|
+
@title = title
|
|
8
|
+
@tabs = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def add_tab(tab, &block)
|
|
12
|
+
tb = TabBuilder.new(tab)
|
|
13
|
+
block.call(tb)
|
|
14
|
+
@tabs << tb
|
|
15
|
+
tb
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to_hash
|
|
19
|
+
{
|
|
20
|
+
:name => @name,
|
|
21
|
+
:tabs => @tabs.map { |tab| tab.to_hash }
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
require 'active_support/all'
|
|
4
|
-
|
|
5
3
|
require_relative '../extensions/big_decimal'
|
|
6
4
|
|
|
7
5
|
module GoodData
|
|
@@ -16,21 +14,24 @@ module GoodData
|
|
|
16
14
|
puts to_s
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
def to_s(options={})
|
|
20
|
-
with_indices = options[:index]
|
|
17
|
+
def to_s(options = {})
|
|
18
|
+
with_indices = options[:index]
|
|
19
|
+
|
|
21
20
|
a = to_table.to_a
|
|
22
21
|
data = a.transpose
|
|
23
22
|
data.unshift((1..a.length).to_a) if with_indices
|
|
24
|
-
data.each_with_index.map
|
|
23
|
+
processed_data = data.each_with_index.map do |col, i|
|
|
25
24
|
col.unshift(i.zero? ? nil : i) if with_indices # inserts row labels #
|
|
26
25
|
w = col.map { |cell| cell.to_s.length }.max # w = "column width" #
|
|
27
|
-
col.each_with_index.map
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
col.each_with_index.map do |cell, j|
|
|
27
|
+
j.zero? ? cell.to_s.center(w) : cell.to_s.ljust(w)
|
|
28
|
+
end # alligns the column #
|
|
29
|
+
end
|
|
30
|
+
processed_data.transpose.map { |row| "[#{row.join(' | ')}]" }.unshift('').join("\n")
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def to_table
|
|
33
|
-
|
|
34
|
+
fail 'Should be implemented in subclass'
|
|
34
35
|
end
|
|
35
36
|
end
|
|
36
37
|
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative 'account_settings'
|
|
4
|
+
|
|
5
|
+
module GoodData
|
|
6
|
+
class Domain
|
|
7
|
+
attr_reader :name
|
|
8
|
+
|
|
9
|
+
USERS_OPTIONS = { :offset => 0, :limit => 1000 }
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
# Looks for domain
|
|
13
|
+
#
|
|
14
|
+
# @param domain_name [String] Domain name
|
|
15
|
+
# @return [String] Domain object instance
|
|
16
|
+
def [](domain_name, options = {})
|
|
17
|
+
fail "Using pseudo-id 'all' is not supported by GoodData::Domain" if domain_name.to_s == 'all'
|
|
18
|
+
GoodData::Domain.new(domain_name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Adds user to domain
|
|
22
|
+
#
|
|
23
|
+
# @param domain [String] Domain name
|
|
24
|
+
# @param login [String] Login of user to be invited
|
|
25
|
+
# @param password [String] Default preset password
|
|
26
|
+
# @return [Object] Raw response
|
|
27
|
+
def add_user(domain, login, password)
|
|
28
|
+
data = {
|
|
29
|
+
:accountSetting => {
|
|
30
|
+
:login => login,
|
|
31
|
+
:firstName => 'FirstName',
|
|
32
|
+
:lastName => 'LastName',
|
|
33
|
+
:password => password,
|
|
34
|
+
:verifyPassword => password,
|
|
35
|
+
:email => login
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
url = "/gdc/account/domains/#{domain}/users"
|
|
40
|
+
GoodData.post(url, data)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Finds user in domain by login
|
|
44
|
+
#
|
|
45
|
+
# @param domain [String] Domain name
|
|
46
|
+
# @param login [String] User login
|
|
47
|
+
# @return [GoodData::AccountSettings] User account settings
|
|
48
|
+
def find_user_by_login(domain, login)
|
|
49
|
+
url = "/gdc/account/domains/#{domain}/users?login=#{login}"
|
|
50
|
+
tmp = GoodData.get url
|
|
51
|
+
items = tmp['accountSettings']['items'] if tmp['accountSettings']
|
|
52
|
+
if items && items.length > 0
|
|
53
|
+
return GoodData::AccountSettings.new(items.first)
|
|
54
|
+
end
|
|
55
|
+
nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns list of users for domain specified
|
|
59
|
+
# @param [String] domain Domain to list the users for
|
|
60
|
+
# @param [Hash] opts Options.
|
|
61
|
+
# @option opts [Number] :offset The subject
|
|
62
|
+
# @option opts [Number] :limit From address
|
|
63
|
+
def users(domain, opts = USERS_OPTIONS)
|
|
64
|
+
result = []
|
|
65
|
+
|
|
66
|
+
options = USERS_OPTIONS.merge(opts)
|
|
67
|
+
|
|
68
|
+
tmp = GoodData.get("/gdc/account/domains/#{domain}/users?offset=#{options[:offset]}&limit=#{options[:limit]}")
|
|
69
|
+
tmp['accountSettings']['items'].each do |account|
|
|
70
|
+
result << GoodData::AccountSettings.new(account)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
result
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def initialize(domain_name)
|
|
78
|
+
@name = domain_name
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Adds user to domain
|
|
82
|
+
#
|
|
83
|
+
# @param login [String] Login of user to be invited
|
|
84
|
+
# @param password [String] Default preset password
|
|
85
|
+
# @return [Object] Raw response
|
|
86
|
+
#
|
|
87
|
+
# Example
|
|
88
|
+
#
|
|
89
|
+
# GoodData.connect 'tomas.korcak@gooddata.com' 'your-password'
|
|
90
|
+
# domain = GoodData::Domain['gooddata-tomas-korcak']
|
|
91
|
+
# domain.add_user 'joe.doe@example', 'sup3rS3cr3tP4ssW0rtH'
|
|
92
|
+
#
|
|
93
|
+
def add_user(login, password)
|
|
94
|
+
GoodData::Domain.add_user(name, login, password)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Finds user in domain by login
|
|
98
|
+
#
|
|
99
|
+
# @param login [String] User login
|
|
100
|
+
# @return [GoodData::AccountSettings] User account settings
|
|
101
|
+
def find_user_by_login(login)
|
|
102
|
+
GoodData::Domain.find_user_by_login(name, login)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# List users in domain
|
|
106
|
+
#
|
|
107
|
+
# @param [Hash] opts Additional user listing options.
|
|
108
|
+
# @option opts [Number] :offset Offset to start listing from
|
|
109
|
+
# @option opts [Number] :limit Limit of users to be listed
|
|
110
|
+
# @return [Array<GoodData::AccountSettings>] List of user account settings
|
|
111
|
+
#
|
|
112
|
+
# Example
|
|
113
|
+
#
|
|
114
|
+
# GoodData.connect 'tomas.korcak@gooddata.com' 'your-password'
|
|
115
|
+
# domain = GoodData::Domain['gooddata-tomas-korcak']
|
|
116
|
+
# pp domain.users
|
|
117
|
+
#
|
|
118
|
+
def users(opts = USERS_OPTIONS)
|
|
119
|
+
GoodData::Domain.users(name, opts)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
private
|
|
123
|
+
|
|
124
|
+
# Private setter of domain name. Used by constructor not available for external users.
|
|
125
|
+
#
|
|
126
|
+
# @param domain_name [String] Domain name to be set.
|
|
127
|
+
def name=(domain_name) # rubocop:disable TrivialAccessors
|
|
128
|
+
@name = domain_name
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -4,6 +4,8 @@ require_relative 'data_result.rb'
|
|
|
4
4
|
|
|
5
5
|
module GoodData
|
|
6
6
|
class EmptyResult < DataResult
|
|
7
|
+
attr_reader :table
|
|
8
|
+
|
|
7
9
|
def initialize(data, options = {})
|
|
8
10
|
super(data)
|
|
9
11
|
@options = options
|
|
@@ -19,15 +21,10 @@ module GoodData
|
|
|
19
21
|
# CSV::Table.new([GoodData::Row.new([],[],false)])
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def without_column_headers
|
|
27
|
-
@table
|
|
28
|
-
end
|
|
24
|
+
alias_method :to_table, :table
|
|
25
|
+
alias_method :without_column_headers, :table
|
|
29
26
|
|
|
30
|
-
def ==
|
|
27
|
+
def ==(other)
|
|
31
28
|
false
|
|
32
29
|
end
|
|
33
30
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative '../metadata/fact'
|
|
4
|
+
|
|
5
|
+
module GoodData
|
|
6
|
+
module Model
|
|
7
|
+
##
|
|
8
|
+
# Fact representation of a time of a day
|
|
9
|
+
#
|
|
10
|
+
class TimeFact < Fact
|
|
11
|
+
def column_prefix
|
|
12
|
+
TIME_COLUMN_PREFIX
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def type_prefix
|
|
16
|
+
TIME_FACT_PREFIX
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative '../metadata/folder'
|
|
4
|
+
|
|
5
|
+
module GoodData
|
|
6
|
+
module Model
|
|
7
|
+
##
|
|
8
|
+
# GoodData attribute folder abstraction
|
|
9
|
+
#
|
|
10
|
+
class AttributeFolder < Folder
|
|
11
|
+
def type
|
|
12
|
+
'ATTRIBUTE'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def type_prefix
|
|
16
|
+
'dim'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative '../metadata/folder'
|
|
4
|
+
|
|
5
|
+
module GoodData
|
|
6
|
+
module Model
|
|
7
|
+
##
|
|
8
|
+
# GoodData fact folder abstraction
|
|
9
|
+
#
|
|
10
|
+
class FactFolder < Folder
|
|
11
|
+
def type
|
|
12
|
+
'FACT'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def type_prefix
|
|
16
|
+
'ffld'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module GoodData
|
|
4
|
+
class Invitation
|
|
5
|
+
def initialize(json)
|
|
6
|
+
@json = json
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def author
|
|
10
|
+
# TODO: Return object instead
|
|
11
|
+
@json['invitation']['meta']['author']
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def contributor
|
|
15
|
+
# TODO: Return object instead
|
|
16
|
+
@json['invitation']['meta']['contributor']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def created
|
|
20
|
+
DateTime.parse(@json['invitation']['meta']['created'])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def email
|
|
24
|
+
@json['invitation']['content']['email']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def first_name
|
|
28
|
+
@json['invitation']['content']['firstname']
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def first_name
|
|
32
|
+
@json['invitation']['content']['firstname']
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def phone
|
|
36
|
+
@json['invitation']['content']['phone']
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def profile
|
|
40
|
+
# TODO: Return object instead
|
|
41
|
+
@json['invitation']['links']['profile']
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def project
|
|
45
|
+
# TODO: Return object instead
|
|
46
|
+
@json['invitation']['links']['project']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def project_name
|
|
50
|
+
@json['invitation']['content']['projectname']
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def role
|
|
54
|
+
# TODO: Return object instead
|
|
55
|
+
@json['invitation']['content']['role']
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def status
|
|
59
|
+
@json['invitation']['content']['status']
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def summary
|
|
63
|
+
@json['invitation']['content']['summary']
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def title
|
|
67
|
+
@json['invitation']['content']['title']
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def updated
|
|
71
|
+
DateTime.parse(@json['invitation']['meta']['updated'])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def uri
|
|
75
|
+
@json['invitation']['links']['self']
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|