fog-azure-rm 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +9 -0
  4. data/lib/fog/azurerm/docs/compute.md +1 -1
  5. data/lib/fog/azurerm/docs/sql.md +39 -0
  6. data/lib/fog/azurerm/docs/storage.md +89 -2
  7. data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -7
  8. data/lib/fog/azurerm/models/compute/availability_sets.rb +4 -6
  9. data/lib/fog/azurerm/models/compute/servers.rb +5 -8
  10. data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +0 -3
  11. data/lib/fog/azurerm/models/dns/record_sets.rb +5 -9
  12. data/lib/fog/azurerm/models/dns/zones.rb +4 -7
  13. data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +0 -3
  14. data/lib/fog/azurerm/models/network/express_route_circuit_peerings.rb +5 -9
  15. data/lib/fog/azurerm/models/network/express_route_circuits.rb +4 -7
  16. data/lib/fog/azurerm/models/network/express_route_service_providers.rb +2 -5
  17. data/lib/fog/azurerm/models/network/load_balancers.rb +4 -7
  18. data/lib/fog/azurerm/models/network/local_network_gateways.rb +0 -3
  19. data/lib/fog/azurerm/models/network/network_interfaces.rb +4 -7
  20. data/lib/fog/azurerm/models/network/network_security_groups.rb +4 -7
  21. data/lib/fog/azurerm/models/network/network_security_rules.rb +2 -6
  22. data/lib/fog/azurerm/models/network/public_ips.rb +4 -7
  23. data/lib/fog/azurerm/models/network/subnets.rb +5 -9
  24. data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +0 -3
  25. data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +4 -7
  26. data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -7
  27. data/lib/fog/azurerm/models/resources/azure_resources.rb +2 -5
  28. data/lib/fog/azurerm/models/resources/deployments.rb +4 -7
  29. data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -7
  30. data/lib/fog/azurerm/models/sql/firewall_rule.rb +52 -0
  31. data/lib/fog/azurerm/models/sql/firewall_rules.rb +28 -0
  32. data/lib/fog/azurerm/models/storage/data_disk.rb +1 -0
  33. data/lib/fog/azurerm/models/storage/directories.rb +1 -4
  34. data/lib/fog/azurerm/models/storage/files.rb +1 -4
  35. data/lib/fog/azurerm/models/storage/recovery_vault.rb +50 -0
  36. data/lib/fog/azurerm/models/storage/recovery_vaults.rb +27 -0
  37. data/lib/fog/azurerm/models/storage/storage_account.rb +23 -4
  38. data/lib/fog/azurerm/models/storage/storage_accounts.rb +5 -7
  39. data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +4 -4
  40. data/lib/fog/azurerm/requests/sql/create_or_update_firewall_rule.rb +56 -0
  41. data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +4 -5
  42. data/lib/fog/azurerm/requests/sql/delete_database.rb +4 -4
  43. data/lib/fog/azurerm/requests/sql/delete_firewall_rule.rb +36 -0
  44. data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +2 -2
  45. data/lib/fog/azurerm/requests/sql/get_database.rb +2 -2
  46. data/lib/fog/azurerm/requests/sql/get_firewall_rule.rb +43 -0
  47. data/lib/fog/azurerm/requests/sql/get_sql_server.rb +2 -2
  48. data/lib/fog/azurerm/requests/sql/list_databases.rb +2 -2
  49. data/lib/fog/azurerm/requests/sql/list_firewall_rules.rb +55 -0
  50. data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +2 -2
  51. data/lib/fog/azurerm/requests/storage/create_disk.rb +36 -0
  52. data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +54 -0
  53. data/lib/fog/azurerm/requests/storage/create_storage_account.rb +13 -2
  54. data/lib/fog/azurerm/requests/storage/delete_disk.rb +5 -9
  55. data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +35 -0
  56. data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +60 -0
  57. data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +61 -0
  58. data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +56 -0
  59. data/lib/fog/azurerm/requests/storage/get_backup_container.rb +53 -0
  60. data/lib/fog/azurerm/requests/storage/get_backup_item.rb +58 -0
  61. data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +53 -0
  62. data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +64 -0
  63. data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +49 -0
  64. data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +48 -0
  65. data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +36 -0
  66. data/lib/fog/azurerm/requests/storage/start_backup.rb +54 -0
  67. data/lib/fog/azurerm/requests/storage/update_storage_account.rb +59 -0
  68. data/lib/fog/azurerm/sql.rb +9 -0
  69. data/lib/fog/azurerm/storage.rb +24 -0
  70. data/lib/fog/azurerm/version.rb +1 -1
  71. data/rake-script.sh +8 -0
  72. data/rakefile +11 -3
  73. data/test/api_stub.rb +4 -0
  74. data/test/api_stub/models/sql/sql_firewall_rule.rb +22 -0
  75. data/test/api_stub/models/storage/recovery_vault.rb +23 -0
  76. data/test/api_stub/requests/sql/firewall_rule.rb +46 -0
  77. data/test/api_stub/requests/storage/recovery_vault.rb +189 -0
  78. data/test/api_stub/requests/storage/storageaccount.rb +2 -1
  79. data/test/integration/container.rb +4 -3
  80. data/test/integration/data_disk.rb +77 -0
  81. data/test/integration/express_route_circuit.rb +9 -9
  82. data/test/integration/server.rb +9 -2
  83. data/test/integration/sql_server.rb +35 -0
  84. data/test/integration/storage_account.rb +9 -1
  85. data/test/models/sql/test_firewall_rule.rb +54 -0
  86. data/test/models/sql/test_firewall_rules.rb +41 -0
  87. data/test/models/storage/test_recovery_vault.rb +61 -0
  88. data/test/models/storage/test_recovery_vaults.rb +47 -0
  89. data/test/models/storage/test_storage_account.rb +8 -1
  90. data/test/requests/sql/test_create_or_update_firewall_rule.rb +27 -0
  91. data/test/requests/sql/test_delete_firewall_rule.rb +34 -0
  92. data/test/requests/sql/test_get_firewall_rule.rb +35 -0
  93. data/test/requests/sql/test_list_firewall_rules.rb +35 -0
  94. data/test/requests/storage/test_create_disk.rb +17 -0
  95. data/test/requests/storage/test_create_recovery_vault.rb +35 -0
  96. data/test/requests/storage/test_delete_disk.rb +23 -0
  97. data/test/requests/storage/test_delete_recovery_vault.rb +34 -0
  98. data/test/requests/storage/test_disable_backup_protection.rb +52 -0
  99. data/test/requests/storage/test_enable_backup_protection.rb +66 -0
  100. data/test/requests/storage/test_get_all_backup_jobs.rb +35 -0
  101. data/test/requests/storage/test_get_backup_container.rb +35 -0
  102. data/test/requests/storage/test_get_backup_item.rb +35 -0
  103. data/test/requests/storage/test_get_backup_job_for_vm.rb +26 -0
  104. data/test/requests/storage/test_get_backup_protection_policy.rb +35 -0
  105. data/test/requests/storage/test_get_recovery_vault.rb +35 -0
  106. data/test/requests/storage/test_list_recovery_vault.rb +35 -0
  107. data/test/requests/storage/test_set_recovery_vault_context.rb +34 -0
  108. data/test/requests/storage/test_start_backup.rb +55 -0
  109. data/test/requests/storage/test_update_storage_account.rb +34 -0
  110. data/test/smoke_tests/compute/test_resource_group_smoke.rb +34 -24
  111. data/test/test_helper.rb +26 -0
  112. metadata +55 -2
