Module: Awspec::Helper::Finder::Backup
- Included in:
- Awspec::Helper::Finder
- Defined in:
- lib/awspec/helper/finder/backup.rb
Constant Summary collapse
- STATES =
%w[ creating available failed ]
Instance Method Summary collapse
- #airgapped? ⇒ Boolean
- #find_backup_plan(id) ⇒ Object
- #find_backup_selection(id) ⇒ Object
- #find_backup_vault(id) ⇒ Object
- #locked? ⇒ Boolean
- #select_backup_rule_by_plan_id(id) ⇒ Object
Instance Method Details
#airgapped? ⇒ Boolean
83 84 85 |
# File 'lib/awspec/helper/finder/backup.rb', line 83 def airgapped? resource_via_client.vault_type == 'LOGICALLY_AIR_GAPPED_BACKUP_VAULT' end |
#find_backup_plan(id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/awspec/helper/finder/backup.rb', line 23 def find_backup_plan(id) selected = [] req = {} loop do res = backup_client.list_backup_plans(req) selected += res.backup_plans_list.select do |p| p.backup_plan_name == id || p.backup_plan_arn == id || p.backup_plan_id == id end break if res.next_token.nil? req[:next_token] = res.next_token end selected.single_resource(id) rescue Aws::Backup::Errors::ResourceNotFoundException nil end |
#find_backup_selection(id) ⇒ Object
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 |
# File 'lib/awspec/helper/finder/backup.rb', line 40 def find_backup_selection(id) backup_plans = [] req = {} loop do res = backup_client.list_backup_plans(req) backup_plans += res.backup_plans_list.map { |p| p.backup_plan_id } break if res.next_token.nil? req[:next_token] = res.next_token end selected = [] next_token = nil backup_plans.each do |plan_id| loop do res = backup_client.list_backup_selections({ backup_plan_id: plan_id, next_token: next_token }) selected += res.backup_selections_list.select do |s| s.selection_id == id || s.selection_name == id end break if res.next_token.nil? next_token = res.next_token end end selected.single_resource(id) rescue Aws::Backup::Errors::ResourceNotFoundException nil end |
#find_backup_vault(id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/awspec/helper/finder/backup.rb', line 6 def find_backup_vault(id) selected = [] req = {} loop do res = backup_client.list_backup_vaults(req) selected += res.backup_vault_list.select do |v| v.backup_vault_name == id || v.backup_vault_arn == id end break if res.next_token.nil? req[:next_token] = res.next_token end selected.single_resource(id) rescue Aws::Backup::Errors::ResourceNotFoundException nil end |
#locked? ⇒ Boolean
79 80 81 |
# File 'lib/awspec/helper/finder/backup.rb', line 79 def locked? resource_via_client.locked end |
#select_backup_rule_by_plan_id(id) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/awspec/helper/finder/backup.rb', line 70 def select_backup_rule_by_plan_id(id) selected = [] req = { backup_plan_id: id } res = backup_client.get_backup_plan(req) selected = res.backup_plan.rules rescue Aws::Backup::Errors::ResourceNotFoundException nil end |