Class: GoodData::AdsOutputStage
- Inherits:
-
Rest::Resource
- Object
- Rest::Object
- Rest::Resource
- GoodData::AdsOutputStage
- Defined in:
- lib/gooddata/models/ads_output_stage.rb
Constant Summary collapse
- OUTPUT_STAGE_PATH =
'/gdc/dataload/projects/%s/outputStage'
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#output_stage_prefix ⇒ Object
Returns the value of attribute output_stage_prefix.
-
#schema ⇒ Object
Returns the value of attribute schema.
Attributes inherited from Rest::Object
Class Method Summary collapse
- .[](opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
- .create(opts = { client: GoodData.connection }) ⇒ Object
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(json) ⇒ AdsOutputStage
constructor
A new instance of AdsOutputStage.
- #save ⇒ Object
- #sql_diff ⇒ Object
Methods included from Mixin::ObjId
Methods inherited from Rest::Object
client, default_client, #saved?
Methods included from Mixin::DataPropertyReader
Methods included from Mixin::DataPropertyWriter
Methods included from Mixin::MetaPropertyReader
Methods included from Mixin::MetaPropertyWriter
Methods included from Mixin::MetaGetter
Methods included from Mixin::DataGetter
Methods included from Mixin::RootKeyGetter
Methods included from Mixin::ContentGetter
Constructor Details
#initialize(json) ⇒ AdsOutputStage
Returns a new instance of AdsOutputStage.
46 47 48 49 50 51 52 53 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 46 def initialize(json) super @json = json @schema = data['schema'] @client_id = data['clientId'] @output_stage_prefix = data['outputStagePrefix'] end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
13 14 15 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 13 def client_id @client_id end |
#output_stage_prefix ⇒ Object
Returns the value of attribute output_stage_prefix.
13 14 15 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 13 def output_stage_prefix @output_stage_prefix end |
#schema ⇒ Object
Returns the value of attribute schema.
13 14 15 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 13 def schema @schema end |
Class Method Details
.[](opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 16 def [](opts = { client: GoodData.connection, project: GoodData.project }) c, project = GoodData.get_client_and_project(opts) uri = OUTPUT_STAGE_PATH % project.pid data = c.get(uri) c.create(AdsOutputStage, data, opts) end |
.create(opts = { client: GoodData.connection }) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 23 def create(opts = { client: GoodData.connection }) c = GoodData.get_client(opts) [:project, :ads].each do |key| fail "No #{key.inspect} specified" unless opts[key] end schema = (opts[:ads].respond_to?(:schemas) && opts[:ads].schemas) || opts[:ads] schema += '/default' unless schema.end_with?('/default') json = { 'outputStage' => { 'schema' => schema } } output_stage = c.create(AdsOutputStage, json, opts) output_stage.save output_stage end |
Instance Method Details
#delete ⇒ Object
72 73 74 75 76 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 72 def delete data_to_send = { 'outputStage' => { 'clientId' => '', 'outputStagePrefix' => '' } } url = build_output_stage_path @json = client.put(url, data_to_send, accept: 'application/json; version=1') end |
#save ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 61 def save data_to_send = GoodData::Helpers.deep_dup(raw_data).tap do |d| d['outputStage']['clientId'] = client_id if client_id d['outputStage']['outputStagePrefix'] = output_stage_prefix if output_stage_prefix d['outputStage']['schema'] = schema end url = build_output_stage_path @json = client.put(url, data_to_send, accept: 'application/json; version=1') end |
#sql_diff ⇒ Object
55 56 57 58 59 |
# File 'lib/gooddata/models/ads_output_stage.rb', line 55 def sql_diff res = client.get "#{build_output_stage_path}/sqlDiff" ret = client.poll_on_response(res['asyncTask']['link']['poll']) { |body| body['asyncTask'] } ret.freeze end |