fog-azure-rm 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/lib/fog/azurerm/compute.rb +6 -0
  4. data/lib/fog/azurerm/docs/compute.md +67 -11
  5. data/lib/fog/azurerm/docs/network.md +59 -0
  6. data/lib/fog/azurerm/docs/storage.md +107 -35
  7. data/lib/fog/azurerm/models/compute/server.rb +15 -9
  8. data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +78 -0
  9. data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +30 -0
  10. data/lib/fog/azurerm/models/network/express_route_circuit.rb +21 -21
  11. data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +21 -21
  12. data/lib/fog/azurerm/models/network/express_route_service_provider.rb +8 -8
  13. data/lib/fog/azurerm/models/network/network_security_rule.rb +27 -0
  14. data/lib/fog/azurerm/models/network/network_security_rules.rb +31 -0
  15. data/lib/fog/azurerm/models/network/subnet.rb +16 -12
  16. data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -6
  17. data/lib/fog/azurerm/models/storage/{containers.rb → directories.rb} +10 -10
  18. data/lib/fog/azurerm/models/storage/{container.rb → directory.rb} +13 -13
  19. data/lib/fog/azurerm/models/storage/file.rb +151 -0
  20. data/lib/fog/azurerm/models/storage/files.rb +31 -0
  21. data/lib/fog/azurerm/network.rb +6 -0
  22. data/lib/fog/azurerm/requests/compute/create_or_update_vm_extension.rb +63 -0
  23. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +45 -8
  24. data/lib/fog/azurerm/requests/compute/delete_vm_extension.rb +28 -0
  25. data/lib/fog/azurerm/requests/compute/get_vm_extension.rb +46 -0
  26. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +44 -31
  27. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_peering.rb +23 -13
  28. data/lib/fog/azurerm/requests/network/create_or_update_network_security_rule.rb +59 -0
  29. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway.rb +23 -15
  30. data/lib/fog/azurerm/requests/network/delete_network_security_rule.rb +30 -0
  31. data/lib/fog/azurerm/requests/network/get_available_ipaddresses_count.rb +23 -0
  32. data/lib/fog/azurerm/requests/network/get_network_security_rule.rb +47 -0
  33. data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +1 -1
  34. data/lib/fog/azurerm/requests/network/list_network_security_rules.rb +51 -0
  35. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +29 -0
  36. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +29 -0
  37. data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +25 -0
  38. data/lib/fog/azurerm/requests/storage/compare_blob.rb +73 -0
  39. data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
  40. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
  41. data/lib/fog/azurerm/requests/storage/delete_blob.rb +27 -0
  42. data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +56 -0
  43. data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +37 -9
  44. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +53 -0
  45. data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +2 -2
  46. data/lib/fog/azurerm/requests/storage/list_blobs.rb +82 -0
  47. data/lib/fog/azurerm/requests/storage/list_containers.rb +1 -1
  48. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +27 -0
  49. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +27 -0
  50. data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +4 -4
  51. data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +26 -0
  52. data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +3 -3
  53. data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +60 -0
  54. data/lib/fog/azurerm/storage.rb +26 -8
  55. data/lib/fog/azurerm/utilities/general.rb +14 -1
  56. data/lib/fog/azurerm/version.rb +1 -1
  57. data/test/api_stub.rb +8 -4
  58. data/test/api_stub/models/compute/virtual_machine_extension.rb +31 -0
  59. data/test/api_stub/models/network/network_security_rule.rb +30 -0
  60. data/test/api_stub/models/storage/{container.rb → directory.rb} +1 -1
  61. data/test/api_stub/models/storage/file.rb +178 -0
  62. data/test/api_stub/requests/compute/virtual_machine.rb +119 -0
  63. data/test/api_stub/requests/compute/virtual_machine_extension.rb +46 -0
  64. data/test/api_stub/requests/network/network_security_rule.rb +72 -0
  65. data/test/api_stub/requests/storage/{container.rb → directory.rb} +2 -2
  66. data/test/api_stub/requests/storage/file.rb +164 -0
  67. data/test/integration/availability_set.rb +6 -0
  68. data/test/integration/blob.rb +205 -0
  69. data/test/integration/credentials/azure.yml +4 -4
  70. data/test/integration/deployment.rb +9 -0
  71. data/test/integration/external_load_balancer.rb +9 -0
  72. data/test/integration/internal_load_balancer.rb +8 -0
  73. data/test/integration/network_security_group.rb +9 -0
  74. data/test/integration/network_security_rule.rb +86 -0
  75. data/test/integration/server.rb +62 -9
  76. data/test/integration/server_custom_image.rb +118 -0
  77. data/test/integration/subnet.rb +12 -1
  78. data/test/integration/virtual_machine_extension.rb +148 -0
  79. data/test/integration/virtual_network.rb +9 -1
  80. data/test/integration/virtual_network_gateway.rb +7 -29
  81. data/test/integration/virtual_network_gateway_connection_to_express_route.rb +116 -0
  82. data/test/models/compute/test_virtual_machine_extension.rb +61 -0
  83. data/test/models/compute/test_virtual_machine_extensions.rb +36 -0
  84. data/test/models/network/test_express_route_circuit.rb +4 -10
  85. data/test/models/network/test_express_route_circuit_peering.rb +4 -10
  86. data/test/models/network/test_network_interface.rb +4 -8
  87. data/test/models/network/test_network_security_rule.rb +14 -0
  88. data/test/models/network/test_network_security_rules.rb +42 -0
  89. data/test/models/network/test_subnet.rb +5 -0
  90. data/test/models/storage/test_directories.rb +106 -0
  91. data/test/models/storage/test_directory.rb +125 -0
  92. data/test/models/storage/test_file.rb +258 -0
  93. data/test/models/storage/test_files.rb +67 -0
  94. data/test/models/storage/test_storage_account.rb +2 -4
  95. data/test/requests/compute/test_create_virtual_machine.rb +19 -5
  96. data/test/requests/compute/test_create_vm_extension.rb +35 -0
  97. data/test/requests/compute/test_get_vm_extension.rb +26 -0
  98. data/test/requests/compute/test_update_vm_extension.rb +35 -0
  99. data/test/requests/network/test_create_or_update_network_security_rule.rb +28 -0
  100. data/test/requests/network/test_delete_network_security_rule.rb +25 -0
  101. data/test/requests/network/test_get_available_ipaddresses_count.rb +18 -0
  102. data/test/requests/network/test_get_network_security_rule.rb +26 -0
  103. data/test/requests/network/test_list_network_security_groups.rb +2 -2
  104. data/test/requests/network/test_list_network_security_rules.rb +26 -0
  105. data/test/requests/storage/test_acquire_blob_lease.rb +17 -0
  106. data/test/requests/storage/test_acquire_container_lease.rb +17 -0
  107. data/test/requests/storage/test_check_blob_exist.rb +17 -0
  108. data/test/requests/storage/test_compare_blob.rb +17 -0
  109. data/test/requests/storage/test_copy_blob.rb +17 -0
  110. data/test/requests/storage/test_copy_blob_from_uri.rb +17 -0
  111. data/test/requests/storage/test_create_container.rb +2 -2
  112. data/test/requests/storage/test_delete_blob.rb +22 -0
  113. data/test/requests/storage/test_delete_container.rb +1 -1
  114. data/test/requests/storage/test_download_blob_to_file.rb +25 -0
  115. data/test/requests/storage/test_get_blob_metadata.rb +2 -2
  116. data/test/requests/storage/test_get_blob_properties.rb +23 -0
  117. data/test/requests/storage/test_get_container_access_control_list.rb +2 -2
  118. data/test/requests/storage/test_get_container_metadata.rb +2 -2
  119. data/test/requests/storage/test_get_container_properties.rb +2 -2
  120. data/test/requests/storage/test_list_blobs_in_container.rb +23 -0
  121. data/test/requests/storage/test_list_containers.rb +2 -2
  122. data/test/requests/storage/test_release_blob_lease.rb +16 -0
  123. data/test/requests/storage/test_release_container_lease.rb +16 -0
  124. data/test/requests/storage/test_set_blob_metadata.rb +1 -1
  125. data/test/requests/storage/test_set_blob_properties.rb +16 -0
  126. data/test/requests/storage/test_set_container_metadata.rb +1 -1
  127. data/test/requests/storage/test_upload_block_blob_from_file.rb +23 -0
  128. data/test/test_helper.rb +116 -3
  129. metadata +73 -15
  130. data/.DS_Store +0 -0
  131. data/lib/fog/azurerm/fog_azure_rm_exception.rb +0 -13
  132. data/lib/fog/azurerm/models/storage/blob.rb +0 -13
  133. data/lib/fog/azurerm/models/storage/blobs.rb +0 -22
  134. data/test/api_stub/models/storage/blob.rb +0 -17
  135. data/test/api_stub/requests/storage/blob.rb +0 -24
  136. data/test/models/storage/test_blobs.rb +0 -32
  137. data/test/models/storage/test_container.rb +0 -67
  138. data/test/models/storage/test_containers.rb +0 -56
