-
Notifications
You must be signed in to change notification settings - Fork 284
/
show.json.rabl
80 lines (64 loc) · 2.29 KB
/
show.json.rabl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
71
72
73
74
75
76
77
78
79
80
object @resource
@resource ||= @object
extends "katello/api/v2/products/base"
child(:product_contents => :product_content) do
extends "katello/api/v2/products/product_content"
end
child(:available_content => :available_content) do
extends "katello/api/v2/products/product_content"
end
attributes :redhat? => :redhat
child :library_repositories => :repositories do |_repo|
attributes :name, :id
end
node(:gpg_key, :unless => lambda { |product| product.gpg_key.nil? }) do |product|
{:id => product.gpg_key.id, :name => product.gpg_key.name}
end
node(:ssl_ca_cert, :unless => lambda { |product| product.ssl_ca_cert.nil? }) do |product|
{:id => product.ssl_ca_cert.id, :name => product.ssl_ca_cert.name}
end
node(:ssl_client_cert, :unless => lambda { |product| product.ssl_client_cert.nil? }) do |product|
{:id => product.ssl_client_cert.id, :name => product.ssl_client_cert.name}
end
node(:ssl_client_key, :unless => lambda { |product| product.ssl_client_key.nil? }) do |product|
{:id => product.ssl_client_key.id, :name => product.ssl_client_key.name}
end
child :provider do
attribute :name
end
node :sync_status do |product|
local_sync_status = product.sync_status
{
:id => local_sync_status[:id],
:product_id => local_sync_status[:product_id],
:progress => local_sync_status[:progress],
:sync_id => local_sync_status[:sync_id],
:state => local_sync_status[:state],
:raw_state => local_sync_status[:raw_state],
:start_time => local_sync_status[:start_time],
:finish_time => local_sync_status[:finish_time],
:duration => local_sync_status[:duration],
:display_size => local_sync_status[:display_size],
:size => local_sync_status[:size],
:is_running => local_sync_status[:is_running],
:error_details => local_sync_status[:error_details]
}
end
node :permissions do |product|
{
:view_products => product.readable?,
:edit_products => product.editable?,
:destroy_products => product.deletable?,
:sync_products => product.syncable?
}
end
node(:published_content_view_ids) do |product|
product.published_content_views.map(&:id).uniq
end
node :redhat do |product|
product.redhat?
end
node :active_task_count do |product|
ForemanTasks::Task::DynflowTask.for_resource(product).active.count
end
extends 'katello/api/v2/common/timestamps'