/
base.json.rabl
72 lines (56 loc) · 1.83 KB
/
base.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
object @resource
extends 'katello/api/v2/common/identifier'
attributes :version, :major, :minor
attributes :composite_content_view_ids
attributes :content_view_id
attributes :default
attributes :description
attributes :package_count
attributes :puppet_module_count
attributes :docker_image_count
attributes :docker_tag_count
node :errata_counts do |version|
partial('katello/api/v2/errata/counts', :object => Katello::RelationPresenter.new(version.errata))
end
child :content_view => :content_view do
attributes :id, :name, :label
end
child :composite_content_views do
attributes :id, :name, :label
end
node :permissions do |cvv|
{
:deletable => cvv.removable?
}
end
extends 'katello/api/v2/common/timestamps'
version = @object || @resource
child :environments => :environments do
attributes :id, :name, :label
node :puppet_environment_id do |environment|
version.puppet_env(environment).try(:puppet_environment).try(:id)
end
node :permissions do |env|
{
:readable => env.readable?,
:promotable_or_removable => env.promotable_or_removable?,
:all_systems_editable => Katello::System.all_editable?(version.content_view_id, env.id),
:all_keys_editable => Katello::System.all_editable?(version.content_view_id, env.id)
}
end
node :system_count do |env|
Katello::System.in_environment(env).where(:content_view_id => version.content_view_id).count
end
node :activation_key_count do |env|
Katello::ActivationKey.where(:environment_id => env.id).where(:content_view_id => version.content_view_id).count
end
end
child :archived_repos => :repositories do
attributes :id, :name, :label
end
child :last_event => :last_event do
extends 'katello/api/v2/content_view_histories/show'
end
child :active_history => :active_history do
extends 'katello/api/v2/content_view_histories/show'
end