@@ -0,0 +1,78 @@
1
+ module Fog
2
+ module Compute
3
+ class AzureRM
4
+ # This class is giving implementation For Virtual Machine Extension
5
+ class VirtualMachineExtension < Fog::Model
6
+ identity :name
7
+ attribute :id
8
+ attribute :resource_group
9
+ attribute :location
10
+ attribute :vm_name
11
+ attribute :type
12
+ attribute :publisher
13
+ attribute :type_handler_version
14
+ attribute :auto_upgrade_minor_version
15
+ attribute :settings
16
+ attribute :protected_settings
17
+
18
+ def self.parse(vm_extension)
19
+ virtual_machine_extension = {}
20
+ virtual_machine_extension[:id] = vm_extension.id
21
+ virtual_machine_extension[:resource_group] = get_resource_group_from_id(vm_extension.id)
22
+ virtual_machine_extension[:name] = vm_extension.name
23
+ virtual_machine_extension[:location] = vm_extension.location
24
+ virtual_machine_extension[:vm_name] = get_virtual_machine_from_id(vm_extension.id)
25
+ virtual_machine_extension[:type] = vm_extension.virtual_machine_extension_type
26
+ virtual_machine_extension[:publisher] = vm_extension.publisher
27
+ virtual_machine_extension[:type_handler_version] = vm_extension.type_handler_version
28
+ virtual_machine_extension[:auto_upgrade_minor_version] = vm_extension.auto_upgrade_minor_version
29
+ virtual_machine_extension[:settings] = vm_extension.settings
30
+ virtual_machine_extension[:protected_settings] = vm_extension.protected_settings
31
+ virtual_machine_extension
32
+ end
33
+
34
+ def save
35
+ requires :resource_group, :location, :name, :vm_name, :type, :publisher, :type_handler_version, :settings
36
+ vm_extension_params = get_vm_extension_params
37
+ vm_extension = service.create_or_update_vm_extension(vm_extension_params)
38
+ merge_attributes(VirtualMachineExtension.parse(vm_extension))
39
+ end
40
+
41
+ def update(vm_extension_input)
42
+ validate_input(vm_extension_input)
43
+ merge_attributes(vm_extension_input) unless vm_extension_input.empty?
44
+ vm_extension_params = get_vm_extension_params
45
+ vm_extension = service.create_or_update_vm_extension(vm_extension_params)
46
+ merge_attributes(VirtualMachineExtension.parse(vm_extension))
47
+ end
48
+
49
+ def destroy
50
+ service.delete_vm_extension(resource_group, vm_name, name)
51
+ end
52
+
53
+ private
54
+
55
+ def validate_input(vm_extension_input)
56
+ invalid_attr = [:id, :resource_group, :location, :name, :vm_name, :type, :publisher]
57
+ result = invalid_attr & vm_extension_input.keys
58
+ raise 'Cannot modify the given attribute(s)' unless result.empty?
59
+ end
60
+
61
+ def get_vm_extension_params
62
+ {
63
+ resource_group: resource_group,
64
+ location: location,
65
+ name: name,
66
+ vm_name: vm_name,
67
+ type: type,
68
+ publisher: publisher,
69
+ type_handler_version: type_handler_version,
70
+ auto_upgrade_minor_version: auto_upgrade_minor_version,
71
+ settings: settings,
72
+ protected_settings: protected_settings
73
+ }
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,30 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/azurerm/models/compute/virtual_machine_extension'
3
+
4
+ module Fog
5
+ module Compute
6
+ class AzureRM
7
+ # This class gives the implementation for get for virtual machine extension
8
+ class VirtualMachineExtensions < Fog::Collection
9
+ model VirtualMachineExtension
10
+ attribute :resource_group
11
+ attribute :vm_name
12
+
13
+ def all
14
+ requires :resource_group, :vm_name
15
+ vm_extensions = []
16
+ service.get_virtual_machine(resource_group, vm_name).resources.each do |extension|
17
+ vm_extensions << VirtualMachineExtension.parse(extension)
18
+ end
19
+ load(vm_extensions)
20
+ end
21
+
22
+ def get(resource_group_name, virtual_machine_name, vm_extension_name)
23
+ vm_extension = service.get_vm_extension(resource_group_name, virtual_machine_name, vm_extension_name)
24
+ vm_extension_obj = VirtualMachineExtension.new(service: service)
25
+ vm_extension_obj.merge_attributes(VirtualMachineExtension.parse(vm_extension))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -22,36 +22,36 @@ module Fog
22
22
  attribute :peerings
