Class: GoodData::DataWarehouse
Constant Summary
collapse
- CREATE_URL =
'/gdc/datawarehouse/instances'
Instance Attribute Summary
Attributes inherited from Rest::Object
#client, #json, #project
Class Method Summary
collapse
Instance Method Summary
collapse
#obj_id
client, default_client, #saved?
#data_property_reader
#data_property_writer
#metadata_property_reader
#metadata_property_writer
#meta
#data
#root_key
#content
Constructor Details
Returns a new instance of DataWarehouse.
73
74
75
76
|
# File 'lib/gooddata/models/datawarehouse.rb', line 73
def initialize(json)
super
@json = json
end
|
Class Method Details
.[](id = :all, options = { client: GoodData.client }) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# 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 }) ⇒ Object
27
28
29
|
# File 'lib/gooddata/models/datawarehouse.rb', line 27
def all(options = { client: GoodData.client })
DataWarehouse[:all, options]
end
|
.create(opts) ⇒ Object
Create a data warehouse from given attributes
Expected keys:
- :title (mandatory)
- :auth_token (mandatory)
- :summary
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# 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]
res = c.post(CREATE_URL, json)
final_res = c.poll_on_response(res['asyncTask']['links']['poll'], opts.merge(sleep_interval: 3)) do |r|
r['asyncTask']['links']['instance'].nil?
end
final_json = c.get(final_res['asyncTask']['links']['instance'])
c.create(DataWarehouse, final_json)
end
|
Instance Method Details
98
99
100
101
102
103
|
# 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
|
94
95
96
|
# File 'lib/gooddata/models/datawarehouse.rb', line 94
def id
uri.split('/')[-1]
end
|
110
111
112
|
# File 'lib/gooddata/models/datawarehouse.rb', line 110
def schemas
json['instance']['links']['schemas']
end
|
#status ⇒ Object
Also known as:
state
86
87
88
|
# File 'lib/gooddata/models/datawarehouse.rb', line 86
def status
json['instance']['status']
end
|
#summary ⇒ Object
Also known as:
description
82
83
84
|
# File 'lib/gooddata/models/datawarehouse.rb', line 82
def summary
json['instance']['description']
end
|
78
79
80
|
# File 'lib/gooddata/models/datawarehouse.rb', line 78
def title
json['instance']['title']
end
|
90
91
92
|
# File 'lib/gooddata/models/datawarehouse.rb', line 90
def uri
json['instance']['links']['self']
end
|