gooddata 0.6.24 → 0.6.25

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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +54 -0
  3. data/CHANGELOG.md +3 -0
  4. data/DEPENDENCIES.md +155 -154
  5. data/README.md +15 -6
  6. data/Rakefile +5 -3
  7. data/dependency_decisions.yml +2 -0
  8. data/gooddata.gemspec +2 -3
  9. data/lib/gooddata/cli/cli.rb +1 -3
  10. data/lib/gooddata/cli/commands/auth_cmd.rb +16 -7
  11. data/lib/gooddata/cli/commands/project_cmd.rb +16 -178
  12. data/lib/gooddata/cli/shared.rb +46 -44
  13. data/lib/gooddata/commands/auth.rb +4 -0
  14. data/lib/gooddata/commands/project.rb +7 -24
  15. data/lib/gooddata/exceptions/object_migration.rb +4 -0
  16. data/lib/gooddata/exceptions/segment_not_empty.rb +18 -0
  17. data/lib/gooddata/extensions/object.rb +12 -0
  18. data/lib/gooddata/goodzilla/goodzilla.rb +56 -9
  19. data/lib/gooddata/helpers/global_helpers.rb +92 -0
  20. data/lib/gooddata/mixins/md_finders.rb +2 -8
  21. data/lib/gooddata/mixins/md_grantees.rb +42 -0
  22. data/lib/gooddata/mixins/md_id_to_uri.rb +1 -8
  23. data/lib/gooddata/mixins/md_object_id.rb +1 -1
  24. data/lib/gooddata/mixins/md_object_indexer.rb +5 -8
  25. data/lib/gooddata/mixins/md_object_query.rb +2 -2
  26. data/lib/gooddata/mixins/not_group.rb +17 -0
  27. data/lib/gooddata/mixins/rest_getters.rb +2 -2
  28. data/lib/gooddata/mixins/rest_resource.rb +1 -0
  29. data/lib/gooddata/mixins/to_json.rb +11 -0
  30. data/lib/gooddata/mixins/uri_getter.rb +9 -0
  31. data/lib/gooddata/models/blueprint/anchor_field.rb +14 -0
  32. data/lib/gooddata/models/blueprint/project_blueprint.rb +15 -1
  33. data/lib/gooddata/models/blueprint/to_wire.rb +10 -0
  34. data/lib/gooddata/models/client.rb +178 -0
  35. data/lib/gooddata/models/client_synchronization_result.rb +31 -0
  36. data/lib/gooddata/models/client_synchronization_result_details.rb +41 -0
  37. data/lib/gooddata/models/datawarehouse.rb +1 -5
  38. data/lib/gooddata/models/domain.rb +85 -1
  39. data/lib/gooddata/models/execution.rb +0 -2
  40. data/lib/gooddata/models/execution_detail.rb +0 -2
  41. data/lib/gooddata/models/from_wire.rb +10 -0
  42. data/lib/gooddata/models/invitation.rb +1 -1
  43. data/lib/gooddata/models/links.rb +1 -1
  44. data/lib/gooddata/models/membership.rb +10 -6
  45. data/lib/gooddata/models/metadata.rb +98 -11
  46. data/lib/gooddata/models/metadata/attribute.rb +6 -7
  47. data/lib/gooddata/models/metadata/dashboard.rb +41 -75
  48. data/lib/gooddata/models/metadata/dashboard/dashboard_item.rb +20 -4
  49. data/lib/gooddata/models/metadata/dashboard/filter_apply_item.rb +37 -0
  50. data/lib/gooddata/models/metadata/dashboard/filter_item.rb +49 -0
  51. data/lib/gooddata/models/metadata/dashboard/geo_chart_item.rb +56 -0
  52. data/lib/gooddata/models/metadata/dashboard/headline_item.rb +56 -0
  53. data/lib/gooddata/models/metadata/dashboard/iframe_item.rb +46 -0
  54. data/lib/gooddata/models/metadata/dashboard/report_item.rb +49 -8
  55. data/lib/gooddata/models/metadata/dashboard/text_item.rb +55 -0
  56. data/lib/gooddata/models/metadata/dashboard_tab.rb +83 -30
  57. data/lib/gooddata/models/metadata/dataset.rb +0 -2
  58. data/lib/gooddata/models/metadata/dimension.rb +1 -3
  59. data/lib/gooddata/models/metadata/fact.rb +1 -3
  60. data/lib/gooddata/models/metadata/label.rb +1 -3
  61. data/lib/gooddata/models/metadata/metric.rb +11 -42
  62. data/lib/gooddata/models/metadata/report.rb +7 -18
  63. data/lib/gooddata/models/metadata/report_definition.rb +21 -113
  64. data/lib/gooddata/models/metadata/scheduled_mail.rb +274 -0
  65. data/lib/gooddata/models/metadata/scheduled_mail/dashboard_attachment.rb +62 -0
  66. data/lib/gooddata/models/metadata/scheduled_mail/report_attachment.rb +64 -0
  67. data/lib/gooddata/models/metadata/variable.rb +8 -2
  68. data/lib/gooddata/models/model.rb +2 -9
  69. data/lib/gooddata/models/process.rb +7 -29
  70. data/lib/gooddata/models/profile.rb +1 -1
  71. data/lib/gooddata/models/project.rb +131 -167
  72. data/lib/gooddata/models/project_creator.rb +2 -7
  73. data/lib/gooddata/models/project_metadata.rb +2 -10
  74. data/lib/gooddata/models/project_role.rb +4 -10
  75. data/lib/gooddata/models/report_data_result.rb +3 -5
  76. data/lib/gooddata/models/schedule.rb +4 -31
  77. data/lib/gooddata/models/segment.rb +192 -0
  78. data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +2 -2
  79. data/lib/gooddata/models/user_filters/user_filter_builder.rb +1 -1
  80. data/lib/gooddata/models/user_filters/variable_user_filter.rb +11 -0
  81. data/lib/gooddata/models/user_group.rb +241 -0
  82. data/lib/gooddata/rest/connection.rb +81 -16
  83. data/lib/gooddata/rest/object.rb +29 -0
  84. data/lib/gooddata/rest/object_factory.rb +6 -1
  85. data/lib/gooddata/rest/resource.rb +7 -1
  86. data/lib/gooddata/version.rb +1 -1
  87. data/spec/environment/default.rb +19 -16
  88. data/spec/environment/develop.rb +10 -10
  89. data/spec/environment/hotfix.rb +6 -6
  90. data/spec/environment/production.rb +14 -14
  91. data/spec/environment/release.rb +6 -6
  92. data/spec/environment/staging.rb +9 -9
  93. data/spec/environment/staging_3.rb +14 -15
  94. data/spec/integration/blueprint_with_grain_spec.rb +72 -0
  95. data/spec/integration/clients_spec.rb +135 -0
  96. data/spec/integration/date_dim_switch_spec.rb +142 -0
  97. data/spec/integration/full_project_spec.rb +3 -3
  98. data/spec/integration/project_spec.rb +20 -0
  99. data/spec/integration/segments_spec.rb +141 -0
  100. data/spec/integration/user_group_spec.rb +127 -0
  101. data/spec/spec_helper.rb +4 -0
  102. data/spec/unit/models/domain_spec.rb +7 -1
  103. data/spec/unit/models/metric_spec.rb +0 -8
  104. data/spec/unit/models/profile_spec.rb +1 -1
  105. data/spec/unit/models/report_result_data_spec.rb +6 -0
  106. metadata +38 -38
  107. data/lib/gooddata/cli/commands/api_cmd.rb +0 -34
  108. data/lib/gooddata/cli/commands/console_cmd.rb +0 -40
  109. data/lib/gooddata/cli/commands/domain_cmd.rb +0 -46
  110. data/lib/gooddata/cli/commands/process_cmd.rb +0 -145
  111. data/lib/gooddata/cli/commands/projects_cmd.rb +0 -23
  112. data/lib/gooddata/cli/commands/run_ruby_cmd.rb +0 -77
  113. data/lib/gooddata/cli/commands/scaffold_cmd.rb +0 -35
  114. data/lib/gooddata/cli/commands/user_cmd.rb +0 -24
