Class: Fog::TrafficManager::AzureRM::TrafficManagerProfile

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb

Overview

Traffic Manager Profile model for TrafficManager Service

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(profile) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb', line 22

def self.parse(profile)
  traffic_manager_profile = get_hash_from_object(profile)

  if profile.dns_config
    traffic_manager_profile['relative_name'] = profile.dns_config.relative_name
    traffic_manager_profile['fqdn'] = profile.dns_config.fqdn
    traffic_manager_profile['ttl'] = profile.dns_config.ttl
  end

  if profile.monitor_config
    traffic_manager_profile['profile_monitor_status'] = profile.monitor_config.profile_monitor_status
    traffic_manager_profile['protocol'] = profile.monitor_config.protocol
    traffic_manager_profile['port'] = profile.monitor_config.port
    traffic_manager_profile['path'] = profile.monitor_config.path
  end
  traffic_manager_profile['resource_group'] = get_resource_group_from_id(profile.id)
  traffic_manager_profile['endpoints'] = []
  profile.endpoints.each do |endpoint|
    end_point = Fog::TrafficManager::AzureRM::TrafficManagerEndPoint.new
    traffic_manager_profile['endpoints'] << end_point.merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerEndPoint.parse(endpoint))
  end
  traffic_manager_profile
end

Instance Method Details

#destroyObject



53
54
55
# File 'lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb', line 53

def destroy
  service.delete_traffic_manager_profile(resource_group, name)
end

#saveObject



46
47
48
49
50
51
# File 'lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb', line 46

def save
  requires :name, :resource_group, :traffic_routing_method, :relative_name, :ttl,
           :protocol, :port, :path
  traffic_manager_profile = service.create_or_update_traffic_manager_profile(traffic_manager_profile_hash)
  merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerProfile.parse(traffic_manager_profile))
end

#update(profile_params) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb', line 57

def update(profile_params)
  validate_input(profile_params)
  profile_params[:endpoints] = endpoints.map { |endpoint| get_hash_from_object(endpoint)['attributes'] } unless endpoints.nil?
  merge_attributes(profile_params)
  profile = service.create_or_update_traffic_manager_profile(traffic_manager_profile_hash)
  merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerProfile.parse(profile))
end