gooddata 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,26 +1,30 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'uri'
|
2
4
|
require 'net/http'
|
3
5
|
require 'pathname'
|
4
6
|
|
5
7
|
require_relative 'base_middleware'
|
6
8
|
|
7
|
-
module GoodData
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
module GoodData
|
10
|
+
module Bricks
|
11
|
+
class FsUploadMiddleware < Bricks::Middleware
|
12
|
+
def initialize(options = {})
|
13
|
+
super
|
14
|
+
@destination = options[:destination]
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
def call(params)
|
18
|
+
returning(@app.call(params)) do |result|
|
19
|
+
destination = @destination
|
20
|
+
(params['gdc_files_to_upload'] || []).each do |f|
|
21
|
+
path = f[:path]
|
22
|
+
case destination.to_s
|
23
|
+
when 'staging'
|
24
|
+
url = GoodData.get_user_webdav_path(path)
|
25
|
+
GoodData.upload_to_user_webdav(path)
|
26
|
+
puts "Uploaded local file \"#{path}\" to url \"#{url + path}\""
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -4,28 +4,30 @@ require 'gooddata'
|
|
4
4
|
|
5
5
|
require_relative 'base_middleware'
|
6
6
|
|
7
|
-
module GoodData
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
module GoodData
|
8
|
+
module Bricks
|
9
|
+
class GoodDataMiddleware < Bricks::Middleware
|
10
|
+
def call(params)
|
11
|
+
logger = params['GDC_LOGGER']
|
12
|
+
token_name = 'GDC_SST'
|
13
|
+
protocol_name = 'GDC_PROTOCOL'
|
14
|
+
server_name = 'GDC_HOSTNAME'
|
15
|
+
project_id = params['GDC_PROJECT_ID']
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
fail 'SST (SuperSecureToken) not present in params' if params[token_name].nil?
|
18
|
+
server = if !params[protocol_name].empty? && !params[server_name].empty?
|
19
|
+
"#{params[protocol_name]}://#{params[server_name]}"
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
fail 'GoodData username is missing. Expected param :GDC_USERNAME' if params['GDC_USERNAME'].nil?
|
23
|
+
fail 'GoodData password is missing. Expected param :GDC_PASSWORD' if params['GDC_PASSWORD'].nil?
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
GoodData.connect(params['GDC_USERNAME'], params['GDC_PASSWORD'], :server => server)
|
26
|
+
GoodData.logger = logger
|
27
|
+
GoodData.with_project(project_id) do |p|
|
28
|
+
@app.call(params)
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
31
|
-
end
|
33
|
+
end
|
@@ -4,14 +4,16 @@ require 'logger'
|
|
4
4
|
|
5
5
|
require_relative 'base_middleware'
|
6
6
|
|
7
|
-
module GoodData
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
module GoodData
|
8
|
+
module Bricks
|
9
|
+
class LoggerMiddleware < Bricks::Middleware
|
10
|
+
def call(params)
|
11
|
+
logger = params['GDC_LOGGER'] = params[:GDC_LOGGER_FILE].nil? ? Logger.new(STDOUT) : Logger.new(params[:GDC_LOGGER_FILE])
|
12
|
+
logger.info('Pipeline starts')
|
13
|
+
returning(@app.call(params)) do |result|
|
14
|
+
logger.info('Pipeline ending')
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
|
-
end
|
19
|
+
end
|
@@ -4,42 +4,44 @@ require 'gooddata'
|
|
4
4
|
|
5
5
|
require_relative 'base_middleware'
|
6
6
|
|
7
|
-
module GoodData
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
module GoodData
|
8
|
+
module Bricks
|
9
|
+
class RestForceMiddleware < Bricks::Middleware
|
10
|
+
def call(params)
|
11
|
+
username = params[:salesforce_username]
|
12
|
+
password = params[:salesforce_password]
|
13
|
+
token = params[:salesforce_token]
|
14
|
+
client_id = params[:salesforce_client_id]
|
15
|
+
client_secret = params[:salesforce_client_secret]
|
16
|
+
oauth_token = params[:salesforce_oauth_token]
|
17
|
+
refresh_token = params[:salesforce_refresh_token]
|
18
|
+
host = params[:salesforce_host]
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
if username && password && token
|
21
|
+
credentials = {
|
22
|
+
:username => username,
|
23
|
+
:password => password,
|
24
|
+
:security_token => token
|
25
|
+
}
|
26
|
+
elsif oauth_token && refresh_token
|
27
|
+
{
|
28
|
+
:oauth_token => oauth_token,
|
29
|
+
:refresh_token => refresh_token
|
30
|
+
}
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
if credentials
|
34
|
+
client = credentials.merge!(
|
35
|
+
:client_id => client_id,
|
36
|
+
:client_secret => client_secret
|
37
|
+
)
|
38
|
+
credentials[:host] = host unless host.nil?
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
Restforce.log = true if params[:salesforce_client_logger]
|
41
|
+
Restforce.new(credentials)
|
42
|
+
end
|
43
|
+
@app.call(params.merge(:salesforce_client => client))
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
|
-
end
|
47
|
+
end
|
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
require_relative 'base_middleware'
|
4
4
|
|
5
|
-
module GoodData
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
module GoodData
|
6
|
+
module Bricks
|
7
|
+
class STDOUTLoggingMiddleware < Bricks::Middleware
|
8
|
+
def call(params)
|
9
|
+
logger = Logger.new(STDOUT)
|
10
|
+
params[:logger] = logger
|
11
|
+
logger.info('Pipeline starting with STDOUT logger')
|
12
|
+
returning(@app.call(params)) do
|
13
|
+
logger.info('Pipeline ending')
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
end
|
18
|
+
end
|
@@ -4,19 +4,21 @@
|
|
4
4
|
|
5
5
|
require_relative 'base_middleware'
|
6
6
|
|
7
|
-
module GoodData
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
module GoodData
|
8
|
+
module Bricks
|
9
|
+
class TwitterMiddleware < Bricks::Middleware
|
10
|
+
def call(params)
|
11
|
+
client = Twitter::REST::Client.new do |config|
|
12
|
+
config.consumer_key = params[:twitter_consumer_key]
|
13
|
+
config.consumer_secret = params[:twitter_consumer_secret]
|
14
|
+
config.access_token = params[:twitter_access_token]
|
15
|
+
config.access_token_secret = params[:twitter_access_token_secret]
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
returning(@app.call(params)) do |result|
|
19
|
+
client.update(result)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
22
|
-
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative 'base_downloader'
|
4
|
+
require_relative 'utils'
|
5
|
+
|
6
|
+
require_relative 'middleware/middleware'
|
7
|
+
|
8
|
+
module GoodData
|
9
|
+
module Bricks
|
10
|
+
class Pipeline
|
11
|
+
# Pipeline preparation code
|
12
|
+
def self.prepare(pipeline)
|
13
|
+
pipeline.reverse.reduce(nil) do |memo, app|
|
14
|
+
if memo.nil?
|
15
|
+
app.respond_to?(:new) ? (app.new) : app
|
16
|
+
else
|
17
|
+
if app.respond_to?(:new)
|
18
|
+
app.new(:app => memo)
|
19
|
+
else
|
20
|
+
app.app = memo
|
21
|
+
app
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
module GoodData
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
module GoodData
|
4
|
+
module Bricks
|
5
|
+
module Utils
|
6
|
+
def returning(value, &block)
|
7
|
+
fail 'Block was not provided' if block.nil?
|
8
|
+
return_val = value
|
9
|
+
block.call(value)
|
10
|
+
return_val
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
|
-
end
|
14
|
+
end
|
data/lib/gooddata/cli/cli.rb
CHANGED
@@ -16,15 +16,10 @@ module GoodData
|
|
16
16
|
|
17
17
|
GLI::App.commands_from(File.join(File.dirname(__FILE__), 'commands'))
|
18
18
|
|
19
|
-
def self.init
|
20
|
-
end
|
21
|
-
|
22
19
|
def self.main(args = ARGV)
|
23
20
|
run(args)
|
24
21
|
end
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
28
|
-
if __FILE__ == $
|
29
|
-
GoodData::CLI.main(ARGV)
|
30
|
-
end
|
25
|
+
GoodData::CLI.main(ARGV) if __FILE__ == $PROGRAM_NAME
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'pp'
|
2
4
|
|
3
|
-
require_relative
|
5
|
+
require_relative '../shared'
|
4
6
|
|
5
7
|
GoodData::CLI.module_eval do
|
6
8
|
desc 'Interactive session with gooddata sdk loaded'
|
@@ -9,9 +11,9 @@ GoodData::CLI.module_eval do
|
|
9
11
|
c.action do |global_options, options, args|
|
10
12
|
puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
|
11
13
|
binding.pry(:quiet => true,
|
12
|
-
:prompt => [proc
|
13
|
-
|
14
|
-
|
14
|
+
:prompt => [proc do |target_self, nest_level, pry|
|
15
|
+
'sdk_live_sesion: '
|
16
|
+
end])
|
15
17
|
end
|
16
18
|
end
|
17
|
-
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative '../shared'
|
4
|
+
require_relative '../../commands/domain'
|
5
|
+
|
6
|
+
GoodData::CLI.module_eval do
|
7
|
+
|
8
|
+
desc 'Manage domain'
|
9
|
+
command :domain do |c|
|
10
|
+
|
11
|
+
c.desc 'Add user to domain'
|
12
|
+
c.command :add_user do |add_user|
|
13
|
+
add_user.action do |global_options, options, args|
|
14
|
+
opts = options.merge(global_options)
|
15
|
+
GoodData.connect(opts)
|
16
|
+
|
17
|
+
domain = args[0]
|
18
|
+
fail 'Domain name has to be provided' if domain.nil? || domain.empty?
|
19
|
+
|
20
|
+
email = args[1]
|
21
|
+
fail 'Email has to be provided' if email.nil? || email.empty?
|
22
|
+
|
23
|
+
password = args[2]
|
24
|
+
fail 'Password has to be provided' if password.nil? || password.empty?
|
25
|
+
|
26
|
+
GoodData::Command::Domain.add_user(domain, email, password)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
c.desc 'List users in domain'
|
31
|
+
c.command :list_users do |list_users|
|
32
|
+
list_users.action do |global_options, options, args|
|
33
|
+
opts = options.merge(global_options)
|
34
|
+
GoodData.connect(opts)
|
35
|
+
|
36
|
+
domain = args[0]
|
37
|
+
fail 'Domain name has to be provided' if domain.nil? || domain.empty?
|
38
|
+
|
39
|
+
users = GoodData::Command::Domain.list_users(domain)
|
40
|
+
puts users.map { |u| [u['firstName'], u['lastName'], u['login']].join(',') }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -27,21 +27,29 @@ GoodData::CLI.module_eval do
|
|
27
27
|
c.default_value nil
|
28
28
|
c.flag :name
|
29
29
|
|
30
|
+
c.desc 'Specify executable of the process'
|
31
|
+
c.default_value nil
|
32
|
+
c.flag :executable
|
33
|
+
|
30
34
|
c.desc "Lists all user's processes deployed on the plaform"
|
31
35
|
c.command :list do |list|
|
32
36
|
list.action do |global_options, options, args|
|
33
37
|
opts = options.merge(global_options)
|
34
38
|
GoodData.connect(opts)
|
35
|
-
|
39
|
+
opts = opts.merge(:project_id => args[0]) if args.length > 0
|
40
|
+
processes = GoodData::Command::Process.list(opts)
|
41
|
+
processes.each do |process|
|
42
|
+
puts "#{process.name},#{GoodData.connection.url + process.uri}"
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
39
47
|
c.desc 'Gives you some basic info about the process'
|
40
|
-
c.command :
|
48
|
+
c.command :show do |get|
|
41
49
|
get.action do |global_options, options, args|
|
42
50
|
opts = options.merge(global_options)
|
43
51
|
GoodData.connect(opts)
|
44
|
-
pp GoodData::Command::Process.get(options.merge(global_options))
|
52
|
+
pp GoodData::Command::Process.get(options.merge(global_options)).raw_data
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
@@ -49,9 +57,38 @@ GoodData::CLI.module_eval do
|
|
49
57
|
c.command :deploy do |deploy|
|
50
58
|
deploy.action do |global_options, options, args|
|
51
59
|
opts = options.merge(global_options)
|
60
|
+
dir = opts[:dir]
|
61
|
+
name = opts[:name]
|
62
|
+
fail 'You have to provide a directory or a file to deploy. Use --dir param' if dir.nil? || dir.empty?
|
63
|
+
fail 'You have to provide a name of the deployed process. Use --name param' if name.nil? || name.empty?
|
64
|
+
GoodData.connect(opts)
|
65
|
+
pp GoodData::Command::Process.deploy(dir, options.merge(global_options))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
c.desc 'Delete specific process'
|
70
|
+
c.command :delete do |deploy|
|
71
|
+
deploy.action do |global_options, options, args|
|
72
|
+
opts = options.merge(global_options)
|
73
|
+
process_id = opts[:process_id]
|
74
|
+
fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
|
75
|
+
GoodData.connect(opts)
|
76
|
+
pp GoodData::Command::Process.delete(process_id, opts)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
c.desc 'Execute specific deployed process'
|
81
|
+
# TODO: Add params. HOW?
|
82
|
+
c.command :execute do |deploy|
|
83
|
+
deploy.action do |global_options, options, args|
|
84
|
+
opts = options.merge(global_options)
|
85
|
+
process_id = opts[:process_id]
|
86
|
+
executable = opts[:executable]
|
87
|
+
fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
|
88
|
+
fail 'You have to provide an executable for the process. Use --executable param' if executable.nil? || executable.empty?
|
52
89
|
GoodData.connect(opts)
|
53
|
-
pp GoodData::Command::Process.
|
90
|
+
pp GoodData::Command::Process.execute_process(process_id, executable, opts)
|
54
91
|
end
|
55
92
|
end
|
56
93
|
end
|
57
|
-
end
|
94
|
+
end
|