@@ -1,17 +1,14 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/express_route_service_provider'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # ExpressRouteServiceProvider collection class for Network Service
8
5
  class ExpressRouteServiceProviders < Fog::Collection
9
- model Fog::Network::AzureRM::ExpressRouteServiceProvider
6
+ model ExpressRouteServiceProvider
10
7
 
11
8
  def all
12
9
  express_route_service_providers = []
13
10
  service.list_express_route_service_providers.each do |service_provider|
14
- express_route_service_providers << Fog::Network::AzureRM::ExpressRouteServiceProvider.parse(service_provider)
11
+ express_route_service_providers << ExpressRouteServiceProvider.parse(service_provider)
15
12
  end
16
13
  load(express_route_service_providers)
17
14
  end
@@ -1,27 +1,24 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/load_balancer'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # LoadBalancers collection class for Network Service
8
5
  class LoadBalancers < Fog::Collection
9
- model Fog::Network::AzureRM::LoadBalancer
6
+ model LoadBalancer
10
7
  attribute :resource_group
11
8
 
12
9
  def all
13
10
  requires :resource_group
14
11
  load_balancers = []
15
12
  service.list_load_balancers(resource_group).each do |load_balancer|
16
- load_balancers << Fog::Network::AzureRM::LoadBalancer.parse(load_balancer)
13
+ load_balancers << LoadBalancer.parse(load_balancer)
17
14
  end
