Class: Fog::AWS::AutoScaling::Mock
- Inherits:
-
Object
- Object
- Fog::AWS::AutoScaling::Mock
- Includes:
- CredentialFetcher::ConnectionMethods
- Defined in:
- lib/fog/aws/auto_scaling.rb,
lib/fog/aws/requests/auto_scaling/delete_tags.rb,
lib/fog/aws/requests/auto_scaling/delete_policy.rb,
lib/fog/aws/requests/auto_scaling/describe_tags.rb,
lib/fog/aws/requests/auto_scaling/execute_policy.rb,
lib/fog/aws/requests/auto_scaling/attach_instances.rb,
lib/fog/aws/requests/auto_scaling/detach_instances.rb,
lib/fog/aws/requests/auto_scaling/resume_processes.rb,
lib/fog/aws/requests/auto_scaling/describe_policies.rb,
lib/fog/aws/requests/auto_scaling/suspend_processes.rb,
lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb,
lib/fog/aws/requests/auto_scaling/set_instance_health.rb,
lib/fog/aws/requests/auto_scaling/set_desired_capacity.rb,
lib/fog/aws/requests/auto_scaling/attach_load_balancers.rb,
lib/fog/aws/requests/auto_scaling/create_or_update_tags.rb,
lib/fog/aws/requests/auto_scaling/detach_load_balancers.rb,
lib/fog/aws/requests/auto_scaling/delete_scheduled_action.rb,
lib/fog/aws/requests/auto_scaling/set_instance_protection.rb,
lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb,
lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb,
lib/fog/aws/requests/auto_scaling/describe_adjustment_types.rb,
lib/fog/aws/requests/auto_scaling/enable_metrics_collection.rb,
lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb,
lib/fog/aws/requests/auto_scaling/describe_scheduled_actions.rb,
lib/fog/aws/requests/auto_scaling/disable_metrics_collection.rb,
lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb,
lib/fog/aws/requests/auto_scaling/delete_launch_configuration.rb,
lib/fog/aws/requests/auto_scaling/describe_scaling_activities.rb,
lib/fog/aws/requests/auto_scaling/describe_auto_scaling_groups.rb,
lib/fog/aws/requests/auto_scaling/describe_launch_configurations.rb,
lib/fog/aws/requests/auto_scaling/describe_scaling_process_types.rb,
lib/fog/aws/requests/auto_scaling/put_notification_configuration.rb,
lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb,
lib/fog/aws/requests/auto_scaling/describe_metric_collection_types.rb,
lib/fog/aws/requests/auto_scaling/delete_notification_configuration.rb,
lib/fog/aws/requests/auto_scaling/describe_termination_policy_types.rb,
lib/fog/aws/requests/auto_scaling/put_scheduled_update_group_action.rb,
lib/fog/aws/requests/auto_scaling/attach_load_balancer_target_groups.rb,
lib/fog/aws/requests/auto_scaling/detach_load_balancer_target_groups.rb,
lib/fog/aws/requests/auto_scaling/describe_notification_configurations.rb,
lib/fog/aws/requests/auto_scaling/describe_auto_scaling_notification_types.rb,
lib/fog/aws/requests/auto_scaling/terminate_instance_in_auto_scaling_group.rb
Instance Attribute Summary collapse
-
#region ⇒ Object
Returns the value of attribute region.
Class Method Summary collapse
Instance Method Summary collapse
- #attach_instances(auto_scaling_group_name, options = {}) ⇒ Object
- #attach_load_balancer_target_groups(auto_scaling_group_name, options = {}) ⇒ Object
- #attach_load_balancers(auto_scaling_group_name, options = {}) ⇒ Object
- #create_auto_scaling_group(auto_scaling_group_name, availability_zones, launch_configuration_name, max_size, min_size, options = {}) ⇒ Object
- #create_launch_configuration(image_id, instance_type, launch_configuration_name, options = {}) ⇒ Object
- #create_or_update_tags(tags) ⇒ Object
- #data ⇒ Object
- #delete_auto_scaling_group(auto_scaling_group_name, options = {}) ⇒ Object
- #delete_launch_configuration(launch_configuration_name) ⇒ Object
- #delete_notification_configuration(auto_scaling_group_name, topic_arn) ⇒ Object
- #delete_policy(auto_scaling_group_name, policy_name) ⇒ Object
- #delete_scheduled_action(auto_scaling_group_name, scheduled_action_name) ⇒ Object
- #delete_tags(tags) ⇒ Object
- #describe_adjustment_types ⇒ Object
- #describe_auto_scaling_groups(options = {}) ⇒ Object
- #describe_auto_scaling_instances(options = {}) ⇒ Object
- #describe_auto_scaling_notification_types ⇒ Object
- #describe_launch_configurations(options = {}) ⇒ Object
- #describe_metric_collection_types ⇒ Object
- #describe_notification_configurations(options = {}) ⇒ Object
- #describe_policies(options = {}) ⇒ Object
- #describe_scaling_activities(options = {}) ⇒ Object
- #describe_scaling_process_types ⇒ Object
- #describe_scheduled_actions(options = {}) ⇒ Object
- #describe_tags(options = {}) ⇒ Object
- #describe_termination_policy_types ⇒ Object
- #detach_instances(auto_scaling_group_name, options = {}) ⇒ Object
- #detach_load_balancer_target_groups(auto_scaling_group_name, options = {}) ⇒ Object
- #detach_load_balancers(auto_scaling_group_name, options = {}) ⇒ Object
- #disable_metrics_collection(auto_scaling_group_name, options = {}) ⇒ Object
- #enable_metrics_collection(auto_scaling_group_name, granularity, options = {}) ⇒ Object
- #execute_policy(policy_name, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #put_notification_configuration(auto_scaling_group_name, notification_types, topic_arn) ⇒ Object
- #put_scaling_policy(adjustment_type, auto_scaling_group_name, policy_name, scaling_adjustment, options = {}) ⇒ Object
- #put_scheduled_update_group_action(auto_scaling_group_name, scheduled_policy_name, time, options = {}) ⇒ Object
- #region_data ⇒ Object
- #reset_data ⇒ Object
- #resume_processes(auto_scaling_group_name, options = {}) ⇒ Object
- #set_desired_capacity(auto_scaling_group_name, desired_capacity, options = {}) ⇒ Object
- #set_instance_health(health_status, instance_id, options = {}) ⇒ Object
- #set_instance_protection(auto_scaling_group_name, options = {}) ⇒ Object
- #setup_credentials(options) ⇒ Object
- #suspend_processes(auto_scaling_group_name, options = {}) ⇒ Object
- #terminate_instance_in_auto_scaling_group(instance_id, should_decrement_desired_capacity) ⇒ Object
- #update_auto_scaling_group(auto_scaling_group_name, options = {}) ⇒ Object
Methods included from CredentialFetcher::ConnectionMethods
#refresh_credentials_if_expired
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
256 257 258 259 260 261 262 |
# File 'lib/fog/aws/auto_scaling.rb', line 256 def initialize(={}) @use_iam_profile = [:use_iam_profile] setup_credentials() @region = [:region] || 'us-east-1' Fog::AWS.validate_region!(@region) end |
Instance Attribute Details
#region ⇒ Object
Returns the value of attribute region.
188 189 190 |
# File 'lib/fog/aws/auto_scaling.rb', line 188 def region @region end |
Class Method Details
.data ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/fog/aws/auto_scaling.rb', line 190 def self.data @data ||= Hash.new do |hash, region| owner_id = Fog::AWS::Mock.owner_id hash[region] = Hash.new do |region_hash, key| region_hash[key] = { :adjustment_types => [ 'ChangeInCapacity', 'ExactCapacity', 'PercentChangeInCapacity' ], :auto_scaling_groups => {}, :scaling_policies => {}, :health_states => [ 'Healthy', 'Unhealthy' ], :launch_configurations => {}, :metric_collection_types => { :granularities => [ '1Minute' ], :metrics => [ 'GroupMinSize', 'GroupMaxSize', 'GroupDesiredCapacity', 'GroupInServiceInstances', 'GroupPendingInstances', 'GroupTerminatingInstances', 'GroupTotalInstances' ] }, :notification_configurations => {}, :notification_types => [ 'autoscaling:EC2_INSTANCE_LAUNCH', 'autoscaling:EC2_INSTANCE_LAUNCH_ERROR', 'autoscaling:EC2_INSTANCE_TERMINATE', 'autoscaling:EC2_INSTANCE_TERMINATE_ERROR', 'autoscaling:TEST_NOTIFICATION' ], :owner_id => owner_id, :process_types => [ 'AZRebalance', 'AddToLoadBalancer', 'AlarmNotification', 'HealthCheck', 'Launch', 'ReplaceUnhealthy', 'ScheduledActions', 'Terminate' ], :termination_policy_types => [ 'ClosestToNextInstanceHour', 'Default', 'NewestInstance', 'OldestInstance', 'OldestLaunchConfiguration' ] } end end end |
.reset ⇒ Object
252 253 254 |
# File 'lib/fog/aws/auto_scaling.rb', line 252 def self.reset @data = nil end |
Instance Method Details
#attach_instances(auto_scaling_group_name, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fog/aws/requests/auto_scaling/attach_instances.rb', line 39 def attach_instances(auto_scaling_group_name, = {}) = .keys - ExpectedOptions[:asg_name] - ExpectedOptions[:instance_ids] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#attach_load_balancer_target_groups(auto_scaling_group_name, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fog/aws/requests/auto_scaling/attach_load_balancer_target_groups.rb', line 37 def attach_load_balancer_target_groups(auto_scaling_group_name, = {}) = .keys - ExpectedOptions[:attach_load_balancer_target_groups] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#attach_load_balancers(auto_scaling_group_name, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fog/aws/requests/auto_scaling/attach_load_balancers.rb', line 37 def attach_load_balancers(auto_scaling_group_name, = {}) = .keys - ExpectedOptions[:attach_load_balancers] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#create_auto_scaling_group(auto_scaling_group_name, availability_zones, launch_configuration_name, max_size, min_size, options = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb', line 94 def create_auto_scaling_group(auto_scaling_group_name, availability_zones, launch_configuration_name, max_size, min_size, = {}) = .keys - ExpectedOptions[:create_auto_scaling_group] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end if self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::IdentifierTaken.new("AutoScalingGroup by this name already exists - A group with the name #{auto_scaling_group_name} already exists") end unless self.data[:launch_configurations].key?(launch_configuration_name) raise Fog::AWS::AutoScaling::ValidationError.new('Launch configuration name not found - null') end self.data[:auto_scaling_groups][auto_scaling_group_name] = { 'AutoScalingGroupARN' => Fog::AWS::Mock.arn('autoscaling', self.data[:owner_id], "autoScalingGroup:00000000-0000-0000-0000-000000000000:autoScalingGroupName/#{auto_scaling_group_name}", @region), 'AutoScalingGroupName' => auto_scaling_group_name, 'AvailabilityZones' => [*availability_zones], 'CreatedTime' => Time.now.utc, 'DefaultCooldown' => 300, 'DesiredCapacity' => 0, 'EnabledMetrics' => [], 'HealthCheckGracePeriod' => 0, 'HealthCheckType' => 'EC2', 'Instances' => [], 'LaunchConfigurationName' => launch_configuration_name, 'LoadBalancerNames' => [], 'MaxSize' => max_size, 'MinSize' => min_size, 'PlacementGroup' => nil, 'SuspendedProcesses' => [], 'Tags' => [], 'TargetGroupARNs' => [], 'TerminationPolicies' => ['Default'], 'VPCZoneIdentifier' => nil }.merge!() response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#create_launch_configuration(image_id, instance_type, launch_configuration_name, options = {}) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb', line 86 def create_launch_configuration(image_id, instance_type, launch_configuration_name, = {}) if self.data[:launch_configurations].key?(launch_configuration_name) raise Fog::AWS::AutoScaling::IdentifierTaken.new("Launch Configuration by this name already exists - A launch configuration already exists with the name #{launch_configuration_name}") end self.data[:launch_configurations][launch_configuration_name] = { 'AssociatePublicIpAddress' => nil, 'BlockDeviceMappings' => [], 'CreatedTime' => Time.now.utc, 'EbsOptimized' => false, 'IamInstanceProfile' => nil, 'ImageId' => image_id, 'InstanceMonitoring' => {'Enabled' => true}, 'InstanceType' => instance_type, 'KernelId' => nil, 'KeyName' => nil, 'LaunchConfigurationARN' => Fog::AWS::Mock.arn('autoscaling', self.data[:owner_id], "launchConfiguration:00000000-0000-0000-0000-000000000000:launchConfigurationName/#{launch_configuration_name}", @region), 'LaunchConfigurationName' => launch_configuration_name, 'PlacementTenancy' => nil, 'RamdiskId' => nil, 'SecurityGroups' => [], 'UserData' => nil }.merge!() response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#create_or_update_tags(tags) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fog/aws/requests/auto_scaling/create_or_update_tags.rb', line 48 def () if .to_a.empty? raise Fog::AWS::AutoScaling::ValidationError.new("1 validation error detected: Value null at 'tags' failed to satisfy constraint: Member must not be null") end raise Fog::Mock::NotImplementedError end |
#data ⇒ Object
268 269 270 |
# File 'lib/fog/aws/auto_scaling.rb', line 268 def data self.region_data[@aws_access_key_id] end |
#delete_auto_scaling_group(auto_scaling_group_name, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb', line 38 def delete_auto_scaling_group(auto_scaling_group_name, = {}) unless self.data[:auto_scaling_groups].delete(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError, "The auto scaling group '#{auto_scaling_group_name}' does not exist." end self.data[:notification_configurations].delete(auto_scaling_group_name) response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#delete_launch_configuration(launch_configuration_name) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fog/aws/requests/auto_scaling/delete_launch_configuration.rb', line 36 def delete_launch_configuration(launch_configuration_name) unless self.data[:launch_configurations].delete(launch_configuration_name) raise Fog::AWS::AutoScaling::NotFound, "The launch configuration '#{launch_configuration_name}' does not exist." end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#delete_notification_configuration(auto_scaling_group_name, topic_arn) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fog/aws/requests/auto_scaling/delete_notification_configuration.rb', line 35 def delete_notification_configuration(auto_scaling_group_name, topic_arn) unless self.data[:notification_configurations].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - %s' % auto_scaling_group_name) end unless self.data[:notification_configurations][auto_scaling_group_name].key?(topic_arn) raise Fog::AWS::AutoScaling::ValidationError.new("Notification Topic '#{topic_arn}' doesn't exist for '#{self.data[:owner_id]}'") end self.data[:notification_configurations][auto_scaling_group_name].delete(topic_arn) if self.data[:notification_configurations][auto_scaling_group_name].empty? self.data[:notification_configurations].delete(auto_scaling_group_name) end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#delete_policy(auto_scaling_group_name, policy_name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/aws/requests/auto_scaling/delete_policy.rb', line 35 def delete_policy(auto_scaling_group_name, policy_name) unless self.data[:scaling_policies].delete(policy_name) raise Fog::AWS::AutoScaling::NotFound, "The scaling policy '#{policy_name}' does not exist." end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#delete_scheduled_action(auto_scaling_group_name, scheduled_action_name) ⇒ Object
36 37 38 |
# File 'lib/fog/aws/requests/auto_scaling/delete_scheduled_action.rb', line 36 def delete_scheduled_action(auto_scaling_group_name, scheduled_action_name) Fog::Mock.not_implemented end |
#delete_tags(tags) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fog/aws/requests/auto_scaling/delete_tags.rb', line 48 def () if .to_a.empty? raise Fog::AWS::AutoScaling::ValidationError.new("1 validation error detected: Value null at 'tags' failed to satisfy constraint: Member must not be null") end raise Fog::Mock::NotImplementedError end |
#describe_adjustment_types ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/aws/requests/auto_scaling/describe_adjustment_types.rb', line 32 def describe_adjustment_types() results = { 'AdjustmentTypes' => [] } self.data[:adjustment_types].each do |adjustment_type| results['AdjustmentTypes'] << { 'AdjustmentType' => adjustment_type } end response = Excon::Response.new response.status = 200 response.body = { 'DescribeAdjustmentTypesResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_auto_scaling_groups(options = {}) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/fog/aws/requests/auto_scaling/describe_auto_scaling_groups.rb', line 108 def describe_auto_scaling_groups( = {}) results = { 'AutoScalingGroups' => [] } asg_set = self.data[:auto_scaling_groups] if !["AutoScalingGroupNames"].nil? asg_set = asg_set.reject do |asg_name, asg_data| ![*["AutoScalingGroupNames"]].include?(asg_name) end end asg_set.each do |asg_name, asg_data| results['AutoScalingGroups'] << { 'AutoScalingGroupName' => asg_name }.merge!(asg_data) end response = Excon::Response.new response.status = 200 response.body = { 'DescribeAutoScalingGroupsResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_auto_scaling_instances(options = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb', line 69 def describe_auto_scaling_instances( = {}) results = { 'AutoScalingInstances' => [] } self.data[:auto_scaling_groups].each do |asg_name, asg_data| asg_data['Instances'].each do |instance| results['AutoScalingInstances'] << { 'AutoScalingGroupName' => asg_name }.merge!(instance) end end response = Excon::Response.new response.status = 200 response.body = { 'DescribeAutoScalingInstancesResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_auto_scaling_notification_types ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/aws/requests/auto_scaling/describe_auto_scaling_notification_types.rb', line 32 def describe_auto_scaling_notification_types() results = { 'AutoScalingNotificationTypes' => [], } self.data[:notification_types].each do |notification_type| results['AutoScalingNotificationTypes'] << notification_type end response = Excon::Response.new response.status = 200 response.body = { 'DescribeAutoScalingNotificationTypesResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_launch_configurations(options = {}) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/fog/aws/requests/auto_scaling/describe_launch_configurations.rb', line 85 def describe_launch_configurations( = {}) launch_configuration_names = .delete('LaunchConfigurationNames') # even a nil object will turn into an empty array lc = [*launch_configuration_names] launch_configurations = if lc.any? lc.map do |lc_name| l_conf = self.data[:launch_configurations].find { |name, data| name == lc_name } #raise Fog::AWS::AutoScaling::NotFound unless l_conf l_conf[1].dup if l_conf end.compact else self.data[:launch_configurations].map { |lc, values| values.dup } end response = Excon::Response.new response.status = 200 response.body = { 'DescribeLaunchConfigurationsResult' => { 'LaunchConfigurations' => launch_configurations }, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_metric_collection_types ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/aws/requests/auto_scaling/describe_metric_collection_types.rb', line 34 def describe_metric_collection_types() results = { 'Granularities' => [], 'Metrics' => [] } self.data[:metric_collection_types][:granularities].each do |granularity| results['Granularities'] << { 'Granularity' => granularity } end self.data[:metric_collection_types][:metrics].each do |metric| results['Metrics'] << { 'Metric' => metric } end response = Excon::Response.new response.status = 200 response.body = { 'DescribeMetricCollectionTypesResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_notification_configurations(options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fog/aws/requests/auto_scaling/describe_notification_configurations.rb', line 48 def describe_notification_configurations( = {}) results = { 'NotificationConfigurations' => [] } (['AutoScalingGroupNames']||self.data[:notification_configurations].keys).each do |asg_name| (self.data[:notification_configurations][asg_name]||{}).each do |topic_arn, notification_types| notification_types.each do |notification_type| results['NotificationConfigurations'] << { 'AutoScalingGroupName' => asg_name, 'NotificationType' => notification_type, 'TopicARN' => topic_arn, } end end end response = Excon::Response.new response.status = 200 response.body = { 'DescribeNotificationConfigurationsResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_policies(options = {}) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fog/aws/requests/auto_scaling/describe_policies.rb', line 73 def describe_policies( = {}) results = { 'ScalingPolicies' => [] } policy_set = self.data[:scaling_policies] for opt_key, opt_value in if opt_key == "PolicyNames" && opt_value != nil && opt_value != "" policy_set = policy_set.reject do |asp_name, asp_data| ![*["PolicyNames"]].include?(asp_name) end elsif opt_key == "AutoScalingGroupName" && opt_value != nil && opt_value != "" policy_set = policy_set.reject do |asp_name, asp_data| ["AutoScalingGroupName"] != asp_data["AutoScalingGroupName"] end end end policy_set.each do |asp_name, asp_data| results['ScalingPolicies'] << { 'PolicyName' => asp_name }.merge!(asp_data) end response = Excon::Response.new response.status = 200 response.body = { 'DescribePoliciesResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_scaling_activities(options = {}) ⇒ Object
76 77 78 |
# File 'lib/fog/aws/requests/auto_scaling/describe_scaling_activities.rb', line 76 def describe_scaling_activities( = {}) Fog::Mock.not_implemented end |
#describe_scaling_process_types ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/aws/requests/auto_scaling/describe_scaling_process_types.rb', line 33 def describe_scaling_process_types() results = { 'Processes' => [] } self.data[:process_types].each do |process_type| results['Processes'] << { 'ProcessName' => process_type } end response = Excon::Response.new response.status = 200 response.body = { 'DescribeScalingProcessTypesResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#describe_scheduled_actions(options = {}) ⇒ Object
76 77 78 |
# File 'lib/fog/aws/requests/auto_scaling/describe_scheduled_actions.rb', line 76 def describe_scheduled_actions( = {}) Fog::Mock.not_implemented end |
#describe_tags(options = {}) ⇒ Object
62 63 64 |
# File 'lib/fog/aws/requests/auto_scaling/describe_tags.rb', line 62 def (={}) raise Fog::Mock::NotImplementedError end |
#describe_termination_policy_types ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/aws/requests/auto_scaling/describe_termination_policy_types.rb', line 31 def describe_termination_policy_types() results = { 'TerminationPolicyTypes' => [] } self.data[:termination_policy_types].each do |termination_policy_type| results['TerminationPolicyTypes'] << termination_policy_type end response = Excon::Response.new response.status = 200 response.body = { 'DescribeTerminationPolicyTypesResult' => results, 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#detach_instances(auto_scaling_group_name, options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/aws/requests/auto_scaling/detach_instances.rb', line 47 def detach_instances(auto_scaling_group_name, = {}) = .keys - ExpectedOptions[:asg_name] - ExpectedOptions[:instance_ids] - ExpectedOptions[:should_decrement_desired_capacity] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#detach_load_balancer_target_groups(auto_scaling_group_name, options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/aws/requests/auto_scaling/detach_load_balancer_target_groups.rb', line 36 def detach_load_balancer_target_groups(auto_scaling_group_name, = {}) = .keys - ExpectedOptions[:detach_load_balancer_target_groups] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#detach_load_balancers(auto_scaling_group_name, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fog/aws/requests/auto_scaling/detach_load_balancers.rb', line 41 def detach_load_balancers(auto_scaling_group_name, = {}) = .keys - ExpectedOptions[:detach_load_balancers] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#disable_metrics_collection(auto_scaling_group_name, options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/fog/aws/requests/auto_scaling/disable_metrics_collection.rb', line 40 def disable_metrics_collection(auto_scaling_group_name, = {}) unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) Fog::AWS::AutoScaling::ValidationError.new("Group #{auto_scaling_group_name} not found") end Fog::Mock.not_implemented end |
#enable_metrics_collection(auto_scaling_group_name, granularity, options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fog/aws/requests/auto_scaling/enable_metrics_collection.rb', line 47 def enable_metrics_collection(auto_scaling_group_name, granularity, = {}) unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) Fog::AWS::AutoScaling::ValidationError.new("Group #{auto_scaling_group_name} not found") end unless self.data[:metric_collection_types][:granularities].include?(granularity) Fog::AWS::AutoScaling::ValidationError.new('Valid metrics granularity type is: [1Minute].') end Fog::Mock.not_implemented end |
#execute_policy(policy_name, options = {}) ⇒ Object
38 39 40 |
# File 'lib/fog/aws/requests/auto_scaling/execute_policy.rb', line 38 def execute_policy(policy_name, = {}) Fog::Mock.not_implemented end |
#put_notification_configuration(auto_scaling_group_name, notification_types, topic_arn) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fog/aws/requests/auto_scaling/put_notification_configuration.rb', line 39 def put_notification_configuration(auto_scaling_group_name, notification_types, topic_arn) unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new("AutoScalingGroup name not found - #{auto_scaling_group_name}") end if notification_types.to_a.empty? raise Fog::AWS::AutoScaling::ValidationError.new("1 validation error detected: Value null at 'notificationTypes' failed to satisfy constraint: Member must not be null") end invalid_types = notification_types.to_a - self.data[:notification_types] unless invalid_types.empty? raise Fog::AWS::AutoScaling::ValidationError.new(""#{invalid_types.first}" is not a valid Notification Type.") end self.data[:notification_configurations][auto_scaling_group_name] ||= {} self.data[:notification_configurations][auto_scaling_group_name][topic_arn] = notification_types.to_a.uniq response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#put_scaling_policy(adjustment_type, auto_scaling_group_name, policy_name, scaling_adjustment, options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb', line 54 def put_scaling_policy(adjustment_type, auto_scaling_group_name, policy_name, scaling_adjustment, = {}) unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('Auto Scaling Group name not found - null') end self.data[:scaling_policies][policy_name] = { 'AdjustmentType' => adjustment_type, 'Alarms' => [], 'AutoScalingGroupName' => auto_scaling_group_name, 'Cooldown' => 0, 'MinAdjustmentStep' => 0, 'PolicyARN' => Fog::AWS::Mock.arn('autoscaling', self.data[:owner_id], "scalingPolicy:00000000-0000-0000-0000-000000000000:autoScalingGroupName/#{auto_scaling_group_name}:policyName/#{policy_name}", self.region), 'PolicyName' => policy_name, 'ScalingAdjustment' => scaling_adjustment }.merge!() response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#put_scheduled_update_group_action(auto_scaling_group_name, scheduled_policy_name, time, options = {}) ⇒ Object
58 59 60 |
# File 'lib/fog/aws/requests/auto_scaling/put_scheduled_update_group_action.rb', line 58 def put_scheduled_update_group_action(auto_scaling_group_name, scheduled_policy_name, time, = {}) Fog::Mock.not_implemented end |
#region_data ⇒ Object
264 265 266 |
# File 'lib/fog/aws/auto_scaling.rb', line 264 def region_data self.class.data[@region] end |
#reset_data ⇒ Object
272 273 274 |
# File 'lib/fog/aws/auto_scaling.rb', line 272 def reset_data self.region_data.delete(@aws_access_key_id) end |
#resume_processes(auto_scaling_group_name, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/aws/requests/auto_scaling/resume_processes.rb', line 38 def resume_processes(auto_scaling_group_name, = {}) unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new("AutoScalingGroup name not found - no such group: #{auto_scaling_group_name}") end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#set_desired_capacity(auto_scaling_group_name, desired_capacity, options = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fog/aws/requests/auto_scaling/set_desired_capacity.rb', line 65 def set_desired_capacity(auto_scaling_group_name, desired_capacity, = {}) unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end self.data[:auto_scaling_groups][auto_scaling_group_name]['DesiredCapacity'] = desired_capacity response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#set_instance_health(health_status, instance_id, options = {}) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/fog/aws/requests/auto_scaling/set_instance_health.rb', line 39 def set_instance_health(health_status, instance_id, = {}) unless self.data[:health_states].include?(health_status) raise Fog::AWS::AutoScaling::ValidationError.new('Valid instance health states are: [#{self.data[:health_states].join(", ")}].') end Fog::Mock.not_implemented end |
#set_instance_protection(auto_scaling_group_name, options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fog/aws/requests/auto_scaling/set_instance_protection.rb', line 43 def set_instance_protection(auto_scaling_group_name, = {}) = .keys - \ ExpectedOptions[:asg_name] - \ ExpectedOptions[:instance_ids] - \ ExpectedOptions[:protected_from_scale_in] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#setup_credentials(options) ⇒ Object
276 277 278 |
# File 'lib/fog/aws/auto_scaling.rb', line 276 def setup_credentials() @aws_access_key_id = [:aws_access_key_id] end |
#suspend_processes(auto_scaling_group_name, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/aws/requests/auto_scaling/suspend_processes.rb', line 41 def suspend_processes(auto_scaling_group_name, = {}) unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new("AutoScalingGroup name not found - no such group: #{auto_scaling_group_name}") end response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |
#terminate_instance_in_auto_scaling_group(instance_id, should_decrement_desired_capacity) ⇒ Object
53 54 55 |
# File 'lib/fog/aws/requests/auto_scaling/terminate_instance_in_auto_scaling_group.rb', line 53 def terminate_instance_in_auto_scaling_group(instance_id, should_decrement_desired_capacity) Fog::Mock.not_implemented end |
#update_auto_scaling_group(auto_scaling_group_name, options = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb', line 72 def update_auto_scaling_group(auto_scaling_group_name, = {}) = .keys - ExpectedOptions[:update_auto_scaling_group] unless .empty? raise Fog::AWS::AutoScaling::ValidationError.new("Options #{.join(',')} should not be included in request") end unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name) raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null') end self.data[:auto_scaling_groups][auto_scaling_group_name].merge!() response = Excon::Response.new response.status = 200 response.body = { 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response end |