@@ -1,40 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require 'pp'
8
-
9
- require_relative '../shared'
10
-
11
- GoodData::CLI.module_eval do
12
- desc 'Interactive session with gooddata sdk loaded'
13
- command :console do |c|
14
- c.action do |global_options, _options, _args|
15
- username = global_options[:username]
16
- fail ArgumentError, 'No username specified' if username.nil? || username.empty?
17
-
18
- password = global_options[:password]
19
- fail ArgumentError, 'No password specified' if password.nil? || password.empty?
20
-
21
- pid = global_options[:project_id]
22
- fail ArgumentError, 'No project specified' if pid.nil?
23
-
24
- client = GoodData.connect username, password
25
-
26
- proj = GoodData::Project[pid, :client => client]
27
-
28
- GoodData.with_project(proj, :client => client) do |project|
29
- fail ArgumentError, 'Wrong project specified' if project.nil?
30
-
31
- puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
32
- binding.pry(:quiet => true, # rubocop:disable Lint/Debugger
33
- :prompt => [proc do |_target_self, _nest_level, _pry|
34
- 'sdk_live_session: '
35
- end])
36
- end
37
- client.disconnect
38
- end
39
- end
40
- end
@@ -1,46 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require_relative '../shared'
8
- require_relative '../../commands/domain'
9
-
10
- GoodData::CLI.module_eval do
11
- desc 'Manage domain'
12
- command :domain do |c|
13
- c.desc 'Add user to domain'
14
- c.command :add_user do |add_user|
15
- add_user.action do |global_options, options, args|
16
- opts = options.merge(global_options)
17
- client = GoodData.connect(opts)
18
-
19
- domain = args[0]
20
- fail ArgumentError, 'Domain name has to be provided' if domain.nil? || domain.empty?
21
-
22
- email = args[1]
23
- fail ArgumentError, 'Email has to be provided' if email.nil? || email.empty?
24
-
25
- password = args[2]
26
- fail ArgumentError, 'Password has to be provided' if password.nil? || password.empty?
27
-
28
- GoodData::Command::Domain.add_user(domain, email, password, :client => client)
29
- end
30
- end
31
-
32
- c.desc 'List users in domain'
33
- c.command :list_users do |list_users|
34
- list_users.action do |global_options, options, args|
35
- opts = options.merge(global_options)
36
- client = GoodData.connect(opts)
37
-
38
- domain = args[0]
39
- fail ArgumentError, 'Domain name has to be provided' if domain.nil? || domain.empty?
40
-
41
- users = GoodData::Command::Domain.list_users(domain, :client => client)
42
- puts users.map { |u| [u.first_name, u.last_name, u.login].join(',') }
43
- end
44
- end
45
- end
46
- end
@@ -1,145 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require 'pp'
8
-
9
- require_relative '../shared'
10
- require_relative '../../commands/process'
11
-
12
- def read_params_file(filename)
13
- # read params from a file
14
- # if filename nil, return empty hash
15
- if filename
16
- JSON.parse(IO.read(filename))
17
- else
18
- {}
19
- end
20
- end
21
-
22
- GoodData::CLI.module_eval do
23
- desc 'Work with deployed processes'
24
- arg_name 'Describe arguments to list here'
25
- command :process do |c|
26
- c.desc 'Use when you need to redeploy a specific process'
27
- c.default_value nil
28
- c.flag :process_id
29
-
30
- c.desc 'Specify directory for deployment'
31
- c.default_value nil
32
- c.flag :dir
33
-
34
- c.desc 'Specify type of deployment'
35
- c.default_value nil
36
- c.flag :type
37
-
38
- c.desc 'Specify name of deployed process'
39
- c.default_value nil
40
- c.flag :name
41
-
42
- c.desc 'Specify executable of the process'
43
- c.default_value nil
44
- c.flag :executable
45
-
46
- c.desc 'Specify parameters file to execute the process with'
47
- c.default_value nil
48
- c.flag :params
49
-
50
- c.desc 'Specify hidden paremeters to execute the process with'
51
- c.default_value nil
52
- c.flag :hidden_params
53
-
54
- c.desc 'Specify cron expression for the schedule'
55
- c.default_value nil
56
- c.flag :cron
57
-
58
- c.desc "Lists all user's processes deployed on the plaform"
59
- c.command :list do |list|
60
- list.action do |global_options, options, args|
61
- opts = options.merge(global_options)
62
- client = GoodData.connect(opts)
63
- opts = opts.merge(:project_id => args[0]) if args.length > 0
64
- processes = GoodData::Command::Process.list(opts.merge(client: client))
65
- processes.each do |process|
66
- puts "#{process.name},#{client.connection.server_url + process.uri}"
67
- end
68
- end
69
- end
70
-
71
- c.desc 'Gives you some basic info about the process'
72
- c.command :show do |get|
73
- get.action do |global_options, options, _args|
74
- opts = options.merge(global_options)
75
- client = GoodData.connect(opts)
76
- pp GoodData::Command::Process.get(opts.merge(client: client)).raw_data
77
- end
78
- end
79
-
80
- c.desc 'Deploys provided directory to the server'
81
- c.command :deploy do |deploy|
82
- deploy.action do |global_options, options, _args|
83
- opts = options.merge(global_options)
84
- dir = opts[:dir]
85
- name = opts[:name]
86
- fail 'You have to provide a directory or a file to deploy. Use --dir param' if dir.nil? || dir.empty?
87
- fail 'You have to provide a name of the deployed process. Use --name param' if name.nil? || name.empty?
88
- client = GoodData.connect(opts)
89
- process = GoodData::Command::Process.deploy(dir, opts.merge(client: client))
90
- puts "Process #{process.uri} was deployed"
91
- end
92
- end
93
-
94
- c.desc 'Delete specific process'
95
- c.command :delete do |deploy|
96
- deploy.action do |global_options, options, _args|
97
- opts = options.merge(global_options)
98
- process_id = opts[:process_id]
99
- fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
100
- client = GoodData.connect(opts)
101
- GoodData::Command::Process.delete(process_id, opts.merge(client: client))
102
- puts "Process #{process_id} was deleted"
103
- end
104
- end
105
-
106
- c.desc 'Execute specific deployed process'
107
- c.command :execute do |deploy|
108
- deploy.action do |global_options, options, _args|
109
- opts = options.merge(global_options)
110
- process_id = opts[:process_id]
111
- executable = opts[:executable]
112
-
113
- fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
114
- fail 'You have to provide an executable for the process. Use --executable param' if executable.nil? || executable.empty?
115
- client = GoodData.connect(options)
116
- project = client.projects(options[:project_id])
117
- process = project.processes(options[:process_id])
118
- params = read_params_file(options[:params])
119
- hidden_params = read_params_file(options[:hidden_params])
120
- process.execute(options[:executable], params: params, hidden_params: hidden_params)
121
- end
122
- end
123
-
124
- c.desc 'Schedule specific deployed process'
125
- c.command :schedule do |schedule|
126
- schedule.action do |global_options, command_options, _|
127
- options = command_options.merge(global_options)
128
- process_id = options[:process_id]
129
- executable = options[:executable]
130
- cron = options[:cron]
131
-
132
- fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
133
- fail 'You have to provide an executable for the process. Use --executable param' if executable.nil? || executable.empty?
134
- fail 'You have to provide a cron expression for the schedule. Use --cron param' if cron.nil? || cron.empty?
135
-
136
- client = GoodData.connect(options)
137
- project = client.projects(options[:project_id])
138
- process = project.processes(options[:process_id])
139
- params = read_params_file(options[:params])
140
- hidden_params = read_params_file(options[:hidden_params])
141
- process.create_schedule(cron, options[:executable], params: params, hidden_params: hidden_params)
142
- end
143
- end
144
- end
145
- end
@@ -1,23 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require_relative '../shared'
8
- require_relative '../../commands/projects'
9
-
10
- GoodData::CLI.module_eval do
11
- desc 'Manage your projects'
12
- command :projects do |c|
13
- c.desc "Lists user's projects"
14
- c.command :list do |list|
15
- list.action do |global_options, options, _args|
16
- opts = options.merge(global_options)
17
- client = GoodData.connect(opts)
18
- list = GoodData::Command::Projects.list(client: client)
19
- puts list.map { |p| [p.uri, p.title].join(',') }
20
- end
21
- end
22
- end
23
- end
@@ -1,77 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require 'pp'
8
- require 'hashie'
9
-
10
- require_relative '../shared'
11
- require_relative '../../commands/process'
12
- require_relative '../../commands/runners'
13
- require_relative '../../client'
14
-
15
- # translate given params (with dots) to json-like params
16
- def load_undot(filename)
17
- p = MultiJson.load(File.read(filename))
18
- GoodData::Helper.undot(GoodData::Helper::DeepMergeableHash[p])
19
- end
20
-
21
- GoodData::CLI.module_eval do
22
- desc 'Run ruby bricks either locally or remotely deployed on our server. Currently private alpha.'
23
- # arg_name 'show'
24
- command :run_ruby do |c|
25
- c.desc 'Directory of the ruby brick'
26
- c.default_value nil
27
- c.flag [:d, :dir]
28
-
29
- c.desc 'Log file. If empty STDOUT will be used instead'
30
- c.default_value nil
31
- c.flag [:l, :logger]
32
-
33
- c.desc 'Params file path. Inside should be hash of key values. These params override any defaults given in bricks.'
34
- c.default_value nil
35
- c.flag [:params, :paramfile]
36
-
37
- c.desc 'Remote system credentials file path. Inside should be hash of key values.'
38
- c.default_value nil
39
- c.flag [:credentials]
40
-
41
- c.desc 'Run on remote machine'
42
- c.switch [:r, :remote]
43
-
44
- c.desc 'Name of the deployed process'
45
- c.default_value nil
46
- c.flag [:n, :name]
47
-
48
- c.action do |global_options, options, _args|
49
- verbose = global_options[:verbose]
50
- options[:expanded_params] = if options[:params]
51
- # load params and credentials if given
52
- runtime_params = load_undot(options[:params])
53
- if options[:credentials]
54
- runtime_params = runtime_params.deep_merge(load_undot(options[:credentials]))
55
- end
56
- { 'config' => runtime_params }
57
- else
58
- { 'config' => {} }
59
- end
60
-
61
- # if there are some GDC_* params in config, put them on the level above
62
- gdc_params = options[:expanded_params]['config'].select { |k, _| k =~ /GDC_.*/ }
63
- options[:expanded_params].merge!(gdc_params)
64
- opts = options.merge(global_options).merge(:type => 'RUBY')
65
- GoodData.connect(opts)
66
- if options[:remote]
67
- fail 'You have to specify name of the deploy when deploying remotely' if options[:name].nil? || options[:name].empty?
68
- require_relative '../../commands/process'
69
- GoodData::Command::Process.run(options[:dir], './main.rb', opts)
70
- else
71
- require_relative '../../commands/runners'
72
- GoodData::Command::Runners.run_ruby_locally(options[:dir], opts)
73
- end
74
- puts HighLine.color('Running ruby brick - DONE', HighLine::GREEN) if verbose
75
- end
76
- end
77
- end
@@ -1,35 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require 'pp'
8
-
9
- require_relative '../shared'
10
- require_relative '../../commands/scaffold'
11
-
12
- GoodData::CLI.module_eval do
13
- desc 'Scaffold things'
14
- arg_name 'show'
15
- command :scaffold do |c|
16
- c.desc 'Scaffold a gooddata project blueprint'
17
- c.command :project do |project|
18
- project.action do |_global_options, _options, args|
19
- name = args.first
20
- fail 'Name of the project has to be provided' if name.nil? || name.empty?
21
- GoodData::Command::Scaffold.project(name)
22
- end
23
- end
24
-
25
- c.desc 'Scaffold a gooddata ruby brick. This is a piece of code that you can run on our platform'
26
- c.command :brick do |brick|
27
- # brick.arg_name 'name'
28
- brick.action do |_global_options, _options, args|
29
- name = args.first
30
- fail 'Name of the brick has to be provided' if name.nil? || name.empty?
31
- GoodData::Command::Scaffold.brick(name)
32
- end
33
- end
34
- end
35
- end
@@ -1,24 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require_relative '../shared'
8
- require_relative '../../commands/project'
9
- require_relative '../../commands/role'
10
- require_relative '../../commands/user'
11
-
12
- GoodData::CLI.module_eval do
13
- desc 'User management'
14
- command :user do |c|
15
- c.desc 'Show your profile'
16
- c.command :show do |show|
17
- show.action do |global_options, options, _args|
18
- opts = options.merge(global_options)
19
- client = GoodData.connect(opts)
20
- pp GoodData::Command::User.show(client: client)
21
- end
22
- end
23
- end
24
- end