18
15
  load(load_balancers)
19
16
  end
20
17
 
21
18
  def get(resource_group_name, load_balancer_name)
22
19
  lb = service.get_load_balancer(resource_group_name, load_balancer_name)
23
- load_balancer = Fog::Network::AzureRM::LoadBalancer.new(service: service)
24
- load_balancer.merge_attributes(Fog::Network::AzureRM::LoadBalancer.parse(lb))
20
+ load_balancer = LoadBalancer.new(service: service)
21
+ load_balancer.merge_attributes(LoadBalancer.parse(lb))
25
22
  end
26
23
  end
27
24
  end
@@ -1,6 +1,3 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/local_network_gateway'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
@@ -1,27 +1,24 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/network_interface'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # NetworkInterfaces collection class for Network Service
8
5
  class NetworkInterfaces < Fog::Collection
9
- model Fog::Network::AzureRM::NetworkInterface
6
+ model NetworkInterface
10
7
  attribute :resource_group
11
8
 
12
9
  def all
13
10
  requires :resource_group
14
11
  network_interfaces = []
15
12
  service.list_network_interfaces(resource_group).each do |nic|
16
- network_interfaces << Fog::Network::AzureRM::NetworkInterface.parse(nic)
13
+ network_interfaces << NetworkInterface.parse(nic)
17
14
  end
18
15
  load(network_interfaces)
19
16
  end
20
17
 
21
18
  def get(resource_group_name, name)
22
19
  nic = service.get_network_interface(resource_group_name, name)
23
- network_interface_card = Fog::Network::AzureRM::NetworkInterface.new(service: service)
24
- network_interface_card.merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
20
+ network_interface_card = NetworkInterface.new(service: service)
21
+ network_interface_card.merge_attributes(NetworkInterface.parse(nic))
25
22
  end
26
23
  end
27
24
  end
@@ -1,27 +1,24 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/network_security_group'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # collection class for Network Security Group
8
5
  class NetworkSecurityGroups < Fog::Collection
9
- model Fog::Network::AzureRM::NetworkSecurityGroup
6
+ model NetworkSecurityGroup
10
7
  attribute :resource_group
11
8
 
12
9
  def all
13
10
  requires :resource_group
14
11
  network_security_groups = []
15
12
  service.list_network_security_groups(resource_group).each do |nsg|
16
- network_security_groups << Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg)
13
+ network_security_groups << NetworkSecurityGroup.parse(nsg)
17
14
  end
18
15
  load(network_security_groups)
19
16
  end
20
17
 
21
18
  def get(resource_group, name)
22
19
  nsg = service.get_network_security_group(resource_group, name)
23
- network_security_group = Fog::Network::AzureRM::NetworkSecurityGroup.new(service: service)
24
- network_security_group.merge_attributes(Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg))
20
+ network_security_group = NetworkSecurityGroup.new(service: service)
21
+ network_security_group.merge_attributes(NetworkSecurityGroup.parse(nsg))
25
22
  end
26
23
  end
