gd_bam 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,26 +27,34 @@ create a project `bam scaffold project test`
27
27
  this will create a project. You can also scaffold a project from a know template. Currently it is again just goodsales. The goal is that after spinning you gooddata and BAM project you are good to run. If you want the defaults there is nothing you need to do besides filling credentials.
28
28
 
29
29
  -->
30
- ##Sample project
30
+ ##Sample project -- GoodSales
31
+
32
+ ###Prerequisites
33
+ You need a working project with API access. You should also have username pass and token ready to fill in to params.json.
34
+
35
+ ### Warnings
36
+ The project is currently cloned out of an existing project. That means that you need to have access to it. If you do not (the project PID is i49w4c73c2mh75iiehte3fv3fbos8h2k) ask svarovsky@gooddata.com. Eventually this will be covered by a template so you will not need to do anything special. The template creation is tracked here https://jira.intgdc.com/browse/GD-34641 .
31
37
 
32
38
  We will spin a goodsales project and load it with data. Prerequisite for this is a functioning Salesforce poject that you can grab at force.com.
33
39
 
34
40
  `bam scaffold project test --blueprint goodsales`
35
41
 
36
42
  now you can go inside `cd test`. You will notice several directories and files. We will get to `flows`, `taps` and `sinks` late. Currently focus just on `params.json`
37
- If you open it you will see several parameters which you will have to fill. Common one should be predefined and empty. BAM should warn you when it needs something it does not have.
43
+ If you open it you will see several parameters which you will have to fill. Common one should be predefined and empty. For starters you will need `gd_login` and `gd_pass` parameters filled in.
38
44
 
39
45
  One of the parameters is project_pid. To get that you need a project.
40
46
 
41
- `bam project --blueprint goodsales`
47
+ `bam project --blueprint goodsales --token YOUR_TOKEN`
48
+
42
49
  This should spin for a while and eventually should give you project ID. Fill it in your params.json.
43
50
 
44
51
  Now go ahead and generate the downloaders.
52
+
45
53
  `bam generate_downloaders`
46
54
 
47
55
  We will talk in detail why we split etl for project into downloaders and rest of the ETL. Now just trust us. By default it is generated into downloader_project folder. You can go ahead and run it on platform.
48
56
 
49
- `bam run project_downloaders --email joe@example.com`
57
+ `bam run downloader-project --email joe@example.com`
50
58
 
51
59
  You can watch the progress in our CloudConnect console.
52
60
 
@@ -56,7 +64,7 @@ Now generate the etl.
56
64
 
57
65
  This works the same as with downloaders but its default target is clover_project
58
66
 
59
- `bam run clover_project --email joe@example.com`
67
+ `bam run clover-project --email joe@example.com`
60
68
 
61
69
  After it is finished log in to gooddata go into your project and celebrate. You just did project using BAM.
62
70
 
data/bin/bam CHANGED
@@ -98,6 +98,7 @@ command :project do |c|
98
98
  c.flag :token
99
99
 
100
100
  c.action do |global_options,options,args|
101
+ fail "You need to specify token to create a project" if options[:token].nil?
101
102
 
102
103
  pid = case options[:blueprint]
103
104
  when "goodsales"
@@ -164,7 +165,9 @@ command :project do |c|
164
165
  sleep 5
165
166
  result = GoodData.get(status_url)
166
167
  state = result["taskState"]["status"]
167
- end
168
+ end
169
+ GoodData.post "/gdc/projects/#{new_project.obj_id}/eventStore/stores", {:store => {:storeId => "es_0"}}
170
+ puts "Your project token is #{new_project.obj_id}"
168
171
 
169
172
  end
170
173
 
@@ -246,9 +249,10 @@ end
246
249
 
247
250
  desc 'Runs the project on server'
248
251
  command :run do |c|
249
- # c.desc 'existing process id under which it is going to be redeployed'
250
- # c.arg_name 'process'
251
- # c.flag :process
252
+
253
+ c.desc 'email to addresses when the run is finished'
254
+ c.arg_name 'email'
255
+ c.flag :email
252
256
 
253
257
  c.action do |global_options,options,args|
254
258
 
@@ -262,7 +266,8 @@ command :run do |c|
262
266
  options = global_options.merge({:name => "temporary"})
263
267
  GoodData::CloverGenerator.deploy(dir, options) do |deploy_response|
264
268
  puts HighLine::color("Executing", HighLine::BOLD) if verbose
265
- GoodData::CloverGenerator.create_email_channel do
269
+ GoodData::CloverGenerator.create_email_channel(options) do |channel_response|
270
+ GoodData::CloverGenerator.subscribe_on_finish(:success, channel_response["channelConfiguration"]["meta"]["uri"], deploy_response["cloverTransformation"]["links"]["self"].split('/').last)
266
271
  GoodData::CloverGenerator.execute_process(deploy_response["cloverTransformation"]["links"]["executions"], dir)
267
272
  end
268
273
  end
