Class: Fog::Network::AzureRM::TrafficManagerEndPoint

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

Overview

Traffic Manager End Point model for Network Service

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(endpoint) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/azurerm/models/network/traffic_manager_end_point.rb', line 20

def self.parse(endpoint)
  hash = {}
  hash['id'] = endpoint['id']
  hash['name'] = endpoint['name']
  hash['resource_group'] = endpoint['id'].split('/')[4]
  type = endpoint['type'].split('/')[2]
  type.slice!('Endpoints')
  hash['type'] = type
  hash['target_resource_id'] = endpoint['properties']['targetResourceId']
  hash['target'] = endpoint['properties']['target']
  hash['endpoint_status'] = endpoint['properties']['endpointStatus']
  hash['endpoint_monitor_status'] = endpoint['properties']['endpointMonitorStatus']
  hash['weight'] = endpoint['properties']['weight']
  hash['priority'] = endpoint['properties']['priority']
  hash['endpoint_location'] = endpoint['properties']['endpointLocation']
  hash['min_child_endpoints'] = endpoint['properties']['minChildEndpoints']
  hash
end

Instance Method Details

#destroyObject



57
58
59
# File 'lib/fog/azurerm/models/network/traffic_manager_end_point.rb', line 57

def destroy
  service.delete_traffic_manager_endpoint(resource_group, name, traffic_manager_profile_name, type)
end

#saveObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/azurerm/models/network/traffic_manager_end_point.rb', line 39

def save
  requires :name, :traffic_manager_profile_name, :resource_group, :type
  requires :target_resource_id if type.eql?('azure')
  requires :target, :endpoint_location if type.eql?('external')
  requires :target_resource_id, :endpoint_location, :min_child_endpoints if type.eql?('nested')

  if %w(azure external nested).select { |type| type if type.eql?(type) }.any?
    traffic_manager_endpoint = service.create_traffic_manager_endpoint(resource_group, name,
                                                                       traffic_manager_profile_name, type,
                                                                       target_resource_id, target, weight,
                                                                       priority, endpoint_location,
                                                                       min_child_endpoints)
    merge_attributes(Fog::Network::AzureRM::TrafficManagerEndPoint.parse(traffic_manager_endpoint))
  else
    raise(ArgumentError, ':type should be "azure", "external" or "nested"')
  end
end