27
24
  end
@@ -1,18 +1,14 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/network_security_rule'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # collection class for Network Security Rule
8
5
  class NetworkSecurityRules < Fog::Collection
9
- model Fog::Network::AzureRM::NetworkSecurityRule
6
+ model NetworkSecurityRule
10
7
  attribute :resource_group
11
8
  attribute :network_security_group_name
12
9
 
13
10
  def all
14
- requires :resource_group
15
- requires :network_security_group_name
11
+ requires :resource_group, :network_security_group_name
16
12
  network_security_rules = []
17
13
  service.list_network_security_rules(resource_group, network_security_group_name).each do |nsr|
18
14
  network_security_rules << NetworkSecurityRule.parse(nsr)
@@ -1,27 +1,24 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/public_ip'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # PublicIPs collection class for Network Service
8
5
  class PublicIps < Fog::Collection
9
- model Fog::Network::AzureRM::PublicIp
6
+ model PublicIp
10
7
  attribute :resource_group
11
8
 
12
9
  def all
13
10
  requires :resource_group
14
11
  public_ips = []
15
12
  service.list_public_ips(resource_group).each do |pip|
16
- public_ips << Fog::Network::AzureRM::PublicIp.parse(pip)
13
+ public_ips << PublicIp.parse(pip)
17
14
  end
18
15
  load(public_ips)
19
16
  end
20
17
 
21
18
  def get(resource_group_name, public_ip_name)
22
19
  public_ip = service.get_public_ip(resource_group_name, public_ip_name)
23
- public_ip_object = Fog::Network::AzureRM::PublicIp.new(service: service)
24
- public_ip_object.merge_attributes(Fog::Network::AzureRM::PublicIp.parse(public_ip))
20
+ public_ip_object = PublicIp.new(service: service)
21
+ public_ip_object.merge_attributes(PublicIp.parse(public_ip))
25
22
  end
26
23
 
27
24
  def check_if_exists(resource_group, name)
@@ -1,29 +1,25 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/subnet'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # Subnet collection for network service
8
5
  class Subnets < Fog::Collection
9
- model Fog::Network::AzureRM::Subnet
6
+ model Subnet
10
7
  attribute :resource_group
11
8
  attribute :virtual_network_name
12
9
 
13
10
  def all
14
- requires :resource_group
15
- requires :virtual_network_name
11
+ requires :resource_group, :virtual_network_name
16
12
  subnets = []
17
13
  service.list_subnets(resource_group, virtual_network_name).each do |subnet|
18
- subnets << Fog::Network::AzureRM::Subnet.parse(subnet)
14
+ subnets << Subnet.parse(subnet)
19
15
  end
20
16
  load(subnets)
21
17
  end
22
18
 
23
19
  def get(resource_group, virtual_network_name, subnet_name)
24
20
  subnet = service.get_subnet(resource_group, virtual_network_name, subnet_name)
25
- subnet_object = Fog::Network::AzureRM::Subnet.new(service: service)
26
- subnet_object.merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
21
+ subnet_object = Subnet.new(service: service)
22
+ subnet_object.merge_attributes(Subnet.parse(subnet))
27
23
  end
28
24
  end
29
25
  end
@@ -1,6 +1,3 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/virtual_network_gateway_connection'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
@@ -1,27 +1,24 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/virtual_network_gateway'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # VirtualNetworkGateways collection class for Network Service
8
5
  class VirtualNetworkGateways < Fog::Collection
9
- model Fog::Network::AzureRM::VirtualNetworkGateway
6
+ model VirtualNetworkGateway
10
7
  attribute :resource_group
11
8
 
12
9
  def all
13
10
  requires :resource_group
14
11
  network_gateways = []
15
12
  service.list_virtual_network_gateways(resource_group).each do |gateway|
16
- network_gateways << Fog::Network::AzureRM::VirtualNetworkGateway.parse(gateway)
13
+ network_gateways << VirtualNetworkGateway.parse(gateway)
17
14
  end
18
15
  load(network_gateways)
