Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #420 from coliver/aws-iam-additions

Aws iam additions
  • Loading branch information...
commit ab9a2eb28b36e81eb92d4e2a0c15d256183e5758 2 parents ddfe5d5 + 84e6d1a
Wesley Beary authored
View
4 lib/fog/aws/iam.rb
@@ -8,10 +8,12 @@ class IAM < Fog::Service
request_path 'fog/aws/requests/iam'
request :add_user_to_group
request :create_access_key
+ request :create_account_alias
request :create_group
request :create_user
request :create_login_profile
request :delete_access_key
+ request :delete_account_alias
request :delete_group
request :delete_group_policy
request :delete_login_profile
@@ -23,7 +25,9 @@ class IAM < Fog::Service
request :get_user
request :get_user_policy
request :get_group
+ request :get_group_policy
request :list_access_keys
+ request :list_account_aliases
request :list_groups
request :list_groups_for_user
request :list_group_policies
View
4 lib/fog/aws/models/rds/server.rb
@@ -28,6 +28,7 @@ class Server < Fog::Model
attribute :db_security_groups, :aliases => 'DBSecurityGroups'
attribute :db_parameter_groups, :aliases => 'DBParameterGroups'
attribute :backup_retention_period, :aliases => 'BackupRetentionPeriod', :type => :integer
+ attribute :license_model, :aliases => 'LicenseModel'
attr_accessor :password, :parameter_group_name, :security_group_names, :port
@@ -89,7 +90,8 @@ def save
'MasterUserPassword' => password,
'PreferredMaintenanceWindow' => preferred_maintenance_window,
'PreferredBackupWindow' => preferred_backup_window,
- 'MultiAZ' => multi_az
+ 'MultiAZ' => multi_az,
+ 'LicenseModel' => license_model
}
options.delete_if {|key, value| value.nil?}
View
24 lib/fog/aws/parsers/auto_scaling/describe_policies.rb
@@ -10,6 +10,7 @@ def reset
reset_alarm
@results = { 'ScalingPolicies' => [] }
@response = { 'DescribePoliciesResult' => {}, 'ResponseMetadata' => {} }
+ @in_alarms = false
end
def reset_scaling_policy
@@ -19,20 +20,24 @@ def reset_scaling_policy
def reset_alarm
@alarm = {}
end
+
+ def start_element(name, attrs = [])
+ super
+ case name
+ when 'Alarms'
+ @in_alarms = true
+ end
+ end
def end_element(name)
case name
- when 'member'
- @scaling_policy['Alarms'] << @alarm
- reset_alarm
-
when 'AlarmARN', 'AlarmName'
@alarm[name] = value
when 'AdjustmentType', 'AutoScalingGroupName', 'PolicyARN', 'PolicyName'
@scaling_policy[name] = value
when 'Cooldown', 'ScalingAdjustment'
- @scaling_adjustment[name] = value.to_i
+ @scaling_policy[name] = value.to_i
when 'NextToken'
@results[name] = value
@@ -42,6 +47,15 @@ def end_element(name)
when 'DescribePoliciesResponse'
@response['DescribePoliciesResult'] = @results
+
+ when 'Alarms'
+ if @in_alarms == true
+ @scaling_policy['Alarms'] << @alarm
+ reset_alarm
+ end
+ when 'member'
+ @results['ScalingPolicies'] << @scaling_policy
+ reset_scaling_policy
end
end
View
27 lib/fog/aws/parsers/iam/get_group_policy.rb
@@ -0,0 +1,27 @@
+module Fog
+ module Parsers
+ module AWS
+ module IAM
+
+ class GetGroupPolicy < Fog::Parsers::Base
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_GetGroupPolicy.html
+
+ def reset
+ @response = {}
+ end
+
+ def end_element(name)
+ case name
+ when 'GroupName', 'PolicyName', 'PolicyDocument'
+ @response[name] = @value
+ when 'RequestId'
+ @response[name] = @value
+ end
+ end
+
+ end
+
+ end
+ end
+ end
+end
View
28 lib/fog/aws/parsers/iam/list_account_aliases.rb
@@ -0,0 +1,28 @@
+module Fog
+ module Parsers
+ module AWS
+ module IAM
+
+ class ListAccountAliases < Fog::Parsers::Base
+
+ def reset
+ @response = { 'AccountAliases' => [] }
+ end
+
+ def end_element(name)
+ case name
+ when 'member'
+ @response['AccountAliases'] << @value
+ when 'IsTruncated'
+ response[name] = (@value == 'true')
+ when 'Marker', 'RequestId'
+ response[name] = @value
+ end
+ end
+
+ end
+
+ end
+ end
+ end
+end
View
35 lib/fog/aws/parsers/rds/db_engine_version_parser.rb
@@ -0,0 +1,35 @@
+module Fog
+ module Parsers
+ module AWS
+ module RDS
+
+ class DBEngineVersionParser < Fog::Parsers::Base
+
+ def reset
+ @db_engine_version = fresh_engine_version
+ end
+
+ def fresh_engine_version
+ {}
+ end
+
+ def start_element(name, attrs = [])
+ super
+
+ end
+
+ def end_element(name)
+ case name
+ when 'DBEngineDescription' then @db_engine_version['DBEngineDescription'] = @value
+ when 'DBEngineVersionDescription' then @db_engine_version['DBEngineVersionDescription'] = @value
+ when 'DBParameterGroupFamily' then @db_engine_version['DBParameterGroupFamily'] = @value
+ when 'DBEngineVersionIdentifier' then @db_engine_version['DBEngineVersionIdentifier'] = @value
+ when 'Engine' then @db_engine_version['Engine'] = @value
+ when 'EngineVersion' then @db_engine_version['EngineVersion'] = @value
+ end
+ end
+ end
+ end
+ end
+ end
+end
View
2  lib/fog/aws/parsers/rds/db_parser.rb
@@ -45,7 +45,7 @@ def end_element(name)
when 'Engine',
'DBInstanceStatus', 'DBInstanceIdentifier', 'EngineVersion',
'PreferredBackupWindow', 'PreferredMaintenanceWindow',
- 'AvailabilityZone', 'MasterUsername', 'DBName'
+ 'AvailabilityZone', 'MasterUsername', 'DBName', 'LicenseModel'
@db_instance[name] = value
when 'MultiAZ', 'AutoMinorVersionUpgrade'
if value == 'false'
View
39 lib/fog/aws/parsers/rds/describe_db_engine_versions.rb
@@ -0,0 +1,39 @@
+module Fog
+ module Parsers
+ module AWS
+ module RDS
+
+ require 'fog/aws/parsers/rds/db_engine_version_parser'
+
+ class DescribeDBEngineVersions < Fog::Parsers::AWS::RDS::DBEngineVersionParser
+
+ def reset
+ @response = { 'DescribeDBEngineVersionsResult' => {'DBEngineVersions' => []}, 'ResponseMetadata' => {} }
+ super
+ end
+
+ def start_element(name, attrs = [])
+ super
+ end
+
+ def end_element(name)
+ case name
+ when 'DBEngineVersion' then
+ @response['DescribeDBEngineVersionsResult']['DBEngineVersions'] << @db_engine_version
+ @db_engine_version = fresh_engine_version
+ when 'Marker'
+ @response['DescribeDBEngineVersionsResult']['Marker'] = @value
+ when 'RequestId'
+ @response['ResponseMetadata'][name] = @value
+ else
+ super
+ end
+
+ end
+
+ end
+
+ end
+ end
+ end
+end
View
43 lib/fog/aws/parsers/rds/describe_db_reserved_instances.rb
@@ -0,0 +1,43 @@
+module Fog
+ module Parsers
+ module AWS
+ module RDS
+
+ class DescribeDBReservedInstances < Fog::Parsers::Base
+
+ def reset
+ @reserved_instance = {}
+ @response = { 'ReservedDBInstances' => [] }
+ end
+
+ def end_element(name)
+ case name
+ when 'ReservedDBInstanceId', 'ReservedDBInstancesOfferingId', 'DBInstanceClass', 'ProductDescription', 'State'
+ @reserved_instance[name] = @value
+ when 'Duration', 'DBInstanceCount'
+ @reserved_instance[name] = @value.to_i
+ when 'FixedPrice', 'UsagePrice'
+ @reserved_instance[name] = @value.to_f
+ when 'ReservedDBInstance'
+ @response['ReservedDBInstances'] << @reserved_instance
+ @reserved_instance = {}
+ when 'Marker'
+ @response[name] = @value
+ when 'MultiAZ'
+ if @value == 'false'
+ @reserved_instance[name] = false
+ else
+ @reserved_instance[name] = true
+ end
+ when 'StartTime'
+ @reserved_instance[name] = Time.parse(@value)
+ end
+ end
+
+ end
+
+ end
+ end
+ end
+end
+
View
4 lib/fog/aws/rds.rb
@@ -15,6 +15,8 @@ class IdentifierTaken < Fog::Errors::Error; end
request :delete_db_instance
request :reboot_db_instance
request :create_db_instance_read_replica
+ request :describe_db_engine_versions
+ request :describe_db_reserved_instances
request :describe_db_snapshots
request :create_db_snapshot
@@ -123,7 +125,7 @@ def request(params)
:host => @host,
:path => @path,
:port => @port,
- :version => '2010-07-28'
+ :version => '2011-04-01' #'2010-07-28'
}
)
View
2  lib/fog/aws/requests/auto_scaling/delete_policy.rb
@@ -29,7 +29,7 @@ def delete_policy(auto_scaling_group_name, policy_name)
'AutoScalingGroupName' => auto_scaling_group_name,
'PolicyName' => policy_name,
:parser => Fog::Parsers::AWS::AutoScaling::Basic.new
- }.merge!(options))
+ })
end
end
View
2  lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb
@@ -46,7 +46,7 @@ def put_scaling_policy(adjustment_type, auto_scaling_group_name, policy_name, sc
'AdjustmentType' => adjustment_type,
'AutoScalingGroupName' => auto_scaling_group_name,
'PolicyName' => policy_name,
- 'ScalingAdustment' => scaling_adjustment,
+ 'ScalingAdjustment' => scaling_adjustment,
:parser => Fog::Parsers::AWS::AutoScaling::PutScalingPolicy.new
}.merge!(options))
end
View
19 lib/fog/aws/requests/iam/create_account_alias.rb
@@ -0,0 +1,19 @@
+module Fog
+ module AWS
+ class IAM
+ class Real
+
+ require 'fog/aws/parsers/iam/basic'
+
+ def create_account_alias(account_alias)
+ request(
+ 'Action' => 'CreateAccountAlias',
+ 'AccountAlias' => account_alias,
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
+ )
+ end
+
+ end
+ end
+ end
+end
View
19 lib/fog/aws/requests/iam/delete_account_alias.rb
@@ -0,0 +1,19 @@
+module Fog
+ module AWS
+ class IAM
+ class Real
+
+ require 'fog/aws/parsers/iam/basic'
+
+ def delete_account_alias(account_alias)
+ request(
+ 'Action' => 'DeleteAccountAlias',
+ 'AccountAlias' => account_alias,
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
+ )
+ end
+
+ end
+ end
+ end
+end
View
36 lib/fog/aws/requests/iam/get_group_policy.rb
@@ -0,0 +1,36 @@
+module Fog
+ module AWS
+ class IAM
+ class Real
+
+ require 'fog/aws/parsers/iam/get_group_policy'
+
+ # Get Group Policy
+ #
+ # ==== Parameters
+ # * 'PolicyName'<~String>: Name of the policy to get
+ # * 'GroupName'<~String>: Name of the Group who the policy is associated with.
+ #
+ # ==== Returns
+ # * response<~Excon::Response>:
+ # * body<~Hash>:
+ # * PolicyDocument<~String> The policy document.
+ # * PolicyName<~String> The name of the policy.
+ # * GroupName<~String> The Group the policy is associated with.
+ #
+ # ==== See Also
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_GetGroupPolicy.html
+ #
+ def get_group_policy(policy_name, group_name)
+ request({
+ 'Action' => 'GetGroupPolicy',
+ 'PolicyName' => policy_name,
+ 'GroupName' => group_name,
+ :parser => Fog::Parsers::AWS::IAM::GetGroupPolicy.new
+ })
+ end
+
+ end
+ end
+ end
+end
View
18 lib/fog/aws/requests/iam/list_account_aliases.rb
@@ -0,0 +1,18 @@
+module Fog
+ module AWS
+ class IAM
+ class Real
+
+ require 'fog/aws/parsers/iam/list_account_aliases'
+
+ def list_account_aliases(options = {})
+ request({
+ 'Action' => 'ListAccountAliases',
+ :parser => Fog::Parsers::AWS::IAM::ListAccountAliases.new
+ }.merge!(options))
+ end
+
+ end
+ end
+ end
+end
View
34 lib/fog/aws/requests/rds/describe_db_engine_versions.rb
@@ -0,0 +1,34 @@
+module Fog
+ module AWS
+ class RDS
+ class Real
+
+ require 'fog/aws/parsers/rds/describe_db_engine_versions'
+
+ def describe_db_engine_versions(opts={})
+ params = {}
+ params['DBParameterGroupFamily'] = opts[:db_parameter_group_family] if opts[:db_parameter_group_family]
+ params['DefaultOnly'] = opts[:default_only] if opts[:default_only]
+ params['Engine'] = opts[:engine] if opts[:engine]
+ params['EngineVersion'] = opts[:engine_version] if opts[:engine_version]
+ params['Marker'] = opts[:marker] if opts[:marker]
+ params['MaxRecords'] = opts[:max_records] if opts[:max_records]
+
+ request({
+ 'Action' => 'DescribeDBEngineVersions',
+ :parser => Fog::Parsers::AWS::RDS::DescribeDBEngineVersions.new
+ }.merge(params))
+ end
+
+ end
+
+ class Mock
+
+ def describe_db_engine_versions(opts={})
+ Fog::Mock.not_implemented
+ end
+
+ end
+ end
+ end
+end
View
42 lib/fog/aws/requests/rds/describe_db_reserved_instances.rb
@@ -0,0 +1,42 @@
+module Fog
+ module AWS
+ class RDS
+ class Real
+
+ require 'fog/aws/parsers/rds/describe_db_reserved_instances'
+
+ # Describe all or specified load db instances
+ # http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html
+ # ==== Parameters
+ # * DBInstanceIdentifier <~String> - ID of instance to retrieve information for. if absent information for all instances is returned
+ # ==== Returns
+ # * response<~Excon::Response>:
+ # * body<~Hash>:
+ def describe_db_reserved_instances(identifier=nil, opts={})
+ params = {}
+ params['ReservedDBInstanceId'] = identifier if identifier
+ if opts[:marker]
+ params['Marker'] = opts[:marker]
+ end
+ if opts[:max_records]
+ params['MaxRecords'] = opts[:max_records]
+ end
+
+ request({
+ 'Action' => 'DescribeReservedDBInstances',
+ :parser => Fog::Parsers::AWS::RDS::DescribeDBReservedInstances.new
+ }.merge(params))
+ end
+
+ end
+
+ class Mock
+
+ def describe_db_instances(identifier=nil, opts={})
+ Fog::Mock.not_implemented
+ end
+
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.