23
23
 
24
24
  def self.parse(circuit)
25
- hash = {}
26
- hash['id'] = circuit.id
27
- hash['name'] = circuit.name
28
- hash['location'] = circuit.location
29
- hash['service_key'] = circuit.service_key
30
- hash['service_provider_notes'] = circuit.service_provider_notes
31
- hash['resource_group'] = get_resource_group_from_id(circuit.id)
32
- hash['resource_group'] = circuit.id.split('/')[4]
33
- hash['tags'] = circuit.tags
25
+ express_route_circuit = {}
26
+ express_route_circuit['id'] = circuit.id
27
+ express_route_circuit['name'] = circuit.name
28
+ express_route_circuit['location'] = circuit.location
29
+ express_route_circuit['service_key'] = circuit.service_key
30
+ express_route_circuit['service_provider_notes'] = circuit.service_provider_notes
31
+ express_route_circuit['resource_group'] = get_resource_group_from_id(circuit.id)
32
+ express_route_circuit['resource_group'] = circuit.id.split('/')[4]
33
+ express_route_circuit['tags'] = circuit.tags
34
34
  sku = circuit.sku
35
35
  unless sku.nil?
36
- hash['sku_name'] = sku.name
37
- hash['sku_tier'] = sku.tier
38
- hash['sku_family'] = sku.family
36
+ express_route_circuit['sku_name'] = sku.name
37
+ express_route_circuit['sku_tier'] = sku.tier
38
+ express_route_circuit['sku_family'] = sku.family
39
39
  end
