gooddata 0.6.53 → 0.6.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.flayignore +6 -0
- data/.gitignore +1 -0
- data/.pronto.yml +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +18 -0
- data/CONTRIBUTING.md +14 -1
- data/DEPENDENCIES.md +324 -253
- data/Dockerfile.jruby +5 -7
- data/Dockerfile.ruby +8 -8
- data/Rakefile +24 -0
- data/ci.rake +47 -0
- data/docker-compose.yml +34 -0
- data/gooddata.gemspec +8 -2
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +0 -3
- data/lib/gooddata/helpers/data_helper.rb +10 -7
- data/lib/gooddata/helpers/global_helpers_params.rb +8 -3
- data/lib/gooddata/lcm/actions/apply_custom_maql.rb +2 -1
- data/lib/gooddata/lcm/actions/associate_clients.rb +10 -1
- data/lib/gooddata/lcm/actions/collect_client_projects.rb +78 -0
- data/lib/gooddata/lcm/actions/collect_clients.rb +20 -6
- data/lib/gooddata/lcm/actions/collect_data_product.rb +62 -0
- data/lib/gooddata/lcm/actions/collect_dynamic_schedule_params.rb +62 -0
- data/lib/gooddata/lcm/actions/{collect_attrs.rb → collect_ldm_objects.rb} +3 -3
- data/lib/gooddata/lcm/actions/collect_meta.rb +6 -3
- data/lib/gooddata/lcm/actions/collect_segment_clients.rb +2 -1
- data/lib/gooddata/lcm/actions/collect_segments.rb +6 -7
- data/lib/gooddata/lcm/actions/collect_tagged_objects.rb +7 -4
- data/lib/gooddata/lcm/actions/create_segment_masters.rb +7 -3
- data/lib/gooddata/lcm/actions/ensure_data_product.rb +53 -0
- data/lib/gooddata/lcm/actions/ensure_technical_users_domain.rb +6 -2
- data/lib/gooddata/lcm/actions/ensure_technical_users_project.rb +30 -18
- data/lib/gooddata/lcm/actions/execute_schedules.rb +128 -0
- data/lib/gooddata/lcm/actions/provision_clients.rb +32 -21
- data/lib/gooddata/lcm/actions/purge_clients.rb +25 -39
- data/lib/gooddata/lcm/actions/rename_existing_client_projects.rb +70 -0
- data/lib/gooddata/lcm/actions/segments_filter.rb +6 -0
- data/lib/gooddata/lcm/actions/synchronize_cas.rb +11 -0
- data/lib/gooddata/lcm/actions/synchronize_clients.rb +2 -1
- data/lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb +34 -15
- data/lib/gooddata/lcm/actions/synchronize_ldm.rb +10 -1
- data/lib/gooddata/lcm/actions/synchronize_new_segments.rb +2 -1
- data/lib/gooddata/lcm/actions/synchronize_processes.rb +4 -7
- data/lib/gooddata/lcm/actions/synchronize_tag_objects.rb +8 -5
- data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +224 -0
- data/lib/gooddata/lcm/actions/synchronize_user_groups.rb +53 -0
- data/lib/gooddata/lcm/actions/synchronize_users.rb +324 -0
- data/lib/gooddata/lcm/dsl/type_dsl.rb +1 -0
- data/lib/gooddata/lcm/helpers/check_helper.rb +4 -0
- data/lib/gooddata/lcm/helpers/tags_helper.rb +4 -3
- data/lib/gooddata/lcm/lcm2.rb +33 -1
- data/lib/gooddata/lcm/types/complex/segment.rb +3 -0
- data/lib/gooddata/lcm/types/complex/update_preference.rb +8 -2
- data/lib/gooddata/lcm/types/special/array.rb +1 -3
- data/lib/gooddata/lcm/types/special/enum.rb +1 -3
- data/lib/gooddata/mixins/md_id_to_uri.rb +0 -1
- data/lib/gooddata/mixins/md_json.rb +2 -2
- data/lib/gooddata/models/blueprint/project_blueprint.rb +15 -0
- data/lib/gooddata/models/blueprint/to_wire.rb +1 -0
- data/lib/gooddata/models/client.rb +21 -9
- data/lib/gooddata/models/data_product.rb +149 -0
- data/lib/gooddata/models/domain.rb +26 -72
- data/lib/gooddata/models/from_wire.rb +2 -0
- data/lib/gooddata/models/metadata/report.rb +9 -3
- data/lib/gooddata/models/metadata/report_definition.rb +2 -2
- data/lib/gooddata/models/model.rb +1 -1
- data/lib/gooddata/models/process.rb +4 -0
- data/lib/gooddata/models/project.rb +58 -35
- data/lib/gooddata/models/project_creator.rb +13 -0
- data/lib/gooddata/models/segment.rb +63 -16
- data/lib/gooddata/models/style_setting.rb +2 -15
- data/lib/gooddata/models/user_group.rb +2 -0
- data/lib/gooddata/rest/connection.rb +32 -9
- data/lib/gooddata/rest/object_factory.rb +0 -25
- data/lib/gooddata/version.rb +1 -1
- data/spec/data/blueprints/invalid_blueprint.json +2 -2
- data/spec/data/blueprints/test_project_model_spec.json +1 -1
- data/spec/data/dynamic_schedule_params_table.csv +7 -0
- data/spec/data/workspace_table.csv +3 -3
- data/spec/environment/staging.rb +3 -3
- data/spec/integration/ads_output_stage_spec.rb +0 -10
- data/spec/integration/clients_spec.rb +1 -1
- data/spec/{unit → integration}/commands/command_projects_spec.rb +0 -0
- data/spec/{unit → integration}/core/connection_spec.rb +0 -0
- data/spec/{unit → integration}/core/logging_spec.rb +0 -0
- data/spec/{unit → integration}/core/project_spec.rb +0 -0
- data/spec/integration/date_dim_switch_spec.rb +13 -0
- data/spec/integration/full_process_schedule_spec.rb +2 -2
- data/spec/integration/helpers_spec.rb +16 -0
- data/spec/integration/lcm_spec.rb +12 -2
- data/spec/integration/mixins/id_to_uri_spec.rb +44 -0
- data/spec/integration/models/data_product_spec.rb +71 -0
- data/spec/{unit → integration}/models/domain_spec.rb +2 -2
- data/spec/{unit → integration}/models/invitation_spec.rb +0 -0
- data/spec/{unit → integration}/models/membership_spec.rb +0 -0
- data/spec/{unit → integration}/models/params_spec.rb +0 -0
- data/spec/{unit → integration}/models/profile_spec.rb +0 -0
- data/spec/{unit → integration}/models/project_role_spec.rb +0 -0
- data/spec/integration/models/project_spec.rb +225 -0
- data/spec/{unit → integration}/models/schedule_spec.rb +0 -0
- data/spec/{unit → integration}/models/unit_project_spec.rb +0 -0
- data/spec/integration/project_spec.rb +40 -5
- data/spec/integration/segments_spec.rb +27 -26
- data/spec/integration/user_filters_spec.rb +1 -1
- data/spec/spec_helper.rb +15 -19
- data/spec/unit/actions/associate_clients_spec.rb +47 -0
- data/spec/unit/actions/collect_client_projects_spec.rb +47 -0
- data/spec/unit/actions/collect_clients_spec.rb +27 -0
- data/spec/unit/actions/collect_data_product_spec.rb +64 -0
- data/spec/unit/actions/collect_dynamic_schedule_params_spec.rb +56 -0
- data/spec/unit/actions/collect_meta_spec.rb +4 -4
- data/spec/unit/actions/collect_segment_clients_spec.rb +44 -3
- data/spec/unit/actions/collect_tagged_objects_spec.rb +20 -4
- data/spec/unit/actions/create_segment_masters_spec.rb +64 -0
- data/spec/unit/actions/ensure_data_product_spec.rb +38 -0
- data/spec/unit/actions/ensure_technical_users_domain_spec.rb +51 -0
- data/spec/unit/actions/ensure_technical_users_project_spec.rb +72 -0
- data/spec/unit/actions/execute_schedules_spec.rb +94 -0
- data/spec/unit/actions/provision_clients_spec.rb +45 -0
- data/spec/unit/actions/purge_clients_spec.rb +47 -0
- data/spec/unit/actions/rename_existing_client_projects_spec.rb +54 -0
- data/spec/unit/actions/segments_filter_spec.rb +46 -0
- data/spec/unit/actions/shared_examples_for_user_actions.rb +10 -0
- data/spec/unit/actions/synchronize_cas_spec.rb +58 -0
- data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +174 -13
- data/spec/unit/actions/synchronize_ldm_spec.rb +57 -0
- data/spec/unit/actions/synchronize_user_filters_spec.rb +142 -0
- data/spec/unit/actions/synchronize_user_groups_spec.rb +49 -0
- data/spec/unit/actions/synchronize_users_spec.rb +76 -0
- data/spec/unit/helpers/data_helper_spec.rb +17 -0
- data/spec/unit/helpers/global_helpers_spec.rb +16 -0
- data/spec/unit/helpers_spec.rb +0 -6
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +21 -4
- data/spec/unit/models/project_creator_spec.rb +16 -0
- data/spec/unit/models/project_spec.rb +66 -197
- metadata +202 -100
- data/PULL_REQUEST_TEMPLATE.md +0 -5
- data/lib/gooddata/bricks/middleware/params_inspect_middleware.rb +0 -21
data/Dockerfile.jruby
CHANGED
@@ -5,15 +5,13 @@ MAINTAINER Tomas Korcak <korczis@gmail.com>
|
|
5
5
|
RUN apk add --no-cache curl make gcc git g++ python linux-headers binutils-gold gnupg libstdc++
|
6
6
|
|
7
7
|
# Switch to directory with sources
|
8
|
-
WORKDIR /
|
9
|
-
|
10
|
-
# Copy required stuff
|
11
|
-
ADD . .
|
8
|
+
WORKDIR /var/lib/jenkins-slave
|
12
9
|
|
13
10
|
RUN gem update --system \
|
14
|
-
&& gem install bundler
|
15
|
-
&& bundle install
|
11
|
+
&& gem install bundler
|
16
12
|
|
17
|
-
|
13
|
+
ENV BUNDLE_PATH=/bundle
|
14
|
+
|
15
|
+
ADD . .
|
18
16
|
|
19
17
|
CMD ["./bin/gooddata"]
|
data/Dockerfile.ruby
CHANGED
@@ -2,18 +2,18 @@ FROM ruby:2.3-alpine
|
|
2
2
|
|
3
3
|
MAINTAINER Tomas Korcak <korczis@gmail.com>
|
4
4
|
|
5
|
-
RUN apk add --no-cache curl make gcc git g++ python linux-headers binutils-gold gnupg libstdc++ openssl
|
5
|
+
RUN apk add --no-cache curl make gcc git g++ python linux-headers binutils-gold gnupg libstdc++ openssl cmake
|
6
6
|
|
7
|
-
|
8
|
-
WORKDIR /src
|
7
|
+
RUN ln -s /usr/bin/make /usr/bin/gmake
|
9
8
|
|
10
|
-
#
|
11
|
-
|
9
|
+
# Switch to directory with sources
|
10
|
+
WORKDIR /var/lib/jenkins-slave
|
12
11
|
|
13
12
|
RUN gem update --system \
|
14
|
-
&& gem install bundler
|
15
|
-
&& bundle install
|
13
|
+
&& gem install bundler
|
16
14
|
|
17
|
-
|
15
|
+
ENV BUNDLE_PATH=/bundle
|
16
|
+
|
17
|
+
ADD . .
|
18
18
|
|
19
19
|
CMD ["./bin/gooddata"]
|
data/Rakefile
CHANGED
@@ -17,6 +17,7 @@ require 'rubocop/rake_task'
|
|
17
17
|
desc 'Run RuboCop'
|
18
18
|
RuboCop::RakeTask.new(:cop) do |task|
|
19
19
|
task.patterns = ['{lib,spec}/**/*.rb']
|
20
|
+
task.options = ['--force-exclusion']
|
20
21
|
end
|
21
22
|
|
22
23
|
desc 'Run continuous integration test'
|
@@ -141,6 +142,29 @@ namespace :license do
|
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
145
|
+
namespace :changelog do
|
146
|
+
desc 'Updates the changelog with commit messages'
|
147
|
+
task :update do
|
148
|
+
require_relative 'lib/gooddata/version'
|
149
|
+
new_version = GoodData::VERSION
|
150
|
+
changelog = File.read('CHANGELOG.md')
|
151
|
+
fail 'the version is already mentioned in the changelog' if changelog =~ /## #{new_version}/
|
152
|
+
puts "Creating changelog for version #{new_version}"
|
153
|
+
current_commit = `git rev-parse HEAD`.chomp
|
154
|
+
last_release = %x(git describe --tags `git rev-list --tags --max-count=1`)
|
155
|
+
last_release_commit = `git rev-parse #{last_release}`.chomp
|
156
|
+
changes = `git log --format=%B --no-merges #{last_release_commit}..#{current_commit}`.split("\n").reject(&:empty?)
|
157
|
+
changelog_header = '# GoodData Ruby SDK Changelog'
|
158
|
+
changelog.slice! changelog_header
|
159
|
+
File.open('CHANGELOG.md', 'w+') do |file|
|
160
|
+
file.puts changelog_header + "\n"
|
161
|
+
file.puts "## #{new_version}"
|
162
|
+
changes.each { |change| file.puts ' - ' + change }
|
163
|
+
file.puts changelog
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
144
168
|
RSpec::Core::RakeTask.new(:test)
|
145
169
|
|
146
170
|
namespace :test do
|
data/ci.rake
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
namespace :docker do
|
2
|
+
desc 'Build Docker image'
|
3
|
+
task :build do
|
4
|
+
system('docker-compose build')
|
5
|
+
end
|
6
|
+
|
7
|
+
desc 'Bundles gems using cache'
|
8
|
+
namespace :bundle do
|
9
|
+
task :ruby do
|
10
|
+
system('docker-compose run gooddata-ruby bundle')
|
11
|
+
end
|
12
|
+
|
13
|
+
task :jruby do
|
14
|
+
system('docker-compose run gooddata-jruby bundle')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :test do
|
20
|
+
task :test do
|
21
|
+
system('docker-compose run gooddata-ruby bundle exec echo ahoj')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :pronto do
|
26
|
+
desc 'Performs automated code review on the PR'
|
27
|
+
task :ci do
|
28
|
+
system('docker-compose run gooddata-ruby bundle exec pronto run -f github_pr -c origin/develop --exit-code') ||
|
29
|
+
fail('Pronto execution failed!')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
namespace :test do
|
34
|
+
namespace :unit do
|
35
|
+
task :docker do
|
36
|
+
system('docker-compose run -u 1002:1002 -e HOME=/var/lib/jenkins-slave gooddata-ruby bundle exec rake test:unit') ||
|
37
|
+
fail('Test execution failed!')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
namespace :integration do
|
42
|
+
task :docker do
|
43
|
+
system('docker-compose run -u 1002:1002 -e HOME=/var/lib/jenkins-slave gooddata-jruby bundle exec rake test:integration') ||
|
44
|
+
fail('Test execution failed!')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
version: '2'
|
2
|
+
services:
|
3
|
+
gooddata-ruby:
|
4
|
+
image: gooddata/ruby
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
dockerfile: Dockerfile.ruby
|
8
|
+
environment:
|
9
|
+
- PRONTO_GITHUB_ACCESS_TOKEN
|
10
|
+
- PRONTO_PULL_REQUEST_ID
|
11
|
+
- GD_ENV
|
12
|
+
volumes:
|
13
|
+
- /etc/passwd:/etc/passwd:ro
|
14
|
+
- .:/var/lib/jenkins-slave
|
15
|
+
volumes_from:
|
16
|
+
- bundle
|
17
|
+
gooddata-jruby:
|
18
|
+
image: gooddata/jruby
|
19
|
+
build:
|
20
|
+
context: .
|
21
|
+
dockerfile: Dockerfile.jruby
|
22
|
+
environment:
|
23
|
+
- GD_PROJECT_TOKEN
|
24
|
+
- GD_SPEC_PASSWORD
|
25
|
+
- GD_ENV
|
26
|
+
volumes:
|
27
|
+
- /etc/passwd:/etc/passwd:ro
|
28
|
+
- .:/var/lib/jenkins-slave
|
29
|
+
volumes_from:
|
30
|
+
- bundle
|
31
|
+
bundle:
|
32
|
+
image: busybox
|
33
|
+
volumes:
|
34
|
+
- /bundle
|
data/gooddata.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_development_dependency 'redcarpet', '~> 3.1' if RUBY_PLATFORM != 'java'
|
35
35
|
s.add_development_dependency 'rspec', '~> 3.5'
|
36
36
|
s.add_development_dependency 'rspec-expectations', '~> 3.5'
|
37
|
+
s.add_development_dependency 'rspec_junit_formatter', '~> 0.3.0'
|
37
38
|
s.add_development_dependency 'rubocop', '< 0.48' # TODO: remove it after dealing with new rules introduced in 0.48 version
|
38
39
|
s.add_development_dependency 'simplecov', '~> 0.12'
|
39
40
|
s.add_development_dependency 'webmock', '~> 1.21'
|
@@ -41,20 +42,25 @@ Gem::Specification.new do |s|
|
|
41
42
|
s.add_development_dependency 'yard-rspec', '~> 0.1'
|
42
43
|
s.add_development_dependency 'ZenTest', '~> 4.11'
|
43
44
|
s.add_development_dependency 'pry'
|
45
|
+
s.add_development_dependency 'activesupport', '~> 4.2.9'
|
46
|
+
s.add_development_dependency 'pronto', '~> 0.9.5' if RUBY_PLATFORM != 'java'
|
47
|
+
s.add_development_dependency 'pronto-rubocop', '~> 0.9.0' if RUBY_PLATFORM != 'java'
|
48
|
+
s.add_development_dependency 'pronto-reek', '~> 0.9.0' if RUBY_PLATFORM != 'java'
|
49
|
+
s.add_development_dependency 'pronto-flay', '~> 0.9.0' if RUBY_PLATFORM != 'java'
|
44
50
|
|
45
51
|
s.add_dependency 'aws-sdk', '~> 2.9', '>= 2.9.42'
|
46
52
|
s.add_dependency 'docile', '~> 1.1'
|
47
53
|
s.add_dependency 'erubis', '~> 2.7'
|
48
54
|
s.add_dependency 'gli', '~> 2.15'
|
49
55
|
s.add_dependency 'gooddata_datawarehouse' if RUBY_PLATFORM == 'java'
|
50
|
-
s.add_dependency 'gooddata-dss-jdbc' if RUBY_PLATFORM == 'java'
|
56
|
+
s.add_dependency 'gooddata-dss-jdbc', '0.1.12' if RUBY_PLATFORM == 'java'
|
51
57
|
s.add_dependency 'highline', '~> 1.7'
|
52
58
|
s.add_dependency 'json_pure', '~> 1.8'
|
53
59
|
s.add_dependency 'multi_json', '~> 1.12'
|
54
60
|
s.add_dependency 'parseconfig', '~> 1.0'
|
55
61
|
s.add_dependency 'pmap', '~> 1.1'
|
56
62
|
s.add_dependency 'restforce', '~> 2.4'
|
57
|
-
s.add_dependency 'rest-client', '~>
|
63
|
+
s.add_dependency 'rest-client', '~> 2.0'
|
58
64
|
s.add_dependency 'rubyzip', '~> 1.2'
|
59
65
|
s.add_dependency 'salesforce_bulk_query', '~> 0.2'
|
60
66
|
s.add_dependency 'terminal-table', '~> 1.7'
|
@@ -97,7 +97,7 @@ module GoodData
|
|
97
97
|
open(link) { |rf| f.write(rf.read) }
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
100
|
+
GoodData.logger.info("Realizing web download from \"#{link}\" took #{measure.real}")
|
101
101
|
filename
|
102
102
|
end
|
103
103
|
|
@@ -109,16 +109,19 @@ module GoodData
|
|
109
109
|
key = @options[:key]
|
110
110
|
raise 'Key "bucket" is missing in S3 datasource' if bucket_name.blank?
|
111
111
|
raise 'Key "key" is missing in S3 datasource' if key.blank?
|
112
|
-
|
112
|
+
GoodData.logger.info("Realizing download from S3. Bucket #{bucket_name}, object with key #{key}.")
|
113
113
|
filename = Digest::SHA256.new.hexdigest(@options.to_json)
|
114
114
|
bucket = s3_client.bucket(bucket_name)
|
115
115
|
obj = bucket.object(key)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
obj.get(response_target: filename, bucket: bucket_name, key: key)
|
117
|
+
s3_size = obj.size
|
118
|
+
actual_size = File.size(filename)
|
119
|
+
GoodData.logger.info("File size in S3: #{s3_size}")
|
120
|
+
GoodData.logger.info("Downloaded file size: #{actual_size}")
|
121
|
+
unless s3_size == actual_size
|
122
|
+
fail "Error downloading file #{key}. Expected size #{s3_size}, got #{actual_size}."
|
120
123
|
end
|
121
|
-
|
124
|
+
GoodData.logger.info('Done downloading file.')
|
122
125
|
filename
|
123
126
|
end
|
124
127
|
end
|
@@ -264,9 +264,14 @@ module GoodData
|
|
264
264
|
elsif match =~ /\\\$/
|
265
265
|
'$'
|
266
266
|
elsif match =~ /\$\{(\w+)\}/
|
267
|
-
val = params["#{$1}"]
|
268
|
-
|
269
|
-
|
267
|
+
val = params["#{$1}"]
|
268
|
+
if val
|
269
|
+
reference_values << val
|
270
|
+
val
|
271
|
+
else
|
272
|
+
GoodData.logger.warn "Reference '#{$1}' is not found!"
|
273
|
+
match
|
274
|
+
end
|
270
275
|
end
|
271
276
|
end
|
272
277
|
end
|
@@ -44,9 +44,10 @@ module GoodData
|
|
44
44
|
|
45
45
|
domain_name = params.organization || params.domain
|
46
46
|
domain = client.domain(domain_name) || fail("Invalid domain name specified - #{domain_name}")
|
47
|
+
data_product = params.data_product
|
47
48
|
|
48
49
|
segment_ids = params.segments.map(&:segment_id)
|
49
|
-
domain_segments = domain.segments.select do |ds|
|
50
|
+
domain_segments = domain.segments(:all, data_product).select do |ds|
|
50
51
|
segment_ids.include?(ds.segment_id)
|
51
52
|
end
|
52
53
|
|
@@ -45,14 +45,23 @@ module GoodData
|
|
45
45
|
|
46
46
|
domain_name = params.organization || params.domain
|
47
47
|
domain = client.domain(domain_name) || fail("Invalid domain name specified - #{domain_name}")
|
48
|
+
data_product = params.data_product
|
49
|
+
|
50
|
+
segments = {}
|
48
51
|
|
49
52
|
params.clients.group_by { |data| data[:segment] }.each do |segment_name, clients|
|
50
|
-
segment = domain.segments(segment_name)
|
53
|
+
segment = domain.segments(segment_name, data_product)
|
54
|
+
segments[segment_name] = segment
|
51
55
|
(clients.map(&:id) - segment.clients.map(&:id)).each do |c|
|
52
56
|
segment.create_client(id: c)
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
60
|
+
params.clients.map! do |data|
|
61
|
+
data[:data_product_id] = segments[data[:segment]].data_product.data_product_id
|
62
|
+
data
|
63
|
+
end
|
64
|
+
|
56
65
|
domain.update_clients_settings(params.clients)
|
57
66
|
|
58
67
|
delete_projects = GoodData::Helpers.to_boolean(params.delete_projects)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2010-2017 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 'base_action'
|
8
|
+
require 'thread_safe'
|
9
|
+
|
10
|
+
module GoodData
|
11
|
+
module LCM2
|
12
|
+
class CollectClientProjects < BaseAction
|
13
|
+
DESCRIPTION = 'Collect All Client Projects In Domain'
|
14
|
+
|
15
|
+
PARAMS = define_params(self) do
|
16
|
+
description 'Client Used for Connecting to GD'
|
17
|
+
param :gdc_gd_client, instance_of(Type::GdClientType), required: true
|
18
|
+
|
19
|
+
description 'Organization Name'
|
20
|
+
param :organization, instance_of(Type::StringType), required: true
|
21
|
+
|
22
|
+
description 'Segments to manage'
|
23
|
+
param :segments, array_of(instance_of(Type::SegmentType)), required: true
|
24
|
+
end
|
25
|
+
|
26
|
+
RESULT_HEADER = [
|
27
|
+
:client_id,
|
28
|
+
:project
|
29
|
+
]
|
30
|
+
|
31
|
+
class << self
|
32
|
+
def call(params)
|
33
|
+
client = params.gdc_gd_client
|
34
|
+
|
35
|
+
domain = client.domain(params.organization) || fail("Invalid domain name specified - #{params.organization}")
|
36
|
+
|
37
|
+
data_product = params.data_product
|
38
|
+
all_segments = domain.segments(:all, data_product)
|
39
|
+
|
40
|
+
segment_names = params.segments.map do |segment|
|
41
|
+
segment.segment_id.downcase
|
42
|
+
end
|
43
|
+
|
44
|
+
segments = all_segments.select do |segment|
|
45
|
+
segment_names.include?(segment.segment_id.downcase)
|
46
|
+
end
|
47
|
+
|
48
|
+
client_projects = ThreadSafe::Hash.new
|
49
|
+
|
50
|
+
results = segments.pmap do |segment|
|
51
|
+
segment.clients.map do |segment_client|
|
52
|
+
project = segment_client.project
|
53
|
+
|
54
|
+
res = {
|
55
|
+
client_id: segment_client.client_id,
|
56
|
+
project: project && project.pid
|
57
|
+
}
|
58
|
+
|
59
|
+
client_projects[segment_client.client_id] = {
|
60
|
+
segment_client: segment_client,
|
61
|
+
project: project
|
62
|
+
}
|
63
|
+
|
64
|
+
res
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
{
|
69
|
+
results: results.flatten,
|
70
|
+
params: {
|
71
|
+
client_projects: client_projects
|
72
|
+
}
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -47,7 +47,8 @@ module GoodData
|
|
47
47
|
def call(params)
|
48
48
|
segment_names = params.segments.map(&:segment_id)
|
49
49
|
|
50
|
-
clients = collect_clients(params, segment_names)
|
50
|
+
clients, errors = collect_clients(params, segment_names)
|
51
|
+
fail "These are errors while collecting clients from input data:\n#{errors.join("\n")}" unless errors.empty?
|
51
52
|
|
52
53
|
results = clients.map do |client|
|
53
54
|
{
|
@@ -57,7 +58,6 @@ module GoodData
|
|
57
58
|
}
|
58
59
|
end
|
59
60
|
|
60
|
-
# Return results
|
61
61
|
{
|
62
62
|
results: results,
|
63
63
|
params: {
|
@@ -72,8 +72,10 @@ module GoodData
|
|
72
72
|
project_id_column = params.project_id_column || 'project_id'
|
73
73
|
project_title_column = params.project_title_column || 'project_title'
|
74
74
|
project_token_column = params.project_token_column || 'project_token'
|
75
|
+
client = params.gdc_gd_client
|
75
76
|
|
76
77
|
clients = []
|
78
|
+
errors = []
|
77
79
|
data_source = GoodData::Helpers::DataSource.new(params.input_source)
|
78
80
|
input_data = File.open(data_source.realize(params), 'r:UTF-8')
|
79
81
|
GoodData.logger.debug("Input data: #{input_data.read}")
|
@@ -83,10 +85,22 @@ module GoodData
|
|
83
85
|
segment_name = row[segment_id_column]
|
84
86
|
GoodData.logger.debug("Segment name: #{segment_name}")
|
85
87
|
if segment_names.nil? || segment_names.include?(segment_name)
|
88
|
+
client_id = row[client_id_column]
|
89
|
+
pid = row[project_id_column]
|
90
|
+
|
91
|
+
if pid
|
92
|
+
begin
|
93
|
+
errors << "Project #{pid} of client #{client_id} is deleted." if client.projects(pid).deleted?
|
94
|
+
rescue
|
95
|
+
errors << "Seems like you (user executing the script - #{client.user.login}) \
|
96
|
+
do not have access to project \"#{pid}\" of client \"#{client_id}\""
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
86
100
|
clients << {
|
87
|
-
id:
|
101
|
+
id: client_id,
|
88
102
|
segment: segment_name,
|
89
|
-
project:
|
103
|
+
project: pid,
|
90
104
|
settings: [
|
91
105
|
{
|
92
106
|
name: 'lcm.token',
|
@@ -102,11 +116,11 @@ module GoodData
|
|
102
116
|
end
|
103
117
|
|
104
118
|
if clients.empty?
|
105
|
-
|
119
|
+
errors << "No segments or clients qualify for provisioning. \
|
106
120
|
Please check the input source data, platform segments, and the SEGMENTS_FILTER parameter. \
|
107
121
|
The intersection of these three elements is empty set."
|
108
122
|
end
|
109
|
-
clients
|
123
|
+
[clients, errors]
|
110
124
|
end
|
111
125
|
end
|
112
126
|
end
|