Project

General

Profile

Revision c06f1783

Added by Thomas McKay over 6 years ago

fixes #15743 - import and export of subscriptions one-per-line

View differences:

lib/hammer_cli_csv/lifecycle_environments.rb
8 8
      PRIORENVIRONMENT = 'Prior Environment'
9 9
      DESCRIPTION = 'Description'
10 10

  
11
      def export
12
        CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
13
          csv << [NAME, ORGANIZATION, PRIORENVIRONMENT, DESCRIPTION]
14
          @api.resource(:organizations).call(:index, {
15
              'per_page' => 999999
16
          })['results'].each do |organization|
17
            next if option_organization && organization['name'] != option_organization
11
      def export(csv)
12
        csv << [NAME, ORGANIZATION, PRIORENVIRONMENT, DESCRIPTION]
13
        @api.resource(:organizations).call(:index, {
14
            'per_page' => 999999
15
        })['results'].each do |organization|
16
          next if option_organization && organization['name'] != option_organization
18 17

  
19
            @api.resource(:lifecycle_environments).call(:index, {
20
                'per_page' => 999999,
21
                'organization_id' => organization['id']
22
            })['results'].sort { |a, b| a['created_at'] <=> b['created_at'] }.each do |environment|
23
              if environment['name'] != 'Library'
24
                name = environment['name']
25
                prior = environment['prior']['name']
26
                description = environment['description']
27
                csv << [name, organization['name'], prior, description]
28
              end
18
          @api.resource(:lifecycle_environments).call(:index, {
19
              'per_page' => 999999,
20
              'organization_id' => organization['id']
21
          })['results'].sort { |a, b| a['created_at'] <=> b['created_at'] }.each do |environment|
22
            if environment['name'] != 'Library'
23
              name = environment['name']
24
              prior = environment['prior']['name']
25
              description = environment['description']
26
              csv << [name, organization['name'], prior, description]
29 27
            end
30 28
          end
31 29
        end

Also available in: Unified diff