40
- hash['provisioning_state'] = circuit.provisioning_state
41
- hash['circuit_provisioning_state'] = circuit.circuit_provisioning_state
42
- hash['service_provider_provisioning_state'] = circuit.service_provider_provisioning_state
40
+ express_route_circuit['provisioning_state'] = circuit.provisioning_state
41
+ express_route_circuit['circuit_provisioning_state'] = circuit.circuit_provisioning_state
42
+ express_route_circuit['service_provider_provisioning_state'] = circuit.service_provider_provisioning_state
43
43
  service_provider_properties = circuit.service_provider_properties
44
44
  unless service_provider_properties.nil?
45
- hash['service_provider_name'] = service_provider_properties.service_provider_name
46
- hash['peering_location'] = service_provider_properties.peering_location
47
- hash['bandwidth_in_mbps'] = service_provider_properties.bandwidth_in_mbps
45
+ express_route_circuit['service_provider_name'] = service_provider_properties.service_provider_name
46
+ express_route_circuit['peering_location'] = service_provider_properties.peering_location
47
+ express_route_circuit['bandwidth_in_mbps'] = service_provider_properties.bandwidth_in_mbps
48
48
  end
49
- hash['peerings'] = []
49
+ express_route_circuit['peerings'] = []
50
50
  circuit.peerings.each do |peering|
51
51
  circuit_peering = Fog::Network::AzureRM::ExpressRouteCircuitPeering.new