data/lib/bam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bam
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/lib/nodes/nodes.rb CHANGED
@@ -84,12 +84,13 @@ module GoodData
84
84
  :charset => "UTF-8",
85
85
  :quotedStrings => "true",
86
86
  :append => "false",
87
- :outputFieldNames => "false"
87
+ :outputFieldNames => "false",
88
+ :makeDirs => "true"
88
89
  }
89
90
  defaults = local_defaults.merge(options[:defaults] || {})
90
91
 
91
92
  base_node(defaults.merge(data), {
92
- :allowed => [:fileURL, :quotedStrings, :quoteCharacter, :charset, :outputFieldNames, :append],
93
+ :allowed => [:fileURL, :quotedStrings, :quoteCharacter, :charset, :outputFieldNames, :append, :makeDirs],
93
94
  :defaults => defaults,
94
95
  :required => [:fileURL]
95
96
  })
data/lib/runtime.rb CHANGED
@@ -144,7 +144,6 @@ module GoodData
144
144
 
145
145
  taps = ""
146
146
  sources.each do |source|
147
- # x = GoodData::CloverGenerator.transformation_acts_as(source)
148
147
  taps += "#####{source[:object]}"
149
148
  taps += "\n"
150
149
  source[:fields].each do |f|
@@ -168,7 +167,7 @@ module GoodData
168
167
  model_update_dir = Pathname('model_update')
169
168
  cl_home = ENV['CL_HOME'] || PARAMS['CL_HOME'] || fail("Home of cl tool cannot be found. Either set up CL_HOME in your env with 'export CL_HOME=path/to/cl or set it up in your params.json. Point to the directory of CL not to the bin dir.'")
170
169
  cl_home = Pathname(cl_home) + 'bin/gdi.sh'
171
-
170
+
172
171
  FileUtils::mkdir_p(model_update_dir)
173
172
  File.open(model_update_dir + 'xy', 'w')
174
173
  FileUtils::cd(model_update_dir) do
@@ -226,7 +225,6 @@ module GoodData
226
225
 
227
226
 
228
227
  def self.execute_process(link, dir)
229
- binding.pry
230
228
  result = GoodData.post(link, {
231
229
  :graphExecution => {
232
230
  :graph => "./#{dir}/graphs/main.grf",
@@ -242,12 +240,57 @@ module GoodData
242
240
  GoodData.project = PARAMS[:project_pid] if !PARAMS[:project_pid].nil? && !PARAMS[:project_pid].empty?
243
241
  end
244
242
 
245
- def self.create_email_channel(&block)
243
+ def self.subscribe_on_finish(event_type, channel_uri, process_id)
244
+ event_id = case event_type
245
+ when :success
246
+ "dataload.process.finish.ok"
247
+ when :failure
248
+ "dataload.process.finish.error"
249
+ else
250
+ fail "You specified unknown event \"#{event_type}\""
251
+ end
252
+ data = {
253
+ :subscription => {
254
+ :triggers => [
255
+ {
256
+ :projectEventTrigger => {
257
+ :types => [event_id]
258
+ }
259
+ }
260
+ ],
261
+ :condition => {
262
+ :condition => {
263
+ :expression => "params.PROCESS_ID==\"#{process_id}\""
264
+ }
265
+ },
266
+ :subject => {
267
+ :template => {
268
+ :expression => "Subject"
269
+ }
270
+ },
271
+ :message => {
272
+ :template => {
273
+ :expression => "JEDU"
274
+ }
275
+ },
276
+ :channels => [channel_uri],
277
+ :meta => {
278
+ :title => "Temporary notification for process #{process_id}"
279
+ }
280
+ }
281
+ }
282
+ profile_id = GoodData.connection.user["profile"].split("/").last
283
+ GoodData.post("/gdc/projects/#{PARAMS[:project_pid]}/users/#{profile_id}/subscriptions", data)
284
+ end
285
+
286
+
287
+ def self.create_email_channel(options={}, &block)
288
+ # email = option[:email]
246
289
  data = {
247
290
  :channelConfiguration => {
248
291
  :configuration => {
249
292
  :emailConfiguration => {
250
- :to => "svarovsky@gooddata.com"
293
+ :to => 'svarovsky@gooddata.com'
251
294
  }
252
295
  },
253
296
  :meta => {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gd_bam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-18 00:00:00.000000000 Z
12
+ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -393,7 +393,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
393
393
  version: '0'
394
394
  segments:
395
395
  - 0
396
- hash: -596246612218275016
396
+ hash: -3695581438203549297
397
397
  required_rubygems_version: !ruby/object:Gem::Requirement
398
398
  none: false
399
399
  requirements:
@@ -402,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
402
402
  version: '0'
403
403
  segments:
404
404
  - 0
405
- hash: -596246612218275016
405
+ hash: -3695581438203549297
406
406
  requirements: []
407
407
  rubyforge_project:
408
408
  rubygems_version: 1.8.25