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
data/README.md CHANGED
@@ -49,18 +49,27 @@ If you are using gems just
49
49
 
50
50
  ## Credits
51
51
 
52
- This project was originaly started by Pavel Kolesnikov [ <mailto:pavel@gooddata.com> / [@koles](http://twitter.com/koles) ]
52
+ **Originaly started by**
53
53
 
54
- Project is now actively developed and maintained by following folks
54
+ Pavel Kolesnikov [ <mailto:pavel@gooddata.com> / [@koles](http://twitter.com/koles) ]
55
+
56
+ **Actively developed and maintained by**
57
+
58
+ - [Tomas Korcak](https://github.com/korczis) [ <mailto:korczis@gmail.com> / [@korczis](http://twitter.com/korczis) ]
59
+ - [Tomas Svarovsky](https://github.com/fluke777) [ <mailto:svarovsky.tomas@gmail.com> / [@fluke777](http://twitter.com/fluke777) ]
60
+
61
+ **Contributors**
55
62
 
56
- - [Tomas Korcak](https://github.com/korczis) [<mailto:korczis@gmail.com> / [@korczis](http://twitter.com/korczis)]
57
- - [Tomas Svarovsky](https://github.com/fluke777) [<mailto:svarovsky.tomas@gmail.com> / [@fluke777](http://twitter.com/fluke777)]
58
63
  - [Patrick McConlogue](https://github.com/thnkr/)
59
64
  - [Petr Cvengros](https://github.com/cvengros)
60
65
 
61
- Special thanks to Thomas Watson Steen [ <mailto:w@tson.dk> / [@wa7son](http://twitter.com/wa7son) ].
66
+ For full contributor info see [contributors page](https://github.com/gooddata/gooddata-ruby/graphs/contributors).
67
+
68
+ **Special thanks to**
69
+
70
+ - Thomas Watson Steen [ <mailto:w@tson.dk> / [@wa7son](http://twitter.com/wa7son) ].
62
71
 
63
72
  ## Copyright
64
73
 
65
- Copyright (c) 2010 - 2014 GoodData Corporation and Thomas Watson Steen. See LICENSE for details.
74
+ Copyright (c) 2010 - 2015 GoodData Corporation and Thomas Watson Steen. See LICENSE for details.
66
75
 
data/Rakefile CHANGED
@@ -12,9 +12,11 @@ require 'rspec/core/rake_task'
12
12
 
13
13
  require 'yard'
14
14
 
15
- desc 'Run Rubocop'
16
- task :cop do
17
- exec 'rubocop lib/ gooddata.gemspec Rakefile'
15
+ require 'rubocop/rake_task'
16
+
17
+ desc 'Run RuboCop'
18
+ RuboCop::RakeTask.new(:rubocop) do |task|
19
+ task.patterns = ['lib/**/*.rb']
18
20
  end
19
21
 
20
22
  desc 'Run continuous integration test'
@@ -100,3 +100,5 @@
100
100
  - :who:
101
101
  :why:
102
102
  :when: 2015-08-03 10:50:05.464030000 Z
103
+
104
+
@@ -27,8 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.homepage = 'http://github.com/gooddata/gooddata-ruby'
28
28
  s.require_paths = ['lib']
29
29
 
30
- s.add_development_dependency 'bundler', '~> 1.10.6', '>= 1.10.6'
31
- s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8.2'
30
+ s.add_development_dependency 'bundler', '>= 1.10.6'
32
31
  s.add_development_dependency 'debase', '~> 0.1', '>= 0.1.7' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
33
32
  s.add_development_dependency 'guard', '~> 2.13', '>= 2.13.0'
34
33
  s.add_development_dependency 'guard-rspec', '~> 4.6', '>= 4.6.4'
@@ -54,7 +53,7 @@ Gem::Specification.new do |s|
54
53
  s.add_dependency 'multi_json', '~> 1.11', '>= 1.11.2'
55
54
  s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.6'
56
55
  s.add_dependency 'pmap', '~> 1.0', '>= 1.0.2'
57
- s.add_dependency 'pry', '~> 0.9.12.6' # '~> 0.10', '>= 0.10.1'
56
+ s.add_dependency 'pry', '~> 0.10', '>= 0.10.3'
58
57
  s.add_dependency 'restforce', '~> 2.1', '>= 2.1.1'
59
58
  s.add_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
60
59
  s.add_dependency 'rubyzip', '~> 1.1', '>= 1.1.7'
@@ -10,15 +10,13 @@ require 'pp'
10
10
  # Define GoodData::CLI as GLI Wrapper
11
11
  module GoodData
12
12
  module CLI
13
- include GLI::App
14
-
15
13
  # Require shared part of GLI::App - flags, meta, etc
16
14
  require_relative 'shared.rb'
17
15
 
18
16
  # Require Hooks
19
17
  require_relative 'hooks.rb'
20
18
 
21
- GLI::App.commands_from(File.join(File.dirname(__FILE__), 'commands'))
19
+ commands_from(File.join(File.dirname(__FILE__), 'commands'))
22
20
 
23
21
  def self.main(args = ARGV)
24
22
  run(args)
@@ -7,13 +7,22 @@
7
7
  require_relative '../shared'
8
8
  require_relative '../../commands/auth'
9
9
 
10
- GoodData::CLI.module_eval do
11
- desc 'Work with your locally stored credentials'
12
- command :auth do |c|
13
- c.desc 'Store your credentials to ~/.gooddata so client does not have to ask you every single time'
14
- c.command :store do |store|
15
- store.action do |_global_options, _options, _args|
16
- GoodData::Command::Auth.store
10
+ module GoodData
11
+ module CLI
12
+ desc 'Work with your locally stored credentials'
13
+ command :auth do |c|
14
+ c.desc 'Store your credentials to ~/.gooddata so client does not have to ask you every single time'
15
+ c.command :store do |store|
16
+ store.action do |_global_options, _options, _args|
17
+ GoodData::Command::Auth.store
18
+ end
19
+ end
20
+
21
+ c.desc 'Clean the credentials'
22
+ c.command :clear do |store|
23
+ store.action do |_global_options, _options, _args|
24
+ GoodData::Command::Auth.unstore
25
+ end
17
26
  end
18
27
  end
19
28
  end
@@ -10,189 +10,27 @@ require 'pp'
10
10
  require_relative '../shared'
11
11
  require_relative '../../commands/project'
12
12
 
13
- GoodData::CLI.module_eval do
14
- desc 'Manage your project'
15
- arg_name 'project_command'
16
- command :project do |c|
17
- c.desc 'If you are in a gooddata project blueprint or if you provide a project id it will start an interactive session inside that project'
18
- c.command :jack_in do |jack|
19
- jack.action do |global_options, options, _args|
20
- opts = options.merge(global_options)
21
- GoodData::Command::Project.jack_in(opts)
22
- end
23
- end
24
-
25
- # TODO: Move away the ask methods. Provide params
26
- c.desc 'Create a gooddata project'
27
- c.command :create do |create|
28
- create.default_value nil
29
- create.arg_name :driver
30
- create.flag [:driver]
31
-
32
- create.default_value nil
33
- create.arg_name :template
34
- create.flag [:template]
35
-
36
- create.default_value nil
37
- create.arg_name :summary
38
- create.flag [:summary]
39
-
40
- create.action do |global_options, options, args|
41
- opts = options.merge(global_options)
42
-
43
- title = args[0] || ask('Project name')
44
- summary = opts[:summary] || args[1] || ask('Project summary') { |q| q.default = '' }
45
- template = opts[:template] || args[2] || ask('Project template')
46
- token = opts['token'] || ask('Token')
47
- driver = opts[:driver] || ask('Driver') { |q| q.default = 'Pg' }
48
-
49
- opts = options.merge(global_options)
50
- client = GoodData.connect(opts)
51
- begin
52
- project = GoodData::Command::Project.create(
53
- :title => title,
54
- :summary => summary,
55
- :template => template,
56
- :token => token,
57
- :driver => driver,
58
- client: client)
59
- rescue => e
60
- puts "Error creating project, reason: #{e.inspect}"
61
- raise e
13
+ module GoodData
14
+ module CLI
15
+ desc 'Manage your project'
16
+ arg_name 'project_command'
17
+
18
+ command :project do |c|
19
+ c.desc 'If you are in a gooddata project blueprint or if you provide a project id it will start an interactive session inside that project'
20
+ c.command :jack_in do |jack|
21
+ jack.action do |global_options, options, _args|
22
+ warn '[DEPRECATION] `gooddata project jack_in` is deprecated. Please use `gooddata jack_in` instead.'
23
+ opts = options.merge(global_options)
24
+ GoodData::Command::Project.jack_in(opts)
62
25
  end
63
-
64
- puts "Project '#{project.title}' with id #{project.pid} created successfully!"
65
- end
66
- end
67
-
68
- c.desc 'Delete a project. Be careful this is impossible to revert'
69
- c.command :delete do |delete|
70
- delete.action do |global_options, options, _args|
71
- id = global_options[:project_id]
72
- opts = options.merge(global_options)
73
- client = GoodData.connect(opts)
74
- GoodData::Command::Project.delete(id, opts.merge(client: client))
75
- end
76
- end
77
-
78
- c.desc 'Clones a project. Useful for testing'
79
- c.command :clone do |clone|
80
- clone.desc 'Name of the new project'
81
-
82
- clone.default_value nil
83
- clone.arg_name 'cloned_project_name'
84
- clone.flag [:t, :title]
85
-
86
- clone.default_value false
87
- clone.switch [:u, :users]
88
-
89
- clone.default_value true
90
- clone.switch [:d, :data]
91
-
92
- clone.action do |global_options, options, _args|
93
- opts = options.merge(global_options)
94
- id = global_options[:project_id]
95
- token = opts[:token]
96
- opts[:auth_token] = token
97
- fail 'You have to provide a token for creating a project. Please use parameter --token' if token.nil? || token.empty?
98
-
99
- client = GoodData.connect(opts)
100
- new_project = GoodData::Command::Project.clone(id, opts.merge(client: client))
101
- puts "Project with title \"#{new_project.title}\" was cloned with id #{new_project.pid}"
102
- end
103
- end
104
-
105
- c.desc 'Invites user to project'
106
- c.command :invite do |store|
107
- store.action do |global_options, options, args|
108
- project_id = global_options[:project_id]
109
- fail 'Project ID has to be provided' if project_id.nil? || project_id.empty?
110
-
111
- email = args.first
112
- fail 'Email of user to be invited has to be provided' if email.nil? || email.empty?
113
-
114
- role = args[1]
115
- fail 'Role name has to be provided' if role.nil? || role.empty?
116
-
117
- msg = args[2]
118
- msg = GoodData::Project::DEFAULT_INVITE_MESSAGE if msg.nil? || msg.empty?
119
-
120
- opts = options.merge(global_options)
121
- client = GoodData.connect(opts)
122
-
123
- GoodData::Command::Project.invite(project_id, email, role, msg, opts.merge(client: client))
124
- end
125
- end
126
-
127
- c.desc 'List users'
128
- c.command :users do |list|
129
- list.action do |global_options, options, _args|
130
- opts = options.merge(global_options)
131
- client = GoodData.connect(opts)
132
-
133
- pid = global_options[:project_id]
134
- fail 'Project ID has to be provided' if pid.nil? || pid.empty?
135
-
136
- user_list = GoodData::Command::Project.users(pid, opts.merge(client: client))
137
- puts user_list.map { |u| [u.last_name, u.first_name, u.login, u.uri].join(',') }
138
- end
139
- end
140
-
141
- c.desc 'Shows basic info about a project'
142
- c.command :show do |show|
143
- show.action do |global_options, options, _args|
144
- id = global_options[:project_id]
145
- opts = options.merge(global_options)
146
- client = GoodData.connect(opts)
147
- p = GoodData::Command::Project.show(id, client: client)
148
- pp p.data
149
26
  end
150
27
  end
151
28
 
152
- c.desc 'If you are in a gooddata project blueprint it will apply the changes. If you do not provide a project id it will build it from scratch and create a project for you.'
153
- c.command :build do |show|
154
- show.action do |global_options, options, _args|
155
- opts = options.merge(global_options)
156
- client = GoodData.connect(opts)
157
- spec = GoodData::Command::Project.get_spec_and_project_id('.')[0]
158
- new_project = GoodData::Command::Project.build(opts.merge(spec: spec, client: client))
159
- puts "Project was created. New project PID is #{new_project.pid}, URI is #{new_project.uri}."
160
- end
161
- end
162
-
163
- c.desc 'If you are in a gooddata project blueprint it will apply the changes. If you do not provide a project id it will build it from scratch and create a project for you.'
164
- c.command :update do |show|
165
- show.action do |global_options, options, _args|
166
- opts = options.merge(global_options)
167
- GoodData.connect(opts)
168
- spec, project_id = GoodData::Command::Project.get_spec_and_project_id('.')
169
- project_id = global_options[:project_id] || project_id
170
- fail 'You have to provide "project_id". You can either provide it through -p flag or even better way is to fill it in in your Goodfile under key "project_id". If you just started a project you have to create it first. One way might be through "gooddata project build"' if project_id.nil? || project_id.empty?
171
- project = GoodData::Command::Project.update(opts.merge(:spec => spec, :project_id => project_id))
172
- puts "Migration was done. Project PID is #{project.pid}, URI is #{project.uri}."
173
- end
174
- end
175
-
176
- c.desc 'Shows roles in the project'
177
- c.command :roles do |roles|
178
- roles.action do |global_options, options, _args|
179
- project_id = global_options[:project_id]
180
- fail 'Project ID has to be provided' if project_id.nil? || project_id.empty?
181
-
182
- opts = options.merge(global_options)
183
- client = GoodData.connect(opts)
184
-
185
- roles = GoodData::Command::Project.roles(project_id, client: client)
186
- puts roles.map { |r| [r.uri, r.title].join(',') }
187
- end
188
- end
189
-
190
- c.desc 'You can run project validation which will check RI and other problems.'
191
- c.command :validate do |show|
192
- show.action do |global_options, options, _args|
29
+ desc 'If you are in a gooddata project blueprint or if you provide a project id it will start an interactive session inside that project'
30
+ command :jack_in do |jack|
31
+ jack.action do |global_options, options, _args|
193
32
  opts = options.merge(global_options)
194
- client = GoodData.connect(opts)
195
- pp GoodData::Command::Project.validate(global_options[:project_id], opts.merge(client: client))
33
+ GoodData::Command::Project.jack_in(opts)
196
34
  end
197
35
  end
198
36
  end
@@ -12,48 +12,50 @@ require_relative '../extensions/extensions'
12
12
  require_relative '../exceptions/exceptions'
13
13
  require_relative '../helpers/auth_helpers'
14
14
 
15
- include GLI::App
16
-
17
- GoodData::CLI.module_eval do
18
- program_desc 'GoodData Ruby gem - a wrapper over GoodData API and several useful abstractions to make your everyday usage of GoodData easier.'
19
-
20
- version GoodData::VERSION
21
-
22
- desc 'GoodData user name'
23
- default_value nil
24
- arg_name 'gooddata-login'
25
- flag [:U, :username, :login]
26
-
27
- desc 'GoodData password'
28
- default_value nil
29
- arg_name 'gooddata-password'
30
- flag [:P, :password]
31
-
32
- desc 'Project pid'
33
- default_value nil
34
- arg_name 'project-id'
35
- flag [:p, :project_id]
36
-
37
- desc 'Server'
38
- default_value GoodData::Helpers::AuthHelper.read_server
39
- arg_name 'server'
40
- flag [:s, :server]
41
-
42
- desc 'WEBDAV Server. Used for uploads of files'
43
- default_value nil
44
- arg_name 'web dav server'
45
- flag [:w, :webdav_server]
46
-
47
- desc 'Token for project creation'
48
- default_value nil
49
- arg_name 'token'
50
- flag [:t, :token]
51
-
52
- desc 'Verbose mode'
53
- arg_name 'verbose'
54
- switch [:v, :verbose]
55
-
56
- desc 'Http logger on stdout'
57
- arg_name 'logger'
58
- switch [:l, :logger]
15
+ module GoodData
16
+ module CLI
17
+ extend GLI::App
18
+
19
+ program_desc 'GoodData Ruby gem - a wrapper over GoodData API and several useful abstractions to make your everyday usage of GoodData easier.'
20
+
21
+ version GoodData::VERSION
22
+
23
+ desc 'GoodData user name'
24
+ default_value nil
25
+ arg_name 'gooddata-login'
26
+ flag [:U, :username, :login]
27
+
28
+ desc 'GoodData password'
29
+ default_value nil
30
+ arg_name 'gooddata-password'
31
+ flag [:P, :password]
32
+
33
+ desc 'Project pid'
34
+ default_value nil
35
+ arg_name 'project-id'
36
+ flag [:p, :project_id]
37
+
38
+ desc 'Server'
39
+ default_value GoodData::Helpers::AuthHelper.read_server
40
+ arg_name 'server'
41
+ flag [:s, :server]
42
+
43
+ desc 'WEBDAV Server. Used for uploads of files'
44
+ default_value nil
45
+ arg_name 'web dav server'
46
+ flag [:w, :webdav_server]
47
+
48
+ desc 'Token for project creation'
49
+ default_value nil
50
+ arg_name 'token'
51
+ flag [:t, :token]
52
+
53
+ desc 'Verbose mode'
54
+ arg_name 'verbose'
55
+ switch [:v, :verbose]
56
+
57
+ desc 'Http logger on stdout'
58
+ arg_name 'logger'
59
+ switch [:l, :logger]
60
+ end
59
61
  end
@@ -64,6 +64,10 @@ module GoodData
64
64
 
65
65
  # Ask for credentials and store them
66
66
  def store(credentials_file_path = Helpers::AuthHelper.credentials_file)
67
+ puts 'This will store credntials to GoodData in an enencrypted form to your harddrive to file ~/.gooddata.'
68
+ overwrite = GoodData::CLI.terminal.ask('Do you want to continue? (y/n)')
69
+ return if overwrite != 'y'
70
+
67
71
  credentials = ask_for_credentials
68
72
 
69
73
  ovewrite = if File.exist?(credentials_file_path)
@@ -79,15 +79,7 @@ module GoodData
79
79
 
80
80
  # Update project
81
81
  def update(opts = { client: GoodData.connection })
82
- client = opts[:client]
83
- fail ArgumentError, 'No :client specified' if client.nil?
84
-
85
- p = opts[:project]
86
- fail ArgumentError, 'No :project specified' if p.nil?
87
-
88
- project = GoodData::Project[p, opts]
89
- fail ArgumentError, 'Wrong :project specified' if project.nil?
90
-
82
+ client, project = GoodData.get_client_and_project(opts)
91
83
  GoodData::Model::ProjectCreator.migrate(:spec => opts[:spec], :client => client, :project => project)
92
84
  end
93
85
 
@@ -113,25 +105,16 @@ module GoodData
113
105
 
114
106
  spin_session = proc do |goodfile, _blueprint|
115
107
  project_id = options[:project_id] || goodfile[:project_id]
116
- message = 'You have to provide "project_id". You can either provide it through -p flag'\
117
- 'or even better way is to fill it in in your Goodfile under key "project_id".'\
118
- 'If you just started a project you have to create it first. One way might be'\
119
- 'through "gooddata project build"'
120
- fail message if project_id.nil? || project_id.empty?
121
108
 
122
109
  begin
123
110
  require 'gooddata'
124
111
  client = GoodData.connect(options)
125
-
126
- GoodData.with_project(project_id, :client => client) do |project|
127
- fail ArgumentError, 'Wrong project specified' if project.nil?
128
-
129
- puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
130
- binding.pry(:quiet => true, # rubocop:disable Lint/Debugger
131
- :prompt => [proc do |_target_self, _nest_level, _pry|
132
- 'project_live_session: '
133
- end])
134
- end
112
+ project = client.projects(project_id) if project_id
113
+ puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
114
+ binding.pry(:quiet => true, # rubocop:disable Lint/Debugger
115
+ :prompt => [proc do |_target_self, _nest_level, _pry|
116
+ 'project_live_session: '
117
+ end])
135
118
  rescue GoodData::ProjectNotFound
136
119
  puts "Project with id \"#{project_id}\" could not be found. Make sure that the id you provided is correct."
137
120
  end