52
- hash['peerings'] << circuit_peering.merge_attributes(Fog::Network::AzureRM::ExpressRouteCircuitPeering.parse(peering))
52
+ express_route_circuit['peerings'] << circuit_peering.merge_attributes(Fog::Network::AzureRM::ExpressRouteCircuitPeering.parse(peering))
53
53
  end unless circuit.peerings.nil?
54
- hash
54
+ express_route_circuit
55
55
  end
56
56
 
57
57
  def save
@@ -25,35 +25,35 @@ module Fog
25
25
  attribute :routing_registry_name
26
26
 
27
27
  def self.parse(circuit_peering)
28
- hash = {}
29
- hash['id'] = circuit_peering.id
30
- hash['name'] = circuit_peering.name
31
- hash['resource_group'] = get_resource_group_from_id(circuit_peering.id)
32
- hash['circuit_name'] = circuit_peering.id.split('/')[8]
33
- hash['provisioning_state'] = circuit_peering.provisioning_state
34
- hash['peering_type'] = circuit_peering.peering_type
35
- hash['peer_asn'] = circuit_peering.peer_asn
36
- hash['azure_asn'] = circuit_peering.azure_asn
37
- hash['primary_azure_port'] = circuit_peering.primary_azure_port
38
- hash['secondary_azure_port'] = circuit_peering.secondary_azure_port
39
- hash['state'] = circuit_peering.state
40
- hash['primary_peer_address_prefix'] = circuit_peering.primary_peer_address_prefix
41
- hash['secondary_peer_address_prefix'] = circuit_peering.secondary_peer_address_prefix
42
- hash['vlan_id'] = circuit_peering.vlan_id
28
+ express_route_circuit_peering = {}
29
+ express_route_circuit_peering['id'] = circuit_peering.id
30
+ express_route_circuit_peering['name'] = circuit_peering.name
31
+ express_route_circuit_peering['resource_group'] = get_resource_group_from_id(circuit_peering.id)
32
+ express_route_circuit_peering['circuit_name'] = circuit_peering.id.split('/')[8]
33
+ express_route_circuit_peering['provisioning_state'] = circuit_peering.provisioning_state
34
+ express_route_circuit_peering['peering_type'] = circuit_peering.peering_type
35
+ express_route_circuit_peering['peer_asn'] = circuit_peering.peer_asn
36
+ express_route_circuit_peering['azure_asn'] = circuit_peering.azure_asn
37
+ express_route_circuit_peering['primary_azure_port'] = circuit_peering.primary_azure_port
38
+ express_route_circuit_peering['secondary_azure_port'] = circuit_peering.secondary_azure_port
39
+ express_route_circuit_peering['state'] = circuit_peering.state
40
+ express_route_circuit_peering['primary_peer_address_prefix'] = circuit_peering.primary_peer_address_prefix
41
+ express_route_circuit_peering['secondary_peer_address_prefix'] = circuit_peering.secondary_peer_address_prefix
42
+ express_route_circuit_peering['vlan_id'] = circuit_peering.vlan_id
43
43
 
44
44
  microsoft_peering_config = circuit_peering.microsoft_peering_config
45
45
  unless microsoft_peering_config.nil?
46
46
  public_prefixes = microsoft_peering_config.advertised_public_prefixes
47
- hash['advertised_public_prefixes'] = []
47
+ express_route_circuit_peering['advertised_public_prefixes'] = []
48
48
  public_prefixes.each do |public_prefix|
49
- hash['advertised_public_prefixes'] << public_prefix
49
+ express_route_circuit_peering['advertised_public_prefixes'] << public_prefix
50
50
  end unless public_prefixes.nil?
51
51
 
52
- hash['advertised_public_prefix_state'] = microsoft_peering_config.advertised_public_prefixes_state
53
- hash['customer_asn'] = microsoft_peering_config.customer_asn
54
- hash['routing_registry_name'] = microsoft_peering_config.routing_registry_name
52
+ express_route_circuit_peering['advertised_public_prefix_state'] = microsoft_peering_config.advertised_public_prefixes_state
53
+ express_route_circuit_peering['customer_asn'] = microsoft_peering_config.customer_asn
54
+ express_route_circuit_peering['routing_registry_name'] = microsoft_peering_config.routing_registry_name
55
55
  end
