Skip to content

Commit

Permalink
Add subnets and vnets api endpoints and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
01100010011001010110010101110000 committed Jun 22, 2017
1 parent d196a3e commit 69cc3e0
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion app/models/foreman_azure_rm/azure_rm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/views/api/v2/compute_resources/available_subnets.rabl
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions app/views/api/v2/compute_resources/available_vnets.rabl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
collection @available_vnets

attribute :name, :id, :location, :resource_group, :dns_servers, :subnets, :address_prefixes
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/foreman_azure_rm/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ForemanAzureRM
VERSION = '1.2.0'.freeze
VERSION = '1.3.0'.freeze
end

0 comments on commit 69cc3e0

Please sign in to comment.