class GoodData::AdsOutputStage

Constants

OUTPUT_STAGE_PATH

Attributes

client_id[RW]
output_stage_prefix[RW]
schema[RW]

Public Class Methods

[](opts = { client: GoodData.connection, project: GoodData.project }) click to toggle source
# 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 }) click to toggle source
# 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
new(json) click to toggle source
Calls superclass method
# 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

Public Instance Methods

delete() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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

Private Instance Methods

build_output_stage_path() click to toggle source
# File lib/gooddata/models/ads_output_stage.rb, line 80
def build_output_stage_path
  pid = (project.respond_to?(:pid) && project.pid) || project
  OUTPUT_STAGE_PATH % pid
end