56
- hash
56
+ express_route_circuit_peering
57
57
  end
58
58
 
59
59
  def save
@@ -9,19 +9,19 @@ module Fog
9
9
  attribute :bandwidths_offered
10
10
 
11
11
  def self.parse(service_provider)
12
- hash = {}
13
- hash['id'] = service_provider.id
14
- hash['name'] = service_provider.name
12
+ express_route_service_provider = {}
13
+ express_route_service_provider['id'] = service_provider.id
14
+ express_route_service_provider['name'] = service_provider.name
15
15
 
16
- hash['peering_locations'] = []
16
+ express_route_service_provider['peering_locations'] = []
17
17
  service_provider.peering_locations.each do |peering_location|
18
- hash['peering_locations'] << peering_location
18
+ express_route_service_provider['peering_locations'] << peering_location
19
19
  end unless service_provider.peering_locations.nil?
20
- hash['bandwidths_offered'] = []
20
+ express_route_service_provider['bandwidths_offered'] = []
21
21
  service_provider.bandwidths_offered.each do |bandwidth_offered|
22
- hash['bandwidths_offered'] << bandwidth_offered
22
+ express_route_service_provider['bandwidths_offered'] << bandwidth_offered
23
23
  end unless service_provider.bandwidths_offered.nil?
24
- hash
24
+ express_route_service_provider
25
25
  end
26
26
  end
27
27
  end
@@ -34,6 +34,33 @@ module Fog
34
34
  hash['direction'] = nsr.direction
35
35
  hash
36
36
  end
37
+
38
+ def save
39
+ requires :name, :network_security_group_name, :resource_group, :protocol, :source_port_range, :destination_port_range, :source_address_prefix, :destination_address_prefix, :access, :priority, :direction
40
+ security_rule_params = get_security_rule_params
41
+ network_security_rule = service.create_or_update_network_security_rule(security_rule_params)
42
+ merge_attributes(NetworkSecurityRule.parse(network_security_rule))
43
+ end
44
+
45
+ def get_security_rule_params
46
+ {
47
+ name: name,
48
+ resource_group: resource_group,
49
+ protocol: protocol,
50
+ network_security_group_name: network_security_group_name,
51
+ source_port_range: source_port_range,
52
+ destination_port_range: destination_port_range,
53
+ source_address_prefix: source_address_prefix,
54
+ destination_address_prefix: destination_address_prefix,
55
+ access: access,
56
+ priority: priority,
57
+ direction: direction
58
+ }
59
+ end
60
+
61
+ def destroy
62
+ service.delete_network_security_rule(resource_group, network_security_group_name, name)
63
+ end
37
64
  end
38
65
  end
39
66
  end
@@ -0,0 +1,31 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/azurerm/models/network/network_security_rule'
3
+
4
+ module Fog
5
+ module Network
6
+ class AzureRM
7
+ # collection class for Network Security Rule
8
+ class NetworkSecurityRules < Fog::Collection
9
+ model Fog::Network::AzureRM::NetworkSecurityRule
10
+ attribute :resource_group
11
+ attribute :network_security_group_name
12
+
13
+ def all
14
+ requires :resource_group
15
+ requires :network_security_group_name
16
+ network_security_rules = []
17
+ service.list_network_security_rules(resource_group, network_security_group_name).each do |nsr|
18
+ network_security_rules << NetworkSecurityRule.parse(nsr)
19
+ end
20
+ load(network_security_rules)
21
+ end
22
+
23
+ def get(resource_group, network_security_group_name, name)
24
+ network_security_rule = service.get_network_security_rule(resource_group, network_security_group_name, name)
25
+ network_security_rule_obj = NetworkSecurityRule.new(service: service)
26
+ network_security_rule_obj.merge_attributes(NetworkSecurityRule.parse(network_security_rule))
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -13,18 +13,18 @@ module Fog
13
13
  attribute :ip_configurations_ids
14
14
 
15
15
  def self.parse(subnet)
