def export
CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
csv << [NAME, COUNT, LABEL, ORGANIZATION, REPOSITORY, REPOSITORY_TYPE, REPOSITORY_URL]
@api.resource(:organizations)\
.call(:index, {
:per_page => 999999
})['results'].each do |organization|
@api.resource(:products)\
.call(:index, {
'per_page' => 999999,
'enabled' => true,
'organization_id' => foreman_organization(:name => organization['name'])
})['results'].each do |product|
product['repositories'].each do |repository|
repository_type = repository['product_type'] == 'custom' ? 'Custom' : 'Red Hat'
repository_type += " #{repository['content_type'].capitalize}"
csv << [product['name'], 1, product['label'], organization['name'],
repository['name'], repository_type, repository['url']]
end
end
end
end
end