gd_bam 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/bam +2 -68
  2. data/lib/bam/version.rb +1 -1
  3. data/lib/runtime.rb +68 -0
  4. metadata +3 -3
data/bin/bam CHANGED
@@ -125,78 +125,12 @@ command :project do |c|
125
125
 
126
126
  c.action do |global_options,options,args|
127
127
  fail "You need to specify token to create a project" if options[:token].nil?
128
-
129
- pid = case options[:blueprint]
130
- when "goodsales"
131
- "nt935rwzls50zfqwy6dh62tabu8h0ocy"
132
- when nil
133
- fail "Empty project not supported now"
134
- end
135
128
 
136
129
  logger = Logger.new(STDOUT) if global_options[:l]
137
130
  GoodData::CloverGenerator.connect_to_gd(:logger => logger)
138
- with_users = options[:with_users]
139
-
140
- export = {
141
- :exportProject => {
142
- :exportUsers => with_users ? 1 : 0,
143
- :exportData => 1
144
- }
145
- }
146
-
147
- result = GoodData.post("/gdc/md/#{pid}/maintenance/export", export)
148
- token = result["exportArtifact"]["token"]
149
- status_url = result["exportArtifact"]["status"]["uri"]
150
-
151
-
152
- state = GoodData.get(status_url)["taskState"]["status"]
153
- while state == "RUNNING"
154
- sleep 5
155
- result = GoodData.get(status_url)
156
- state = result["taskState"]["status"]
157
- end
158
-
159
- old_project = GoodData::Project[pid]
160
-
161
-
162
- pr = {
163
- :project => {
164
- :content => {
165
- :guidedNavigation => 1,
166
- :driver => "Pg",
167
- :authorizationToken => options[:token]
168
- },
169
- :meta => {
170
- :title => "Test Project",
171
- :summary => "Testing Project"
172
- }
173
- }
174
- }
175
- result = GoodData.post("/gdc/projects/", pr)
176
- uri = result["uri"]
177
- while(GoodData.get(uri)["project"]["content"]["state"] == "LOADING")
178
- sleep(5)
179
- end
180
-
181
- new_project = GoodData::Project[uri]
182
-
183
- import = {
184
- :importProject => {
185
- :token => token
186
- }
187
- }
188
-
189
- result = GoodData.post("/gdc/md/#{new_project.obj_id}/maintenance/import", import)
190
- status_url = result["uri"]
191
- state = GoodData.get(status_url)["taskState"]["status"]
192
- while state == "RUNNING"
193
- sleep 5
194
- result = GoodData.get(status_url)
195
- state = result["taskState"]["status"]
196
- end
197
- GoodData.post "/gdc/projects/#{new_project.obj_id}/eventStore/stores", {:store => {:storeId => "es_0"}}
198
- puts "Your project pid is #{new_project.obj_id}"
131
+ new_project = GoodData::CloverGenerator.clone_project(options)
199
132
 
133
+ puts "Your project pid is #{new_project}"
200
134
  end
201
135
 
202
136
  end
data/lib/bam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bam
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
data/lib/runtime.rb CHANGED
@@ -302,6 +302,74 @@ module GoodData
302
302
  GoodData.post("/gdc/projects/#{PARAMS[:project_pid]}/users/#{profile_id}/subscriptions", data)
303
303
  end
304
304
 
305
+ def self.clone_project(options={})
306
+ pid = case options[:blueprint]
307
+ when "goodsales"
308
+ "nt935rwzls50zfqwy6dh62tabu8h0ocy"
309
+ when nil
310
+ fail "Empty project not supported now"
311
+ end
312
+
313
+ with_users = options[:with_users]
314
+
315
+ export = {
316
+ :exportProject => {
317
+ :exportUsers => with_users ? 1 : 0,
318
+ :exportData => 1
319
+ }
320
+ }
321
+
322
+ result = GoodData.post("/gdc/md/#{pid}/maintenance/export", export)
323
+ token = result["exportArtifact"]["token"]
324
+ status_url = result["exportArtifact"]["status"]["uri"]
325
+
326
+ state = GoodData.get(status_url)["taskState"]["status"]
327
+ while state == "RUNNING"
328
+ sleep 5
329
+ result = GoodData.get(status_url)
330
+ state = result["taskState"]["status"]
331
+ end
332
+
333
+ old_project = GoodData::Project[pid]
334
+
335
+ pr = {
336
+ :project => {
337
+ :content => {
338
+ :guidedNavigation => 1,
339
+ :driver => "Pg",
340
+ :authorizationToken => options[:token]
341
+ },
342
+ :meta => {
343
+ :title => "Test Project",
344
+ :summary => "Testing Project"
345
+ }
346
+ }
347
+ }
348
+ result = GoodData.post("/gdc/projects/", pr)
349
+ uri = result["uri"]
350
+ while(GoodData.get(uri)["project"]["content"]["state"] == "LOADING")
351
+ sleep(5)
352
+ end
353
+
354
+ new_project = GoodData::Project[uri]
355
+
356
+ import = {
357
+ :importProject => {
358
+ :token => token
359
+ }
360
+ }
361
+
362
+ result = GoodData.post("/gdc/md/#{new_project.obj_id}/maintenance/import", import)
363
+ status_url = result["uri"]
364
+ state = GoodData.get(status_url)["taskState"]["status"]
365
+ while state == "RUNNING"
366
+ sleep 5
367
+ result = GoodData.get(status_url)
368
+ state = result["taskState"]["status"]
369
+ end
370
+ GoodData.post "/gdc/projects/#{new_project.obj_id}/eventStore/stores", {:store => {:storeId => "es_0"}}
371
+ new_project.obj_id
372
+ end
305
373
 
306
374
  def self.create_email_channel(options={}, &block)
307
375
  # email = option[:email]
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.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -397,7 +397,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
397
397
  version: '0'
398
398
  segments:
399
399
  - 0
400
- hash: -223004513366541779
400
+ hash: 3042654429209588317
401
401
  required_rubygems_version: !ruby/object:Gem::Requirement
402
402
  none: false
403
403
  requirements:
@@ -406,7 +406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
406
406
  version: '0'
407
407
  segments:
408
408
  - 0
409
- hash: -223004513366541779
409
+ hash: 3042654429209588317
410
410
  requirements: []
411
411
  rubyforge_project:
412
412
  rubygems_version: 1.8.25