19
16
  end
20
17
 
21
18
  def get(resource_group_name, name)
22
19
  network_gateway = service.get_virtual_network_gateway(resource_group_name, name)
23
- virtual_network_gateway = Fog::Network::AzureRM::VirtualNetworkGateway.new(service: service)
24
- virtual_network_gateway.merge_attributes(Fog::Network::AzureRM::VirtualNetworkGateway.parse(network_gateway))
20
+ virtual_network_gateway = VirtualNetworkGateway.new(service: service)
21
+ virtual_network_gateway.merge_attributes(VirtualNetworkGateway.parse(network_gateway))
25
22
  end
26
23
  end
27
24
  end
@@ -1,28 +1,25 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/virtual_network'
3
-
4
1
  module Fog
5
2
  module Network
6
3
  class AzureRM
7
4
  # This class is giving implementation of all/list, get and
8
5
  # check name availability for virtual network.
9
6
  class VirtualNetworks < Fog::Collection
10
- model Fog::Network::AzureRM::VirtualNetwork
7
+ model VirtualNetwork
11
8
  attribute :resource_group
12
9
 
13
10
  def all
14
11
  requires :resource_group
15
12
  virtual_networks = []
16
13
  service.list_virtual_networks(resource_group).each do |vnet|
17
- virtual_networks << Fog::Network::AzureRM::VirtualNetwork.parse(vnet)
14
+ virtual_networks << VirtualNetwork.parse(vnet)
18
15
  end
19
16
  load(virtual_networks)
20
17
  end
21
18
 
22
19
  def get(resource_group_name, virtual_network_name)
23
20
  virtual_network = service.get_virtual_network(resource_group_name, virtual_network_name)
24
- virtual_network_object = Fog::Network::AzureRM::VirtualNetwork.new(service: service)
25
- virtual_network_object.merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
21
+ virtual_network_object = VirtualNetwork.new(service: service)
22
+ virtual_network_object.merge_attributes(VirtualNetwork.parse(virtual_network))
26
23
  end
27
24
 
28
25
  def check_if_exists(resource_group, name)
@@ -1,6 +1,3 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/resources/azure_resource'
3
-
4
1
  module Fog
5
2
  module Resources
6
3
  class AzureRM
@@ -8,13 +5,13 @@ module Fog
8
5
  class AzureResources < Fog::Collection
9
6
  attribute :tag_name
10
7
  attribute :tag_value
11
- model Fog::Resources::AzureRM::AzureResource
8
+ model AzureResource
12
9
 
13
10
  def all
14
11
  unless tag_name.nil? && tag_value.nil?
15
12
  resources = []
16
13
  service.list_tagged_resources(tag_name, tag_value).each do |resource|
17
- resources << Fog::Resources::AzureRM::AzureResource.parse(resource)
14
+ resources << AzureResource.parse(resource)
18
15
  end
19
16
  resources.inspect
20
17
  return load(resources)
@@ -1,27 +1,24 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/resources/deployment'
3
-
4
1
  module Fog
5
2
  module Resources
6
3
  class AzureRM
7
4
  # Deployments collection class
8
5
  class Deployments < Fog::Collection
9
6
  attribute :resource_group
10
- model Fog::Resources::AzureRM::Deployment
7
+ model Deployment
11
8
 
12
9
  def all
13
10
  requires :resource_group
14
11
  deployments = []
15
12
  service.list_deployments(resource_group).each do |deployment|
16
- deployments << Fog::Resources::AzureRM::Deployment.parse(deployment)
13
+ deployments << Deployment.parse(deployment)
17
14
  end
18
15
  load(deployments)
19
16
  end
20
17
 
21
18
  def get(resource_group_name, deployment_name)
22
19
  deployment = service.get_deployment(resource_group_name, deployment_name)
23
- deployment_object = Fog::Resources::AzureRM::Deployment.new(service: service)
24
- deployment_object.merge_attributes(Fog::Resources::AzureRM::Deployment.parse(deployment))
20
+ deployment_object = Deployment.new(service: service)
21
+ deployment_object.merge_attributes(Deployment.parse(deployment))
25
22
  end
