gooddata 0.6.10 → 0.6.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/gooddata.gemspec +38 -40
- data/lib/gooddata/bricks/base_downloader.rb +1 -1
- data/lib/gooddata/bricks/middleware/base_middleware.rb +36 -0
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +8 -38
- data/lib/gooddata/bricks/middleware/decode_params_middleware.rb +14 -0
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +7 -6
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +7 -5
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +1 -1
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +20 -14
- data/lib/gooddata/bricks/middleware/undot_params_middleware.rb +33 -0
- data/lib/gooddata/cli/commands/api_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/auth_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/console_cmd.rb +2 -2
- data/lib/gooddata/cli/commands/process_cmd.rb +54 -7
- data/lib/gooddata/cli/commands/project_cmd.rb +9 -9
- data/lib/gooddata/cli/commands/projects_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +24 -7
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +2 -2
- data/lib/gooddata/cli/commands/user_cmd.rb +1 -1
- data/lib/gooddata/cli/hooks.rb +3 -3
- data/lib/gooddata/commands/datasets.rb +1 -1
- data/lib/gooddata/commands/project.rb +2 -2
- data/lib/gooddata/commands/role.rb +1 -1
- data/lib/gooddata/commands/runners.rb +2 -2
- data/lib/gooddata/connection.rb +2 -2
- data/lib/gooddata/core/nil_logger.rb +1 -1
- data/lib/gooddata/core/rest.rb +12 -8
- data/lib/gooddata/data/guesser.rb +1 -1
- data/lib/gooddata/exceptions/attr_element_not_found.rb +1 -1
- data/lib/gooddata/extensions/enumerable.rb +1 -1
- data/lib/gooddata/extensions/hash.rb +20 -0
- data/lib/gooddata/helpers/csv_helper.rb +1 -1
- data/lib/gooddata/helpers/global_helpers.rb +59 -1
- data/lib/gooddata/mixins/md_lock.rb +83 -0
- data/lib/gooddata/mixins/md_object_indexer.rb +1 -1
- data/lib/gooddata/mixins/md_object_query.rb +1 -1
- data/lib/gooddata/mixins/md_relations.rb +0 -9
- data/lib/gooddata/models/dashboard_builder.rb +1 -1
- data/lib/gooddata/models/domain.rb +2 -2
- data/lib/gooddata/models/empty_result.rb +5 -5
- data/lib/gooddata/models/execution.rb +74 -0
- data/lib/gooddata/models/execution_detail.rb +74 -0
- data/lib/gooddata/models/membership.rb +1 -1
- data/lib/gooddata/models/metadata/attribute.rb +4 -6
- data/lib/gooddata/models/metadata/dashboard.rb +2 -0
- data/lib/gooddata/models/metadata/fact.rb +2 -2
- data/lib/gooddata/models/metadata/metric.rb +4 -1
- data/lib/gooddata/models/metadata/report.rb +84 -34
- data/lib/gooddata/models/metadata/report_definition.rb +28 -17
- data/lib/gooddata/models/metadata.rb +1 -1
- data/lib/gooddata/models/model.rb +1 -1
- data/lib/gooddata/models/process.rb +70 -54
- data/lib/gooddata/models/profile.rb +47 -10
- data/lib/gooddata/models/project.rb +74 -30
- data/lib/gooddata/models/project_blueprint.rb +9 -10
- data/lib/gooddata/models/project_builder.rb +2 -2
- data/lib/gooddata/models/project_creator.rb +4 -4
- data/lib/gooddata/models/report_data_result.rb +1 -1
- data/lib/gooddata/models/schedule.rb +39 -32
- data/lib/gooddata/models/to_manifest.rb +5 -5
- data/lib/gooddata/models/to_wire.rb +3 -3
- data/lib/gooddata/rest/client.rb +64 -31
- data/lib/gooddata/rest/connection.rb +7 -7
- data/lib/gooddata/rest/connections/dummy_connection.rb +5 -5
- data/lib/gooddata/rest/connections/rest_client_connection.rb +106 -44
- data/lib/gooddata/rest/object.rb +1 -1
- data/lib/gooddata/version.rb +1 -1
- data/spec/bricks/bricks_spec.rb +67 -0
- data/spec/bricks/default-config.json +8 -0
- data/spec/data/gooddata_version_process/gooddata_version.rb +3 -0
- data/spec/data/gooddata_version_process/gooddata_version.zip +0 -0
- data/spec/data/ruby_params_process/ruby_params.rb +3 -0
- data/spec/helpers/process_helper.rb +12 -0
- data/spec/helpers/schedule_helper.rb +21 -0
- data/spec/integration/create_project_spec.rb +19 -0
- data/spec/integration/full_process_schedule_spec.rb +129 -8
- data/spec/integration/full_project_spec.rb +52 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/core/rest_spec.rb +76 -3
- data/spec/unit/helpers_spec.rb +43 -0
- data/spec/unit/models/metric_spec.rb +33 -0
- data/spec/unit/models/params_spec.rb +96 -0
- data/spec/unit/models/profile_spec.rb +16 -0
- data/spec/unit/models/schedule_spec.rb +12 -3
- metadata +350 -187
- data/lib/gooddata/helper/class_helper.rb +0 -1
- data/lib/gooddata/helper/helpers.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599d5759ccffd91b5e59aa9fde03eccee81c4138
|
4
|
+
data.tar.gz: 95ec2b6b381f940b686fe29c201c99ec1b1300c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b82f86ca736a3dbb5d6402c1085a3062c6d3213ff5f2f782f115496408d97d230779870be2923fcb5aa472615c539d65b08c52b022628b06467d2e6ad15816aa
|
7
|
+
data.tar.gz: 018ad7f05291a4f5ce238254d3f24ab3680d2dc0ab4a374990004db785bd1e9b15534cf553d88958ead9eb5bc5b82c8b94507cdc876955144d155283bc016bb7
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
AbcSize:
|
2
|
+
Enabled: false
|
3
|
+
|
1
4
|
ClassLength:
|
2
5
|
Enabled: false
|
3
6
|
|
@@ -7,6 +10,9 @@ CyclomaticComplexity:
|
|
7
10
|
Documentation:
|
8
11
|
Enabled: false
|
9
12
|
|
13
|
+
EachWithObject:
|
14
|
+
Enabled: false
|
15
|
+
|
10
16
|
Eval:
|
11
17
|
Enabled: false
|
12
18
|
|
@@ -21,3 +27,6 @@ LineLength:
|
|
21
27
|
|
22
28
|
MethodLength:
|
23
29
|
Enabled: false
|
30
|
+
|
31
|
+
PerceivedComplexity:
|
32
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# GoodData Ruby SDK Changelog
|
2
2
|
|
3
|
+
## 0.6.11
|
4
|
+
- Ability to download deployed process
|
5
|
+
- Added locking objects capabilities
|
6
|
+
- Added removing color mapping form a report definition
|
7
|
+
- Report defintions are deleted along with a report
|
8
|
+
|
3
9
|
## 0.6.10
|
4
10
|
- Fixed client default missing in ProjectMetadata
|
5
11
|
- Listing schedules on processes is working
|
data/README.md
CHANGED
@@ -10,6 +10,7 @@ The best documentation for the GoodData API can be found using these resources:
|
|
10
10
|
* http://developer.gooddata.com/api
|
11
11
|
* https://secure.gooddata.com/gdc
|
12
12
|
* http://rubydoc.info/gems/gooddata/frames
|
13
|
+
* http://developer.gooddata.com/ruby-cookbook
|
13
14
|
|
14
15
|
## Status
|
15
16
|
|
data/gooddata.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib/", __FILE__)
|
3
|
-
require
|
3
|
+
require 'gooddata/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{gooddata}
|
@@ -9,54 +9,52 @@ Gem::Specification.new do |s|
|
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
'Pavel Kolesnikov',
|
13
|
+
'Thomas Watson Steen',
|
14
|
+
'Tomas Svarovsky',
|
15
|
+
'Tomas Korcak'
|
16
16
|
]
|
17
17
|
|
18
18
|
s.summary = %q{A convenient Ruby wrapper around the GoodData RESTful API}
|
19
19
|
s.description = %q{Use the GoodData::Client class to integrate GoodData into your own application or use the CLI to work with GoodData directly from the command line.}
|
20
20
|
s.email = %q{pavel@gooddata.com}
|
21
|
-
s.executables = [
|
22
|
-
s.extra_rdoc_files =
|
23
|
-
|
24
|
-
"README.md"
|
25
|
-
]
|
21
|
+
s.executables = ['gooddata']
|
22
|
+
s.extra_rdoc_files = %w(LICENSE README.md)
|
23
|
+
|
26
24
|
s.files = `git ls-files`.split($/)
|
27
25
|
s.homepage = %q{http://github.com/gooddata/gooddata-ruby}
|
28
26
|
s.require_paths = ["lib"]
|
29
27
|
|
30
|
-
s.add_development_dependency "debase" if RUBY_VERSION >= '2.1'
|
31
|
-
s.add_development_dependency
|
32
|
-
s.add_development_dependency
|
33
|
-
s.add_development_dependency
|
34
|
-
s.add_development_dependency
|
28
|
+
# s.add_development_dependency "debase" if RUBY_VERSION >= '2.1'
|
29
|
+
s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.1'
|
30
|
+
s.add_development_dependency 'rake-notes', '~> 0.2', '>= 0.2.0'
|
31
|
+
s.add_development_dependency 'redcarpet', '~> 3.1', '>= 3.1.1' if RUBY_PLATFORM != 'java'
|
32
|
+
s.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
|
35
33
|
# s.add_development_dependency "ruby-debug-base"
|
36
|
-
s.add_development_dependency "ruby-debug-ide" if RUBY_VERSION >= '2.1'
|
37
|
-
s.add_development_dependency
|
38
|
-
s.add_development_dependency
|
39
|
-
s.add_development_dependency
|
40
|
-
s.add_development_dependency
|
41
|
-
s.add_development_dependency
|
42
|
-
s.add_development_dependency
|
34
|
+
# s.add_development_dependency "ruby-debug-ide" if RUBY_VERSION >= '2.1'
|
35
|
+
s.add_development_dependency 'rubocop', '~> 0.27', '>= 0.27.0'
|
36
|
+
s.add_development_dependency 'simplecov', '~> 0.9', '>= 0.9.1'
|
37
|
+
s.add_development_dependency 'yard', '~> 0.8.7.3'
|
38
|
+
s.add_development_dependency 'yard-rspec', '~> 0.1'
|
39
|
+
s.add_development_dependency 'ZenTest', '~> 4.10', '>= 4.11.0'
|
40
|
+
s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7.0'
|
43
41
|
|
44
|
-
s.add_dependency
|
45
|
-
s.add_dependency
|
46
|
-
s.add_dependency 'docile', '~> 1.1.
|
47
|
-
s.add_dependency
|
48
|
-
s.add_dependency
|
49
|
-
s.add_dependency
|
50
|
-
s.add_dependency
|
51
|
-
s.add_dependency
|
52
|
-
s.add_dependency
|
53
|
-
s.add_dependency
|
54
|
-
s.add_dependency 'pmap', '~> 1.0.1'
|
55
|
-
s.add_dependency
|
56
|
-
s.add_dependency
|
57
|
-
s.add_dependency
|
58
|
-
s.add_dependency
|
59
|
-
s.add_dependency
|
60
|
-
s.add_dependency
|
61
|
-
s.add_dependency
|
42
|
+
s.add_dependency 'activesupport', '~> 4.1', '>= 4.1.0'
|
43
|
+
s.add_dependency 'bundler', '~> 1.7', '>= 1.7.3'
|
44
|
+
s.add_dependency 'docile', '~> 1.1', '>= 1.1.5'
|
45
|
+
s.add_dependency 'erubis', '~> 2.7', '>= 2.7.0'
|
46
|
+
s.add_dependency 'gli', '~> 2.12', '>= 2.12.2'
|
47
|
+
s.add_dependency 'highline', '~> 1.6', '>= 1.6.21'
|
48
|
+
s.add_dependency 'i18n', '~> 0.6', '>= 0.6.9'
|
49
|
+
s.add_dependency 'json_pure', '~> 1.8', '>= 1.8.1'
|
50
|
+
s.add_dependency 'multi_json', '~> 1.10', '>= 1.10.0'
|
51
|
+
s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.4'
|
52
|
+
s.add_dependency 'pmap', '~> 1.0', '>= 1.0.1'
|
53
|
+
s.add_dependency 'pry', '~> 0.9.12.6' # '~> 0.10', '>= 0.10.1'
|
54
|
+
s.add_dependency 'restforce', '~> 1.5', '>= 1.5.0'
|
55
|
+
s.add_dependency 'rest-client', '~> 1.7', '>= 1.7.2'
|
56
|
+
s.add_dependency 'rubyzip', '~> 1.1', '>= 1.1.0'
|
57
|
+
s.add_dependency 'terminal-table', '~> 1.4', '>= 1.4.5'
|
58
|
+
s.add_dependency 'salesforce_bulk_query', '~> 0.0'
|
59
|
+
s.add_dependency 'aws-sdk', '~> 1.45'
|
62
60
|
end
|
@@ -23,7 +23,7 @@ module GoodData
|
|
23
23
|
def backup(meta)
|
24
24
|
@logger.info 'would send a backup list of files to backup' if @logger
|
25
25
|
|
26
|
-
files = meta['objects'].map { |
|
26
|
+
files = meta['objects'].map { |_k, o| o }.reduce([]) do |a, e|
|
27
27
|
a + e['filenames']
|
28
28
|
end
|
29
29
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
require 'hashie'
|
2
3
|
|
3
4
|
module GoodData
|
4
5
|
module Bricks
|
@@ -7,6 +8,41 @@ module GoodData
|
|
7
8
|
|
8
9
|
include Bricks::Utils
|
9
10
|
|
11
|
+
# Loads defaults to params from a json file in @config.
|
12
|
+
#
|
13
|
+
# The idea is to have a set of parameter defaults
|
14
|
+
# for a middleware. The defaults are loaded from a json file.
|
15
|
+
# If a brick user wants to override a default, they can
|
16
|
+
# do that in runtime params which come to the method in 'params'.
|
17
|
+
#
|
18
|
+
# A deep merge is done on the params. Arrays and other
|
19
|
+
# non-hash types are overwritten (params win).
|
20
|
+
#
|
21
|
+
# ### Examples
|
22
|
+
#
|
23
|
+
# A brick developer develops a SalesforceDownloaderMiddleware
|
24
|
+
# with default preset 'gse' having a configuration preset
|
25
|
+
# {"entities": ["Acount", "Event", "OpportunityLineItem", "Opportunity", "User"]}
|
26
|
+
#
|
27
|
+
# The brick user only wants to use Opportunity, so he passes
|
28
|
+
# runtime parameter {"entities": ["Opportunity"]} which overrides
|
29
|
+
# the default.
|
30
|
+
# See spec/bricks/bricks_spec.rb for usage.
|
31
|
+
def load_defaults(params)
|
32
|
+
# if default params given, fill what's not given in runtime params
|
33
|
+
if @config
|
34
|
+
# load it from file and merge it
|
35
|
+
defaults = { 'config' => MultiJson.load(File.read(@config)) }
|
36
|
+
default_params = defaults.extend(Hashie::Extensions::DeepMerge)
|
37
|
+
params = default_params.deep_merge(params)
|
38
|
+
end
|
39
|
+
params
|
40
|
+
end
|
41
|
+
|
42
|
+
def call(params)
|
43
|
+
load_defaults(params)
|
44
|
+
end
|
45
|
+
|
10
46
|
def initialize(options = {})
|
11
47
|
@app = options[:app]
|
12
48
|
end
|
@@ -9,53 +9,23 @@ module GoodData
|
|
9
9
|
class BulkSalesforceMiddleware < Bricks::Middleware
|
10
10
|
DEFAULT_VERSION = '29.0'
|
11
11
|
|
12
|
-
def
|
13
|
-
username = params['salesforce_username']
|
14
|
-
password = params['salesforce_password']
|
15
|
-
token = params['salesforce_token']
|
16
|
-
oauth_refresh_token = params['salesforce_oauth_refresh_token']
|
17
|
-
|
18
|
-
client_id = params['salesforce_client_id']
|
19
|
-
client_secret = params['salesforce_client_secret']
|
20
|
-
host = params['salesforce_host']
|
21
|
-
version = params['salesforce_api_version'] || DEFAULT_VERSION
|
22
|
-
|
23
|
-
app_info = {
|
24
|
-
:client_id => client_id,
|
25
|
-
:client_secret => client_secret
|
26
|
-
}
|
27
|
-
app_info[:host] = host unless host.nil?
|
12
|
+
def self.create_client(params)
|
28
13
|
salesforce = nil
|
29
|
-
|
30
|
-
|
31
|
-
if username && password && token
|
32
|
-
# use basic auth
|
33
|
-
client_params = {
|
34
|
-
:username => username,
|
35
|
-
:password => password,
|
36
|
-
:security_token => token
|
37
|
-
}.merge(app_info)
|
38
|
-
|
39
|
-
elsif oauth_refresh_token
|
40
|
-
# use oauth
|
41
|
-
client_params = {
|
42
|
-
:refresh_token => oauth_refresh_token
|
43
|
-
}.merge(app_info)
|
44
|
-
end
|
45
|
-
|
46
|
-
if client_params
|
47
|
-
|
48
|
-
client_params[:api_version] = version
|
14
|
+
if params['salesforce_client']
|
49
15
|
|
50
|
-
client = params['salesforce_client']
|
16
|
+
client = params['salesforce_client']
|
51
17
|
client.authenticate!
|
52
18
|
|
53
19
|
salesforce = SalesforceBulkQuery::Api.new(client, :logger => params['GDC_LOGGER'])
|
54
20
|
# SalesforceBulkQuery adds its own Restforce logging so turn it off
|
55
21
|
Restforce.log = false if params['GDC_LOGGER']
|
56
22
|
end
|
23
|
+
params.merge('salesforce_bulk_client' => salesforce)
|
24
|
+
end
|
57
25
|
|
58
|
-
|
26
|
+
def call(params)
|
27
|
+
params = self.class.create_client(params)
|
28
|
+
@app.call(params)
|
59
29
|
end
|
60
30
|
end
|
61
31
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'base_middleware'
|
2
|
+
|
3
|
+
module GoodData
|
4
|
+
module Bricks
|
5
|
+
# Converts params from encoded hash to decoded hash
|
6
|
+
class DecodeParamsMiddleware < Bricks::Middleware
|
7
|
+
def call(params)
|
8
|
+
params = params.to_hash
|
9
|
+
|
10
|
+
@app.call(GoodData::Helpers.decode_params(params))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -8,26 +8,27 @@ require_relative 'base_middleware'
|
|
8
8
|
|
9
9
|
module GoodData
|
10
10
|
module Bricks
|
11
|
-
class
|
11
|
+
class FsProjectUploadMiddleware < Bricks::Middleware
|
12
12
|
def initialize(options = {})
|
13
13
|
super
|
14
14
|
@destination = options[:destination]
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(params)
|
18
|
-
returning(@app.call(params)) do |
|
18
|
+
returning(@app.call(params)) do |_result|
|
19
19
|
destination = @destination
|
20
20
|
(params['gdc_files_to_upload'] || []).each do |f|
|
21
|
-
path = f[:path]
|
22
21
|
case destination.to_s
|
23
22
|
when 'staging'
|
24
|
-
|
25
|
-
|
26
|
-
puts "Uploaded local file \"#{path}\" to url \"#{url + path}\""
|
23
|
+
GoodData.upload_to_project_webdav(f[:path], directory: f[:webdav_directory])
|
24
|
+
puts "Uploaded local file \"#{f[:path]}\" to webdav."
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
30
|
+
|
31
|
+
# Alias to make it backwards compatible
|
32
|
+
FsUploadMiddleware = FsProjectUploadMiddleware
|
32
33
|
end
|
33
34
|
end
|
@@ -16,16 +16,18 @@ module GoodData
|
|
16
16
|
project_id = params['GDC_PROJECT_ID']
|
17
17
|
|
18
18
|
fail 'SST (SuperSecureToken) not present in params' if params[token_name].nil?
|
19
|
+
|
19
20
|
server = if !params[protocol_name].empty? && !params[server_name].empty?
|
20
21
|
"#{params[protocol_name]}://#{params[server_name]}"
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
client = if params['GDC_USERNAME'].nil? || params['GDC_PASSWORD'].nil?
|
25
|
+
GoodData.connect(sst_token: params['GDC_SST'], server: server)
|
26
|
+
else
|
27
|
+
GoodData.connect(params['GDC_USERNAME'], params['GDC_PASSWORD'], server: server)
|
28
|
+
end
|
27
29
|
GoodData.logger = logger
|
28
|
-
GoodData.with_project(project_id, :client => client) do |
|
30
|
+
GoodData.with_project(project_id, :client => client) do |_p|
|
29
31
|
@app.call(params)
|
30
32
|
end
|
31
33
|
end
|
@@ -10,7 +10,7 @@ module GoodData
|
|
10
10
|
def call(params)
|
11
11
|
logger = params['GDC_LOGGER'] = params[:GDC_LOGGER_FILE].nil? ? Logger.new(STDOUT) : Logger.new(params[:GDC_LOGGER_FILE])
|
12
12
|
logger.info('Pipeline starts')
|
13
|
-
returning(@app.call(params)) do |
|
13
|
+
returning(@app.call(params)) do |_result|
|
14
14
|
logger.info('Pipeline ending')
|
15
15
|
end
|
16
16
|
end
|
@@ -10,15 +10,16 @@ module GoodData
|
|
10
10
|
class RestForceMiddleware < Bricks::Middleware
|
11
11
|
DEFAULT_VERSION = '29.0'
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
def self.create_client(params)
|
14
|
+
downloader_config = params['config']['downloader']['salesforce']
|
15
|
+
username = downloader_config['username']
|
16
|
+
password = downloader_config['password']
|
17
|
+
token = downloader_config['token']
|
18
|
+
client_id = downloader_config['client_id']
|
19
|
+
client_secret = downloader_config['client_secret']
|
20
|
+
oauth_refresh_token = downloader_config['oauth_refresh_token']
|
21
|
+
host = downloader_config['host']
|
22
|
+
version = downloader_config['api_version'] || DEFAULT_VERSION
|
22
23
|
|
23
24
|
credentials = if username && password && token
|
24
25
|
{
|
@@ -34,17 +35,22 @@ module GoodData
|
|
34
35
|
|
35
36
|
client = if credentials
|
36
37
|
credentials.merge!(
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
:client_id => client_id,
|
39
|
+
:client_secret => client_secret
|
40
|
+
)
|
40
41
|
credentials[:host] = host unless host.nil?
|
41
42
|
credentials[:api_version] = version
|
42
43
|
|
43
|
-
Restforce.log = true if params['
|
44
|
+
Restforce.log = true if params['GDC_LOGGER']
|
44
45
|
|
45
46
|
Restforce.new(credentials)
|
46
47
|
end
|
47
|
-
|
48
|
+
params.merge('salesforce_client' => client)
|
49
|
+
end
|
50
|
+
|
51
|
+
def call(params)
|
52
|
+
params = self.class.create_client(params)
|
53
|
+
@app.call(params)
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative 'base_middleware'
|
4
|
+
|
5
|
+
module GoodData
|
6
|
+
module Bricks
|
7
|
+
# Converts params from double underscore notation to nested hash under 'config'
|
8
|
+
# Parameters starting GDC_ are considered system params and aren't converted.
|
9
|
+
#
|
10
|
+
# This is useful because the executor platform can currently
|
11
|
+
# do just key-value parameters. Also it makes it easier for
|
12
|
+
# a user, as there aren't as much curly braces.
|
13
|
+
#
|
14
|
+
#
|
15
|
+
# ### Examples
|
16
|
+
# If you pass params in form:
|
17
|
+
# {"my__namespace__param": "value"}
|
18
|
+
#
|
19
|
+
# you'll get:
|
20
|
+
# {"my": {"namespace": {"param": value}}}
|
21
|
+
class UndotParamsMiddleware < Bricks::Middleware
|
22
|
+
def call(params)
|
23
|
+
params = params.to_hash
|
24
|
+
unless params['config']
|
25
|
+
# split the params to those starting with GDC and those that don't, put other params under config
|
26
|
+
gdc_params, other_params = params.partition { |k, _| k =~ /GDC_.*/ }.map { |h| Hash[h] }
|
27
|
+
params = gdc_params.merge('config' => other_params.undot)
|
28
|
+
end
|
29
|
+
@app.call(params)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -12,7 +12,7 @@ GoodData::CLI.module_eval do
|
|
12
12
|
|
13
13
|
c.desc 'Info about the API version etc'
|
14
14
|
c.command :info do |info|
|
15
|
-
info.action do |global_options, options,
|
15
|
+
info.action do |global_options, options, _args|
|
16
16
|
opts = options.merge(global_options)
|
17
17
|
GoodData.connect(opts)
|
18
18
|
pp GoodData::Command::Api.info
|
@@ -10,7 +10,7 @@ GoodData::CLI.module_eval do
|
|
10
10
|
|
11
11
|
c.desc 'Store your credentials to ~/.gooddata so client does not have to ask you every single time'
|
12
12
|
c.command :store do |store|
|
13
|
-
store.action do |
|
13
|
+
store.action do |_global_options, _options, _args|
|
14
14
|
GoodData::Command::Auth.store
|
15
15
|
end
|
16
16
|
end
|
@@ -8,7 +8,7 @@ GoodData::CLI.module_eval do
|
|
8
8
|
desc 'Interactive session with gooddata sdk loaded'
|
9
9
|
command :console do |c|
|
10
10
|
|
11
|
-
c.action do |global_options,
|
11
|
+
c.action do |global_options, _options, _args|
|
12
12
|
username = global_options[:username]
|
13
13
|
fail ArgumentError, 'No username specified' if username.nil? || username.empty?
|
14
14
|
|
@@ -27,7 +27,7 @@ GoodData::CLI.module_eval do
|
|
27
27
|
|
28
28
|
puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
|
29
29
|
binding.pry(:quiet => true,
|
30
|
-
:prompt => [proc do |
|
30
|
+
:prompt => [proc do |_target_self, _nest_level, _pry|
|
31
31
|
'sdk_live_sesion: '
|
32
32
|
end])
|
33
33
|
end
|
@@ -5,6 +5,16 @@ require 'pp'
|
|
5
5
|
require_relative '../shared'
|
6
6
|
require_relative '../../commands/process'
|
7
7
|
|
8
|
+
def read_params_file(filename)
|
9
|
+
# read params from a file
|
10
|
+
# if filename nil, return empty hash
|
11
|
+
if filename
|
12
|
+
JSON.parse(IO.read(filename))
|
13
|
+
else
|
14
|
+
{}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
GoodData::CLI.module_eval do
|
9
19
|
|
10
20
|
desc 'Work with deployed processes'
|
@@ -31,6 +41,18 @@ GoodData::CLI.module_eval do
|
|
31
41
|
c.default_value nil
|
32
42
|
c.flag :executable
|
33
43
|
|
44
|
+
c.desc 'Specify parameters file to execute the process with'
|
45
|
+
c.default_value nil
|
46
|
+
c.flag :params
|
47
|
+
|
48
|
+
c.desc 'Specify hidden paremeters to execute the process with'
|
49
|
+
c.default_value nil
|
50
|
+
c.flag :hidden_params
|
51
|
+
|
52
|
+
c.desc 'Specify cron expression for the schedule'
|
53
|
+
c.default_value nil
|
54
|
+
c.flag :cron
|
55
|
+
|
34
56
|
c.desc "Lists all user's processes deployed on the plaform"
|
35
57
|
c.command :list do |list|
|
36
58
|
list.action do |global_options, options, args|
|
@@ -46,7 +68,7 @@ GoodData::CLI.module_eval do
|
|
46
68
|
|
47
69
|
c.desc 'Gives you some basic info about the process'
|
48
70
|
c.command :show do |get|
|
49
|
-
get.action do |global_options, options,
|
71
|
+
get.action do |global_options, options, _args|
|
50
72
|
opts = options.merge(global_options)
|
51
73
|
client = GoodData.connect(opts)
|
52
74
|
pp GoodData::Command::Process.get(opts.merge(client: client)).raw_data
|
@@ -55,7 +77,7 @@ GoodData::CLI.module_eval do
|
|
55
77
|
|
56
78
|
c.desc 'Deploys provided directory to the server'
|
57
79
|
c.command :deploy do |deploy|
|
58
|
-
deploy.action do |global_options, options,
|
80
|
+
deploy.action do |global_options, options, _args|
|
59
81
|
opts = options.merge(global_options)
|
60
82
|
dir = opts[:dir]
|
61
83
|
name = opts[:name]
|
@@ -69,7 +91,7 @@ GoodData::CLI.module_eval do
|
|
69
91
|
|
70
92
|
c.desc 'Delete specific process'
|
71
93
|
c.command :delete do |deploy|
|
72
|
-
deploy.action do |global_options, options,
|
94
|
+
deploy.action do |global_options, options, _args|
|
73
95
|
opts = options.merge(global_options)
|
74
96
|
process_id = opts[:process_id]
|
75
97
|
fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
|
@@ -80,16 +102,41 @@ GoodData::CLI.module_eval do
|
|
80
102
|
end
|
81
103
|
|
82
104
|
c.desc 'Execute specific deployed process'
|
83
|
-
# TODO: Add params. HOW?
|
84
105
|
c.command :execute do |deploy|
|
85
|
-
deploy.action do |global_options, options,
|
106
|
+
deploy.action do |global_options, options, _args|
|
86
107
|
opts = options.merge(global_options)
|
87
108
|
process_id = opts[:process_id]
|
88
109
|
executable = opts[:executable]
|
110
|
+
|
111
|
+
fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
|
112
|
+
fail 'You have to provide an executable for the process. Use --executable param' if executable.nil? || executable.empty?
|
113
|
+
client = GoodData.connect(options)
|
114
|
+
project = client.projects(options[:project_id])
|
115
|
+
process = project.processes(options[:process_id])
|
116
|
+
params = read_params_file(options[:params])
|
117
|
+
hidden_params = read_params_file(options[:hidden_params])
|
118
|
+
process.execute(options[:executable], params: params, hidden_params: hidden_params)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
c.desc 'Schedule specific deployed process'
|
123
|
+
c.command :schedule do |schedule|
|
124
|
+
schedule.action do |global_options, command_options, _|
|
125
|
+
options = command_options.merge(global_options)
|
126
|
+
process_id = options[:process_id]
|
127
|
+
executable = options[:executable]
|
128
|
+
cron = options[:cron]
|
129
|
+
|
89
130
|
fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
|
90
131
|
fail 'You have to provide an executable for the process. Use --executable param' if executable.nil? || executable.empty?
|
91
|
-
|
92
|
-
|
132
|
+
fail 'You have to provide a cron expression for the schedule. Use --cron param' if cron.nil? || cron.empty?
|
133
|
+
|
134
|
+
client = GoodData.connect(options)
|
135
|
+
project = client.projects(options[:project_id])
|
136
|
+
process = project.processes(options[:process_id])
|
137
|
+
params = read_params_file(options[:params])
|
138
|
+
hidden_params = read_params_file(options[:hidden_params])
|
139
|
+
process.create_schedule(cron, options[:executable], params: params, hidden_params: hidden_params)
|
93
140
|
end
|
94
141
|
end
|
95
142
|
end
|