16
- hash = {}
17
- hash['id'] = subnet.id
18
- hash['name'] = subnet.name
19
- hash['resource_group'] = get_resource_group_from_id(subnet.id)
20
- hash['virtual_network_name'] = get_virtual_network_from_id(subnet.id)
21
- hash['address_prefix'] = subnet.address_prefix
22
- hash['network_security_group_id'] = nil
23
- hash['network_security_group_id'] = subnet.network_security_group.id unless subnet.network_security_group.nil?
24
- hash['route_table_id'] = nil
25
- hash['route_table_id'] = subnet.route_table.id unless subnet.route_table.nil?
26
- hash['ip_configurations_ids'] = subnet.ip_configurations.map(&:id) unless subnet.ip_configurations.nil?
27
- hash
16
+ subnet_hash = {}
17
+ subnet_hash['id'] = subnet.id
18
+ subnet_hash['name'] = subnet.name
19
+ subnet_hash['resource_group'] = get_resource_group_from_id(subnet.id)
20
+ subnet_hash['virtual_network_name'] = get_virtual_network_from_id(subnet.id)
21
+ subnet_hash['address_prefix'] = subnet.address_prefix
22
+ subnet_hash['network_security_group_id'] = nil
23
+ subnet_hash['network_security_group_id'] = subnet.network_security_group.id unless subnet.network_security_group.nil?
24
+ subnet_hash['route_table_id'] = nil
25
+ subnet_hash['route_table_id'] = subnet.route_table.id unless subnet.route_table.nil?
26
+ subnet_hash['ip_configurations_ids'] = subnet.ip_configurations.map(&:id) unless subnet.ip_configurations.nil?
27
+ subnet_hash
28
28
  end
29
29
 
30
30
  def save
@@ -53,6 +53,10 @@ module Fog
53
53
  merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
54
54
  end
55
55
 
56
+ def get_available_ipaddresses_count(express_route_enabled)
57
+ service.get_available_ipaddresses_count(name, address_prefix, ip_configurations_ids, express_route_enabled)
58
+ end
59
+
56
60
  def destroy
57
61
  service.delete_subnet(resource_group, name, virtual_network_name)
58
62
  end
@@ -52,24 +52,24 @@ module Fog
52
52
 
53
53
  hash['ip_configurations'] = []
54
54
  network_gateway.ip_configurations.each do |ip_config|
55
- ip_configuration = Fog::Network::AzureRM::FrontendIPConfiguration.new
56
- hash['ip_configurations'] << ip_configuration.merge_attributes(Fog::Network::AzureRM::FrontendIPConfiguration.parse(ip_config))
55
+ ip_configuration = FrontendIPConfiguration.new
56
+ hash['ip_configurations'] << ip_configuration.merge_attributes(FrontendIPConfiguration.parse(ip_config))
57
57
  end unless network_gateway.ip_configurations.nil?
58
58
 
59
59
  unless network_gateway.vpn_client_configuration.nil?
60
- vpn_client_configuration = Fog::Network::AzureRM::VpnClientConfiguration.new
61
- hash['vpn_client_configuration'] = vpn_client_configuration.merge_attributes(Fog::Network::AzureRM::VpnClientConfiguration.parse(network_gateway.vpn_client_configuration))
60
+ vpn_client_configuration = VpnClientConfiguration.new
61
+ hash['vpn_client_configuration'] = vpn_client_configuration.merge_attributes(VpnClientConfiguration.parse(network_gateway.vpn_client_configuration))
62
62
  end
63
63
 
64
64
  hash
65
65
  end
66
66
 
67
67
  def save
68
- requires :name, :location, :resource_group, :gateway_type, :enable_bgp, :gateway_default_site
68
+ requires :name, :location, :resource_group, :gateway_type, :enable_bgp
69
69
  validate_ip_configurations(ip_configurations) unless ip_configurations.nil?
70
70
  virtual_network_params = virtual_gateway_parameters
71
71
  network_gateway = service.create_or_update_virtual_network_gateway(virtual_network_params)
72
- merge_attributes(Fog::Network::AzureRM::VirtualNetworkGateway.parse(network_gateway))
72
+ merge_attributes(VirtualNetworkGateway.parse(network_gateway))
73
73
  end
74
74
 
75
75
  def destroy
