├── lib └── fog │ └── aws │ ├── models │ ├── sns │ │ ├── subscription.rb │ │ ├── subscriptions.rb │ │ └── topics.rb │ ├── elb │ │ ├── backend_server_description.rb │ │ ├── backend_server_descriptions.rb │ │ └── listeners.rb │ ├── cloud_watch │ │ ├── metric.rb │ │ ├── alarm_history.rb │ │ └── alarm_histories.rb │ ├── compute │ │ ├── flavor.rb │ │ ├── tags.rb │ │ └── tag.rb │ ├── beanstalk │ │ ├── events.rb │ │ ├── event.rb │ │ ├── applications.rb │ │ └── environments.rb │ ├── glacier │ │ ├── vaults.rb │ │ └── archives.rb │ ├── rds │ │ ├── parameter.rb │ │ ├── servers.rb │ │ ├── instance_option.rb │ │ ├── subnet_groups.rb │ │ ├── event_subscriptions.rb │ │ ├── parameter_groups.rb │ │ ├── log_file.rb │ │ ├── instance_options.rb │ │ └── subnet_group.rb │ ├── elasticache │ │ ├── security_groups.rb │ │ ├── parameter_group.rb │ │ ├── parameter_groups.rb │ │ ├── clusters.rb │ │ └── subnet_groups.rb │ ├── dns │ │ └── zones.rb │ ├── kms │ │ └── keys.rb │ └── iam │ │ └── policy.rb │ ├── parsers │ ├── dns │ │ ├── create_health_check.rb │ │ ├── delete_hosted_zone.rb │ │ ├── get_change.rb │ │ └── change_resource_record_sets.rb │ ├── cloud_formation │ │ ├── basic.rb │ │ ├── create_stack.rb │ │ ├── update_stack.rb │ │ └── get_template.rb │ ├── iam │ │ ├── basic.rb │ │ ├── create_user.rb │ │ ├── create_group.rb │ │ ├── create_access_key.rb │ │ ├── upload_signing_certificate.rb │ │ ├── list_policies.rb │ │ ├── list_account_aliases.rb │ │ ├── update_group.rb │ │ ├── update_user.rb │ │ ├── login_profile.rb │ │ ├── single_role.rb │ │ ├── single_policy.rb │ │ ├── instance_profile.rb │ │ ├── get_user.rb │ │ ├── upload_server_certificate.rb │ │ ├── list_roles.rb │ │ ├── list_groups.rb │ │ ├── list_access_keys.rb │ │ ├── list_instance_profiles.rb │ │ ├── list_managed_policies.rb │ │ ├── list_groups_for_user.rb │ │ └── list_users.rb │ ├── emr │ │ ├── add_job_flow_steps.rb │ │ ├── terminate_job_flows.rb │ │ ├── modify_instance_groups.rb │ │ ├── set_termination_protection.rb │ │ ├── run_job_flow.rb │ │ └── add_instance_groups.rb │ ├── storage │ │ ├── get_request_payment.rb │ │ ├── get_bucket_location.rb │ │ ├── copy_object.rb │ │ ├── initiate_multipart_upload.rb │ │ ├── complete_multipart_upload.rb │ │ ├── get_bucket_versioning.rb │ │ ├── get_service.rb │ │ └── get_bucket_website.rb │ ├── compute │ │ ├── register_image.rb │ │ ├── deregister_image.rb │ │ ├── associate_route_table.rb │ │ ├── import_key_pair.rb │ │ ├── attach_network_interface.rb │ │ ├── allocate_address.rb │ │ ├── create_key_pair.rb │ │ ├── create_image.rb │ │ ├── copy_image.rb │ │ ├── copy_snapshot.rb │ │ ├── attach_volume.rb │ │ ├── detach_volume.rb │ │ ├── replace_network_acl_association.rb │ │ ├── purchase_reserved_instances_offering.rb │ │ ├── basic.rb │ │ ├── get_password_data.rb │ │ ├── modify_subnet_attribute.rb │ │ ├── associate_address.rb │ │ ├── assign_private_ip_addresses.rb │ │ ├── create_security_group.rb │ │ ├── get_console_output.rb │ │ ├── create_snapshot.rb │ │ ├── describe_key_pairs.rb │ │ ├── create_volume.rb │ │ ├── describe_tags.rb │ │ ├── describe_regions.rb │ │ ├── create_network_acl.rb │ │ ├── create_network_interface.rb │ │ ├── describe_placement_groups.rb │ │ ├── describe_addresses.rb │ │ ├── cancel_spot_instance_requests.rb │ │ └── spot_datafeed_subscription.rb │ ├── sns │ │ ├── delete_topic.rb │ │ ├── unsubscribe.rb │ │ ├── add_permission.rb │ │ ├── publish.rb │ │ ├── remove_permission.rb │ │ ├── set_topic_attributes.rb │ │ ├── create_topic.rb │ │ ├── subscribe.rb │ │ ├── confirm_subscription.rb │ │ ├── list_topics.rb │ │ └── list_subscriptions.rb │ ├── beanstalk │ │ ├── create_storage_location.rb │ │ ├── check_dns_availability.rb │ │ ├── empty.rb │ │ ├── retrieve_environment_info.rb │ │ ├── validate_configuration_settings.rb │ │ ├── list_available_solution_stacks.rb │ │ ├── create_application.rb │ │ ├── update_application.rb │ │ ├── describe_applications.rb │ │ ├── create_application_version.rb │ │ ├── update_application_version.rb │ │ ├── describe_events.rb │ │ └── describe_application_versions.rb │ ├── sqs │ │ ├── basic.rb │ │ ├── create_queue.rb │ │ ├── list_queues.rb │ │ └── send_message.rb │ ├── ses │ │ ├── verify_email_address.rb │ │ ├── delete_verified_email_address.rb │ │ ├── send_email.rb │ │ ├── send_raw_email.rb │ │ ├── verify_domain_identity.rb │ │ ├── get_send_quota.rb │ │ ├── list_verified_email_addresses.rb │ │ └── get_send_statistics.rb │ ├── elb │ │ ├── delete_load_balancer.rb │ │ ├── empty.rb │ │ ├── create_load_balancer.rb │ │ ├── attach_load_balancer_to_subnets.rb │ │ ├── describe_tags.rb │ │ ├── detach_load_balancer_from_subnets.rb │ │ ├── apply_security_groups_to_load_balancer.rb │ │ ├── register_instances_with_load_balancer.rb │ │ ├── deregister_instances_from_load_balancer.rb │ │ ├── enable_availability_zones_for_load_balancer.rb │ │ └── disable_availability_zones_for_load_balancer.rb │ ├── elasticache │ │ ├── single_cache_cluster.rb │ │ ├── single_parameter_group.rb │ │ ├── describe_cache_parameters.rb │ │ ├── describe_engine_default_parameters.rb │ │ ├── authorize_cache_security_group_ingress.rb │ │ ├── describe_cache_clusters.rb │ │ ├── base.rb │ │ ├── describe_security_groups.rb │ │ ├── describe_parameter_groups.rb │ │ ├── reset_parameter_group.rb │ │ ├── modify_parameter_group.rb │ │ └── parameter_group_parser.rb │ ├── sts │ │ ├── assume_role_with_web_identity.rb │ │ ├── assume_role.rb │ │ ├── assume_role_with_saml.rb │ │ └── get_session_token.rb │ ├── auto_scaling │ │ ├── basic.rb │ │ ├── put_notification_configuration.rb │ │ └── put_scaling_policy.rb │ ├── cloud_watch │ │ ├── delete_alarms.rb │ │ ├── put_metric_data.rb │ │ ├── set_alarm_state.rb │ │ ├── put_metric_alarm.rb │ │ ├── disable_alarm_actions.rb │ │ └── enable_alarm_actions.rb │ ├── rds │ │ ├── delete_db_parameter_group.rb │ │ ├── download_db_logfile_portion.rb │ │ ├── base.rb │ │ ├── delete_db_security_group.rb │ │ ├── delete_event_subscription.rb │ │ ├── modify_db_parameter_group.rb │ │ └── delete_db_subnet_group.rb │ ├── redshift │ │ ├── cluster.rb │ │ ├── describe_clusters.rb │ │ ├── update_cluster_parameter_group_parser.rb │ │ ├── cluster_snapshot.rb │ │ ├── create_cluster_security_group.rb │ │ ├── revoke_cluster_security_group_ingress.rb │ │ └── create_cluster_parameter_group.rb │ ├── simpledb │ │ ├── basic.rb │ │ └── list_domains.rb │ └── cdn │ │ ├── post_invalidation.rb │ │ └── get_invalidation.rb │ ├── version.rb │ ├── region_methods.rb │ ├── requests │ ├── iam │ │ ├── list_account_aliases.rb │ │ ├── delete_account_alias.rb │ │ └── create_account_alias.rb │ ├── federation │ │ └── get_signin_token.rb │ ├── sts │ │ └── get_session_token.rb │ ├── storage │ │ ├── sync_clock.rb │ │ ├── delete_bucket_cors.rb │ │ └── delete_bucket_website.rb │ ├── kms │ │ └── describe_key.rb │ ├── dns │ │ └── delete_health_check.rb │ ├── sns │ │ ├── unsubscribe.rb │ │ └── remove_permission.rb │ ├── cloud_formation │ │ └── delete_stack.rb │ ├── beanstalk │ │ ├── create_storage_location.rb │ │ └── list_available_solution_stacks.rb │ └── ses │ │ └── list_verified_email_addresses.rb │ └── errors.rb ├── tests ├── models │ ├── auto_scaling │ │ ├── helper.rb │ │ ├── instances_tests.rb │ │ ├── activities_tests.rb │ │ ├── configurations_tests.rb │ │ ├── configuration_test.rb │ │ ├── instance_tests.rb │ │ └── groups_test.rb │ ├── compute │ │ ├── addresses_tests.rb │ │ ├── vpc_tests.rb │ │ ├── internet_gateway_tests.rb │ │ ├── internet_gateways_tests.rb │ │ ├── key_pairs_tests.rb │ │ ├── volumes_tests.rb │ │ ├── security_groups_tests.rb │ │ ├── dhcp_option_tests.rb │ │ ├── dhcp_options_tests.rb │ │ ├── subnet_tests.rb │ │ ├── subnets_tests.rb │ │ ├── snapshot_tests.rb │ │ ├── snapshots_tests.rb │ │ ├── network_interfaces_test.rb │ │ ├── vpcs_tests.rb │ │ ├── address_tests.rb │ │ ├── network_acls_tests.rb │ │ └── key_pair_tests.rb │ ├── dns │ │ ├── zone_tests.rb │ │ └── zones_tests.rb │ ├── rds │ │ ├── servers_tests.rb │ │ ├── security_groups_tests.rb │ │ ├── event_subscriptions_tests.rb │ │ ├── parameter_groups_tests.rb │ │ ├── event_subscription_tests.rb │ │ ├── snapshot_tests.rb │ │ ├── instance_option_tests.rb │ │ ├── snapshots_tests.rb │ │ ├── helper.rb │ │ ├── tagging_tests.rb │ │ └── parameter_group_tests.rb │ ├── sns │ │ ├── topics_tests.rb │ │ └── topic_tests.rb │ ├── beanstalk │ │ └── applications_tests.rb │ ├── data_pipeline │ │ ├── pipeline_tests.rb │ │ └── pipelines_tests.rb │ ├── elasticache │ │ └── parameter_groups_tests.rb │ ├── elb │ │ └── tagging_tests.rb │ ├── cdn │ │ ├── invalidations_tests.rb │ │ ├── distribution_tests.rb │ │ ├── distributions_tests.rb │ │ ├── streaming_distribution_tests.rb │ │ └── streaming_distributions_tests.rb │ └── cloud_watch │ │ └── alarm_history_tests.rb ├── requests │ ├── sns │ │ └── helper.rb │ ├── ses │ │ ├── helper.rb │ │ └── verified_domain_identity_tests.rb │ ├── sqs │ │ └── helper.rb │ ├── simpledb │ │ └── helper.rb │ ├── compute │ │ ├── helper.rb │ │ ├── spot_price_history_tests.rb │ │ └── availability_zone_tests.rb │ ├── rds │ │ ├── db_engine_versions.rb │ │ ├── describe_events.rb │ │ ├── log_file_tests.rb │ │ └── instance_option_tests.rb │ ├── federation │ │ └── get_signin_token_tests.rb │ ├── sts │ │ ├── session_token_tests.rb │ │ ├── get_federation_token_tests.rb │ │ ├── assume_role_tests.rb │ │ └── assume_role_with_saml_tests.rb │ ├── elasticache │ │ ├── describe_events.rb │ │ └── describe_reserved_cache_nodes.rb │ ├── dns │ │ ├── change_resource_record_sets_tests.rb │ │ └── helper.rb │ ├── glacier │ │ └── archive_tests.rb │ ├── iam │ │ └── mfa_tests.rb │ ├── storage │ │ └── delete_multiple_objects_tests.rb │ ├── kms │ │ ├── key_tests.rb │ │ └── helper.rb │ └── beanstalk │ │ └── solution_stack_tests.rb ├── helpers │ ├── succeeds_helper.rb │ ├── responds_to_helper.rb │ └── compute │ │ ├── servers_helper.rb │ │ └── server_helper.rb ├── storage_tests.rb ├── lorem.txt ├── signed_params_tests.rb └── helper.rb ├── gemfiles ├── Gemfile-ruby-1.8.7 └── Gemfile-edge ├── Rakefile ├── Gemfile ├── .gitignore ├── CONTRIBUTORS.md └── CONTRIBUTING.md /lib/fog/aws/models/sns/subscription.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/models/auto_scaling/helper.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/dns/create_health_check.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/fog/aws/version.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | VERSION = "0.2.2" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /gemfiles/Gemfile-ruby-1.8.7: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'mime-types', '~> 1.16' 4 | gem 'nokogiri', '~> 1.5.11' 5 | 6 | gemspec :path => "../" 7 | -------------------------------------------------------------------------------- /tests/models/compute/addresses_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | addresses", ['aws']) do 2 | 3 | collection_tests(Fog::Compute[:aws].addresses, {}, true) 4 | 5 | end 6 | -------------------------------------------------------------------------------- /tests/models/compute/vpc_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | vpc", ['aws']) do 2 | 3 | model_tests(Fog::Compute[:aws].vpcs, {:cidr_block => '10.0.10.0/28'}, true) 4 | end 5 | -------------------------------------------------------------------------------- /tests/requests/sns/helper.rb: -------------------------------------------------------------------------------- 1 | class AWS 2 | module SNS 3 | module Formats 4 | BASIC = { 5 | 'RequestId' => String 6 | } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /tests/models/compute/internet_gateway_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | internet_gateway", ['aws']) do 2 | model_tests(Fog::Compute[:aws].internet_gateways , {}, true) 3 | end 4 | -------------------------------------------------------------------------------- /tests/models/compute/internet_gateways_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | internet_gateways", ['aws']) do 2 | collection_tests(Fog::Compute[:aws].internet_gateways, {}, true) 3 | end 4 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | task :default => :test 4 | 5 | mock = ENV['FOG_MOCK'] || 'true' 6 | task :test do 7 | sh("export FOG_MOCK=#{mock} && bundle exec shindont") 8 | end 9 | -------------------------------------------------------------------------------- /tests/models/dns/zone_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::DNS[:aws] | zone", ['aws', 'dns']) do 2 | params = {:domain => generate_unique_domain } 3 | model_tests(Fog::DNS[:aws].zones, params) 4 | end 5 | -------------------------------------------------------------------------------- /tests/models/compute/key_pairs_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | key_pairs", ['aws']) do 2 | 3 | collection_tests(Fog::Compute[:aws].key_pairs, {:name => 'fogkeyname'}, true) 4 | 5 | end 6 | -------------------------------------------------------------------------------- /tests/models/dns/zones_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::DNS[:aws] | zones", ['aws', 'dns']) do 2 | params = {:domain => generate_unique_domain } 3 | collection_tests(Fog::DNS[:aws].zones, params) 4 | end 5 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in fog-aws.gemspec 4 | gemspec 5 | gem 'pry-nav', group: :test 6 | gem "codeclimate-test-reporter", group: :test, require: nil 7 | -------------------------------------------------------------------------------- /tests/helpers/succeeds_helper.rb: -------------------------------------------------------------------------------- 1 | module Shindo 2 | class Tests 3 | def succeeds 4 | test('succeeds') do 5 | !!instance_eval(&Proc.new) 6 | end 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /tests/requests/ses/helper.rb: -------------------------------------------------------------------------------- 1 | class AWS 2 | module SES 3 | module Formats 4 | BASIC = { 5 | 'ResponseMetadata' => {'RequestId' => String} 6 | } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /tests/requests/sqs/helper.rb: -------------------------------------------------------------------------------- 1 | class AWS 2 | module SQS 3 | module Formats 4 | BASIC = { 5 | 'ResponseMetadata' => {'RequestId' => String} 6 | } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | tests/.fog 16 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | * Frederick Cheung 2 | * Josh Lane 3 | * Josh Lane 4 | * Wesley Beary 5 | * geemus -------------------------------------------------------------------------------- /tests/models/rds/servers_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | servers", ['aws', 'rds']) do 2 | 3 | collection_tests(Fog::AWS[:rds].servers, rds_default_server_params) do 4 | @instance.wait_for { ready? } 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /tests/requests/simpledb/helper.rb: -------------------------------------------------------------------------------- 1 | class AWS 2 | module SimpleDB 3 | module Formats 4 | BASIC = { 5 | 'BoxUsage' => Float, 6 | 'RequestId' => String 7 | } 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /tests/requests/compute/helper.rb: -------------------------------------------------------------------------------- 1 | class AWS 2 | module Compute 3 | module Formats 4 | BASIC = { 5 | 'requestId' => String, 6 | 'return' => ::Fog::Boolean 7 | } 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_formation/basic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudFormation 5 | class Basic < Fog::Parsers::Base 6 | end 7 | end 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /tests/models/compute/volumes_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | volumes", ['aws']) do 2 | 3 | collection_tests(Fog::Compute[:aws].volumes, {:availability_zone => 'us-east-1a', :size => 1, :device => '/dev/sdz1'}, true) 4 | 5 | end 6 | -------------------------------------------------------------------------------- /tests/models/rds/security_groups_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | security groups", ['aws', 'rds']) do 2 | params = {:id => 'fog-test', :description => 'fog test'} 3 | 4 | collection_tests(Fog::AWS[:rds].security_groups, params) 5 | end 6 | -------------------------------------------------------------------------------- /tests/models/sns/topics_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::SNS | topics", ['aws', 'sns']) do 2 | pending unless Fog.mocking? 3 | params = {:id => 'arn:aws:sns:us-east-1:12345678910:fog'} 4 | 5 | collection_tests(Fog::AWS[:sns].topics, params) 6 | end 7 | -------------------------------------------------------------------------------- /tests/models/auto_scaling/instances_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::AutoScaling | instances', ['aws', 'auto_scaling_m']) do 2 | 3 | pending # FIXME: instance#save is not defined 4 | #collection_tests(Fog::AWS[:auto_scaling].instances, {}, false) 5 | 6 | end 7 | -------------------------------------------------------------------------------- /tests/models/compute/security_groups_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | security_groups", ['aws']) do 2 | 3 | collection_tests(Fog::Compute[:aws].security_groups, {:description => 'foggroupdescription', :name => 'foggroupname'}, true) 4 | 5 | end 6 | -------------------------------------------------------------------------------- /tests/models/auto_scaling/activities_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::AutoScaling | activities', ['aws', 'auto_scaling_m']) do 2 | 3 | pending # FIXME: activity#save is not implemented 4 | collection_tests(Fog::AWS[:auto_scaling].activities, {}, false) 5 | 6 | end 7 | -------------------------------------------------------------------------------- /tests/models/compute/dhcp_option_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | dhcp_options", ['aws']) do 2 | model_tests(Fog::Compute[:aws].dhcp_options, {'dhcp_configuration_set' => {'domain-name' => 'example.com', 'domain-name-servers' => '10.10.10.10'}}, true) 3 | end 4 | -------------------------------------------------------------------------------- /tests/models/beanstalk/applications_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::AWS[:beanstalk] | applications", ['aws', 'beanstalk']) do 2 | 3 | pending if Fog.mocking? 4 | 5 | collection_tests(Fog::AWS[:beanstalk].applications, {:name => uniq_id('fog-test-app')}, false) 6 | 7 | end 8 | -------------------------------------------------------------------------------- /tests/models/compute/dhcp_options_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | dhcp_options", ['aws']) do 2 | collection_tests(Fog::Compute[:aws].dhcp_options, {'dhcp_configuration_set' => {'domain-name' => 'example.com', 'domain-name-servers' => '10.10.10.10'}}, true) 3 | end 4 | -------------------------------------------------------------------------------- /gemfiles/Gemfile-edge: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Shared components 4 | gem "fog-core", :github => "fog/fog-core" 5 | gem "fog-json", :github => "fog/fog-json" 6 | 7 | gem "codeclimate-test-reporter", group: :test, require: nil 8 | 9 | gemspec :path => "../" 10 | -------------------------------------------------------------------------------- /tests/storage_tests.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | Shindo.tests('AWS Storage | escape', ['aws']) do 4 | tests('Keys can contain a hierarchical prefix which should not be escaped') do 5 | returns( Fog::Storage::AWS.new.send(:escape, "key/with/prefix") ) { "key/with/prefix" } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /tests/models/rds/event_subscriptions_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | event subscriptions", ['aws', 'rds']) do 2 | pending unless Fog.mocking? 3 | params = {:id => "fog", :sns_topic_arn => 'arn:aws:sns:us-east-1:12345678910:fog'} 4 | 5 | collection_tests(Fog::AWS[:rds].event_subscriptions, params) 6 | end 7 | -------------------------------------------------------------------------------- /tests/requests/rds/db_engine_versions.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::RDS | describe db engine versions', ['aws', 'rds']) do 2 | tests('success') do 3 | tests("#describe_db_engine_versions").formats(AWS::RDS::Formats::DB_ENGINE_VERSIONS_LIST) do 4 | Fog::AWS[:rds].describe_db_engine_versions.body 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /tests/models/compute/subnet_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | subnet", ['aws']) do 2 | @vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24') 3 | model_tests(Fog::Compute[:aws].subnets, {:vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28', :availability_zone => 'us-east-1b'}, true) 4 | @vpc.destroy 5 | end 6 | -------------------------------------------------------------------------------- /tests/helpers/responds_to_helper.rb: -------------------------------------------------------------------------------- 1 | module Shindo 2 | class Tests 3 | def responds_to(method_names) 4 | for method_name in [*method_names] 5 | tests("#respond_to?(:#{method_name})").returns(true) do 6 | @instance.respond_to?(method_name) 7 | end 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elb/backend_server_description.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class ELB 4 | class BackendServerDescription < Fog::Model 5 | attribute :policy_names, :aliases => 'PolicyNames' 6 | attribute :instance_port, :aliases => 'InstancePort' 7 | end 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /tests/models/compute/subnets_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | subnets", ['aws']) do 2 | @vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/28') 3 | collection_tests(Fog::Compute[:aws].subnets, { :vpc_id => @vpc.id, :cidr_block => '10.0.10.0/28', :availability_zone => 'us-east-1c'}, true) 4 | @vpc.destroy 5 | end 6 | -------------------------------------------------------------------------------- /tests/models/rds/parameter_groups_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | parameter_groups", ['aws', 'rds']) do 2 | 3 | group_name = 'fog-test' 4 | params = {:id => group_name, :family => 'mysql5.1', :description => group_name} 5 | 6 | pending if Fog.mocking? 7 | collection_tests(Fog::AWS[:rds].parameter_groups, params, false) 8 | end 9 | -------------------------------------------------------------------------------- /tests/helpers/compute/servers_helper.rb: -------------------------------------------------------------------------------- 1 | def servers_tests(connection, params = {}, mocks_implemented = true) 2 | collection_tests(connection.servers, params, mocks_implemented) do 3 | 4 | if !Fog.mocking? || mocks_implemented 5 | @instance.wait_for { ready? } 6 | yield if block_given? 7 | end 8 | 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /tests/models/rds/event_subscription_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | event_subscription", ['aws', 'rds']) do 2 | pending unless Fog.mocking? 3 | 4 | name = 'fog' 5 | params = {:id => name, :sns_topic_arn => 'arn:aws:sns:us-east-1:12345678910:fog'} 6 | 7 | model_tests(Fog::AWS[:rds].event_subscriptions, params) do 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/fog/aws/models/cloud_watch/metric.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class CloudWatch 4 | class Metric < Fog::Model 5 | attribute :name, :aliases => 'MetricName' 6 | attribute :namespace, :aliases => 'Namespace' 7 | attribute :dimensions, :aliases => 'Dimensions' 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /tests/models/auto_scaling/configurations_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::AutoScaling | configurations', ['aws', 'auto_scaling_m']) do 2 | 3 | params = { 4 | :id => uniq_id, 5 | :image_id => 'ami-8c1fece5', 6 | :instance_type => 't1.micro' 7 | } 8 | 9 | collection_tests(Fog::AWS[:auto_scaling].configurations, params, false) 10 | 11 | end 12 | -------------------------------------------------------------------------------- /tests/models/data_pipeline/pipeline_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::DataPipeline | pipelines", ['aws', 'data_pipeline']) do 2 | pending if Fog.mocking? 3 | 4 | unique_id = uniq_id 5 | model_tests(Fog::AWS[:data_pipeline].pipelines, { :id => unique_id, :name => "#{unique_id}-name", :unique_id => unique_id }) do 6 | @instance.wait_for { state } 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /tests/models/compute/snapshot_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | snapshot", ['aws']) do 2 | 3 | @volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1a', :size => 1) 4 | @volume.wait_for { ready? } 5 | 6 | model_tests(Fog::Compute[:aws].snapshots, {:volume_id => @volume.identity}, true) 7 | 8 | @volume.destroy 9 | 10 | end 11 | -------------------------------------------------------------------------------- /tests/models/data_pipeline/pipelines_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::DataPipeline | pipelines", ['aws', 'data_pipeline']) do 2 | pending if Fog.mocking? 3 | 4 | unique_id = uniq_id 5 | collection_tests(Fog::AWS[:data_pipeline].pipelines, { :id => unique_id, :name => "#{unique_id}-name", :unique_id => unique_id }) do 6 | @instance.wait_for { state } 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /tests/models/compute/snapshots_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | snapshots", ['aws']) do 2 | 3 | @volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1a', :size => 1) 4 | @volume.wait_for { ready? } 5 | 6 | collection_tests(Fog::Compute[:aws].snapshots, {:volume_id => @volume.identity}, true) 7 | 8 | @volume.destroy 9 | 10 | end 11 | -------------------------------------------------------------------------------- /tests/requests/federation/get_signin_token_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::Federation | signin tokens', ['aws']) do 2 | @signin_token_format = { 3 | 'SigninToken' => String 4 | } 5 | 6 | tests("#get_signin_token").formats(@signin_token_format) do 7 | pending unless Fog.mocking? 8 | 9 | Fog::AWS[:federation].get_signin_token("test_policy") 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/basic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class Basic < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /tests/models/auto_scaling/configuration_test.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::AutoScaling | configuration', ['aws', 'auto_scaling_m']) do 2 | 3 | params = { 4 | :id => uniq_id, 5 | :image_id => 'ami-8c1fece5', 6 | :instance_type => 't1.micro' 7 | } 8 | 9 | model_tests(Fog::AWS[:auto_scaling].configurations, params, false) do 10 | @instance.wait_for { ready? } 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /tests/models/rds/snapshot_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | snapshot", ['aws', 'rds']) do 2 | 3 | @server = Fog::AWS[:rds].servers.create(rds_default_server_params) 4 | @server.wait_for { ready? } 5 | 6 | params = {:id => uniq_id, :instance_id => @server.id} 7 | model_tests(Fog::AWS[:rds].snapshots, params) do 8 | @instance.wait_for { ready? } 9 | end 10 | 11 | @server.destroy 12 | end 13 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/emr/add_job_flow_steps.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module EMR 5 | class AddJobFlowSteps < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /tests/models/rds/instance_option_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | db instance options", ['aws', 'rds']) do 2 | 3 | params = {:engine => 'mysql'} 4 | 5 | pending if Fog.mocking? 6 | 7 | tests('#options') do 8 | tests 'contains options' do 9 | @instance = Fog::AWS[:rds].instance_options.new(params) 10 | returns(true) { @instance.engine == 'mysql' } 11 | end 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /tests/models/rds/snapshots_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | snapshots", ['aws', 'rds']) do 2 | 3 | @server = Fog::AWS[:rds].servers.create(rds_default_server_params) 4 | @server.wait_for { ready? } 5 | 6 | params = {:id => uniq_id, :instance_id => @server.id} 7 | collection_tests(Fog::AWS[:rds].snapshots, params) do 8 | @instance.wait_for { ready? } 9 | end 10 | 11 | @server.destroy 12 | end 13 | -------------------------------------------------------------------------------- /lib/fog/aws/models/sns/subscriptions.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/sns/subscription' 2 | 3 | module Fog 4 | module AWS 5 | class SNS 6 | class Subscriptions < Fog::Collection 7 | model Fgo::AWS::SNS::Subscription 8 | 9 | def all 10 | data = service.list_subscriptions.body["Subscriptions"] 11 | load(data) 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/emr/terminate_job_flows.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module EMR 5 | class TerminateJobFlows < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/emr/modify_instance_groups.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module EMR 5 | class ModifyInstanceGroups < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/get_request_payment.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | class GetRequestPayment < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'Payer' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/register_image.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class RegisterImage < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'requestId', 'imageId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/emr/set_termination_protection.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module EMR 5 | class SetTerminationProtection < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/get_bucket_location.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | class GetBucketLocation < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'LocationConstraint' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/models/compute/flavor.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Compute 3 | class AWS 4 | class Flavor < Fog::Model 5 | identity :id 6 | 7 | attribute :bits 8 | attribute :cores 9 | attribute :disk 10 | attribute :name 11 | attribute :ram 12 | attribute :ebs_optimized_available 13 | attribute :instance_store_volumes 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_formation/create_stack.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudFormation 5 | class CreateStack < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId', 'StackId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_formation/update_stack.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudFormation 5 | class UpdateStack < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId', 'StackId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_formation/get_template.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudFormation 5 | class GetTemplate < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'RequestId', 'TemplateBody' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/deregister_image.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DeregisterImage < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'return', 'requestId', 'imageId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/associate_route_table.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class AssociateRouteTable < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'requestId', 'associationId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/import_key_pair.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class ImportKeyPair < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'keyFingerprint', 'keyName', 'requestId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /tests/lorem.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. -------------------------------------------------------------------------------- /tests/models/rds/helper.rb: -------------------------------------------------------------------------------- 1 | def rds_default_server_params 2 | { 3 | :allocated_storage => 5, 4 | :backup_retention_period => 0, 5 | :engine => 'mysql', 6 | :version => '5.6.22', 7 | :id => uniq_id, 8 | :master_username => 'foguser', 9 | :password => 'fogpassword', 10 | :flavor_id => 'db.m3.medium', 11 | } 12 | end 13 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/attach_network_interface.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class AttachNetworkInterface < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'requestId', 'attachmentId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/allocate_address.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class AllocateAddress < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'publicIp', 'requestId', 'domain', 'allocationId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /tests/requests/rds/describe_events.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::RDS | describe DB events requests',['aws', 'rds']) do 2 | 3 | tests('success') do 4 | pending if Fog.mocking? 5 | 6 | tests( 7 | '#describe_events' 8 | ).formats(AWS::RDS::Formats::EVENT_LIST) do 9 | Fog::AWS[:rds].describe_events().body['Events'] 10 | end 11 | end 12 | 13 | tests('failure') do 14 | #TODO: What constitutes a failure here? 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /tests/requests/ses/verified_domain_identity_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::SES | verified domain identity requests', ['aws', 'ses']) do 2 | 3 | tests('success') do 4 | 5 | tests("#verify_domain_identity('example.com')").formats(AWS::SES::Formats::BASIC) do 6 | pending if Fog.mocking? 7 | Fog::AWS[:ses].verify_domain_identity('example.com').body 8 | end 9 | 10 | end 11 | 12 | tests('failure') do 13 | 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /tests/requests/sts/session_token_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::STS | session tokens', ['aws']) do 2 | 3 | @session_format = { 4 | 'SessionToken' => String, 5 | 'SecretAccessKey' => String, 6 | 'Expiration' => String, 7 | 'AccessKeyId' => String, 8 | 'RequestId' => String 9 | } 10 | 11 | tests("#get_session_token").formats(@session_format) do 12 | pending if Fog.mocking? 13 | Fog::AWS[:sts].get_session_token.body 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/create_key_pair.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CreateKeyPair < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'keyFingerprint', 'keyMaterial', 'keyName', 'requestId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/create_image.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CreateImage < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'instanceId', 'requestId', 'name', 'description', 'noReboot', 'imageId' 9 | @response[name] = value 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /tests/requests/elasticache/describe_events.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::Elasticache | describe cache cluster events', 2 | ['aws', 'elasticache']) do 3 | 4 | tests('success') do 5 | pending if Fog.mocking? 6 | 7 | tests( 8 | '#describe_events' 9 | ).formats(AWS::Elasticache::Formats::EVENT_LIST) do 10 | Fog::AWS[:elasticache].describe_events().body['Events'] 11 | end 12 | end 13 | 14 | tests('failure') do 15 | # TODO: 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/copy_image.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CopyImage < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'imageId' 9 | @response[name] = value 10 | when 'requestId' 11 | @response[name] = value 12 | end 13 | end 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/emr/run_job_flow.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module EMR 5 | class RunJobFlow < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'JobFlowId' 9 | @response[name] = value 10 | when 'RequestId' 11 | @response[name] = value 12 | end 13 | end 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /tests/requests/dns/change_resource_record_sets_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('Fog::DNS[:aws] | change_resource_record_sets', ['aws', 'dns']) do 2 | @r53_connection = Fog::DNS[:aws] 3 | 4 | tests('success') do 5 | test('#elb_hosted_zone_mapping from DNS name') do 6 | zone_id = Fog::DNS::AWS.hosted_zone_for_alias_target('arbitrary-sub-domain.eu-west-1.elb.amazonaws.com') 7 | zone_id == Fog::DNS::AWS.elb_hosted_zone_mapping['eu-west-1'] 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/delete_topic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class DeleteTopic < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response[name] = @value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/unsubscribe.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class Unsubscribe < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response[name] = @value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/region_methods.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | module RegionMethods 4 | def validate_aws_region host, region 5 | if host.end_with?('.amazonaws.com') && !['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1', 'us-gov-west-1', 'eu-central-1'].include?(region) 6 | raise ArgumentError, "Unknown region: #{region.inspect}" 7 | end 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/iam/list_account_aliases.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class IAM 4 | class Real 5 | require 'fog/aws/parsers/iam/list_account_aliases' 6 | 7 | def list_account_aliases(options = {}) 8 | request({ 9 | 'Action' => 'ListAccountAliases', 10 | :parser => Fog::Parsers::AWS::IAM::ListAccountAliases.new 11 | }.merge!(options)) 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /tests/models/auto_scaling/instance_tests.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/auto_scaling/instance' 2 | 3 | Shindo.tests("Fog::AWS::AutoScaling::Instance", 'aws') do 4 | @instance = Fog::AWS::AutoScaling::Instance.new 5 | 6 | test('#healthy? = true') do 7 | @instance.health_status = 'Healthy' 8 | @instance.healthy? == true 9 | end 10 | 11 | test('#heatlhy? = false') do 12 | @instance.health_status = 'Unhealthy' 13 | @instance.healthy? == false 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/create_storage_location.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class CreateStorageLocation < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("CreateStorageLocationResult") 9 | tag 'S3Bucket', :string 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/copy_snapshot.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CopySnapshot < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'snapshotId' 9 | @response[name] = value 10 | when 'requestId' 11 | @response[name] = value 12 | end 13 | end 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/add_permission.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class AddPermission < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response[name] = @value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/iam/delete_account_alias.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class IAM 4 | class Real 5 | require 'fog/aws/parsers/iam/basic' 6 | 7 | def delete_account_alias(account_alias) 8 | request( 9 | 'Action' => 'DeleteAccountAlias', 10 | 'AccountAlias' => account_alias, 11 | :parser => Fog::Parsers::AWS::IAM::Basic.new 12 | ) 13 | end 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/fog/aws/models/cloud_watch/alarm_history.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class CloudWatch 4 | class AlarmHistory < Fog::Model 5 | attribute :alarm_name, :aliases => 'AlarmName' 6 | attribute :end_date, :aliases => 'EndDate' 7 | attribute :history_item_type, :aliases => 'HistoryItemType' 8 | attribute :max_records, :aliases => 'MaxRecords' 9 | attribute :start_date, :aliases => 'StartDate' 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/publish.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class Publish < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'MessageId', 'RequestId' 13 | @response[name] = @value.rstrip 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/remove_permission.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class RemovePermission < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response[name] = @value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/iam/create_account_alias.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class IAM 4 | class Real 5 | require 'fog/aws/parsers/iam/basic' 6 | 7 | def create_account_alias(account_alias) 8 | request( 9 | 'Action' => 'CreateAccountAlias', 10 | 'AccountAlias' => account_alias, 11 | :parser => Fog::Parsers::AWS::IAM::Basic.new 12 | ) 13 | end 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/fog/aws/models/beanstalk/events.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/beanstalk/event' 2 | 3 | module Fog 4 | module AWS 5 | class ElasticBeanstalk 6 | class Events < Fog::Collection 7 | model Fog::AWS::ElasticBeanstalk::Event 8 | 9 | def all(options={}) 10 | data = service.describe_events(options).body['DescribeEventsResult']['Events'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/set_topic_attributes.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class SetTopicAttributes < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response[name] = @value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /tests/models/elasticache/parameter_groups_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::Elasticache | parameter groups', ['aws', 'elasticache']) do 2 | group_name = 'fog-test' 3 | description = 'Fog Test' 4 | 5 | model_tests( 6 | Fog::AWS[:elasticache].parameter_groups, 7 | {:id => group_name, :description => description}, true 8 | ) 9 | 10 | collection_tests( 11 | Fog::AWS[:elasticache].parameter_groups, 12 | {:id => group_name, :description => description}, true 13 | ) 14 | 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/create_topic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class CreateTopic < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'TopicArn', 'RequestId' 13 | @response[name] = @value.strip 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/subscribe.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class Subscribe < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'SubscriptionArn', 'RequestId' 13 | @response[name] = @value.strip 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/copy_object.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | class CopyObject < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'ETag' 9 | @response[name] = value.gsub('"', '') 10 | when 'LastModified' 11 | @response[name] = Time.parse(value) 12 | end 13 | end 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/federation/get_signin_token.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class Federation 4 | class Real 5 | def get_signin_token(session) 6 | 7 | request('getSigninToken', CGI.escape(Fog::JSON.encode(session))) 8 | end 9 | end 10 | 11 | class Mock 12 | def get_signin_token(session) 13 | { 14 | 'SigninToken' => Fog::Mock.random_base64(752) 15 | } 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sqs/basic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SQS 5 | class Basic < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = @value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /tests/models/sns/topic_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::SNS | topic", ['aws', 'sns']) do 2 | params = {:id => 'fog'} 3 | 4 | model_tests(Fog::AWS[:sns].topics, params) do 5 | @instance.wait_for { ready? } 6 | 7 | tests("#display_name").returns('fog') { @instance.display_name } 8 | 9 | tests("#update_topic_attribute") do 10 | @instance.update_topic_attribute("DisplayName", "new-fog") 11 | 12 | tests("#display_name").returns('new-fog') { @instance.display_name } 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/confirm_subscription.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class ConfirmSubscription < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'SubscriptionArn', 'RequestId' 13 | @response[name] = @value.strip 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/errors.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | module Errors 4 | def self.match_error(error) 5 | matcher = lambda {|s| s.match(/(?:.*(.*)<\/Code>)(?:.*(.*)<\/Message>)/m)} 6 | [error.message, error.response.body].each(&Proc.new {|s| 7 | match = matcher.call(s) 8 | return {:code => match[1].split('.').last, :message => match[2]} if match 9 | }) 10 | {} # we did not match the message or response body 11 | end 12 | end 13 | end 14 | end -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/initiate_multipart_upload.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | class InitiateMultipartUpload < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Bucket', 'Key', 'UploadId' 13 | @response[name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /tests/requests/elasticache/describe_reserved_cache_nodes.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::Elasticache | describe reserved cache nodes', 2 | ['aws', 'elasticache']) do 3 | 4 | tests('success') do 5 | pending if Fog.mocking? 6 | 7 | tests( 8 | '#describe_reserved_cache_nodes' 9 | ).formats(AWS::Elasticache::Formats::RESERVED_CACHE_NODES) do 10 | Fog::AWS[:elasticache].describe_reserved_cache_nodes().body['ReservedCacheNodes'] 11 | end 12 | end 13 | 14 | tests('failure') do 15 | # TODO: 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/check_dns_availability.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class CheckDNSAvailability < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("CheckDNSAvailabilityResult") 9 | tag 'FullyQualifiedCNAME', :string 10 | tag 'Available', :boolean 11 | end 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/empty.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | class Empty < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/verify_email_address.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class VerifyEmailAddress < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/attach_volume.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class AttachVolume < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'attachTime' 9 | @response[name] = Time.parse(value) 10 | when 'device', 'instanceId', 'requestId', 'status', 'volumeId' 11 | @response[name] = value 12 | end 13 | end 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/detach_volume.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DetachVolume < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'attachTime' 9 | @response[name] = Time.parse(value) 10 | when 'device', 'instanceId', 'requestId', 'status', 'volumeId' 11 | @response[name] = value 12 | end 13 | end 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/replace_network_acl_association.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class ReplaceNetworkAclAssociation < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'requestId', 'newAssociationId' 13 | @response[name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /tests/requests/glacier/archive_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::Glacier | glacier archive tests', ['aws']) do 2 | pending if Fog.mocking? 3 | 4 | Fog::AWS[:glacier].create_vault('Fog-Test-Vault-upload') 5 | 6 | tests('single part upload') do 7 | id = Fog::AWS[:glacier].create_archive('Fog-Test-Vault-upload', 'data body').headers['x-amz-archive-id'] 8 | Fog::AWS[:glacier].delete_archive('Fog-Test-Vault-upload', id) 9 | end 10 | 11 | #amazon won't let us delete the vault because it has been written to in the past day 12 | 13 | end 14 | -------------------------------------------------------------------------------- /lib/fog/aws/models/cloud_watch/alarm_histories.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/cloud_watch/alarm_history' 2 | 3 | module Fog 4 | module AWS 5 | class CloudWatch 6 | class AlarmHistories < Fog::Collection 7 | model Fog::AWS::CloudWatch::AlarmHistory 8 | 9 | def all(conditions={}) 10 | data = service.describe_alarm_history(conditions).body['DescribeAlarmHistoryResult']['AlarmHistoryItems'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/purchase_reserved_instances_offering.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class PurchaseReservedInstancesOffering < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'reservedInstancesId', 'requestId' 13 | @response[name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/delete_verified_email_address.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class DeleteVerifiedEmailAddress < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/complete_multipart_upload.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | class CompleteMultipartUpload < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Bucket', 'ETag', 'Key', 'Location', 'Code', 'Message' 13 | @response[name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/sts/get_session_token.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class STS 4 | class Real 5 | require 'fog/aws/parsers/sts/get_session_token' 6 | 7 | def get_session_token(duration=43200) 8 | request({ 9 | 'Action' => 'GetSessionToken', 10 | 'DurationSeconds' => duration, 11 | :idempotent => true, 12 | :parser => Fog::Parsers::AWS::STS::GetSessionToken.new 13 | }) 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elb/backend_server_descriptions.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/elb/backend_server_description' 2 | module Fog 3 | module AWS 4 | class ELB 5 | class BackendServerDescriptions < Fog::Collection 6 | model Fog::AWS::ELB::BackendServerDescription 7 | 8 | attr_accessor :data, :load_balancer 9 | 10 | def all 11 | load(data) 12 | end 13 | 14 | def get(instance_port) 15 | all.find{|e| e.instance_port == instance_port} 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/dns/delete_hosted_zone.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module DNS 4 | module AWS 5 | class DeleteHostedZone < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | @response['ChangeInfo'] = {} 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'Id', 'Status', 'SubmittedAt' 14 | @response['ChangeInfo'][name] = value 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/dns/get_change.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module DNS 4 | module AWS 5 | class GetChange < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Id' 13 | @response[name] = value.sub('/change/', '') 14 | when 'Status', 'SubmittedAt' 15 | @response[name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/delete_load_balancer.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class DeleteLoadBalancer < Fog::Parsers::Base 6 | def reset 7 | @response = { 'DeleteLoadBalancerResult' => nil, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/get_bucket_versioning.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | class GetBucketVersioning < Fog::Parsers::Base 6 | def reset 7 | @response = { 'VersioningConfiguration' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Status', 'MfaDelete' 13 | @response['VersioningConfiguration'][name] = value 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/models/glacier/vaults.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/glacier/vault' 2 | 3 | module Fog 4 | module AWS 5 | class Glacier 6 | class Vaults < Fog::Collection 7 | model Fog::AWS::Glacier::Vault 8 | 9 | def all 10 | data = service.list_vaults.body['VaultList'] 11 | load(data) 12 | end 13 | 14 | def get(key) 15 | data = service.describe_vault(key).body 16 | new(data) 17 | rescue Excon::Errors::NotFound 18 | nil 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /tests/models/compute/network_interfaces_test.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | network_interfaces", ['aws']) do 2 | @vpc = Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24') 3 | @subnet = Fog::Compute[:aws].subnets.create('vpc_id' => @vpc.id, 'cidr_block' => '10.0.10.16/28') 4 | @subnet_id = @subnet.subnet_id 5 | 6 | collection_tests(Fog::Compute[:aws].network_interfaces, 7 | {:description => 'nic_desc', :name => 'nic_name', :subnet_id => @subnet_id}, 8 | true) 9 | 10 | @subnet.destroy 11 | @vpc.destroy 12 | end 13 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/basic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class Basic < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'requestId' 9 | @response[name] = value 10 | when 'return' 11 | if value == 'true' 12 | @response[name] = true 13 | else 14 | @response[name] = false 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/list_topics.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class ListTopics < Fog::Parsers::Base 6 | def reset 7 | @response = { 'Topics' => [] } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'TopicArn' 13 | @response['Topics'] << @value.strip 14 | when 'NextToken', 'RequestId' 15 | response[name] = @value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/create_user.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class CreateUser < Fog::Parsers::Base 6 | def reset 7 | @response = { 'User' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Arn', 'UserId', 'UserName', 'Path' 13 | @response['User'][name] = value 14 | when 'RequestId' 15 | @response[name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/send_email.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class SendEmail < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'MessageId' 13 | @response[name] = value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/single_cache_cluster.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/cache_cluster_parser' 6 | 7 | class SingleCacheCluster < CacheClusterParser 8 | def end_element(name) 9 | case name 10 | when 'CacheCluster' 11 | @response[name] = @cache_cluster 12 | reset_cache_cluster 13 | else 14 | super 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/create_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class CreateGroup < Fog::Parsers::Base 6 | def reset 7 | @response = { 'Group' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Arn', 'GroupId', 'GroupName', 'Path' 13 | @response['Group'][name] = value 14 | when 'RequestId' 15 | @response[name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/send_raw_email.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class SendRawEmail < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'MessageId' 13 | @response[name] = value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/dns/change_resource_record_sets.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module DNS 4 | module AWS 5 | class ChangeResourceRecordSets < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Id' 13 | @response[name] = value.sub('/change/', '') 14 | when 'Status', 'SubmittedAt' 15 | @response[name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/empty.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class Empty < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sqs/create_queue.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SQS 5 | class CreateQueue < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = @value 14 | when 'QueueUrl' 15 | @response['QueueUrl'] = @value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/get_password_data.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class GetPasswordData < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'instanceId', 'requestId', 'passwordData' 13 | @response[name] = @value 14 | when 'timestamp' 15 | @response[name] = Time.parse(@value) 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sts/assume_role_with_web_identity.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module STS 5 | class AssumeRoleWithWithWebIdentity < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'AssumedRoleUser', 'Audience', 'Credentials', 'PackedPolicySize', 'Provider', 'SubjectFromWebIdentityToken' 13 | @response[name] = @value.strip 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /tests/models/compute/vpcs_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | vpcs", ['aws']) do 2 | 3 | collection_tests(Fog::Compute[:aws].vpcs, {:cidr_block => '10.0.10.0/28'}, true) 4 | 5 | tests('tags') do 6 | test_tags = {'foo' => 'bar'} 7 | @vpc = Fog::Compute[:aws].vpcs.create(:cidr_block => '1.2.3.4/24', :tags => test_tags) 8 | 9 | tests('@vpc.tags').returns(test_tags) do 10 | @vpc.reload.tags 11 | end 12 | 13 | unless Fog.mocking? 14 | Fog::Compute[:aws].tags.all('resource-id' => @vpc.id).each {|tag| tag.destroy} 15 | end 16 | 17 | @vpc.destroy 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/single_parameter_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/parameter_group_parser' 6 | 7 | class SingleParameterGroup < ParameterGroupParser 8 | def end_element(name) 9 | case name 10 | when 'CacheParameterGroup' 11 | @response[name] = @parameter_group 12 | reset_parameter_group 13 | else 14 | super 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /tests/requests/iam/mfa_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::IAM | mfa requests', ['aws']) do 2 | 3 | tests('success') do 4 | @mfa_devices_format = { 5 | 'MFADevices' => [{ 6 | 'EnableDate' => Time, 7 | 'SerialNumber' => String, 8 | 'UserName' => String 9 | }], 10 | 'IsTruncated' => Fog::Boolean, 11 | 'RequestId' => String 12 | } 13 | 14 | tests('#list_mfa_devices').formats(@mfa_devices_format) do 15 | Fog::AWS[:iam].list_mfa_devices.body 16 | end 17 | end 18 | 19 | tests('failure') do 20 | test('failing conditions') 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/auto_scaling/basic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module AutoScaling 5 | class Basic < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/modify_subnet_attribute.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class ModifySubnetAttribute < Fog::Parsers::Base 6 | def reset 7 | @response = { } 8 | end 9 | 10 | 11 | def end_element(name) 12 | case name 13 | when 'return' 14 | @response[name] = value == 'true' ? true : false 15 | when 'requestId' 16 | @response[name] = value 17 | end 18 | 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/verify_domain_identity.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class VerifyDomainIdentity < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'VerificationToken' 13 | @response[name] = value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sqs/list_queues.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SQS 5 | class ListQueues < Fog::Parsers::Base 6 | def reset 7 | @response = { 'QueueUrls' => [], 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = @value 14 | when 'QueueUrl' 15 | @response['QueueUrls'] << @value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/models/glacier/archives.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/glacier/archive' 2 | 3 | module Fog 4 | module AWS 5 | class Glacier 6 | class Archives < Fog::Collection 7 | model Fog::AWS::Glacier::Archive 8 | attribute :vault 9 | #you can't list a vault's archives 10 | def all 11 | nil 12 | end 13 | 14 | def get(key) 15 | new(:id => key) 16 | end 17 | 18 | def new(attributes = {}) 19 | requires :vault 20 | super({ :vault => vault }.merge!(attributes)) 21 | end 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/fog/aws/models/sns/topics.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/sns/topic' 2 | 3 | module Fog 4 | module AWS 5 | class SNS 6 | class Topics < Fog::Collection 7 | model Fog::AWS::SNS::Topic 8 | 9 | def all 10 | data = service.list_topics.body["Topics"].map { |t| {"id" => t} } #This is an array, but it needs to be an array of hashes for #load 11 | 12 | load(data) 13 | end 14 | 15 | def get(id) 16 | if data = service.get_topic_attributes(id).body["Attributes"] 17 | new(data) 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/associate_address.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class AssociateAddress < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'requestId', 'associationId' 9 | @response[name] = value 10 | when 'return' 11 | if value == 'true' 12 | @response[name] = true 13 | else 14 | @response[name] = false 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /tests/models/elb/tagging_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::ELB | tagging", ['aws', 'elb']) do 2 | @elb5 = Fog::AWS[:elb].load_balancers.create(:id => "fog-test-elb-tagging") 3 | tags1 = {'key1' => 'val1'} 4 | tags2 = {'key2' => 'val2'} 5 | 6 | tests "add and remove tags from an ELB" do 7 | returns({}) { @elb5.tags } 8 | returns(tags1) { @elb5.add_tags tags1 } 9 | returns(tags1.merge tags2) { @elb5.add_tags tags2 } 10 | returns(tags2) { @elb5.remove_tags tags1.keys } 11 | returns(tags2) { @elb5.tags } 12 | 13 | @elb5.destroy 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_watch/delete_alarms.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudWatch 5 | class DeleteAlarms < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = @value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/assign_private_ip_addresses.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class AssignPrivateIpAddresses < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'requestId' 9 | @response[name] = value 10 | when 'return' 11 | if value == 'true' 12 | @response[name] = true 13 | else 14 | @response[name] = false 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/create_security_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CreateSecurityGroup < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'return' 9 | if value == 'true' 10 | @response[name] = true 11 | else 12 | @response[name] = false 13 | end 14 | when 'requestId', 'groupId' 15 | @response[name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/describe_cache_parameters.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/engine_defaults_parser' 6 | 7 | class DescribeCacheParameters < EngineDefaultsParser 8 | def end_element(name) 9 | case name 10 | when 'DescribeCacheParametersResult' 11 | @response[name] = @engine_defaults 12 | reset_engine_defaults 13 | else 14 | super 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/describe_engine_default_parameters.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/engine_defaults_parser' 6 | 7 | class DescribeEngineDefaultParameters < EngineDefaultsParser 8 | def end_element(name) 9 | case name 10 | when 'EngineDefaults' 11 | @response[name] = @engine_defaults 12 | reset_engine_defaults 13 | else 14 | super 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/create_access_key.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class CreateAccessKey < Fog::Parsers::Base 6 | def reset 7 | @response = { 'AccessKey' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'AccessKeyId', 'UserName', 'SecretAccessKey', 'Status' 13 | @response['AccessKey'][name] = value 14 | when 'RequestId' 15 | @response[name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /tests/requests/storage/delete_multiple_objects_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::Storage | delete_multiple_objects', ['aws']) do 2 | @directory = Fog::Storage[:aws].directories.create(:key => 'fogobjecttests-' + Time.now.to_i.to_s(32)) 3 | 4 | tests("doesn't alter options") do 5 | version_id = {'fog_object' => ['12345']} 6 | options = {:quiet => true, 'versionId' => version_id} 7 | Fog::Storage[:aws].delete_multiple_objects(@directory.identity, ['fog_object'], options) 8 | 9 | test(":quiet is unchanged") { options[:quiet] } 10 | test("'versionId' is unchanged") { options['versionId'] == version_id } 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_watch/put_metric_data.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudWatch 5 | class PutMetricData < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = @value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_watch/set_alarm_state.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudWatch 5 | class SetAlarmState < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/get_send_quota.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class GetSendQuota < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when "Max24HourSend", "MaxSendRate", "SentLast24Hours" 13 | @response[name] = value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /tests/models/cdn/invalidations_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::CDN[:aws] | invalidations", ['aws', 'cdn']) do 2 | tests("distributions#create").succeeds do 3 | @distribution = Fog::CDN[:aws].distributions.create(:s3_origin => {'DNSName' => 'fog_test.s3.amazonaws.com'}, :enabled => true) 4 | end 5 | 6 | collection_tests(@distribution.invalidations, { :paths => [ '/index.html' ]}, true) 7 | 8 | tests("distribution#destroy - may take 15/20 minutes to complete").succeeds do 9 | @distribution.wait_for { ready? } 10 | @distribution.disable 11 | @distribution.wait_for { ready? } 12 | @distribution.destroy 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/parameter.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class RDS 4 | class Parameter < Fog::Model 5 | attribute :name, :aliases => ['ParameterName'] 6 | attribute :data_type, :aliases => 'DataType' 7 | attribute :description, :aliases => 'Description' 8 | attribute :allowed_values, :aliases => 'AllowedValues' 9 | attribute :source, :aliases => 'Source' 10 | attribute :modifiable, :aliases => 'IsModifiable' 11 | attribute :apply_type, :aliases => 'ApplyType' 12 | attribute :value, :aliases => 'ParameterValue' 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_watch/put_metric_alarm.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudWatch 5 | class PutMetricAlarm < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value.strip 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_watch/disable_alarm_actions.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudWatch 5 | class DisableAlarmActions < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cloud_watch/enable_alarm_actions.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module CloudWatch 5 | class EnableAlarmActions < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /tests/requests/dns/helper.rb: -------------------------------------------------------------------------------- 1 | class AWS 2 | module DNS 3 | module Formats 4 | RESOURCE_RECORD_SET = { 5 | "ResourceRecords" => Array, 6 | "Name" => String, 7 | "Type" => String, 8 | "AliasTarget"=> Fog::Nullable::Hash, 9 | "TTL" => Fog::Nullable::String 10 | } 11 | 12 | LIST_RESOURCE_RECORD_SETS = { 13 | "ResourceRecordSets" => [RESOURCE_RECORD_SET], 14 | "IsTruncated" => Fog::Boolean, 15 | "MaxItems" => Integer, 16 | "NextRecordName" => Fog::Nullable::String, 17 | "NextRecordType" => Fog::Nullable::String 18 | } 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /tests/signed_params_tests.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | Shindo.tests('AWS | signed_params', ['aws']) do 4 | returns( Fog::AWS.escape( "'Stöp!' said Fred_-~./" ) ) { "%27St%C3%B6p%21%27%20said%20Fred_-~.%2F" } 5 | 6 | tests('Unicode characters should be escaped') do 7 | unicode = ["00E9".to_i(16)].pack("U*") 8 | escaped = "%C3%A9" 9 | returns( escaped ) { Fog::AWS.escape( unicode ) } 10 | end 11 | 12 | tests('Unicode characters with combining marks should be escaped') do 13 | unicode = ["0065".to_i(16), "0301".to_i(16)].pack("U*") 14 | escaped = "e%CC%81" 15 | returns( escaped ) { Fog::AWS.escape( unicode ) } 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/upload_signing_certificate.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class UploadSigningCertificate < Fog::Parsers::Base 6 | def reset 7 | @response = { 'Certificate' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'CertificateId', 'UserName', 'CertificateBody', 'Status' 13 | @response['Certificate'][name] = value 14 | when 'RequestId' 15 | @response[name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/storage/sync_clock.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Storage 3 | class AWS 4 | class Real 5 | # Sync clock against S3 to avoid skew errors 6 | # 7 | def sync_clock 8 | response = begin 9 | get_service 10 | rescue Excon::Errors::HTTPStatusError => error 11 | error.response 12 | end 13 | Fog::Time.now = Time.parse(response.headers['Date']) 14 | end 15 | end # Real 16 | 17 | class Mock # :nodoc:all 18 | def sync_clock 19 | true 20 | end 21 | end # Mock 22 | end # Storage 23 | end # AWS 24 | end # Fog 25 | -------------------------------------------------------------------------------- /tests/models/cloud_watch/alarm_history_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::CloudWatch | alarm_histories", ['aws', 'cloudwatch']) do 2 | 3 | pending if Fog.mocking? 4 | 5 | tests('success') do 6 | tests("#all").succeeds do 7 | Fog::AWS[:cloud_watch].alarm_histories.all 8 | end 9 | 10 | new_attributes = { 11 | :alarm_name => 'tmp-alarm', 12 | :end_date => '', 13 | :history_item_type => 'StateUpdate', 14 | :max_records => 1, 15 | :start_date => '' 16 | } 17 | tests('#new').returns(new_attributes) do 18 | Fog::AWS[:cloud_watch].alarm_histories.new(new_attributes).attributes 19 | end 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/models/beanstalk/event.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class ElasticBeanstalk 4 | class Event < Fog::Model 5 | attribute :application_name, :aliases => 'ApplicationName' 6 | attribute :environment_name, :aliases => 'EnvironmentName' 7 | attribute :date, :aliases => 'EventDate' 8 | attribute :message, :aliases => 'Message' 9 | attribute :request_id, :aliases => 'RequestId' 10 | attribute :severity, :aliases => 'Severity' 11 | attribute :template_name, :aliases => 'TemplateName' 12 | attribute :version_label, :aliases => 'VersionLabel' 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/auto_scaling/put_notification_configuration.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module AutoScaling 5 | class PutNotificationConfiguration < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/create_load_balancer.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class CreateLoadBalancer < Fog::Parsers::Base 6 | def reset 7 | @response = { 'CreateLoadBalancerResult' => {}, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'DNSName' 13 | @response['CreateLoadBalancerResult'][name] = value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /tests/models/compute/address_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | address", ['aws']) do 2 | 3 | model_tests(Fog::Compute[:aws].addresses, {}, true) do 4 | 5 | @server = Fog::Compute[:aws].servers.create 6 | @server.wait_for { ready? } 7 | 8 | tests('#server=').succeeds do 9 | @instance.server = @server 10 | end 11 | 12 | tests('#server') do 13 | test(' == @server') do 14 | @server.reload 15 | @instance.server.public_ip_address == @instance.public_ip 16 | end 17 | end 18 | 19 | @server.destroy 20 | 21 | end 22 | 23 | model_tests(Fog::Compute[:aws].addresses, { :domain => "vpc" }, true) 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/retrieve_environment_info.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class RetrieveEnvironmentInfo < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("RetrieveEnvironmentInfoResult") 9 | tag 'EnvironmentInfo', :object, :list 10 | tag 'Ec2InstanceId', :string 11 | tag 'InfoType', :string 12 | tag 'Message', :string 13 | tag 'SampleTimestamp', :datetime 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/validate_configuration_settings.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class ValidateConfigurationSettings < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("ValidateConfigurationSettingsResult") 9 | tag 'Messages', :object, :list 10 | tag 'Message', :string 11 | tag 'Namespace', :string 12 | tag 'OptionName', :string 13 | tag 'Severity', :string 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /tests/models/cdn/distribution_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::CDN[:aws] | distribution", ['aws', 'cdn']) do 2 | params = { :s3_origin => { 'DNSName' => 'fog_test_cdn.s3.amazonaws.com'}, :enabled => true } 3 | model_tests(Fog::CDN[:aws].distributions, params, true) do 4 | # distribution needs to be ready before being disabled 5 | tests("#ready? - may take 15 minutes to complete...").succeeds do 6 | @instance.wait_for { ready? } 7 | end 8 | 9 | # and disabled before being distroyed 10 | tests("#disable - may take 15 minutes to complete...").succeeds do 11 | @instance.disable 12 | @instance.wait_for { ready? } 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/list_available_solution_stacks.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class ListAvailableSolutionStacks < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("ListAvailableSolutionStacksResult") 9 | tag 'SolutionStackDetails', :object, :list 10 | tag 'PermittedFileTypes', :string, :list 11 | tag 'SolutionStackName', :string 12 | tag 'SolutionStacks', :string, :list 13 | end 14 | end 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_policies.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class ListPolicies < Fog::Parsers::Base 6 | def reset 7 | @response = { 'PolicyNames' => [] } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['PolicyNames'] << value 14 | when 'IsTruncated' 15 | response[name] = (value == 'true') 16 | when 'Marker', 'RequestId' 17 | response[name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/list_verified_email_addresses.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class ListVerifiedEmailAddresses < Fog::Parsers::Base 6 | def reset 7 | @response = { 'VerifiedEmailAddresses' => [], 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['VerifiedEmailAddresses'] << value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /tests/models/cdn/distributions_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::CDN[:aws] | distributions", ['aws', 'cdn']) do 2 | params = { :s3_origin => { 'DNSName' => 'fog_test_cdn.s3.amazonaws.com'}, :enabled => true} 3 | collection_tests(Fog::CDN[:aws].distributions, params, true) do 4 | # distribution needs to be ready before being disabled 5 | tests("#ready? - may take 15 minutes to complete...").succeeds do 6 | @instance.wait_for { ready? } 7 | end 8 | 9 | # and disabled before being distroyed 10 | tests("#disable - may take 15 minutes to complete...").succeeds do 11 | @instance.disable 12 | @instance.wait_for { ready? } 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/rds/delete_db_parameter_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module RDS 5 | class DeleteDbParameterGroup < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | @db_parameter_group = {} 9 | end 10 | 11 | def start_element(name, attrs = []) 12 | super 13 | end 14 | 15 | def end_element(name) 16 | case name 17 | when 'RequestId' 18 | @response['ResponseMetadata'][name] = value 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/rds/download_db_logfile_portion.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module RDS 5 | class DownloadDBLogFilePortion < Fog::Parsers::Base 6 | def reset 7 | @response = { 'DownloadDBLogFilePortionResult' => {}, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | key = (name == 'RequestId') ? 'ResponseMetadata' : 'DownloadDBLogFilePortionResult' 16 | @response[key][name] = value 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/redshift/cluster.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Redshift 4 | module AWS 5 | require 'fog/aws/parsers/redshift/cluster_parser' 6 | 7 | class Cluster < ClusterParser 8 | def reset 9 | super 10 | @response = {} 11 | end 12 | 13 | def start_element(name, attrs = []) 14 | super 15 | end 16 | 17 | def end_element(name) 18 | super 19 | case name 20 | when 'Cluster' 21 | @response = {name => @cluster} 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /tests/requests/sts/get_federation_token_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::STS | session tokens', ['aws']) do 2 | 3 | @policy = {"Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]} 4 | 5 | @federation_format = { 6 | 'SessionToken' => String, 7 | 'SecretAccessKey' => String, 8 | 'Expiration' => String, 9 | 'AccessKeyId' => String, 10 | 'Arn' => String, 11 | 'FederatedUserId' => String, 12 | 'PackedPolicySize' => String, 13 | 'RequestId' => String 14 | } 15 | 16 | tests("#get_federation_token('test@fog.io', #{@policy.inspect})").formats(@federation_format) do 17 | Fog::AWS[:sts].get_federation_token("test@fog.io", @policy).body 18 | end 19 | 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/get_console_output.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class GetConsoleOutput < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'instanceId', 'requestId' 13 | @response[name] = value 14 | when 'output' 15 | @response[name] = value && Base64.decode64(value) 16 | when 'timestamp' 17 | @response[name] = Time.parse(value) 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/authorize_cache_security_group_ingress.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/security_group_parser' 6 | 7 | class AuthorizeCacheSecurityGroupIngress < Fog::Parsers::AWS::Elasticache::SecurityGroupParser 8 | def end_element(name) 9 | case name 10 | when 'CacheSecurityGroup' then 11 | @response['CacheSecurityGroup'] = @security_group 12 | reset_security_group 13 | else 14 | super 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /tests/requests/rds/log_file_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::RDS | log file requests', %w[aws rds]) do 2 | tests('success') do 3 | pending if Fog.mocking? 4 | 5 | suffix = rand(65536).to_s(16) 6 | @db_instance_id = "fog-test-#{suffix}" 7 | 8 | tests('#describe_db_log_files').formats(AWS::RDS::Formats::DESCRIBE_DB_LOG_FILES) do 9 | result = Fog::AWS[:rds].describe_db_log_files(@db_instance_id).body['DescribeDBLogFilesResult'] 10 | returns(true) { result['DBLogFiles'].size > 0 } 11 | result 12 | end 13 | 14 | end 15 | 16 | tests('failures') do 17 | raises(Fog::AWS::RDS::NotFound) {Fog::AWS[:rds].describe_db_log_files('doesntexist')} 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_account_aliases.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class ListAccountAliases < Fog::Parsers::Base 6 | def reset 7 | @response = { 'AccountAliases' => [] } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['AccountAliases'] << @value 14 | when 'IsTruncated' 15 | response[name] = (@value == 'true') 16 | when 'Marker', 'RequestId' 17 | response[name] = @value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/update_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class UpdateGroup < Fog::Parsers::Base 6 | # http://docs.amazonwebservices.com/IAM/latest/APIReference/index.html?API_UpdateGroup.html 7 | def reset 8 | @response = { 'Group' => {} } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'Arn', 'GroupId', 'GroupName', 'Path' 14 | @response['Group'][name] = value 15 | when 'RequestId' 16 | @response[name] = value 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/update_user.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class UpdateUser < Fog::Parsers::Base 6 | # http://docs.amazonwebservices.com/IAM/latest/APIReference/index.html?API_UpdateUser.html 7 | 8 | def reset 9 | @response = { 'User' => {} } 10 | end 11 | 12 | def end_element(name) 13 | case name 14 | when 'Arn', 'UserId', 'UserName', 'Path' 15 | @response['User'][name] = value 16 | when 'RequestId' 17 | @response[name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sqs/send_message.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SQS 5 | class SendMessage < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'RequestId' 13 | @response['ResponseMetadata'][name] = @value 14 | when 'MessageId' 15 | @response['MessageId'] = @value 16 | when 'MD5OfMessageBody' 17 | @response['MD5OfMessageBody'] = @value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /tests/models/cdn/streaming_distribution_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::CDN[:aws] | streaming_distribution", ['aws', 'cdn']) do 2 | params = { :s3_origin => { 'DNSName' => 'fog_test_cdn.s3.amazonaws.com'}, :enabled => true } 3 | model_tests(Fog::CDN[:aws].streaming_distributions, params, true) do 4 | # distribution needs to be ready before being disabled 5 | tests("#ready? - may take 15 minutes to complete...").succeeds do 6 | @instance.wait_for { ready? } 7 | end 8 | 9 | # and disabled before being distroyed 10 | tests("#disable - may take 15 minutes to complete...").succeeds do 11 | @instance.disable 12 | @instance.wait_for { ready? } 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /tests/models/compute/network_acls_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | network_acls", ['aws']) do 2 | @vpc = Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24') 3 | 4 | collection_tests(Fog::Compute[:aws].network_acls, { :vpc_id => @vpc.id }, true) 5 | 6 | tests('tags') do 7 | test_tags = {'foo' => 'bar'} 8 | @acl = Fog::Compute[:aws].network_acls.create(:vpc_id => @vpc.id, :tags => test_tags) 9 | 10 | tests('@acl.tags').returns(test_tags) do 11 | @acl.reload.tags 12 | end 13 | 14 | unless Fog.mocking? 15 | Fog::Compute[:aws].tags.all('resource-id' => @acl.identity).each {|tag| tag.destroy} 16 | end 17 | end 18 | 19 | @vpc.destroy 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/login_profile.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class LoginProfile < Fog::Parsers::Base 6 | def reset 7 | @response = { 'LoginProfile' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'UserName' 13 | @response['LoginProfile']['UserName'] = value 14 | when 'CreateDate' 15 | @response['LoginProfile']['CreateDate'] = Time.parse(value) 16 | when 'RequestId' 17 | @response[name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/single_role.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | require 'fog/aws/parsers/iam/role_parser' 6 | class SingleRole < Fog::Parsers::AWS::IAM::RoleParser 7 | def reset 8 | super 9 | @response = { 'Role' => {} } 10 | end 11 | 12 | def finished_role(role) 13 | @response['Role'] = role 14 | end 15 | 16 | def end_element(name) 17 | case name 18 | when 'RequestId' 19 | @response[name] = value 20 | end 21 | super 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /tests/models/cdn/streaming_distributions_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::CDN[:aws] | streaming_distributions", ['aws', 'cdn']) do 2 | params = { :s3_origin => { 'DNSName' => 'fog_test_cdn.s3.amazonaws.com'}, :enabled => true} 3 | collection_tests(Fog::CDN[:aws].streaming_distributions, params, true) do 4 | # distribution needs to be ready before being disabled 5 | tests("#ready? - may take 15 minutes to complete...").succeeds do 6 | @instance.wait_for { ready? } 7 | end 8 | 9 | # and disabled before being distroyed 10 | tests("#disable - may take 15 minutes to complete...").succeeds do 11 | @instance.disable 12 | @instance.wait_for { ready? } 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/create_snapshot.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CreateSnapshot < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'description', 'ownerId', 'progress', 'snapshotId', 'status', 'volumeId' 9 | @response[name] = value 10 | when 'requestId' 11 | @response[name] = value 12 | when 'startTime' 13 | @response[name] = Time.parse(value) 14 | when 'volumeSize' 15 | @response[name] = value.to_i 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /tests/requests/sts/assume_role_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::STS | assume role', ['aws']) do 2 | 3 | @policy = {"Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]} 4 | 5 | @response_format = { 6 | 'SessionToken' => String, 7 | 'SecretAccessKey' => String, 8 | 'Expiration' => String, 9 | 'AccessKeyId' => String, 10 | 'Arn' => String, 11 | 'RequestId' => String 12 | } 13 | 14 | tests("#assume_role('rolename', 'assumed_role_session', 'external_id', #{@policy.inspect}, 900)").formats(@response_format) do 15 | pending if Fog.mocking? 16 | Fog::AWS[:sts].assume_role("rolename","assumed_role_session","external_id", @policy, 900).body 17 | end 18 | 19 | end 20 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/simpledb/basic.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SimpleDB 5 | class Basic < Fog::Parsers::Base 6 | def initialize(nil_string) 7 | @nil_string = nil_string 8 | reset 9 | end 10 | 11 | def end_element(name) 12 | case(name) 13 | when 'BoxUsage' 14 | response[name] = value.to_f 15 | when 'RequestId' 16 | response[name] = value 17 | end 18 | end 19 | 20 | def sdb_decode(value) 21 | value.eql?(@nil_string) ? nil : value 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /tests/models/compute/key_pair_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("Fog::Compute[:aws] | key_pair", ['aws']) do 2 | 3 | model_tests(Fog::Compute[:aws].key_pairs, {:name => 'fogkeyname'}, true) 4 | 5 | after do 6 | @keypair.destroy 7 | end 8 | 9 | tests("new keypair") do 10 | @keypair = Fog::Compute[:aws].key_pairs.create(:name => 'testkey') 11 | 12 | test ("writable?") do 13 | @keypair.writable? == true 14 | end 15 | end 16 | 17 | tests("existing keypair") do 18 | Fog::Compute[:aws].key_pairs.create(:name => 'testkey') 19 | @keypair = Fog::Compute[:aws].key_pairs.get('testkey') 20 | 21 | test("writable?") do 22 | @keypair.writable? == false 23 | end 24 | end 25 | 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/single_policy.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | require 'fog/aws/parsers/iam/policy_parser' 6 | class SinglePolicy < Fog::Parsers::AWS::IAM::PolicyParser 7 | def reset 8 | super 9 | @response = { 'Policy' => {} } 10 | end 11 | 12 | def finished_policy(policy) 13 | @response['Policy'] = policy 14 | end 15 | 16 | def end_element(name) 17 | case name 18 | when 'RequestId' 19 | @response[name] = value 20 | end 21 | super 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/describe_key_pairs.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DescribeKeyPairs < Fog::Parsers::Base 6 | def reset 7 | @key = {} 8 | @response = { 'keySet' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'item' 14 | @response['keySet'] << @key 15 | @key = {} 16 | when 'keyFingerprint', 'keyName' 17 | @key[name] = value 18 | when 'requestId' 19 | @response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/attach_load_balancer_to_subnets.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class AttachLoadBalancerToSubnets < Fog::Parsers::Base 6 | def reset 7 | @response = { 'AttachLoadBalancerToSubnetsResult' => { 'Subnets' => [] }, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['AttachLoadBalancerToSubnetsResult']['Subnets'] << value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/servers.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/rds/server' 2 | 3 | module Fog 4 | module AWS 5 | class RDS 6 | class Servers < Fog::Collection 7 | model Fog::AWS::RDS::Server 8 | 9 | def all 10 | data = service.describe_db_instances.body['DescribeDBInstancesResult']['DBInstances'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | 14 | def get(identity) 15 | data = service.describe_db_instances(identity).body['DescribeDBInstancesResult']['DBInstances'].first 16 | new(data) # data is an attribute hash 17 | rescue Fog::AWS::RDS::NotFound 18 | nil 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/create_volume.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CreateVolume < Fog::Parsers::Base 6 | def end_element(name) 7 | case name 8 | when 'availabilityZone', 'requestId', 'snapshotId', 'status', 'volumeId', 'volumeType' 9 | @response[name] = value 10 | when 'createTime' 11 | @response[name] = Time.parse(value) 12 | when 'size', 'iops' 13 | @response[name] = value.to_i 14 | when 'encrypted' 15 | @response[name] = (value == 'true') 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/describe_tags.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DescribeTags < Fog::Parsers::Base 6 | def reset 7 | @tag = {} 8 | @response = { 'tagSet' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'resourceId', 'resourceType', 'key', 'value' 14 | @tag[name] = value 15 | when 'item' 16 | @response['tagSet'] << @tag 17 | @tag = {} 18 | when 'requestId' 19 | @response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/describe_cache_clusters.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/cache_cluster_parser' 6 | 7 | class DescribeCacheClusters < CacheClusterParser 8 | def reset 9 | super 10 | @response['CacheClusters'] = [] 11 | end 12 | 13 | def end_element(name) 14 | case name 15 | when 'CacheCluster' 16 | @response["#{name}s"] << @cache_cluster 17 | reset_cache_cluster 18 | else 19 | super 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/describe_tags.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DescribeTags < Fog::Parsers::Base 6 | def reset 7 | @tag = {} 8 | @response = { 'tagSet' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'resourceId', 'resourceType', 'key', 'value' 14 | @tag[name] = value 15 | when 'item' 16 | @response['tagSet'] << @tag 17 | @tag = {} 18 | when 'requestId' 19 | @response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/emr/add_instance_groups.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module EMR 5 | class AddInstanceGroups < Fog::Parsers::Base 6 | def start_element(name, attrs = []) 7 | super 8 | case name 9 | when 'InstanceGroupIds' 10 | @response['InstanceGroupIds'] = [] 11 | end 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'JobFlowId' 17 | @response[name] = value 18 | when 'member' 19 | @response['InstanceGroupIds'] << value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/rds/base.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module RDS 5 | # Base parser for ResponseMetadata, RequestId 6 | class Base < Fog::Parsers::Base 7 | def reset 8 | super 9 | @response = { 'ResponseMetadata' => {} } 10 | end 11 | 12 | def start_element(name, attrs = []) 13 | super 14 | end 15 | 16 | def end_element(name) 17 | case name 18 | when 'RequestId' 19 | @response['ResponseMetadata'][name] = value 20 | else 21 | super 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cdn/post_invalidation.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module CDN 4 | module AWS 5 | class PostInvalidation < Fog::Parsers::Base 6 | def reset 7 | @response = { 'InvalidationBatch' => { 'Path' => [] } } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'CallerReference' 13 | @response['InvalidationBatch'][name] = value 14 | when 'CreateTime', 'Id', 'Status' 15 | @response[name] = value 16 | when 'Path' 17 | @response['InvalidationBatch'][name] << value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/detach_load_balancer_from_subnets.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class DetachLoadBalancerFromSubnets < Fog::Parsers::Base 6 | def reset 7 | @response = { 'DetachLoadBalancerFromSubnetsResult' => { 'Subnets' => [] }, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['DetachLoadBalancerFromSubnetsResult']['Subnets'] << value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/kms/describe_key.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class KMS 4 | class Real 5 | require 'fog/aws/parsers/kms/describe_key' 6 | 7 | def describe_key(identifier) 8 | request( 9 | 'Action' => 'DescribeKey', 10 | 'KeyId' => identifier, 11 | :parser => Fog::Parsers::AWS::KMS::DescribeKey.new 12 | ) 13 | end 14 | end 15 | 16 | class Mock 17 | def describe_key(identifier) 18 | response = Excon::Response.new 19 | key = self.data[:keys][identifier] 20 | 21 | response.body = { "KeyMetadata" => key } 22 | response 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /tests/requests/compute/spot_price_history_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('Fog::Compute[:aws] | spot price history requests', ['aws']) do 2 | 3 | @spot_price_history_format = { 4 | 'spotPriceHistorySet' => [{ 5 | 'availabilityZone' => String, 6 | 'instanceType' => String, 7 | 'spotPrice' => Float, 8 | 'productDescription' => String, 9 | 'timestamp' => Time 10 | }], 11 | 'requestId' => String, 12 | 'nextToken' => Fog::Nullable::String 13 | } 14 | 15 | tests('success') do 16 | 17 | tests("#describe_spot_price_history").formats(@spot_price_history_format) do 18 | Fog::Compute[:aws].describe_spot_price_history.body 19 | end 20 | 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/simpledb/list_domains.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/parsers/simpledb/basic' 2 | 3 | module Fog 4 | module Parsers 5 | module AWS 6 | module SimpleDB 7 | class ListDomains < Fog::Parsers::AWS::SimpleDB::Basic 8 | def reset 9 | @response = { 'Domains' => [] } 10 | end 11 | 12 | def end_element(name) 13 | case(name) 14 | when 'BoxUsage' 15 | response[name] = value.to_f 16 | when 'DomainName' 17 | response['Domains'] << value 18 | when 'NextToken', 'RequestId' 19 | response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/dns/delete_health_check.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module DNS 3 | class AWS 4 | class Real 5 | # This action deletes a health check. 6 | # http://docs.aws.amazon.com/Route53/latest/APIReference/API_DeleteHealthCheck.html 7 | # 8 | # ==== Parameters 9 | # * id<~String> - Health check ID 10 | # === Returns 11 | # * response<~Excon::Response>: 12 | # * status<~Integer> - 200 when successful 13 | 14 | def delete_health_check(id) 15 | request({ 16 | :expects => 200, 17 | :method => 'DELETE', 18 | :path => "healthcheck/#{id}" 19 | }) 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/describe_regions.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DescribeRegions < Fog::Parsers::Base 6 | def reset 7 | @region = {} 8 | @response = { 'regionInfo' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'item' 14 | @response['regionInfo'] << @region 15 | @region = {} 16 | when 'regionEndpoint', 'regionName' 17 | @region[name] = value 18 | when 'requestId' 19 | @response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/base.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | # Base parser for ResponseMetadata, RequestId 6 | class Base < Fog::Parsers::Base 7 | def reset 8 | super 9 | @response = { 'ResponseMetadata' => {} } 10 | end 11 | 12 | def start_element(name, attrs = []) 13 | super 14 | end 15 | 16 | def end_element(name) 17 | case name 18 | when 'RequestId' 19 | @response['ResponseMetadata'][name] = value 20 | else 21 | super 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/describe_security_groups.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/security_group_parser' 6 | 7 | class DescribeSecurityGroups < SecurityGroupParser 8 | def reset 9 | super 10 | @response['CacheSecurityGroups'] = [] 11 | end 12 | 13 | def end_element(name) 14 | case name 15 | when 'CacheSecurityGroup' 16 | @response["#{name}s"] << @security_group 17 | reset_security_group 18 | else 19 | super 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /tests/requests/kms/key_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::KMS | key requests', ['aws', 'kms']) do 2 | key_id = nil 3 | 4 | tests('success') do 5 | tests("#create_key").data_matches_schema(AWS::KMS::Formats::DESCRIBE_KEY) do 6 | result = Fog::AWS[:kms].create_key.body 7 | key_id = result["KeyMetadata"]["KeyId"] 8 | 9 | result 10 | end 11 | end 12 | 13 | tests("#describe_key").data_matches_schema(AWS::KMS::Formats::DESCRIBE_KEY) do 14 | result = Fog::AWS[:kms].describe_key(key_id).body 15 | returns(key_id) { result['KeyMetadata']['KeyId'] } 16 | result 17 | end 18 | 19 | tests("#list_keys").data_matches_schema(AWS::KMS::Formats::LIST_KEYS) do 20 | Fog::AWS[:kms].list_keys.body 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/models/compute/tags.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/compute/tag' 2 | 3 | module Fog 4 | module Compute 5 | class AWS 6 | class Tags < Fog::Collection 7 | attribute :filters 8 | 9 | model Fog::Compute::AWS::Tag 10 | 11 | def initialize(attributes) 12 | self.filters ||= {} 13 | super 14 | end 15 | 16 | def all(filters_arg = filters) 17 | filters = filters_arg 18 | data = service.describe_tags(filters).body 19 | load(data['tagSet']) 20 | end 21 | 22 | def get(key) 23 | if key 24 | self.class.new(:service => service).all('key' => key) 25 | end 26 | end 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/describe_parameter_groups.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/parameter_group_parser' 6 | 7 | class DescribeParameterGroups < ParameterGroupParser 8 | def reset 9 | super 10 | @response['CacheParameterGroups'] = [] 11 | end 12 | 13 | def end_element(name) 14 | case name 15 | when 'CacheParameterGroup' 16 | @response["#{name}s"] << @parameter_group 17 | reset_parameter_group 18 | else 19 | super 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/instance_profile.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | require 'fog/aws/parsers/iam/base_instance_profile' 6 | 7 | class InstanceProfile < Fog::Parsers::AWS::IAM::BaseInstanceProfile 8 | def reset 9 | super 10 | @response = {} 11 | end 12 | 13 | def finished_instance_profile(profile) 14 | @response['InstanceProfile'] = profile 15 | end 16 | 17 | def end_element(name) 18 | case name 19 | when 'RequestId' 20 | @response[name] = value 21 | end 22 | super 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/create_application.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class CreateApplication < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("CreateApplicationResult") 9 | tag 'Application', :object 10 | tag 'Versions', :string, :list 11 | tag 'ConfigurationTemplates', :string, :list 12 | tag 'ApplicationName', :string 13 | tag 'Description', :string 14 | tag 'DateCreated', :datetime 15 | tag 'DateUpdated', :datetime 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/update_application.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class UpdateApplication < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("UpdateApplicationResult") 9 | tag 'Application', :object 10 | tag 'Versions', :string, :list 11 | tag 'ConfigurationTemplates', :string, :list 12 | tag 'ApplicationName', :string 13 | tag 'Description', :string 14 | tag 'DateCreated', :datetime 15 | tag 'DateUpdated', :datetime 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/reset_parameter_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/parameter_group_parser' 6 | 7 | class ResetParameterGroup < ParameterGroupParser 8 | def reset 9 | super 10 | @response['ResetCacheParameterGroupResult'] = [] 11 | end 12 | 13 | def end_element(name) 14 | case name 15 | when 'ResetCacheParameterGroupResult' 16 | @response[name] = @parameter_group 17 | reset_parameter_group 18 | else 19 | super 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/sns/unsubscribe.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class SNS 4 | class Real 5 | require 'fog/aws/parsers/sns/unsubscribe' 6 | 7 | # Delete a subscription 8 | # 9 | # ==== Parameters 10 | # * arn<~String> - Arn of subscription to delete 11 | # 12 | # ==== See Also 13 | # http://docs.amazonwebservices.com/sns/latest/api/API_Unsubscribe.html 14 | # 15 | 16 | def unsubscribe(arn) 17 | request({ 18 | 'Action' => 'Unsubscribe', 19 | 'SubscriptionArn' => arn.strip, 20 | :parser => Fog::Parsers::AWS::SNS::Unsubscribe.new 21 | }) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elasticache/security_groups.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/elasticache/security_group' 2 | 3 | module Fog 4 | module AWS 5 | class Elasticache 6 | class SecurityGroups < Fog::Collection 7 | model Fog::AWS::Elasticache::SecurityGroup 8 | 9 | def all 10 | load( 11 | service.describe_cache_security_groups.body['CacheSecurityGroups'] 12 | ) 13 | end 14 | 15 | def get(identity) 16 | new( 17 | service.describe_cache_security_groups( 18 | identity 19 | ).body['CacheSecurityGroups'].first 20 | ) 21 | rescue Fog::AWS::Elasticache::NotFound 22 | nil 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/instance_option.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class RDS 4 | class InstanceOption < Fog::Model 5 | attribute :multi_az_capable, :aliases => 'MultiAZCapable', :type => :boolean 6 | attribute :engine, :aliases => 'Engine' 7 | attribute :license_model, :aliases => 'LicenseModel' 8 | attribute :read_replica_capable, :aliases => 'ReadReplicaCapable', :type => :boolean 9 | attribute :engine_version, :aliases => 'EngineVersion' 10 | attribute :availability_zones, :aliases => 'AvailabilityZones', :type => :array 11 | attribute :db_instance_class, :aliases => 'DBInstanceClass' 12 | attribute :vpc, :aliases => 'Vpc', :type => :boolean 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/modify_parameter_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/parameter_group_parser' 6 | 7 | class ModifyParameterGroup < ParameterGroupParser 8 | def reset 9 | super 10 | @response['ModifyCacheParameterGroupResult'] = [] 11 | end 12 | 13 | def end_element(name) 14 | case name 15 | when 'ModifyCacheParameterGroupResult' 16 | @response[name] = @parameter_group 17 | reset_parameter_group 18 | else 19 | super 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/apply_security_groups_to_load_balancer.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class ApplySecurityGroupsToLoadBalancer < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ApplySecurityGroupsToLoadBalancerResult' => { 'SecurityGroups' => [] }, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['ApplySecurityGroupsToLoadBalancerResult']['SecurityGroups'] << value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /tests/requests/sts/assume_role_with_saml_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::STS | assume role with SAML', ['aws']) do 2 | 3 | @policy = {"Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]} 4 | 5 | @response_format = { 6 | 'SessionToken' => String, 7 | 'SecretAccessKey' => String, 8 | 'Expiration' => String, 9 | 'AccessKeyId' => String, 10 | 'Arn' => String, 11 | 'RequestId' => String 12 | } 13 | 14 | tests("#assume_role_with_saml('role_arn', 'principal_arn', 'saml_assertion', #{@policy.inspect}, 900)").formats(@response_format) do 15 | pending if Fog.mocking? 16 | Fog::AWS[:sts].assume_role_with_saml("role_arn","principal_arn","saml_assertion", @policy, 900).body 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elasticache/parameter_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class Elasticache 4 | class ParameterGroup < Fog::Model 5 | identity :id, :aliases => 'CacheParameterGroupName' 6 | attribute :description, :aliases => 'Description' 7 | attribute :family, :aliases => 'CacheParameterGroupFamily' 8 | 9 | def destroy 10 | requires :id 11 | service.delete_cache_parameter_group(id) 12 | true 13 | end 14 | 15 | def save 16 | requires :id 17 | service.create_cache_parameter_group( 18 | id, 19 | description = id, 20 | family = 'memcached1.4' 21 | ) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elasticache/parameter_groups.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/elasticache/parameter_group' 2 | 3 | module Fog 4 | module AWS 5 | class Elasticache 6 | class ParameterGroups < Fog::Collection 7 | model Fog::AWS::Elasticache::ParameterGroup 8 | 9 | def all 10 | load( 11 | service.describe_cache_parameter_groups.body['CacheParameterGroups'] 12 | ) 13 | end 14 | 15 | def get(identity) 16 | new( 17 | service.describe_cache_parameter_groups( 18 | identity 19 | ).body['CacheParameterGroups'].first 20 | ) 21 | rescue Fog::AWS::Elasticache::NotFound 22 | nil 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/create_network_acl.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | require 'fog/aws/parsers/compute/network_acl_parser' 6 | 7 | class CreateNetworkAcl < NetworkAclParser 8 | def reset 9 | super 10 | @response = { 'networkAcl' => {} } 11 | end 12 | 13 | def end_element(name) 14 | case name 15 | when 'requestId' 16 | @response[name] = value 17 | when 'networkAcl' 18 | @response['networkAcl'] = @network_acl 19 | reset_nacl 20 | else 21 | super 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/register_instances_with_load_balancer.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class RegisterInstancesWithLoadBalancer < Fog::Parsers::Base 6 | def reset 7 | @response = { 'RegisterInstancesWithLoadBalancerResult' => { 'Instances' => [] }, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'InstanceId' 13 | @response['RegisterInstancesWithLoadBalancerResult']['Instances'] << {name => value} 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/subnet_groups.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/rds/subnet_group' 2 | 3 | module Fog 4 | module AWS 5 | class RDS 6 | class SubnetGroups < Fog::Collection 7 | model Fog::AWS::RDS::SubnetGroup 8 | 9 | def all 10 | data = service.describe_db_subnet_groups.body['DescribeDBSubnetGroupsResult']['DBSubnetGroups'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | 14 | def get(identity) 15 | data = service.describe_db_subnet_groups(identity).body['DescribeDBSubnetGroupsResult']['DBSubnetGroups'].first 16 | new(data) # data is an attribute hash 17 | rescue Fog::AWS::RDS::NotFound 18 | nil 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/describe_applications.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class DescribeApplications < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("DescribeApplicationsResult") 9 | tag 'Applications', :object, :list 10 | tag 'Versions', :string, :list 11 | tag 'ConfigurationTemplates', :string, :list 12 | tag 'ApplicationName', :string 13 | tag 'Description', :string 14 | tag 'DateCreated', :datetime 15 | tag 'DateUpdated', :datetime 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/deregister_instances_from_load_balancer.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class DeregisterInstancesFromLoadBalancer < Fog::Parsers::Base 6 | def reset 7 | @response = { 'DeregisterInstancesFromLoadBalancerResult' => { 'Instances' => [] }, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'InstanceId' 13 | @response['DeregisterInstancesFromLoadBalancerResult']['Instances'] << {name => value} 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/get_user.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class GetUser < Fog::Parsers::Base 6 | # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_GetUser.html 7 | 8 | def reset 9 | @response = { 'User' => {} } 10 | end 11 | 12 | def end_element(name) 13 | case name 14 | when 'Arn', 'UserId', 'UserName', 'Path' 15 | @response['User'][name] = value 16 | when 'CreateDate' 17 | @response['User'][name] = Time.parse(value) 18 | when 'RequestId' 19 | @response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/redshift/describe_clusters.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Redshift 4 | module AWS 5 | require 'fog/aws/parsers/redshift/cluster_parser' 6 | 7 | class DescribeClusters < ClusterParser 8 | def reset 9 | super 10 | @response = {"ClusterSet" => []} 11 | end 12 | 13 | def start_element(name, attrs = []) 14 | super 15 | end 16 | 17 | def end_element(name) 18 | super 19 | case name 20 | when 'Cluster' 21 | @response["ClusterSet"] << {name => @cluster} 22 | @cluster = fresh_cluster 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/models/beanstalk/applications.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/beanstalk/application' 2 | 3 | module Fog 4 | module AWS 5 | class ElasticBeanstalk 6 | class Applications < Fog::Collection 7 | model Fog::AWS::ElasticBeanstalk::Application 8 | 9 | def all(application_names=[]) 10 | data = service.describe_applications(application_names).body['DescribeApplicationsResult']['Applications'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | 14 | def get(application_name) 15 | if data = service.describe_applications([application_name]).body['DescribeApplicationsResult']['Applications'].first 16 | new(data) 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/models/compute/tag.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Compute 3 | class AWS 4 | class Tag < Fog::Model 5 | identity :key 6 | 7 | attribute :value 8 | attribute :resource_id, :aliases => 'resourceId' 9 | attribute :resource_type, :aliases => 'resourceType' 10 | 11 | def initialize(attributes = {}) 12 | super 13 | end 14 | 15 | def destroy 16 | requires :key, :resource_id 17 | service.delete_tags(resource_id, key => value) 18 | true 19 | end 20 | 21 | def save 22 | requires :key, :resource_id 23 | service.create_tags(resource_id, key => value) 24 | true 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/event_subscriptions.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/rds/event_subscription' 2 | 3 | module Fog 4 | module AWS 5 | class RDS 6 | class EventSubscriptions < Fog::Collection 7 | model Fog::AWS::RDS::EventSubscription 8 | 9 | def all 10 | data = service.describe_event_subscriptions.body['DescribeEventSubscriptionsResult']['EventSubscriptionsList'] 11 | load(data) 12 | end 13 | 14 | def get(identity) 15 | data = service.describe_event_subscriptions('SubscriptionName' => identity).body['DescribeEventSubscriptionsResult']['EventSubscriptionsList'] 16 | new(data.first) 17 | rescue Fog::AWS::RDS::NotFound 18 | nil 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sts/assume_role.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module STS 5 | class AssumeRole < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'SessionToken', 'SecretAccessKey', 'Expiration', 'AccessKeyId' 13 | @response[name] = @value.strip 14 | when 'Arn', 'AssumedRoleId' 15 | @response[name] = @value.strip 16 | when 'PackedPolicySize' 17 | @response[name] = @value 18 | when 'RequestId' 19 | @response[name] = @value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /tests/requests/beanstalk/solution_stack_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::ElasticBeanstalk | solution_stack_tests', ['aws', 'beanstalk']) do 2 | 3 | tests('success') do 4 | pending if Fog.mocking? 5 | 6 | @solution_stack_result_format = { 7 | 'ListAvailableSolutionStacksResult' => { 8 | 'SolutionStackDetails' => [ 9 | 'SolutionStackName' => String, 10 | 'PermittedFileTypes' => [String] 11 | ], 12 | 'SolutionStacks' => [String] 13 | }, 14 | 'ResponseMetadata' => {'RequestId'=> String}, 15 | } 16 | tests("#list_available_solution_stacks").formats(@solution_stack_result_format) do 17 | Fog::AWS[:beanstalk].list_available_solution_stacks.body 18 | 19 | end 20 | 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/enable_availability_zones_for_load_balancer.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class EnableAvailabilityZonesForLoadBalancer < Fog::Parsers::Base 6 | def reset 7 | @response = { 'EnableAvailabilityZonesForLoadBalancerResult' => { 'AvailabilityZones' => [] }, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['EnableAvailabilityZonesForLoadBalancerResult']['AvailabilityZones'] << value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/rds/delete_db_security_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module RDS 5 | require 'fog/aws/parsers/rds/snapshot_parser' 6 | 7 | class DeleteDBSecurityGroup < Fog::Parsers::AWS::RDS::SnapshotParser 8 | def reset 9 | @response = { 'ResponseMetadata' => {} } 10 | super 11 | end 12 | 13 | def start_element(name, attrs = []) 14 | super 15 | end 16 | 17 | def end_element(name) 18 | case name 19 | when 'RequestId' 20 | @response['ResponseMetadata'][name] = value 21 | else 22 | super 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/rds/delete_event_subscription.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module RDS 5 | require 'fog/aws/parsers/rds/snapshot_parser' 6 | 7 | class DeleteEventSubscription < Fog::Parsers::AWS::RDS::SnapshotParser 8 | def reset 9 | @response = { 'ResponseMetadata' => {} } 10 | super 11 | end 12 | 13 | def start_element(name, attrs=[]) 14 | super 15 | end 16 | 17 | def end_element(name) 18 | case name 19 | when 'RequestId' 20 | @response['ResponseMetadata'][name] = value 21 | else 22 | super 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/redshift/update_cluster_parameter_group_parser.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Redshift 4 | module AWS 5 | class UpdateClusterParameterGroupParser < Fog::Parsers::Base 6 | # :parameter_group_name - (String) 7 | # :parameter_group_status - (String) 8 | 9 | def reset 10 | @response = {} 11 | end 12 | 13 | def start_element(name, attrs = []) 14 | super 15 | end 16 | 17 | def end_element(name) 18 | super 19 | case name 20 | when 'ParameterGroupName', 'ParameterGroupStatus' 21 | @response[name] = value 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /tests/requests/kms/helper.rb: -------------------------------------------------------------------------------- 1 | class AWS 2 | module KMS 3 | module Formats 4 | BASIC = { 5 | 'ResponseMetadata' => { 'RequestId' => String } 6 | } 7 | 8 | DESCRIBE_KEY = { 9 | "KeyMetadata" => { 10 | "KeyUsage" => String, 11 | "AWSAccountId" => String, 12 | "KeyId" => String, 13 | "Description" => Fog::Nullable::String, 14 | "CreationDate" => Time, 15 | "Arn" => String, 16 | "Enabled" => Fog::Boolean 17 | } 18 | } 19 | 20 | LIST_KEYS = { 21 | "Keys" => [{ "KeyId" => String, "KeyArn" => String }], 22 | "Truncated" => Fog::Boolean, 23 | "Marker" => Fog::Nullable::String 24 | } 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elb/disable_availability_zones_for_load_balancer.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ELB 5 | class DisableAvailabilityZonesForLoadBalancer < Fog::Parsers::Base 6 | def reset 7 | @response = { 'DisableAvailabilityZonesForLoadBalancerResult' => { 'AvailabilityZones' => [] }, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'member' 13 | @response['DisableAvailabilityZonesForLoadBalancerResult']['AvailabilityZones'] << value 14 | when 'RequestId' 15 | @response['ResponseMetadata'][name] = value 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/cloud_formation/delete_stack.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class CloudFormation 4 | class Real 5 | require 'fog/aws/parsers/cloud_formation/basic' 6 | 7 | # Delete a stack. 8 | # 9 | # @param stack_name String] Name of the stack to create. 10 | # 11 | # @return [Excon::Response] 12 | # 13 | # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DeleteStack.html 14 | 15 | def delete_stack(stack_name) 16 | request( 17 | 'Action' => 'DeleteStack', 18 | 'StackName' => stack_name, 19 | :parser => Fog::Parsers::AWS::CloudFormation::Basic.new 20 | ) 21 | end 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/elasticache/parameter_group_parser.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module Elasticache 5 | require 'fog/aws/parsers/elasticache/base' 6 | 7 | class ParameterGroupParser < Base 8 | def reset 9 | super 10 | reset_parameter_group 11 | end 12 | 13 | def reset_parameter_group 14 | @parameter_group = {} 15 | end 16 | 17 | def end_element(name) 18 | case name 19 | when 'Description', 'CacheParameterGroupName', 'CacheParameterGroupFamily' 20 | @parameter_group[name] = value 21 | else 22 | super 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/upload_server_certificate.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class UploadServerCertificate < Fog::Parsers::Base 6 | def reset 7 | @response = { 'Certificate' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'Arn', 'Path', 'ServerCertificateId', 'ServerCertificateName', 'CertificateBody', 'CertificateChain' 13 | @response['Certificate'][name] = value 14 | when 'UploadDate' 15 | @response['Certificate'][name] = Time.parse(value) 16 | when 'RequestId' 17 | @response[name] = value 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sts/assume_role_with_saml.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module STS 5 | class AssumeRoleWithSAML < Fog::Parsers::Base 6 | def reset 7 | @response = {} 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'SessionToken', 'SecretAccessKey', 'Expiration', 'AccessKeyId' 13 | @response[name] = @value.strip 14 | when 'Arn', 'AssumedRoleId' 15 | @response[name] = @value.strip 16 | when 'PackedPolicySize' 17 | @response[name] = @value 18 | when 'RequestId' 19 | @response[name] = @value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/models/dns/zones.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/dns/zone' 2 | 3 | module Fog 4 | module DNS 5 | class AWS 6 | class Zones < Fog::Collection 7 | attribute :marker, :aliases => 'Marker' 8 | attribute :max_items, :aliases => 'MaxItems' 9 | 10 | model Fog::DNS::AWS::Zone 11 | 12 | def all(options = {}) 13 | options['marker'] ||= marker 14 | options['maxitems'] ||= max_items 15 | data = service.list_hosted_zones(options).body['HostedZones'] 16 | load(data) 17 | end 18 | 19 | def get(zone_id) 20 | data = service.get_hosted_zone(zone_id).body 21 | new(data) 22 | rescue Fog::DNS::AWS::NotFound 23 | nil 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/parameter_groups.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/rds/parameter_group' 2 | 3 | module Fog 4 | module AWS 5 | class RDS 6 | class ParameterGroups < Fog::Collection 7 | model Fog::AWS::RDS::ParameterGroup 8 | 9 | def all 10 | data = service.describe_db_parameter_groups.body['DescribeDBParameterGroupsResult']['DBParameterGroups'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | 14 | def get(identity) 15 | data = service.describe_db_parameter_groups(identity).body['DescribeDBParameterGroupsResult']['DBParameterGroups'].first 16 | new(data) # data is an attribute hash 17 | rescue Fog::AWS::RDS::NotFound 18 | nil 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/create_network_interface.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | require 'fog/aws/parsers/compute/network_interface_parser' 6 | 7 | class CreateNetworkInterface < NetworkInterfaceParser 8 | def reset 9 | super 10 | @response = { 'networkInterface' => {} } 11 | end 12 | 13 | def end_element(name) 14 | case name 15 | when 'requestId' 16 | @response[name] = value 17 | when 'networkInterface' 18 | @response['networkInterface'] = @nic 19 | reset_nic 20 | else 21 | super 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_roles.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | require 'fog/aws/parsers/iam/role_parser' 6 | class ListRoles < Fog::Parsers::AWS::IAM::RoleParser 7 | def reset 8 | super 9 | @response = { 'Roles' => [] } 10 | end 11 | 12 | def finished_role(role) 13 | @response['Roles'] << role 14 | end 15 | 16 | def end_element(name) 17 | case name 18 | when 'RequestId', 'Marker' 19 | @response[name] = value 20 | when 'IsTruncated' 21 | @response[name] = (value == 'true') 22 | end 23 | super 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/models/kms/keys.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/kms/key' 2 | 3 | module Fog 4 | module AWS 5 | class KMS 6 | class Keys < Fog::PagedCollection 7 | attribute :filters 8 | attribute :truncated 9 | 10 | model Fog::AWS::KMS::Key 11 | 12 | def initialize(attributes) 13 | self.filters ||= {} 14 | super 15 | end 16 | 17 | # This method deliberately returns only a single page of results 18 | def all(filters_arg = filters) 19 | filters.merge!(filters_arg) 20 | 21 | result = service.list_keys(filters).body 22 | filters[:marker] = result['Marker'] 23 | self.truncated = result['Truncated'] 24 | load(result['Keys']) 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/auto_scaling/put_scaling_policy.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module AutoScaling 5 | class PutScalingPolicy < Fog::Parsers::Base 6 | def reset 7 | @results = {} 8 | @response = { 'PutScalingPolicyResult' => {}, 'ResponseMetadata' => {} } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'PolicyARN' 14 | @results[name] = value 15 | 16 | when 'RequestId' 17 | @response['ResponseMetadata'][name] = value 18 | 19 | when 'PutScalingPolicyResponse' 20 | @response['PutScalingPolicyResult'] = @results 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /tests/helpers/compute/server_helper.rb: -------------------------------------------------------------------------------- 1 | def server_tests(connection, params = {}, mocks_implemented = true) 2 | model_tests(connection.servers, params, mocks_implemented) do 3 | 4 | tests('#reload').returns(true) do 5 | pending if Fog.mocking? && !mocks_implemented 6 | @instance.wait_for { ready? } 7 | identity = @instance.identity 8 | !identity.nil? && identity == @instance.reload.identity 9 | end 10 | 11 | responds_to([:ready?, :state]) 12 | yield if block_given? 13 | 14 | tests('#reboot').succeeds do 15 | pending if Fog.mocking? && !mocks_implemented 16 | @instance.wait_for { ready? } 17 | @instance.reboot 18 | end 19 | 20 | if !Fog.mocking? || mocks_implemented 21 | @instance.wait_for { ready? } 22 | end 23 | 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/describe_placement_groups.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DescribePlacementGroups < Fog::Parsers::Base 6 | def reset 7 | @placement_group = {} 8 | @response = { 'placementGroupSet' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'item' 14 | @response['placementGroupSet'] << @placement_group 15 | @placement_group = {} 16 | when 'groupName', 'state', 'strategy' 17 | @placement_group[name] = value 18 | when 'requestId' 19 | @response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/rds/modify_db_parameter_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module RDS 5 | class ModifyDbParameterGroup < Fog::Parsers::Base 6 | def reset 7 | @response = { 'ModifyDBParameterGroupResult' => {}, 'ResponseMetadata' => {} } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'DBParameterGroupName' 17 | @response['ModifyDBParameterGroupResult']['DBParameterGroupName'] = value 18 | when 'RequestId' 19 | @response['ResponseMetadata'][name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elasticache/clusters.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/elasticache/cluster' 2 | 3 | module Fog 4 | module AWS 5 | class Elasticache 6 | class Clusters < Fog::Collection 7 | model Fog::AWS::Elasticache::Cluster 8 | 9 | def all 10 | load( 11 | service.describe_cache_clusters( 12 | nil, :show_node_info => true 13 | ).body['CacheClusters'] 14 | ) 15 | end 16 | 17 | def get(identity, show_node_info = true) 18 | new( 19 | service.describe_cache_clusters( 20 | identity, :show_node_info => show_node_info 21 | ).body['CacheClusters'].first 22 | ) 23 | rescue Fog::AWS::Elasticache::NotFound 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_groups.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class ListGroups < Fog::Parsers::Base 6 | def reset 7 | @group = {} 8 | @response = { 'Groups' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'Arn', 'GroupId', 'GroupName', 'Path' 14 | @group[name] = value 15 | when 'member' 16 | @response['Groups'] << @group 17 | @group = {} 18 | when 'IsTruncated' 19 | response[name] = (value == 'true') 20 | when 'Marker', 'RequestId' 21 | response[name] = value 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/redshift/cluster_snapshot.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Redshift 4 | module AWS 5 | require 'fog/aws/parsers/redshift/cluster_snapshot_parser' 6 | 7 | class ClusterSnapshot < ClusterSnapshotParser 8 | # :parameter_group_name - (String) 9 | # :parameter_group_status - (String) 10 | 11 | def reset 12 | super 13 | @response = {} 14 | end 15 | 16 | def start_element(name, attrs = []) 17 | super 18 | end 19 | 20 | def end_element(name) 21 | super 22 | case name 23 | when 'Snapshot' 24 | @response = @snapshot 25 | end 26 | end 27 | end 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elasticache/subnet_groups.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/elasticache/subnet_group' 2 | 3 | module Fog 4 | module AWS 5 | class Elasticache 6 | class SubnetGroups < Fog::Collection 7 | model Fog::AWS::Elasticache::SubnetGroup 8 | 9 | def all 10 | data = service.describe_cache_subnet_groups.body['DescribeCacheSubnetGroupsResult']['CacheSubnetGroups'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | 14 | def get(identity) 15 | data = service.describe_cache_subnet_groups(identity).body['DescribeCacheSubnetGroupsResult']['CacheSubnetGroups'].first 16 | new(data) # data is an attribute hash 17 | rescue Fog::AWS::Elasticache::NotFound 18 | nil 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/cdn/get_invalidation.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module CDN 4 | module AWS 5 | class GetInvalidation < Fog::Parsers::Base 6 | def reset 7 | @response = { 'InvalidationBatch' => { 'Path' => [] } } 8 | end 9 | 10 | def start_element(name, attrs = []) 11 | super 12 | end 13 | 14 | def end_element(name) 15 | case name 16 | when 'Path' 17 | @response['InvalidationBatch'][name] << value 18 | when 'Id', 'Status', 'CreateTime' 19 | @response[name] = value 20 | when 'CallerReference' 21 | @response['InvalidationBatch'][name] = value 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/rds/delete_db_subnet_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module RDS 5 | require 'fog/aws/parsers/rds/subnet_group_parser' 6 | 7 | class DeleteDBSubnetGroup < Fog::Parsers::AWS::RDS::SubnetGroupParser 8 | def reset 9 | @response = { 'DeleteDBSubnetGroupResponse' => {}, 'ResponseMetadata' => {} } 10 | super 11 | end 12 | 13 | def start_element(name, attrs = []) 14 | super 15 | end 16 | 17 | def end_element(name) 18 | case name 19 | when 'RequestId' 20 | @response['ResponseMetadata'][name] = value 21 | else 22 | super 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sns/list_subscriptions.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SNS 5 | class ListSubscriptions < Fog::Parsers::Base 6 | def reset 7 | @response = { 'Subscriptions' => [] } 8 | @subscription = {} 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when "TopicArn", "Protocol", "SubscriptionArn", "Owner", "Endpoint" 14 | @subscription[name] = @value.strip 15 | when "member" 16 | @response['Subscriptions'] << @subscription 17 | @subscription = {} 18 | when 'RequestId', 'NextToken' 19 | @response[name] = @value.strip 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /tests/models/rds/tagging_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | tagging", ['aws', 'rds']) do 2 | 3 | @server = Fog::AWS[:rds].servers.create(rds_default_server_params) 4 | Fog::Formatador.display_line "Creating RDS instance #{@server.id}" 5 | Fog::Formatador.display_line "Waiting for instance #{@server.id} to be ready" 6 | @server.wait_for { ready? } 7 | 8 | tags1 = {'key1' => 'val1'} 9 | tags2 = {'key2' => 'val2'} 10 | 11 | tests "add and remove tags from a running RDS model" do 12 | returns({}) { @server.tags } 13 | returns(tags1) { @server.add_tags tags1 } 14 | returns(tags1.merge tags2) { @server.add_tags tags2 } 15 | returns(tags2) { @server.remove_tags tags1.keys } 16 | returns(tags2) { @server.tags } 17 | end 18 | 19 | @server.destroy 20 | end 21 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/describe_addresses.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class DescribeAddresses < Fog::Parsers::Base 6 | def reset 7 | @address = {} 8 | @response = { 'addressesSet' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'instanceId', 'publicIp', 'domain', 'allocationId', 'associationId', 'networkInterfaceId', 'networkInterfaceOwnerId' 14 | @address[name] = value 15 | when 'item' 16 | @response['addressesSet'] << @address 17 | @address = {} 18 | when 'requestId' 19 | @response[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/redshift/create_cluster_security_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Redshift 4 | module AWS 5 | require 'fog/aws/parsers/redshift/cluster_security_group_parser' 6 | 7 | class CreateClusterSecurityGroup < ClusterSecurityGroupParser 8 | # :cluster_security_group 9 | 10 | def reset 11 | super 12 | @response = {} 13 | end 14 | 15 | def start_element(name, attrs = []) 16 | super 17 | end 18 | 19 | def end_element(name) 20 | super 21 | case name 22 | when 'ClusterSecurityGroup' 23 | @response['ClusterSecurityGroup'] = @cluster_security_group 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/get_service.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | class GetService < Fog::Parsers::Base 6 | def reset 7 | @bucket = {} 8 | @response = { 'Owner' => {}, 'Buckets' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'Bucket' 14 | @response['Buckets'] << @bucket 15 | @bucket = {} 16 | when 'CreationDate' 17 | @bucket['CreationDate'] = Time.parse(value) 18 | when 'DisplayName', 'ID' 19 | @response['Owner'][name] = value 20 | when 'Name' 21 | @bucket[name] = value 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/sts/get_session_token.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module STS 5 | class GetSessionToken < Fog::Parsers::Base 6 | # http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?CreatingFedTokens.html 7 | 8 | def reset 9 | @response = {} 10 | end 11 | 12 | def end_element(name) 13 | case name 14 | when 'SessionToken', 'SecretAccessKey', 'Expiration', 'AccessKeyId' 15 | @response[name] = @value.strip 16 | when 'Arn', 'FederatedUserId', 'PackedPolicySize' 17 | @response[name] = @value.strip 18 | when 'RequestId' 19 | @response[name] = @value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /tests/models/auto_scaling/groups_test.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::AutoScaling | group', ['aws', 'auto_scaling_m']) do 2 | 3 | params = { 4 | :id => uniq_id, 5 | :auto_scaling_group_name => "name", 6 | :availability_zones => [], 7 | :launch_configuration_name => "lc" 8 | } 9 | 10 | lc_params = { 11 | :id => params[:launch_configuration_name], 12 | :image_id => "image-id", 13 | :instance_type => "instance-type", 14 | } 15 | 16 | Fog::AWS[:auto_scaling].configurations.new(lc_params).save 17 | 18 | model_tests(Fog::AWS[:auto_scaling].groups, params, true) do 19 | @instance.update 20 | end 21 | 22 | test("setting attributes in the constructor") do 23 | group = Fog::AWS[:auto_scaling].groups.new(:min_size => 1, :max_size => 2) 24 | group.min_size == 1 && group.max_size == 2 25 | end 26 | 27 | end 28 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/create_application_version.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class CreateApplicationVersion < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("CreateApplicationVersionResult") 9 | tag 'ApplicationVersion', :object 10 | tag 'ApplicationName', :string 11 | tag 'DateCreated', :datetime 12 | tag 'DateUpdated', :datetime 13 | tag 'Description', :string 14 | tag 'SourceBundle', :object 15 | tag 'S3Bucket', :string 16 | tag 'S3Key', :string 17 | tag 'VersionLabel', :string 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/update_application_version.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class UpdateApplicationVersion < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("UpdateApplicationVersionResult") 9 | tag 'ApplicationVersion', :object 10 | tag 'ApplicationName', :string 11 | tag 'DateCreated', :datetime 12 | tag 'DateUpdated', :datetime 13 | tag 'Description', :string 14 | tag 'SourceBundle', :object 15 | tag 'S3Bucket', :string 16 | tag 'S3Key', :string 17 | tag 'VersionLabel', :string 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /tests/requests/compute/availability_zone_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('Fog::Compute[:aws] | availability zone requests', ['aws']) do 2 | 3 | @availability_zones_format = { 4 | 'availabilityZoneInfo' => [{ 5 | 'messageSet' => [], 6 | 'regionName' => String, 7 | 'zoneName' => String, 8 | 'zoneState' => String 9 | }], 10 | 'requestId' => String 11 | } 12 | 13 | tests('success') do 14 | 15 | tests('#describe_availability_zones').formats(@availability_zones_format) do 16 | Fog::Compute[:aws].describe_availability_zones.body 17 | end 18 | 19 | tests("#describe_availability_zones('zone-name' => 'us-east-1a')").formats(@availability_zones_format) do 20 | Fog::Compute[:aws].describe_availability_zones('zone-name' => 'us-east-1a').body 21 | end 22 | 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/describe_events.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class DescribeEvents < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("DescribeEventsResult") 9 | tag 'Events', :object, :list 10 | tag 'ApplicationName', :string 11 | tag 'EnvironmentName', :string 12 | tag 'EventDate', :datetime 13 | tag 'Message', :string 14 | tag 'RequestId', :string 15 | tag 'Severity', :string 16 | tag 'TemplateName', :string 17 | tag 'VersionLabel', :string 18 | tag 'NextToken', :string 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/cancel_spot_instance_requests.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class CancelSpotInstanceRequests < Fog::Parsers::Base 6 | def reset 7 | @spot_instance_request = {} 8 | @response = { 'spotInstanceRequestSet' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'item' 14 | @response['spotInstanceRequestSet'] << @spot_instance_request 15 | @spot_instance_request = {} 16 | when 'requestId' 17 | @response[name] = value 18 | when 'spotInstanceRequestId', 'state' 19 | @spot_instance_request[name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/compute/spot_datafeed_subscription.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Compute 4 | module AWS 5 | class SpotDatafeedSubscription < Fog::Parsers::Base 6 | def reset 7 | @response = { 'spotDatafeedSubscription' => {} } 8 | end 9 | 10 | def end_element(name) 11 | case name 12 | when 'bucket', 'ownerId', 'prefix', 'state' 13 | @response['spotDatafeedSubscription'][name] = value 14 | when 'code', 'message' 15 | @response['spotDatafeedSubscription']['fault'] ||= {} 16 | @response['spotDatafeedSubscription'][name] = value 17 | when 'requestId' 18 | @response[name] = value 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_access_keys.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class ListAccessKeys < Fog::Parsers::Base 6 | def reset 7 | @access_key = {} 8 | @response = { 'AccessKeys' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'AccessKeyId', 'Status', 'Username' 14 | @access_key[name] = value 15 | when 'member' 16 | @response['AccessKeys'] << @access_key 17 | @access_key = {} 18 | when 'IsTruncated' 19 | response[name] = (value == 'true') 20 | when 'Marker', 'RequestId' 21 | response[name] = value 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/redshift/revoke_cluster_security_group_ingress.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Redshift 4 | module AWS 5 | require 'fog/aws/parsers/redshift/cluster_security_group_parser' 6 | 7 | class RevokeClusterSecurityGroupIngress < ClusterSecurityGroupParser 8 | # :cluster_security_group 9 | 10 | def reset 11 | super 12 | @response = {} 13 | end 14 | 15 | def start_element(name, attrs = []) 16 | super 17 | end 18 | 19 | def end_element(name) 20 | super 21 | case name 22 | when 'ClusterSecurityGroup' 23 | @response['ClusterSecurityGroup'] = @cluster_security_group 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/storage/get_bucket_website.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Storage 4 | module AWS 5 | 6 | # http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETwebsite.html 7 | class GetBucketWebsite < Fog::Parsers::Base 8 | def reset 9 | @response = { 'ErrorDocument' => {}, 'IndexDocument' => {}, 'RedirectAllRequestsTo' => {} } 10 | end 11 | 12 | def end_element(name) 13 | case name 14 | when 'Key' 15 | @response['ErrorDocument'][name] = value 16 | when 'Suffix' 17 | @response['IndexDocument'][name] = value 18 | when 'HostName' 19 | @response['RedirectAllRequestsTo'][name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/beanstalk/describe_application_versions.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module ElasticBeanstalk 5 | require 'fog/aws/parsers/beanstalk/parser' 6 | class DescribeApplicationVersions < Fog::Parsers::AWS::ElasticBeanstalk::BaseParser 7 | def initialize 8 | super("DescribeApplicationVersionsResult") 9 | tag 'ApplicationVersions', :object, :list 10 | tag 'ApplicationName', :string 11 | tag 'DateCreated', :datetime 12 | tag 'DateUpdated', :datetime 13 | tag 'Description', :string 14 | tag 'SourceBundle', :object 15 | tag 'S3Bucket', :string 16 | tag 'S3Key', :string 17 | tag 'VersionLabel', :string 18 | end 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/storage/delete_bucket_cors.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Storage 3 | class AWS 4 | class Real 5 | # Deletes the cors configuration information set for the bucket. 6 | # 7 | # @param bucket_name [String] name of bucket to delete cors rules from 8 | # 9 | # @return [Excon::Response] response: 10 | # * status [Integer] - 204 11 | # 12 | # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketDELETEcors.html 13 | 14 | def delete_bucket_cors(bucket_name) 15 | request({ 16 | :expects => 204, 17 | :headers => {}, 18 | :bucket_name => bucket_name, 19 | :method => 'DELETE', 20 | :query => {'cors' => nil} 21 | }) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/storage/delete_bucket_website.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Storage 3 | class AWS 4 | class Real 5 | # Delete website configuration for a bucket 6 | # 7 | # @param bucket_name [String] name of bucket to delete website configuration from 8 | # 9 | # @return [Excon::Response] response: 10 | # * status [Integer] - 204 11 | # 12 | # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketDELETEwebsite.html 13 | 14 | def delete_bucket_website(bucket_name) 15 | request({ 16 | :expects => 204, 17 | :headers => {}, 18 | :bucket_name => bucket_name, 19 | :method => 'DELETE', 20 | :query => {'website' => nil} 21 | }) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/ses/get_send_statistics.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module SES 5 | class GetSendStatistics < Fog::Parsers::Base 6 | def reset 7 | @response = { 'SendDataPoints' => [], 'ResponseMetadata' => {} } 8 | @send_data_point = {} 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when "Bounces", "Complaints", "DeliveryAttempts", "Rejects", "Timestamp" 14 | @send_data_point[name] = value 15 | when 'member' 16 | @response['SendDataPoints'] << @send_data_point 17 | @send_data_point = {} 18 | when 'RequestId' 19 | @response['ResponseMetadata'][name] = value 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/sns/remove_permission.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class SNS 4 | class Real 5 | require 'fog/aws/parsers/sns/remove_permission' 6 | 7 | def remove_permission(options = {}) 8 | request({ 9 | 'Action' => 'RemovePermission', 10 | :parser => Fog::Parsers::AWS::SNS::RemovePermission.new 11 | }.merge!(options)) 12 | end 13 | end 14 | 15 | class Mock 16 | def remove_permission(options = {}) 17 | topic_arn = options['TopicArn'] 18 | label = options['Label'] 19 | 20 | self.data[:permissions][topic_arn].delete(label) 21 | 22 | response = Excon::Response.new 23 | response.body = {"RequestId" => Fog::AWS::Mock.request_id} 24 | response 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/log_file.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class RDS 4 | class LogFile < Fog::Model 5 | attribute :rds_id, :aliases => 'DBInstanceIdentifier' 6 | attribute :name, :aliases => 'LogFileName' 7 | attribute :size, :aliases => 'Size', :type => :integer 8 | attribute :last_written, :aliases => 'LastWritten', :type => :time 9 | attribute :content, :aliases => 'LogFileData' 10 | attribute :marker, :aliases => 'Marker' 11 | attribute :more_content_available, :aliases => 'AdditionalDataPending', :type => :boolean 12 | 13 | def content_excerpt(marker=nil) 14 | result = service.download_db_logfile_portion(self.rds_id, self.name, {:marker => marker}) 15 | merge_attributes(result.body['DownloadDBLogFilePortionResult']) 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /tests/requests/rds/instance_option_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests('AWS::RDS | db instance option requests', ['aws', 'rds']) do 2 | tests('success') do 3 | 4 | tests("#describe_orderable_db_instance_options('mysql)").formats(AWS::RDS::Formats::DESCRIBE_ORDERABLE_DB_INSTANCE_OPTION) do 5 | 6 | body = Fog::AWS[:rds].describe_orderable_db_instance_options('mysql').body 7 | 8 | returns(2) {body['DescribeOrderableDBInstanceOptionsResult']['OrderableDBInstanceOptions'].length} 9 | 10 | group = body['DescribeOrderableDBInstanceOptionsResult']['OrderableDBInstanceOptions'].first 11 | returns( true ) { group['MultiAZCapable'] } 12 | returns( 'mysql' ) { group['Engine'] } 13 | returns( true ) { group['ReadReplicaCapable'] } 14 | returns( true ) { group['AvailabilityZones'].length >= 1 } 15 | 16 | body 17 | end 18 | 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_instance_profiles.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | require 'fog/aws/parsers/iam/base_instance_profile' 6 | class ListInstanceProfiles < Fog::Parsers::AWS::IAM::BaseInstanceProfile 7 | def reset 8 | super 9 | @response = {'InstanceProfiles' => []} 10 | end 11 | 12 | def finished_instance_profile(profile) 13 | @response['InstanceProfiles'] << profile 14 | end 15 | 16 | def end_element(name) 17 | case name 18 | when 'RequestId', 'Marker' 19 | @response[name] = value 20 | when 'IsTruncated' 21 | @response[name] = (value == 'true') 22 | end 23 | super 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_managed_policies.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | require 'fog/aws/parsers/iam/policy_parser' 6 | class ListManagedPolicies < Fog::Parsers::AWS::IAM::PolicyParser 7 | def reset 8 | super 9 | @response = { 'Policies' => [] , 'Marker' => '', 'IsTruncated' => false} 10 | end 11 | 12 | def finished_policy(policy) 13 | @response['Policies'] << policy 14 | end 15 | 16 | def end_element(name) 17 | case name 18 | when 'RequestId', 'Marker' 19 | @response[name] = value 20 | when 'IsTruncated' 21 | @response[name] = (value == 'true') 22 | end 23 | super 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/redshift/create_cluster_parameter_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module Redshift 4 | module AWS 5 | class CreateClusterParameterGroup < Fog::Parsers::Base 6 | # :parameter_group_name - (String) 7 | # :parameter_group_family - (String) 8 | # :description - (String) 9 | 10 | def reset 11 | @response = {'ClusterParameterGroup'=>{}} 12 | end 13 | 14 | def start_element(name, attrs = []) 15 | super 16 | end 17 | 18 | def end_element(name) 19 | super 20 | case name 21 | when 'ParameterGroupName', 'ParameterGroupFamily', 'Description' 22 | @response['ClusterParameterGroup'][name] = value 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_groups_for_user.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class ListGroupsForUser < Fog::Parsers::Base 6 | def reset 7 | @group_for_user = {} 8 | @response = { 'GroupsForUser' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'Path', 'GroupName', 'GroupId', 'Arn' 14 | @group_for_user[name] = value 15 | when 'member' 16 | @response['GroupsForUser'] << @group_for_user 17 | @group_for_user = {} 18 | when 'IsTruncated' 19 | response[name] = (value == 'true') 20 | when 'Marker', 'RequestId' 21 | response[name] = value 22 | end 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/fog/aws/models/beanstalk/environments.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/beanstalk/environment' 2 | 3 | module Fog 4 | module AWS 5 | class ElasticBeanstalk 6 | class Environments < Fog::Collection 7 | model Fog::AWS::ElasticBeanstalk::Environment 8 | 9 | def all(options={}) 10 | data = service.describe_environments(options).body['DescribeEnvironmentsResult']['Environments'] 11 | load(data) # data is an array of attribute hashes 12 | end 13 | 14 | # Gets an environment given a name. 15 | # 16 | def get(environment_name) 17 | options = { 'EnvironmentNames' => [environment_name] } 18 | 19 | if data = service.describe_environments(options).body['DescribeEnvironmentsResult']['Environments'].first 20 | new(data) 21 | end 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/models/elb/listeners.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/elb/listener' 2 | module Fog 3 | module AWS 4 | class ELB 5 | class Listeners < Fog::Collection 6 | model Fog::AWS::ELB::Listener 7 | 8 | attr_accessor :data, :load_balancer 9 | 10 | def all 11 | load(munged_data) 12 | end 13 | 14 | def get(lb_port) 15 | all.find{|listener| listener.lb_port == lb_port} 16 | end 17 | 18 | private 19 | # Munge an array of ListenerDescription hashes like: 20 | # {'Listener' => listener, 'PolicyNames' => []} 21 | # to an array of listeners with a PolicyNames key 22 | def munged_data 23 | data.map {|description| 24 | description['Listener'].merge('PolicyNames' => description['PolicyNames']) 25 | } 26 | end 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/instance_options.rb: -------------------------------------------------------------------------------- 1 | require 'fog/aws/models/rds/instance_option' 2 | 3 | module Fog 4 | module AWS 5 | class RDS 6 | class InstanceOptions < Fog::PagedCollection 7 | attribute :filters 8 | attribute :engine 9 | model Fog::AWS::RDS::InstanceOption 10 | 11 | def initialize(attributes) 12 | self.filters ||= {} 13 | super 14 | end 15 | 16 | # This method deliberately returns only a single page of results 17 | def all(filters_arg = filters) 18 | filters.merge!(filters_arg) 19 | 20 | result = service.describe_orderable_db_instance_options(engine, filters).body['DescribeOrderableDBInstanceOptionsResult'] 21 | filters[:marker] = result['Marker'] 22 | load(result['OrderableDBInstanceOptions']) 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/beanstalk/create_storage_location.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class ElasticBeanstalk 4 | class Real 5 | require 'fog/aws/parsers/beanstalk/create_storage_location' 6 | 7 | # Creates the Amazon S3 storage location for the account. 8 | # 9 | # ==== Options 10 | # 11 | # ==== Returns 12 | # * response<~Excon::Response>: 13 | # 14 | # ==== See Also 15 | # http://docs.amazonwebservices.com/elasticbeanstalk/latest/api/API_CreateStorageLocation.html 16 | # 17 | def create_storage_location() 18 | request({ 19 | 'Operation' => 'CreateStorageLocation', 20 | :parser => Fog::Parsers::AWS::ElasticBeanstalk::CreateStorageLocation.new 21 | }) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /tests/models/rds/parameter_group_tests.rb: -------------------------------------------------------------------------------- 1 | Shindo.tests("AWS::RDS | parameter_group", ['aws', 'rds']) do 2 | 3 | group_name = 'fog-test' 4 | params = {:id => group_name, :family => 'mysql5.1', :description => group_name} 5 | 6 | pending if Fog.mocking? 7 | model_tests(Fog::AWS[:rds].parameter_groups, params, false) do 8 | tests('#parameters') do 9 | #search for a sample parameter 10 | tests 'contains parameters' do 11 | returns(true){ @instance.parameters.any? {|p| p.name == 'query_cache_size'}} 12 | end 13 | end 14 | 15 | tests('#modify') do 16 | @instance.modify([{:name => 'query_cache_size', :value => '6553600', :apply_method => 'immediate'}]) 17 | 18 | tests 'parameter has changed' do 19 | returns('6553600'){@instance.parameters.find {|p| p.name == 'query_cache_size'}.value} 20 | end 21 | end 22 | 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Getting Involved 2 | 3 | New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another. 4 | 5 | ### Coding 6 | 7 | * Pick a task: 8 | * Offer feedback on open [pull requests](https://github.com/fog/fog/pulls). 9 | * Review open [issues](https://github.com/fog/fog/issues) for things to help on. 10 | * [Create an issue](https://github.com/fog/fog/issues/new) to start a discussion on additions or features. 11 | * Fork the project, add your changes and tests to cover them in a topic branch. 12 | * Commit your changes and rebase against `fog/fog` to ensure everything is up to date. 13 | * [Submit a pull request](https://github.com/fog/fog/compare/). 14 | 15 | ### Non-Coding 16 | 17 | * Offer feedback on open [issues](https://github.com/fog/fog/issues). 18 | * Organize or volunteer at events. 19 | -------------------------------------------------------------------------------- /lib/fog/aws/parsers/iam/list_users.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module Parsers 3 | module AWS 4 | module IAM 5 | class ListUsers < Fog::Parsers::Base 6 | def reset 7 | @user = {} 8 | @response = { 'Users' => [] } 9 | end 10 | 11 | def end_element(name) 12 | case name 13 | when 'Arn', 'UserId', 'UserName', 'Path' 14 | @user[name] = value 15 | when 'CreateDate' 16 | @user[name] = Time.parse(value) 17 | when 'member' 18 | @response['Users'] << @user 19 | @user = {} 20 | when 'IsTruncated' 21 | response[name] = (value == 'true') 22 | when 'Marker', 'RequestId' 23 | response[name] = value 24 | end 25 | end 26 | end 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/ses/list_verified_email_addresses.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class SES 4 | class Real 5 | require 'fog/aws/parsers/ses/list_verified_email_addresses' 6 | 7 | # Returns a list containing all of the email addresses that have been verified 8 | # 9 | # ==== Parameters 10 | # 11 | # ==== Returns 12 | # * response<~Excon::Response>: 13 | # * body<~Hash>: 14 | # * 'VerifiedEmailAddresses' <~Array> 15 | # * 'ResponseMetadata'<~Hash>: 16 | # * 'RequestId'<~String> - Id of request 17 | def list_verified_email_addresses 18 | request({ 19 | 'Action' => 'ListVerifiedEmailAddresses', 20 | :parser => Fog::Parsers::AWS::SES::ListVerifiedEmailAddresses.new 21 | }) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/fog/aws/models/iam/policy.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class IAM 4 | class Policy < Fog::Model 5 | identity :id, :aliases => 'PolicyName' 6 | attribute :username, :aliases => 'UserName' 7 | attribute :document, :aliases => 'PolicyDocument' 8 | 9 | def save 10 | requires :id 11 | requires :username 12 | requires :document 13 | 14 | data = service.put_user_policy(username, id, document).body 15 | merge_attributes(data) 16 | true 17 | end 18 | 19 | def destroy 20 | requires :id 21 | requires :username 22 | 23 | service.delete_user_policy(username, id) 24 | true 25 | end 26 | 27 | def user 28 | requires :username 29 | service.users.get(username) 30 | end 31 | end 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /lib/fog/aws/models/rds/subnet_group.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class RDS 4 | class SubnetGroup < Fog::Model 5 | identity :id, :aliases => ['DBSubnetGroupName', :name] 6 | attribute :description, :aliases => 'DBSubnetGroupDescription' 7 | attribute :status, :aliases => 'SubnetGroupStatus' 8 | attribute :vpc_id, :aliases => 'VpcId' 9 | attribute :subnet_ids, :aliases => 'Subnets' 10 | 11 | def ready? 12 | requires :status 13 | status == 'Complete' 14 | end 15 | 16 | def save 17 | requires :description, :id, :subnet_ids 18 | service.create_db_subnet_group(id, subnet_ids, description) 19 | reload 20 | end 21 | 22 | def destroy 23 | requires :id 24 | service.delete_db_subnet_group(id) 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/aws/requests/beanstalk/list_available_solution_stacks.rb: -------------------------------------------------------------------------------- 1 | module Fog 2 | module AWS 3 | class ElasticBeanstalk 4 | class Real 5 | require 'fog/aws/parsers/beanstalk/list_available_solution_stacks' 6 | 7 | # Checks if the specified CNAME is available. 8 | # 9 | # ==== Options 10 | # 11 | # ==== Returns 12 | # * response<~Excon::Response>: 13 | # 14 | # ==== See Also 15 | # http://docs.amazonwebservices.com/elasticbeanstalk/latest/api/API_CheckDNSAvailability.html 16 | # 17 | def list_available_solution_stacks() 18 | request({ 19 | 'Operation' => 'ListAvailableSolutionStacks', 20 | :parser => Fog::Parsers::AWS::ElasticBeanstalk::ListAvailableSolutionStacks.new 21 | }) 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /tests/helper.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require "codeclimate-test-reporter" 3 | CodeClimate::TestReporter.start 4 | rescue LoadError => e 5 | $stderr.puts "not recording test coverage: #{e.inspect}" 6 | end 7 | 8 | require File.expand_path('../../lib/fog/aws', __FILE__) 9 | 10 | Bundler.require(:test) 11 | 12 | Excon.defaults.merge!(:debug_request => true, :debug_response => true) 13 | 14 | require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper')) 15 | 16 | # This overrides the default 600 seconds timeout during live test runs 17 | unless Fog.mocking? 18 | Fog.timeout = ENV['FOG_TEST_TIMEOUT'] || 2_000 19 | Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds" 20 | end 21 | 22 | def lorem_file 23 | File.open(File.dirname(__FILE__) + '/lorem.txt', 'r') 24 | end 25 | 26 | def array_differences(array_a, array_b) 27 | (array_a - array_b) | (array_b - array_a) 28 | end 29 | --------------------------------------------------------------------------------