diff --git a/CHANGELOG.md b/CHANGELOG.md index b218262..2ee71f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased] +## Unreleased + +## [1.3.0] ### Added - /compute_resources/:id/:region_id/available_sizes endpoint to list all sizes in an Azure region +- /compute_resources/:id/available_subnets endpoint to list all subnets +- /compute_resources/:id/available_vnets endpoint to list available vnets with complete information ### Fixed - Apply .freeze to version constant - Changelog hyperlink for to compare v1.1.1 to v1.2.0 @@ -36,8 +40,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Initial release - -[Unreleased]: https://github.com/01100010011001010110010101110000/foreman_azure_rm/compare/v1.2.0...HEAD +[Unreleased]: https://github.com/01100010011001010110010101110000/foreman_azure_rm/compare/v1.3.0...HEAD +[1.3.0]: https://github.com/01100010011001010110010101110000/foreman_azure_rm/compare/v1.2.0...v1.3.0 [1.2.0]: https://github.com/01100010011001010110010101110000/foreman_azure_rm/compare/v1.1.1...v1.2.0 [1.1.1]: https://github.com/01100010011001010110010101110000/foreman_azure_rm/compare/v1.0.0...v1.1.1 [1.0.0]: https://github.com/01100010011001010110010101110000/foreman_azure_rm/compare/v0.1.0...v1.0.0 diff --git a/app/controllers/foreman_azure_rm/concerns/compute_resources_controller_extensions.rb b/app/controllers/foreman_azure_rm/concerns/compute_resources_controller_extensions.rb index 0359dc6..e992d4a 100644 --- a/app/controllers/foreman_azure_rm/concerns/compute_resources_controller_extensions.rb +++ b/app/controllers/foreman_azure_rm/concerns/compute_resources_controller_extensions.rb @@ -16,9 +16,21 @@ def available_sizes render :available_sizes, :layout => 'api/v2/layouts/index_layout' end + def available_subnets + compute_resource = ComputeResource.find_by_id(params[:id]) + @available_subnets = compute_resource.available_subnets + render :available_subnets, :layout => 'api/v2/layouts/index_layout' + end + + def available_vnets + compute_resource = ComputeResource.find_by_id(params[:id]) + @available_vnets = compute_resource.available_vnets + render :available_vnets, :layout => 'api/v2/layouts/index_layout' + end + def action_permission case params[:action] - when 'available_resource_groups', 'available_sizes' + when 'available_resource_groups', 'available_sizes', 'available_subnets', 'available_vnets' :view else super diff --git a/app/models/foreman_azure_rm/azure_rm.rb b/app/models/foreman_azure_rm/azure_rm.rb index a6b2869..d5ea3e8 100644 --- a/app/models/foreman_azure_rm/azure_rm.rb +++ b/app/models/foreman_azure_rm/azure_rm.rb @@ -86,10 +86,19 @@ def host_interfaces_attrs(host) end end + def available_vnets(attr = {}) + virtual_networks + end + def available_networks(attr = {}) - networks + subnets + end + + def available_subnets + subnets end + # TODO Delete this def networks subnets end diff --git a/app/views/api/v2/compute_resources/available_subnets.rabl b/app/views/api/v2/compute_resources/available_subnets.rabl new file mode 100644 index 0000000..7925335 --- /dev/null +++ b/app/views/api/v2/compute_resources/available_subnets.rabl @@ -0,0 +1,3 @@ +collection @available_subnets + +attribute :name, :id, :virtual_network_name, :address_prefix, :network_security_group_id, :route_table_id, :ip_configuration_ids \ No newline at end of file diff --git a/app/views/api/v2/compute_resources/available_vnets.rabl b/app/views/api/v2/compute_resources/available_vnets.rabl new file mode 100644 index 0000000..7a8c1a4 --- /dev/null +++ b/app/views/api/v2/compute_resources/available_vnets.rabl @@ -0,0 +1,3 @@ +collection @available_vnets + +attribute :name, :id, :location, :resource_group, :dns_servers, :subnets, :address_prefixes \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7ec3838..5c319bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,8 @@ scope "(:apiv)", :module => :v2, :defaults => { :apiv => 'v2' }, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do resources :compute_resources, :except => [:new, :edit] do get :available_resource_groups, :on => :member + get :available_subnets, :on => :member + get :available_vnets, :on => :member get '(:region_id)/available_sizes', :to => 'compute_resources#available_sizes', :on => :member end end diff --git a/lib/foreman_azure_rm/version.rb b/lib/foreman_azure_rm/version.rb index 6be4354..a820bc5 100644 --- a/lib/foreman_azure_rm/version.rb +++ b/lib/foreman_azure_rm/version.rb @@ -1,3 +1,3 @@ module ForemanAzureRM - VERSION = '1.2.0'.freeze + VERSION = '1.3.0'.freeze end \ No newline at end of file