Class: InsightsCloud::Async::InsightsRulesSync
  
  
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #attempts_before_next_interval, #done!, #done?, #invoke_external_task, #poll_external_task, #poll_intervals
  
  
  
  
  
  
  
  
  
  
  
  #cert_auth_available?, #execute_cloud_request
  
  
  
  
  
  
  
  
  
  
  #candlepin_id_cert, #cp_owner_id, #upstream_owner
  
  
  
  
  
  
  
  
  
  
  #execute_cloud_request
  
  
  
    Instance Method Details
    
      
  
  
    #logger  ⇒ Object 
  
  
  
  
    
      
43
44
45 
     | 
    
      # File 'lib/insights_cloud/async/insights_rules_sync.rb', line 43
def logger
  action_logger
end 
     | 
  
 
    
      
  
  
    #plan(organizations)  ⇒ Object 
  
  
  
  
    
      
9
10
11
12
13
14
15
16 
     | 
    
      # File 'lib/insights_cloud/async/insights_rules_sync.rb', line 9
def plan(organizations)
      sequence do
    plan_self(organization_ids: organizations.map(&:id))
    plan_resolutions
  end
end
     | 
  
 
    
      
  
  
    #plan_resolutions  ⇒ Object 
  
  
  
  
    
      
18
19
20 
     | 
    
      # File 'lib/insights_cloud/async/insights_rules_sync.rb', line 18
def plan_resolutions
  plan_action InsightsResolutionsSync
end 
     | 
  
 
    
      
  
  
    #try_execute  ⇒ Object 
  
  
  
  
    
      
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 
     | 
    
      # File 'lib/insights_cloud/async/insights_rules_sync.rb', line 22
def try_execute
  offset = 0
  InsightsRule.transaction do
    organizations.each do |organization|
      loop do
        api_response = query_insights_rules(offset, organization)
        results = RulesResult.new(api_response)
        logger.debug("Downloaded #{offset + results.count} of #{results.total}")
        write_rules_page(results.rules)
        offset += results.count
        output[:rules_count] = results.total
        break if offset >= results.total
      end
    end
        cleanup_rules
  end
  done!
end
     |