@@ -1,17 +1,17 @@
1
1
  require 'fog/core/collection'
2
- require 'fog/azurerm/models/storage/container'
2
+ require 'fog/azurerm/models/storage/directory'
3
3
 
4
4
  module Fog
5
5
  module Storage
6
6
  class AzureRM
7
7
  # This class is giving implementation of listing containers.
8
- class Containers < Fog::Collection
9
- model Fog::Storage::AzureRM::Container
8
+ class Directories < Fog::Collection
9
+ model Fog::Storage::AzureRM::Directory
10
10
 
11
- def all(options = { :metadata => true })
11
+ def all(options = { metadata: true })
12
12
  containers = []
13
13
  service.list_containers(options).each do |container|
14
- hash = Container.parse container
14
+ hash = Directory.parse container
15
15
  hash['public_access_level'] = 'unknown'
16
16
  containers << hash
17
17
  end
@@ -19,7 +19,7 @@ module Fog
19
19
  end
20
20
 
21
21
  def get(identity)
22
- container = all(prefix: identity, metadata: true).find { |item| item.name == identity }
22
+ container = all(prefix: identity, metadata: true).find { |item| item.key == identity }
23
23
  return if container.nil?
24
24
 
25
25
  access_control_list = service.get_container_access_control_list(identity)[0]
@@ -31,12 +31,12 @@ module Fog
31
31
  container
32
32
  end
33
33
 
34
- def get_container_metadata(name)
35
- service.get_container_metadata(name)
34
+ def get_metadata(name, options = {})
35
+ service.get_container_metadata(name, options)
36
36
  end
37
37
 
38
- def set_container_metadata(name, metadata)
39
- service.set_container_metadata(name, metadata)
38
+ def set_metadata(name, metadata, options = {})
39
+ service.set_container_metadata(name, metadata, options)
40
40
  end
41
41
  end
42
42
  end
@@ -2,8 +2,8 @@ module Fog
2
2
  module Storage
3
3
  class AzureRM
4
4
  # This class is giving implementation of create and delete a container.
5
- class Container < Fog::Model
6
- identity :name
5
+ class Directory < Fog::Model
6
+ identity :key, aliases: %w(Name name)
7
7
  attribute :etag
8
8
  attribute :last_modified
9
9
  attribute :lease_duration
@@ -13,31 +13,31 @@ module Fog
13
13
  attribute :public_access_level
14
14
 
15
15
  def create(options = {})
16
- requires :name
17
- merge_attributes(Container.parse(service.create_container(name, options)))
16
+ requires :key
17
+ merge_attributes(Directory.parse(service.create_container(key, options)))
18
18
  end
19
19
 
20
20
  alias save create
21
21
 
22
22
  def get_properties(options = { metadata: true })
23
- requires :name
24
- merge_attributes(Container.parse(service.get_container_properties(name, options)))
23
+ requires :key
24
+ merge_attributes(Directory.parse(service.get_container_properties(key, options)))
25
25
  end
26
26
 
27
- def get_access_control_list(options = {})
28
- requires :name
29
- merge_attributes(Container.parse(service.get_container_access_control_list(name, options)[0]))
27
+ def access_control_list(options = {})
28
+ requires :key
29
+ merge_attributes(Directory.parse(service.get_container_access_control_list(key, options)[0]))
30
30
  end
31
31
 
32
32
  def destroy(options = {})
33
- requires :name
34
- service.delete_container name, options
33
+ requires :key
34
+ service.delete_container key, options
35
35
  end
36
36
 
37
37
  def self.parse(container)
38
38
  hash = {}
39
39
  if container.is_a? Hash
40
- hash['name'] = container['name']
40
+ hash['key'] = container['name']
41
41
  hash['metadata'] = container['metadata']
42
42
  return hash unless container.key?('properties')
43
43
 
@@ -47,7 +47,7 @@ module Fog
47
47
  hash['lease_status'] = container['properties']['lease_status']
48
48
  hash['lease_state'] = container['properties']['lease_state']
49
49
  else
50
- hash['name'] = container.name
50
+ hash['key'] = container.name
51
51
  hash['metadata'] = container.metadata
52
52
  return hash unless container.respond_to?('properties')
53
53