class GoodData::DataWarehouse

Constants

CREATE_URL

Public Class Methods

[](id = :all, options = { client: GoodData.client }) click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 14
def [](id = :all, options = { client: GoodData.client })
  c = GoodData.get_client(options)

  if id == :all
    data = c.get(CREATE_URL)
    data['instances']['items'].map do |ads_data|
      c.create(DataWarehouse, ads_data)
    end
  else
    c.create(DataWarehouse, c.get("#{CREATE_URL}/#{id}"))
  end
end
all(options = { client: GoodData.client }) click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 27
def all(options = { client: GoodData.client })
  DataWarehouse[:all, options]
end
create(opts) click to toggle source

Create a data warehouse from given attributes Expected keys:

  • :title (mandatory)

  • :auth_token (mandatory)

  • :summary

# File lib/gooddata/models/datawarehouse.rb, line 36
def create(opts)
  GoodData.logger.info "Creating warehouse #{opts[:title]}"

  c = GoodData.get_client(opts)

  opts = { :auth_token => Helpers::AuthHelper.read_token }.merge(opts)
  auth_token = opts[:auth_token] || opts[:token]
  fail ArgumentError, 'You have to provide your token for creating projects as :auth_token parameter' if auth_token.nil? || auth_token.empty?

  title = opts[:title]
  fail ArgumentError, 'You have to provide a title for creating warehouse as :title parameter' if title.nil? || title.empty?

  json = {
    'instance' => {
      'title' => title,
      'description' => opts[:description] || opts[:summary] || 'No summary',
      'authorizationToken' => auth_token
    }
  }
  json['instance']['environment'] = opts[:environment] if opts[:environment]

  # do the first post
  res = c.post(CREATE_URL, json)

  # wait until the instance is created
  final_res = c.poll_on_response(res['asyncTask']['links']['poll'], opts.merge(sleep_interval: 3)) do |r|
    r['asyncTask']['links']['instance'].nil?
  end

  # get the json of the created instance
  final_json = c.get(final_res['asyncTask']['links']['instance'])

  # create the public facing object
  c.create(DataWarehouse, final_json)
end
new(json) click to toggle source
Calls superclass method
# File lib/gooddata/models/datawarehouse.rb, line 73
def initialize(json)
  super
  @json = json
end

Public Instance Methods

delete() click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 98
def delete
  if state == 'DELETED'
    fail "Warehouse '#{title}' with id #{uri} is already deleted"
  end
  client.delete(uri)
end
description()
Alias for: summary
id() click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 94
def id
  uri.split('/')[-1]
end
schemas() click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 110
def schemas
  json['instance']['links']['schemas']
end
state()

alias methods to prevent confusion and support the same keys project has.

Alias for: status
status() click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 86
def status
  json['instance']['status']
end
Also aliased as: state
summary() click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 82
def summary
  json['instance']['description']
end
Also aliased as: description
title() click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 78
def title
  json['instance']['title']
end
uri() click to toggle source
# File lib/gooddata/models/datawarehouse.rb, line 90
def uri
  json['instance']['links']['self']
end