26
23
  end
27
24
  end
@@ -1,26 +1,23 @@
1
- require 'fog/core/collection'
2
- require 'fog/azurerm/models/resources/resource_group'
3
-
4
1
  module Fog
5
2
  module Resources
6
3
  class AzureRM
7
4
  # This class is giving implementation of all/list, get and
8
5
  # check name availability for resource groups.
9
6
  class ResourceGroups < Fog::Collection
10
- model Fog::Resources::AzureRM::ResourceGroup
7
+ model ResourceGroup
11
8
 
12
9
  def all
13
10
  resource_groups = []
14
11
  service.list_resource_groups.each do |resource_group|
15
- resource_groups.push(Fog::Resources::AzureRM::ResourceGroup.parse(resource_group))
12
+ resource_groups.push(ResourceGroup.parse(resource_group))
16
13
  end
17
14
  load(resource_groups)
18
15
  end
19
16
 
20
17
  def get(resource_group_name)
21
18
  resource_group = service.get_resource_group(resource_group_name)
22
- resource_group_object = Fog::Resources::AzureRM::ResourceGroup.new(service: service)
23
- resource_group_object.merge_attributes(Fog::Resources::AzureRM::ResourceGroup.parse(resource_group))
19
+ resource_group_object = ResourceGroup.new(service: service)
20
+ resource_group_object.merge_attributes(ResourceGroup.parse(resource_group))
24
21
  end
25
22
  end
26
23
  end
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Sql
3
+ class AzureRM
4
+ # Sql Server model for Server Firewall Rule Service
5
+ class FirewallRule < Fog::Model
6
+ identity :name
7
+ attribute :id
8
+ attribute :type
9
+ attribute :resource_group
10
+ attribute :location
11
+ attribute :start_ip
12
+ attribute :end_ip
13
+ attribute :server_name
14
+
15
+ def self.parse(firewall)
16
+ {
17
+ id: firewall['id'],
18
+ type: firewall['type'],
19
+ name: firewall['name'],
20
+ location: firewall['location'],
21
+ resource_group: get_resource_group_from_id(firewall['id']),
22
+ server_name: get_server_name_from_id(firewall['id']),
23
+ start_ip: firewall['properties']['startIpAddress'],
24
+ end_ip: firewall['properties']['endIpAddress']
25
+ }
26
+ end
27
+
28
+ def save
29
+ requires :resource_group, :server_name, :name, :start_ip, :end_ip
30
+ firewall_rule = service.create_or_update_firewall_rule(firewall_params)
31
+ merge_attributes(FirewallRule.parse(firewall_rule))
32
+ end
33
+
34
+ def destroy
35
+ service.delete_firewall_rule(resource_group, server_name, name)
36
+ end
37
+
38
+ private
39
+
40
+ def firewall_params
41
+ {
42
+ resource_group: resource_group,
43
+ server_name: server_name,
44
+ name: name,
45
+ start_ip: start_ip,
46
+ end_ip: end_ip
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Sql
3
+ class AzureRM
4
+ # Sql Server Collection for Firewall Rules Service
5
+ class FirewallRules < Fog::Collection
6
+ attribute :resource_group
7
+ attribute :server_name
8
+ model FirewallRule
9
+
10
+ def all
11
+ requires :resource_group, :server_name
12
+
13
+ firewall_rules = []
14
+ service.list_firewall_rules(resource_group, server_name).each do |firewall_rule|
15
+ firewall_rules << FirewallRule.parse(firewall_rule)
16
+ end
17
+ load(firewall_rules)
18
+ end
19
+
20
+ def get(resource_group, server_name, rule_name)
21
+ firewall_rule = service.get_firewall_rule(resource_group, server_name, rule_name)
22
+ firewall_rule_obj = FirewallRule.new(service: service)
23
+ firewall_rule_obj.merge_attributes(FirewallRule.parse(firewall_rule))
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end