Class: Puppet_X::EnterpriseModules::Oci::AssociatedProperty

Inherits:
Puppet::Property
  • Object
show all
Extended by:
Config, Settings
Includes:
EasyType, EasyType::ArrayProperty, Config, Settings
Defined in:
lib/puppet_x/enterprisemodules/oci/associated_property.rb

Overview

Docs

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config

client_for, config_for_settings, default_tenant, determine_setting_for, proxy_config, retry_config, settings_for, tenant_config

Methods included from Settings

configuration, included, read_from_yaml, setting_for, settings, settings_file

Class Method Details

.association(assoc = nil) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 56

def self.association(assoc = nil)
  if assoc
    @assoc = assoc
  else
    @assoc
  end
end

.association_addObject



80
81
82
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 80

def self.association_add
  @assoc[association_name][:add]
end

.association_fromObject



68
69
70
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 68

def self.association_from
  @assoc[association_name][:from]
end

.association_modelObject



72
73
74
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 72

def self.association_model
  @assoc[association_name][:model]
end

.association_nameObject



64
65
66
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 64

def self.association_name
  @assoc.keys.first
end

.association_removeObject



84
85
86
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 84

def self.association_remove
  @assoc[association_name][:remove]
end

.association_toObject



76
77
78
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 76

def self.association_to
  @assoc[association_name][:to]
end

.client(tenant) ⇒ Object



48
49
50
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 48

def self.client(tenant)
  client_for(ServiceInfo.type_to_client(puppet_type), tenant)
end

.puppet_typeObject



52
53
54
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 52

def self.puppet_type
  to_s.split('::')[2].downcase.to_sym
end

Instance Method Details

#before_destroyObject

rubocop: enable Lint/OrAssignmentToConstant



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 25

def before_destroy
  #
  # Most of the time, we access the list by only differentiation on compartment_id. Sometimes
  # hower the first parameter is the availability_domain.
  #
  first_parameter = client.method("list_#{association_name}s").parameters[0]
  case first_parameter
  when [:req, :availability_domain]
    assoc_data = client.send("list_#{association_name}s",
                             provider.availability_domain,
                             provider.compartment_id,
                             association_from => provider.id).data
  when [:req, :compartment_id]
    assoc_data = client.send("list_#{association_name}s",
                             provider.compartment_id,
                             association_from => provider.id).data
  else
    fail 'Internal error, we only support compartment or availability_domain as first parameter'
  end
  assoc_ids = assoc_data.select { |e| ACTIVE_ASSOCIATIONS.include?(e.lifecycle_state) }.collect(&association_to)
  assoc_ids.each { |r| remove_record_by_id(r) }
end

#resolverObject



88
89
90
# File 'lib/puppet_x/enterprisemodules/oci/associated_property.rb', line 88

def resolver
  Puppet_X::EnterpriseModules::Oci::NameResolver.instance(resource.tenant)
end