aws_sdk 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/aws-sdk.rb +14 -0
- data/lib/aws.rb +49 -0
- data/lib/aws/api_config/AutoScaling-2011-01-01.yml +791 -0
- data/lib/aws/api_config/CloudFormation-2010-05-15.yml +303 -0
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +540 -0
- data/lib/aws/api_config/EC2-2011-12-15.yml +3638 -0
- data/lib/aws/api_config/EC2-2012-04-01.yml +3739 -0
- data/lib/aws/api_config/ELB-2011-08-15.yml +512 -0
- data/lib/aws/api_config/IAM-2010-05-08.yml +1221 -0
- data/lib/aws/api_config/SNS-2010-03-31.yml +248 -0
- data/lib/aws/api_config/SQS-2011-10-01.yml +314 -0
- data/lib/aws/api_config/STS-2011-06-15.yml +54 -0
- data/lib/aws/api_config/SimpleDB-2009-04-15.yml +305 -0
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +231 -0
- data/lib/aws/api_config/SimpleWorkflow-2012-01-25.yml +721 -0
- data/lib/aws/auto_scaling.rb +162 -0
- data/lib/aws/auto_scaling/activity.rb +102 -0
- data/lib/aws/auto_scaling/activity_collection.rb +82 -0
- data/lib/aws/auto_scaling/client.rb +765 -0
- data/lib/aws/auto_scaling/config.rb +18 -0
- data/lib/aws/auto_scaling/errors.rb +22 -0
- data/lib/aws/auto_scaling/group.rb +420 -0
- data/lib/aws/auto_scaling/group_collection.rb +96 -0
- data/lib/aws/auto_scaling/group_options.rb +146 -0
- data/lib/aws/auto_scaling/instance.rb +192 -0
- data/lib/aws/auto_scaling/instance_collection.rb +63 -0
- data/lib/aws/auto_scaling/launch_configuration.rb +150 -0
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +144 -0
- data/lib/aws/auto_scaling/notification_configuration.rb +89 -0
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +184 -0
- data/lib/aws/auto_scaling/request.rb +23 -0
- data/lib/aws/auto_scaling/scaling_policy.rb +125 -0
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +72 -0
- data/lib/aws/auto_scaling/scaling_policy_options.rb +61 -0
- data/lib/aws/auto_scaling/scheduled_action.rb +145 -0
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +195 -0
- data/lib/aws/auto_scaling/tag.rb +59 -0
- data/lib/aws/auto_scaling/tag_collection.rb +112 -0
- data/lib/aws/cloud_formation.rb +270 -0
- data/lib/aws/cloud_formation/client.rb +339 -0
- data/lib/aws/cloud_formation/config.rb +18 -0
- data/lib/aws/cloud_formation/errors.rb +22 -0
- data/lib/aws/cloud_formation/request.rb +29 -0
- data/lib/aws/cloud_formation/stack.rb +256 -0
- data/lib/aws/cloud_formation/stack_collection.rb +206 -0
- data/lib/aws/cloud_formation/stack_event.rb +75 -0
- data/lib/aws/cloud_formation/stack_event_collection.rb +47 -0
- data/lib/aws/cloud_formation/stack_options.rb +72 -0
- data/lib/aws/cloud_formation/stack_output.rb +53 -0
- data/lib/aws/cloud_formation/stack_resource.rb +117 -0
- data/lib/aws/cloud_formation/stack_resource_collection.rb +84 -0
- data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +72 -0
- data/lib/aws/cloud_formation/stack_summary.rb +71 -0
- data/lib/aws/cloud_formation/stack_summary_collection.rb +127 -0
- data/lib/aws/core.rb +474 -0
- data/lib/aws/core/async_handle.rb +90 -0
- data/lib/aws/core/autoloader.rb +64 -0
- data/lib/aws/core/cacheable.rb +78 -0
- data/lib/aws/core/client.rb +541 -0
- data/lib/aws/core/client/query_json.rb +110 -0
- data/lib/aws/core/client/query_xml.rb +122 -0
- data/lib/aws/core/collection.rb +234 -0
- data/lib/aws/core/collection/limitable.rb +99 -0
- data/lib/aws/core/collection/simple.rb +90 -0
- data/lib/aws/core/configuration.rb +445 -0
- data/lib/aws/core/data.rb +242 -0
- data/lib/aws/core/default_signer.rb +67 -0
- data/lib/aws/core/http/curb_handler.rb +136 -0
- data/lib/aws/core/http/handler.rb +77 -0
- data/lib/aws/core/http/httparty_handler.rb +114 -0
- data/lib/aws/core/http/net_http_handler.rb +85 -0
- data/lib/aws/core/http/request.rb +250 -0
- data/lib/aws/core/http/response.rb +74 -0
- data/lib/aws/core/indifferent_hash.rb +88 -0
- data/lib/aws/core/inflection.rb +47 -0
- data/lib/aws/core/lazy_error_classes.rb +90 -0
- data/lib/aws/core/log_formatter.rb +454 -0
- data/lib/aws/core/meta_utils.rb +45 -0
- data/lib/aws/core/model.rb +57 -0
- data/lib/aws/core/naming.rb +30 -0
- data/lib/aws/core/option_grammar.rb +700 -0
- data/lib/aws/core/page_result.rb +73 -0
- data/lib/aws/core/policy.rb +916 -0
- data/lib/aws/core/resource.rb +408 -0
- data/lib/aws/core/resource_cache.rb +40 -0
- data/lib/aws/core/response.rb +202 -0
- data/lib/aws/core/response_cache.rb +50 -0
- data/lib/aws/core/service_interface.rb +61 -0
- data/lib/aws/core/session_signer.rb +90 -0
- data/lib/aws/core/signature/version_2.rb +42 -0
- data/lib/aws/core/signature/version_3.rb +73 -0
- data/lib/aws/core/signature/version_3_http.rb +72 -0
- data/lib/aws/core/signature/version_4.rb +138 -0
- data/lib/aws/core/uri_escape.rb +42 -0
- data/lib/aws/core/xml/frame.rb +242 -0
- data/lib/aws/core/xml/frame_stack.rb +85 -0
- data/lib/aws/core/xml/grammar.rb +299 -0
- data/lib/aws/core/xml/parser.rb +70 -0
- data/lib/aws/core/xml/root_frame.rb +65 -0
- data/lib/aws/core/xml/sax_handlers/libxml.rb +47 -0
- data/lib/aws/core/xml/sax_handlers/nokogiri.rb +55 -0
- data/lib/aws/core/xml/sax_handlers/ox.rb +41 -0
- data/lib/aws/core/xml/sax_handlers/rexml.rb +43 -0
- data/lib/aws/core/xml/stub.rb +123 -0
- data/lib/aws/dynamo_db.rb +213 -0
- data/lib/aws/dynamo_db/attribute_collection.rb +460 -0
- data/lib/aws/dynamo_db/batch_get.rb +206 -0
- data/lib/aws/dynamo_db/batch_write.rb +251 -0
- data/lib/aws/dynamo_db/client.rb +888 -0
- data/lib/aws/dynamo_db/config.rb +20 -0
- data/lib/aws/dynamo_db/errors.rb +20 -0
- data/lib/aws/dynamo_db/expectations.rb +40 -0
- data/lib/aws/dynamo_db/item.rb +130 -0
- data/lib/aws/dynamo_db/item_collection.rb +852 -0
- data/lib/aws/dynamo_db/item_data.rb +31 -0
- data/lib/aws/dynamo_db/keys.rb +41 -0
- data/lib/aws/dynamo_db/primary_key_element.rb +47 -0
- data/lib/aws/dynamo_db/request.rb +28 -0
- data/lib/aws/dynamo_db/resource.rb +33 -0
- data/lib/aws/dynamo_db/table.rb +489 -0
- data/lib/aws/dynamo_db/table_collection.rb +165 -0
- data/lib/aws/dynamo_db/types.rb +86 -0
- data/lib/aws/ec2.rb +431 -0
- data/lib/aws/ec2/attachment.rb +140 -0
- data/lib/aws/ec2/attachment_collection.rb +54 -0
- data/lib/aws/ec2/availability_zone.rb +87 -0
- data/lib/aws/ec2/availability_zone_collection.rb +43 -0
- data/lib/aws/ec2/block_device_mappings.rb +53 -0
- data/lib/aws/ec2/client.rb +4121 -0
- data/lib/aws/ec2/collection.rb +36 -0
- data/lib/aws/ec2/config.rb +18 -0
- data/lib/aws/ec2/config_transform.rb +63 -0
- data/lib/aws/ec2/customer_gateway.rb +90 -0
- data/lib/aws/ec2/customer_gateway_collection.rb +73 -0
- data/lib/aws/ec2/dhcp_options.rb +106 -0
- data/lib/aws/ec2/dhcp_options_collection.rb +87 -0
- data/lib/aws/ec2/elastic_ip.rb +157 -0
- data/lib/aws/ec2/elastic_ip_collection.rb +97 -0
- data/lib/aws/ec2/errors.rb +32 -0
- data/lib/aws/ec2/filtered_collection.rb +90 -0
- data/lib/aws/ec2/has_permissions.rb +44 -0
- data/lib/aws/ec2/image.rb +254 -0
- data/lib/aws/ec2/image_collection.rb +228 -0
- data/lib/aws/ec2/instance.rb +669 -0
- data/lib/aws/ec2/instance_collection.rb +346 -0
- data/lib/aws/ec2/internet_gateway.rb +122 -0
- data/lib/aws/ec2/internet_gateway/attachment.rb +78 -0
- data/lib/aws/ec2/internet_gateway_collection.rb +54 -0
- data/lib/aws/ec2/key_pair.rb +82 -0
- data/lib/aws/ec2/key_pair_collection.rb +99 -0
- data/lib/aws/ec2/network_acl.rb +256 -0
- data/lib/aws/ec2/network_acl/association.rb +56 -0
- data/lib/aws/ec2/network_acl/entry.rb +147 -0
- data/lib/aws/ec2/network_acl_collection.rb +64 -0
- data/lib/aws/ec2/network_interface.rb +228 -0
- data/lib/aws/ec2/network_interface/attachment.rb +100 -0
- data/lib/aws/ec2/network_interface_collection.rb +103 -0
- data/lib/aws/ec2/permission_collection.rb +174 -0
- data/lib/aws/ec2/region.rb +97 -0
- data/lib/aws/ec2/region_collection.rb +51 -0
- data/lib/aws/ec2/request.rb +22 -0
- data/lib/aws/ec2/reserved_instances.rb +53 -0
- data/lib/aws/ec2/reserved_instances_collection.rb +40 -0
- data/lib/aws/ec2/reserved_instances_offering.rb +58 -0
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +39 -0
- data/lib/aws/ec2/resource.rb +161 -0
- data/lib/aws/ec2/resource_tag_collection.rb +211 -0
- data/lib/aws/ec2/route_table.rb +205 -0
- data/lib/aws/ec2/route_table/association.rb +119 -0
- data/lib/aws/ec2/route_table/route.rb +113 -0
- data/lib/aws/ec2/route_table_collection.rb +72 -0
- data/lib/aws/ec2/security_group.rb +458 -0
- data/lib/aws/ec2/security_group/egress_ip_permission_collection.rb +63 -0
- data/lib/aws/ec2/security_group/ingress_ip_permission_collection.rb +61 -0
- data/lib/aws/ec2/security_group/ip_permission.rb +128 -0
- data/lib/aws/ec2/security_group_collection.rb +135 -0
- data/lib/aws/ec2/snapshot.rb +143 -0
- data/lib/aws/ec2/snapshot_collection.rb +131 -0
- data/lib/aws/ec2/subnet.rb +161 -0
- data/lib/aws/ec2/subnet_collection.rb +115 -0
- data/lib/aws/ec2/tag.rb +81 -0
- data/lib/aws/ec2/tag_collection.rb +107 -0
- data/lib/aws/ec2/tagged_collection.rb +53 -0
- data/lib/aws/ec2/tagged_item.rb +85 -0
- data/lib/aws/ec2/volume.rb +170 -0
- data/lib/aws/ec2/volume_collection.rb +97 -0
- data/lib/aws/ec2/vpc.rb +166 -0
- data/lib/aws/ec2/vpc_collection.rb +70 -0
- data/lib/aws/ec2/vpn_connection.rb +99 -0
- data/lib/aws/ec2/vpn_connection/telemetry.rb +49 -0
- data/lib/aws/ec2/vpn_connection_collection.rb +96 -0
- data/lib/aws/ec2/vpn_gateway.rb +123 -0
- data/lib/aws/ec2/vpn_gateway/attachment.rb +45 -0
- data/lib/aws/ec2/vpn_gateway_collection.rb +77 -0
- data/lib/aws/elb.rb +65 -0
- data/lib/aws/elb/availability_zone_collection.rb +138 -0
- data/lib/aws/elb/backend_server_policy_collection.rb +140 -0
- data/lib/aws/elb/client.rb +539 -0
- data/lib/aws/elb/config.rb +18 -0
- data/lib/aws/elb/errors.rb +26 -0
- data/lib/aws/elb/instance_collection.rb +174 -0
- data/lib/aws/elb/listener.rb +189 -0
- data/lib/aws/elb/listener_collection.rb +119 -0
- data/lib/aws/elb/listener_opts.rb +45 -0
- data/lib/aws/elb/load_balancer.rb +253 -0
- data/lib/aws/elb/load_balancer_collection.rb +113 -0
- data/lib/aws/elb/load_balancer_policy.rb +93 -0
- data/lib/aws/elb/load_balancer_policy_collection.rb +208 -0
- data/lib/aws/elb/request.rb +23 -0
- data/lib/aws/errors.rb +122 -0
- data/lib/aws/iam.rb +418 -0
- data/lib/aws/iam/access_key.rb +180 -0
- data/lib/aws/iam/access_key_collection.rb +128 -0
- data/lib/aws/iam/account_alias_collection.rb +79 -0
- data/lib/aws/iam/client.rb +1609 -0
- data/lib/aws/iam/collection.rb +83 -0
- data/lib/aws/iam/config.rb +18 -0
- data/lib/aws/iam/errors.rb +22 -0
- data/lib/aws/iam/group.rb +111 -0
- data/lib/aws/iam/group_collection.rb +132 -0
- data/lib/aws/iam/group_policy_collection.rb +47 -0
- data/lib/aws/iam/group_user_collection.rb +84 -0
- data/lib/aws/iam/login_profile.rb +99 -0
- data/lib/aws/iam/mfa_device.rb +52 -0
- data/lib/aws/iam/mfa_device_collection.rb +127 -0
- data/lib/aws/iam/policy.rb +46 -0
- data/lib/aws/iam/policy_collection.rb +188 -0
- data/lib/aws/iam/request.rb +29 -0
- data/lib/aws/iam/resource.rb +71 -0
- data/lib/aws/iam/server_certificate.rb +141 -0
- data/lib/aws/iam/server_certificate_collection.rb +138 -0
- data/lib/aws/iam/signing_certificate.rb +169 -0
- data/lib/aws/iam/signing_certificate_collection.rb +131 -0
- data/lib/aws/iam/user.rb +205 -0
- data/lib/aws/iam/user_collection.rb +133 -0
- data/lib/aws/iam/user_group_collection.rb +98 -0
- data/lib/aws/iam/user_policy.rb +90 -0
- data/lib/aws/iam/user_policy_collection.rb +45 -0
- data/lib/aws/iam/virtual_mfa_device.rb +139 -0
- data/lib/aws/iam/virtual_mfa_device_collection.rb +73 -0
- data/lib/aws/rails.rb +195 -0
- data/lib/aws/record.rb +116 -0
- data/lib/aws/record/abstract_base.rb +645 -0
- data/lib/aws/record/attributes.rb +384 -0
- data/lib/aws/record/conversion.rb +38 -0
- data/lib/aws/record/dirty_tracking.rb +285 -0
- data/lib/aws/record/errors.rb +143 -0
- data/lib/aws/record/exceptions.rb +48 -0
- data/lib/aws/record/hash_model.rb +161 -0
- data/lib/aws/record/hash_model/attributes.rb +182 -0
- data/lib/aws/record/hash_model/finder_methods.rb +172 -0
- data/lib/aws/record/hash_model/scope.rb +108 -0
- data/lib/aws/record/model.rb +427 -0
- data/lib/aws/record/model/attributes.rb +379 -0
- data/lib/aws/record/model/finder_methods.rb +232 -0
- data/lib/aws/record/model/scope.rb +213 -0
- data/lib/aws/record/naming.rb +31 -0
- data/lib/aws/record/scope.rb +199 -0
- data/lib/aws/record/validations.rb +694 -0
- data/lib/aws/record/validator.rb +237 -0
- data/lib/aws/record/validators/acceptance.rb +51 -0
- data/lib/aws/record/validators/block.rb +38 -0
- data/lib/aws/record/validators/confirmation.rb +43 -0
- data/lib/aws/record/validators/count.rb +108 -0
- data/lib/aws/record/validators/exclusion.rb +43 -0
- data/lib/aws/record/validators/format.rb +57 -0
- data/lib/aws/record/validators/inclusion.rb +56 -0
- data/lib/aws/record/validators/length.rb +107 -0
- data/lib/aws/record/validators/method.rb +33 -0
- data/lib/aws/record/validators/numericality.rb +138 -0
- data/lib/aws/record/validators/presence.rb +45 -0
- data/lib/aws/s3.rb +135 -0
- data/lib/aws/s3/access_control_list.rb +250 -0
- data/lib/aws/s3/acl_object.rb +264 -0
- data/lib/aws/s3/bucket.rb +393 -0
- data/lib/aws/s3/bucket_collection.rb +143 -0
- data/lib/aws/s3/bucket_lifecycle_configuration.rb +360 -0
- data/lib/aws/s3/bucket_version_collection.rb +77 -0
- data/lib/aws/s3/client.rb +1184 -0
- data/lib/aws/s3/client/xml.rb +177 -0
- data/lib/aws/s3/config.rb +26 -0
- data/lib/aws/s3/data_options.rb +100 -0
- data/lib/aws/s3/errors.rb +81 -0
- data/lib/aws/s3/multipart_upload.rb +317 -0
- data/lib/aws/s3/multipart_upload_collection.rb +68 -0
- data/lib/aws/s3/object_collection.rb +337 -0
- data/lib/aws/s3/object_metadata.rb +96 -0
- data/lib/aws/s3/object_upload_collection.rb +77 -0
- data/lib/aws/s3/object_version.rb +143 -0
- data/lib/aws/s3/object_version_collection.rb +89 -0
- data/lib/aws/s3/paginated_collection.rb +75 -0
- data/lib/aws/s3/policy.rb +74 -0
- data/lib/aws/s3/prefix_and_delimiter_collection.rb +47 -0
- data/lib/aws/s3/prefixed_collection.rb +81 -0
- data/lib/aws/s3/presigned_post.rb +553 -0
- data/lib/aws/s3/request.rb +201 -0
- data/lib/aws/s3/s3_object.rb +1037 -0
- data/lib/aws/s3/tree.rb +118 -0
- data/lib/aws/s3/tree/branch_node.rb +68 -0
- data/lib/aws/s3/tree/child_collection.rb +104 -0
- data/lib/aws/s3/tree/leaf_node.rb +94 -0
- data/lib/aws/s3/tree/node.rb +22 -0
- data/lib/aws/s3/tree/parent.rb +87 -0
- data/lib/aws/s3/uploaded_part.rb +80 -0
- data/lib/aws/s3/uploaded_part_collection.rb +84 -0
- data/lib/aws/simple_db.rb +217 -0
- data/lib/aws/simple_db/attribute.rb +154 -0
- data/lib/aws/simple_db/attribute_collection.rb +231 -0
- data/lib/aws/simple_db/client.rb +349 -0
- data/lib/aws/simple_db/config.rb +20 -0
- data/lib/aws/simple_db/consistent_read_option.rb +42 -0
- data/lib/aws/simple_db/delete_attributes.rb +62 -0
- data/lib/aws/simple_db/domain.rb +121 -0
- data/lib/aws/simple_db/domain_collection.rb +113 -0
- data/lib/aws/simple_db/domain_metadata.rb +110 -0
- data/lib/aws/simple_db/errors.rb +55 -0
- data/lib/aws/simple_db/expect_condition_option.rb +45 -0
- data/lib/aws/simple_db/item.rb +93 -0
- data/lib/aws/simple_db/item_collection.rb +649 -0
- data/lib/aws/simple_db/item_data.rb +73 -0
- data/lib/aws/simple_db/put_attributes.rb +60 -0
- data/lib/aws/simple_db/request.rb +23 -0
- data/lib/aws/simple_email_service.rb +426 -0
- data/lib/aws/simple_email_service/client.rb +286 -0
- data/lib/aws/simple_email_service/config.rb +19 -0
- data/lib/aws/simple_email_service/email_address_collection.rb +69 -0
- data/lib/aws/simple_email_service/errors.rb +22 -0
- data/lib/aws/simple_email_service/identity.rb +91 -0
- data/lib/aws/simple_email_service/identity_collection.rb +81 -0
- data/lib/aws/simple_email_service/quotas.rb +64 -0
- data/lib/aws/simple_email_service/request.rb +29 -0
- data/lib/aws/simple_workflow.rb +226 -0
- data/lib/aws/simple_workflow/activity_task.rb +173 -0
- data/lib/aws/simple_workflow/activity_task_collection.rb +123 -0
- data/lib/aws/simple_workflow/activity_type.rb +131 -0
- data/lib/aws/simple_workflow/activity_type_collection.rb +93 -0
- data/lib/aws/simple_workflow/client.rb +1434 -0
- data/lib/aws/simple_workflow/config.rb +18 -0
- data/lib/aws/simple_workflow/count.rb +49 -0
- data/lib/aws/simple_workflow/decision_task.rb +601 -0
- data/lib/aws/simple_workflow/decision_task_collection.rb +225 -0
- data/lib/aws/simple_workflow/domain.rb +122 -0
- data/lib/aws/simple_workflow/domain_collection.rb +169 -0
- data/lib/aws/simple_workflow/errors.rb +20 -0
- data/lib/aws/simple_workflow/history_event.rb +276 -0
- data/lib/aws/simple_workflow/history_event_collection.rb +76 -0
- data/lib/aws/simple_workflow/option_formatters.rb +82 -0
- data/lib/aws/simple_workflow/request.rb +36 -0
- data/lib/aws/simple_workflow/resource.rb +94 -0
- data/lib/aws/simple_workflow/type.rb +89 -0
- data/lib/aws/simple_workflow/type_collection.rb +140 -0
- data/lib/aws/simple_workflow/workflow_execution.rb +386 -0
- data/lib/aws/simple_workflow/workflow_execution_collection.rb +617 -0
- data/lib/aws/simple_workflow/workflow_type.rb +177 -0
- data/lib/aws/simple_workflow/workflow_type_collection.rb +91 -0
- data/lib/aws/sns.rb +74 -0
- data/lib/aws/sns/client.rb +371 -0
- data/lib/aws/sns/config.rb +18 -0
- data/lib/aws/sns/errors.rb +22 -0
- data/lib/aws/sns/has_delivery_policy.rb +68 -0
- data/lib/aws/sns/policy.rb +47 -0
- data/lib/aws/sns/request.rb +23 -0
- data/lib/aws/sns/subscription.rb +144 -0
- data/lib/aws/sns/subscription_collection.rb +80 -0
- data/lib/aws/sns/topic.rb +403 -0
- data/lib/aws/sns/topic_collection.rb +67 -0
- data/lib/aws/sns/topic_subscription_collection.rb +55 -0
- data/lib/aws/sqs.rb +79 -0
- data/lib/aws/sqs/client.rb +360 -0
- data/lib/aws/sqs/config.rb +18 -0
- data/lib/aws/sqs/errors.rb +101 -0
- data/lib/aws/sqs/policy.rb +48 -0
- data/lib/aws/sqs/queue.rb +725 -0
- data/lib/aws/sqs/queue_collection.rb +170 -0
- data/lib/aws/sqs/received_message.rb +181 -0
- data/lib/aws/sqs/received_sns_message.rb +112 -0
- data/lib/aws/sqs/request.rb +43 -0
- data/lib/aws/sts.rb +152 -0
- data/lib/aws/sts/client.rb +105 -0
- data/lib/aws/sts/config.rb +18 -0
- data/lib/aws/sts/errors.rb +22 -0
- data/lib/aws/sts/federated_session.rb +56 -0
- data/lib/aws/sts/policy.rb +30 -0
- data/lib/aws/sts/request.rb +29 -0
- data/lib/aws/sts/session.rb +48 -0
- data/lib/net/http/connection_pool.rb +210 -0
- data/lib/net/http/connection_pool/connection.rb +132 -0
- data/lib/net/http/connection_pool/session.rb +93 -0
- data/lib/user.rb +49 -0
- metadata +433 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
|
|
2
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
5
|
+
# may not use this file except in compliance with the License. A copy of
|
|
6
|
+
# the License is located at
|
|
7
|
+
#
|
|
8
|
+
# http://aws.amazon.com/apache2.0/
|
|
9
|
+
#
|
|
10
|
+
# or in the "license" file accompanying this file. This file is
|
|
11
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
12
|
+
# ANY KIND, either express or implied. See the License for the specific
|
|
13
|
+
# language governing permissions and limitations under the License.
|
|
14
|
+
|
|
15
|
+
module AWS
|
|
16
|
+
module Core
|
|
17
|
+
|
|
18
|
+
# @private
|
|
19
|
+
class Resource
|
|
20
|
+
|
|
21
|
+
include Model
|
|
22
|
+
include Cacheable
|
|
23
|
+
|
|
24
|
+
# @private
|
|
25
|
+
class NotFound < StandardError; end
|
|
26
|
+
|
|
27
|
+
# @private
|
|
28
|
+
def initialize *args
|
|
29
|
+
|
|
30
|
+
super
|
|
31
|
+
|
|
32
|
+
# cache static attributes passed into options
|
|
33
|
+
|
|
34
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
|
35
|
+
options.each_pair do |opt_name,opt_value|
|
|
36
|
+
if
|
|
37
|
+
self.class.attributes.has_key?(opt_name) and
|
|
38
|
+
self.class.attributes[opt_name].static?
|
|
39
|
+
then
|
|
40
|
+
static_attributes[opt_name] = opt_value
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [String] Returns a simple string representation of this resource.
|
|
47
|
+
def inspect
|
|
48
|
+
|
|
49
|
+
identifiers = []
|
|
50
|
+
resource_identifiers.each do |key, value|
|
|
51
|
+
if attr = self.class.attributes.values.find{|a| a.get_as == key }
|
|
52
|
+
identifiers << "#{attr.name}:#{value}"
|
|
53
|
+
else
|
|
54
|
+
identifiers << "#{key}:#{value}"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
"<#{self::class} #{identifiers.join(' ')}>"
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# @return [Boolean] Returns true if the objects references the same
|
|
63
|
+
# AWS resource.
|
|
64
|
+
def eql? other
|
|
65
|
+
other.kind_of?(self.class) and
|
|
66
|
+
other.resource_identifiers == resource_identifiers
|
|
67
|
+
end
|
|
68
|
+
alias_method :==, :eql?
|
|
69
|
+
|
|
70
|
+
# @private
|
|
71
|
+
protected
|
|
72
|
+
def get_resource attr_name
|
|
73
|
+
raise NotImplementedError
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# @private
|
|
77
|
+
protected
|
|
78
|
+
def update_resource attr, value
|
|
79
|
+
raise NotImplementedError
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Overide this method is subclasses of Resource. This method should
|
|
83
|
+
# return an array of identifying key/value pairs.
|
|
84
|
+
#
|
|
85
|
+
# # @private
|
|
86
|
+
# protected
|
|
87
|
+
# def resource_identifiers
|
|
88
|
+
# [[:user_name, name]]
|
|
89
|
+
# end
|
|
90
|
+
#
|
|
91
|
+
# @private
|
|
92
|
+
protected
|
|
93
|
+
def resource_identifiers
|
|
94
|
+
raise NotImplementedError
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @protected
|
|
98
|
+
protected
|
|
99
|
+
def resource_options(additional = {})
|
|
100
|
+
Hash[resource_identifiers].merge(additional)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# @private
|
|
104
|
+
protected
|
|
105
|
+
def local_cache_key
|
|
106
|
+
resource_identifiers.collect{|name,value| value.to_s }.join(":")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @private
|
|
110
|
+
protected
|
|
111
|
+
def static_attributes
|
|
112
|
+
@static_attributes ||= {}
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# @private
|
|
116
|
+
protected
|
|
117
|
+
def ruby_name
|
|
118
|
+
@ruby_name ||= Inflection.ruby_name(self.class.name)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# @private
|
|
122
|
+
public
|
|
123
|
+
def attributes_from_response resp
|
|
124
|
+
|
|
125
|
+
# check each provider for this request type to see if it
|
|
126
|
+
# can find the resource and some of its attributes
|
|
127
|
+
attributes = []
|
|
128
|
+
self.class.attribute_providers_for(resp.request_type).each do |provider|
|
|
129
|
+
attributes << provider.attributes_from_response(self, resp)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# drop out those that returned no attributesj
|
|
133
|
+
attributes.compact!
|
|
134
|
+
|
|
135
|
+
# stop here if nothing was found for this resource
|
|
136
|
+
return nil if attributes.empty?
|
|
137
|
+
|
|
138
|
+
# merge the attributes together into a single hash
|
|
139
|
+
attributes = attributes.inject({}) {|hash,attribs| hash.merge(attribs) }
|
|
140
|
+
|
|
141
|
+
# cache static attributes
|
|
142
|
+
attributes.each_pair do |attr_name,value|
|
|
143
|
+
if self.class.attributes[attr_name].static?
|
|
144
|
+
static_attributes[attr_name] = value
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
attributes
|
|
149
|
+
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# @private
|
|
153
|
+
protected
|
|
154
|
+
def cache_static_attributes request_type, resp_obj
|
|
155
|
+
self.class.attribute_providers_for(request_type).each do |provider|
|
|
156
|
+
attributes = provider.attributes_from_response_object(resp_obj)
|
|
157
|
+
attributes.each_pair do |attr_name,value|
|
|
158
|
+
if self.class.attributes[attr_name].static?
|
|
159
|
+
static_attributes[attr_name] = value
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
class << self
|
|
166
|
+
|
|
167
|
+
# @private
|
|
168
|
+
def define_attribute_type type_name
|
|
169
|
+
class_eval <<-METHODS
|
|
170
|
+
|
|
171
|
+
def self.#{type_name}_attributes
|
|
172
|
+
@#{type_name}_attributes ||= {}
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def self.#{type_name}_attribute name, options = {}, &block
|
|
176
|
+
attr = attribute(name, options, &block)
|
|
177
|
+
#{type_name}_attributes[attr.name] = attr
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
METHODS
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# @private
|
|
184
|
+
def new_from request_type, resp_obj, *args
|
|
185
|
+
resource = new(*args)
|
|
186
|
+
resource.send(:cache_static_attributes, request_type, resp_obj)
|
|
187
|
+
resource
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# @private
|
|
191
|
+
def attributes
|
|
192
|
+
@attributes ||= Hash.new do |hash,attr_name|
|
|
193
|
+
raise "uknown attribute #{attr_name}"
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# @private
|
|
198
|
+
def attribute_providers
|
|
199
|
+
@attribute_providers ||= []
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# @private
|
|
203
|
+
def attribute_providers_for request_type
|
|
204
|
+
attribute_providers.select do |provider|
|
|
205
|
+
provider.request_types.include?(request_type)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# @private
|
|
210
|
+
protected
|
|
211
|
+
def attribute name, options = {}, &block
|
|
212
|
+
attr = Attribute.new(name, options)
|
|
213
|
+
attr.instance_eval(&block) if block_given?
|
|
214
|
+
define_attribute_getter(attr)
|
|
215
|
+
define_attribute_setter(attr) if attr.mutable?
|
|
216
|
+
attributes[attr.name] = attr
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# @private
|
|
220
|
+
protected
|
|
221
|
+
def mutable_attribute name, options = {}, &block
|
|
222
|
+
attribute(name, options.merge(:mutable => true), &block)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# @private
|
|
226
|
+
protected
|
|
227
|
+
def define_attribute_getter attribute
|
|
228
|
+
define_method(attribute.name) do
|
|
229
|
+
|
|
230
|
+
return static_attributes[attribute.name] if
|
|
231
|
+
static_attributes.has_key?(attribute.name)
|
|
232
|
+
|
|
233
|
+
begin
|
|
234
|
+
retrieve_attribute(attribute) { get_resource(attribute) }
|
|
235
|
+
rescue Cacheable::NoData => e
|
|
236
|
+
name = ruby_name.tr("_", " ")
|
|
237
|
+
raise NotFound, "unable to find the #{name}"
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# @private
|
|
244
|
+
protected
|
|
245
|
+
def define_attribute_setter attribute
|
|
246
|
+
setter = attribute.name.to_s.sub(/\?/, '') + '='
|
|
247
|
+
define_method(setter) do |value|
|
|
248
|
+
translated_value = attribute.translate_input_value(value)
|
|
249
|
+
update_resource(attribute, translated_value)
|
|
250
|
+
if attribute.static?
|
|
251
|
+
static_attributes[attribute.name] = translated_value
|
|
252
|
+
end
|
|
253
|
+
value
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# @private
|
|
258
|
+
protected
|
|
259
|
+
def populates_from *request_types, &block
|
|
260
|
+
provider = provider(*request_types)
|
|
261
|
+
provider.find(&block)
|
|
262
|
+
provider.provides(*attributes.keys)
|
|
263
|
+
provider
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# @private
|
|
267
|
+
protected
|
|
268
|
+
def provider *request_types, &block
|
|
269
|
+
provider = AttributeProvider.new(self, request_types)
|
|
270
|
+
if block_given?
|
|
271
|
+
yield(provider)
|
|
272
|
+
end
|
|
273
|
+
attribute_providers << provider
|
|
274
|
+
provider
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# @private
|
|
280
|
+
class Attribute
|
|
281
|
+
|
|
282
|
+
def initialize name, options = {}
|
|
283
|
+
@name = name
|
|
284
|
+
@options = options
|
|
285
|
+
@request_types = []
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
attr_reader :name
|
|
289
|
+
|
|
290
|
+
attr_reader :request_types
|
|
291
|
+
|
|
292
|
+
def get_as
|
|
293
|
+
@get_as ||= (@options[:get_as] || @options[:as] || name)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def set_as
|
|
297
|
+
@set_as ||= (@options[:set_as] || @options[:as] || name)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def mutable?
|
|
301
|
+
@options[:mutable] == true
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def static?
|
|
305
|
+
@options[:static] == true
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def translates_input &block
|
|
309
|
+
@input_translator = block
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def translates_output options = {}, &block
|
|
313
|
+
@translates_nil = options[:nil]
|
|
314
|
+
@output_translator = block
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def translate_input_value value
|
|
318
|
+
@input_translator ? @input_translator.call(value) : value
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def translate_output_value value
|
|
322
|
+
|
|
323
|
+
# by default nil values are not translated
|
|
324
|
+
return nil if value.nil? and @translates_nil != true
|
|
325
|
+
|
|
326
|
+
case
|
|
327
|
+
when @options[:to_sym] then value.tr('-','_').downcase.to_sym
|
|
328
|
+
when @options[:timestamp] then Time.at(value.to_i)
|
|
329
|
+
when @output_translator then @output_translator.call(value)
|
|
330
|
+
else value
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
# @private
|
|
338
|
+
class AttributeProvider
|
|
339
|
+
|
|
340
|
+
def initialize klass, request_types
|
|
341
|
+
@klass = klass
|
|
342
|
+
@id = klass.attribute_providers.length
|
|
343
|
+
@request_types = request_types
|
|
344
|
+
@provides = {}
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
attr_reader :request_types
|
|
348
|
+
|
|
349
|
+
def find &block
|
|
350
|
+
@klass.send(:define_method, finder_method, &block)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
def finder_method
|
|
354
|
+
"_find_in_#{request_types.join('_or_')}_response_#{@id}"
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
# Indicates that all of the the named attributes can be retrieved
|
|
358
|
+
# from an appropriate response object.
|
|
359
|
+
#
|
|
360
|
+
# @overload provides(*attr_names, options = {})
|
|
361
|
+
# @param [Symbol] attr_names A list of attributes provided
|
|
362
|
+
# @param [Hash] options
|
|
363
|
+
# @option options [Boolean] :value_wrapped (false) If true, then
|
|
364
|
+
# the value returned by the response object will also receive
|
|
365
|
+
# the message :value before it is translated and returned.
|
|
366
|
+
# @option options [Symbol] :get_as Defaults to the method named
|
|
367
|
+
# by the attribute. This is useful when you have two providers
|
|
368
|
+
# for the same attribute but their response object name
|
|
369
|
+
# them differently.
|
|
370
|
+
def provides *attr_names
|
|
371
|
+
options = attr_names.last.is_a?(Hash) ? attr_names.pop : {}
|
|
372
|
+
attr_names.each do |attr_name|
|
|
373
|
+
attr = @klass.attributes[attr_name]
|
|
374
|
+
attr.request_types.push(*request_types)
|
|
375
|
+
@provides[attr_name] = options
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def attributes_from_response resource, response
|
|
380
|
+
if response_object = resource.send(finder_method, response)
|
|
381
|
+
attributes_from_response_object(response_object)
|
|
382
|
+
else
|
|
383
|
+
nil
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
def attributes_from_response_object resp_obj
|
|
388
|
+
|
|
389
|
+
@provides.inject({}) do |attributes,(attr_name,options)|
|
|
390
|
+
|
|
391
|
+
attr = @klass.attributes[attr_name]
|
|
392
|
+
|
|
393
|
+
method = options[:get_as] || attr.get_as
|
|
394
|
+
|
|
395
|
+
v = resp_obj.key?(method) ? resp_obj[method] : resp_obj[method.to_s]
|
|
396
|
+
v = v[:value] if v and options[:value_wrapped]
|
|
397
|
+
v = attr.translate_output_value(v)
|
|
398
|
+
|
|
399
|
+
attributes.merge(attr_name => v)
|
|
400
|
+
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
|
5
|
+
# the License is located at
|
|
6
|
+
#
|
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
|
8
|
+
#
|
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
|
12
|
+
# language governing permissions and limitations under the License.
|
|
13
|
+
|
|
14
|
+
module AWS
|
|
15
|
+
module Core
|
|
16
|
+
|
|
17
|
+
# @private
|
|
18
|
+
class ResourceCache
|
|
19
|
+
|
|
20
|
+
def initialize
|
|
21
|
+
@cache = {}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def store(key, attributes)
|
|
25
|
+
(@cache[key] ||= {}).merge!(attributes)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def cached?(key, attribute)
|
|
29
|
+
attributes = @cache[key] and attributes.has_key?(attribute)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get(key, attribute)
|
|
33
|
+
raise "No cached value for attribute :#{attribute} of #{key}" unless
|
|
34
|
+
cached?(key, attribute)
|
|
35
|
+
@cache[key][attribute]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
|
5
|
+
# the License is located at
|
|
6
|
+
#
|
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
|
8
|
+
#
|
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
|
12
|
+
# language governing permissions and limitations under the License.
|
|
13
|
+
|
|
14
|
+
module AWS
|
|
15
|
+
module Core
|
|
16
|
+
|
|
17
|
+
# = Response
|
|
18
|
+
#
|
|
19
|
+
# Each service request returns a response object. Responses provide
|
|
20
|
+
# access to response data and request/response metadata.
|
|
21
|
+
#
|
|
22
|
+
# == Response Data
|
|
23
|
+
#
|
|
24
|
+
# Each response has a hash of data that represents the data
|
|
25
|
+
# returned by the service. You can get at this data by
|
|
26
|
+
# calling {#data} (you can also use the {#[]} method as a shortcut)
|
|
27
|
+
#
|
|
28
|
+
# # make a request to describe one instance
|
|
29
|
+
# ec2 = AWS::EC2.new
|
|
30
|
+
# response = ec2.client.describe_instances(:instance_ids => ['i-12345678'])
|
|
31
|
+
#
|
|
32
|
+
# # find the instance in the response data (2 ways to get the data)
|
|
33
|
+
# instance = response[:reservation_set].first[:instance_set].first
|
|
34
|
+
# instance = response.data[:reservation_set].first[:instance_set].first
|
|
35
|
+
#
|
|
36
|
+
# instance[:status] #=> 'running'
|
|
37
|
+
#
|
|
38
|
+
# == Response Metadata
|
|
39
|
+
#
|
|
40
|
+
# In addition to the response data, there is additional information
|
|
41
|
+
# available with the response, including:
|
|
42
|
+
#
|
|
43
|
+
# * the name of the client request method called
|
|
44
|
+
# * the hash of options passed to the client request
|
|
45
|
+
# * the HTTP request object (useful for debugging)
|
|
46
|
+
# * the HTTP response object (useful for debugging)
|
|
47
|
+
#
|
|
48
|
+
# Given the example and response object from above:
|
|
49
|
+
#
|
|
50
|
+
# response.request_type #=> :describe_instances
|
|
51
|
+
# response.request_options #=> { :instance_ids => ['i-12345678'] }
|
|
52
|
+
# response.http_request #=> #<AWS::Core::Http::Request>
|
|
53
|
+
# response.http_response #=> #<AWS::Core::Http::Response>
|
|
54
|
+
#
|
|
55
|
+
class Response
|
|
56
|
+
|
|
57
|
+
include AsyncHandle
|
|
58
|
+
|
|
59
|
+
# @return [Hash] Returns the response data as a hash.
|
|
60
|
+
attr_accessor :data
|
|
61
|
+
|
|
62
|
+
# @return [Symbol] The name of the client request method that
|
|
63
|
+
# returned this response.
|
|
64
|
+
attr_accessor :request_type
|
|
65
|
+
|
|
66
|
+
# @return [Hash] Returns the hash of options passed to the client
|
|
67
|
+
# request method that generated this response.
|
|
68
|
+
attr_accessor :request_options
|
|
69
|
+
|
|
70
|
+
# @return [Core::Http::Request]
|
|
71
|
+
attr_accessor :http_request
|
|
72
|
+
|
|
73
|
+
# @return [Core::Http::Response]
|
|
74
|
+
attr_accessor :http_response
|
|
75
|
+
|
|
76
|
+
# @return [Boolean] true if the response was generated from a
|
|
77
|
+
# another cached response.
|
|
78
|
+
attr_accessor :cached
|
|
79
|
+
|
|
80
|
+
alias_method :cached?, :cached
|
|
81
|
+
|
|
82
|
+
# @return [AWS::Error,nil] Returns nil unless the request failed.
|
|
83
|
+
# Normally this will be nil unless you are using the Asynchronous
|
|
84
|
+
# interface.
|
|
85
|
+
attr_accessor :error
|
|
86
|
+
|
|
87
|
+
# @return [Integer] Returns the number of times the request
|
|
88
|
+
# was retried.
|
|
89
|
+
attr_accessor :retry_count
|
|
90
|
+
|
|
91
|
+
# @return [Float] The total number of seconds taken to make the
|
|
92
|
+
# request and return the response.
|
|
93
|
+
attr_accessor :duration
|
|
94
|
+
|
|
95
|
+
# @param [Http::Request] http_request
|
|
96
|
+
# @param [Http::Response] http_response
|
|
97
|
+
def initialize http_request = nil, http_response = nil, &block
|
|
98
|
+
@http_request = http_request
|
|
99
|
+
@http_response = http_response
|
|
100
|
+
@request_builder = block
|
|
101
|
+
@data = {}
|
|
102
|
+
@retry_count = 0
|
|
103
|
+
@duration = 0
|
|
104
|
+
rebuild_request if @request_builder && !http_request
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Provides access to the response data. This is a short-cut
|
|
108
|
+
# for calling +response.data[key]+.
|
|
109
|
+
#
|
|
110
|
+
# @param [Symbol,String] key
|
|
111
|
+
# @return [Hash,nil]
|
|
112
|
+
def [] key
|
|
113
|
+
data[key]
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# @return [Boolean] Returns true if there is no response error.
|
|
117
|
+
def successful?
|
|
118
|
+
error.nil?
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# @return [Boolean] Returns true if the http request was throttled
|
|
122
|
+
# by AWS.
|
|
123
|
+
def throttled?
|
|
124
|
+
if !successful? and http_response.body
|
|
125
|
+
error = XML::Parser.new.parse(http_response.body)
|
|
126
|
+
error = error[:error] if error[:error]
|
|
127
|
+
error[:code] == "Throttling"
|
|
128
|
+
else
|
|
129
|
+
false
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# @return [Boolean] Returns true if the http request timed out.
|
|
134
|
+
def timeout?
|
|
135
|
+
http_response.timeout?
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# @return [String]
|
|
139
|
+
# @private
|
|
140
|
+
def inspect
|
|
141
|
+
data.inspect
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# @return [String]
|
|
145
|
+
# @private
|
|
146
|
+
def cache_key
|
|
147
|
+
[
|
|
148
|
+
http_request.access_key_id,
|
|
149
|
+
http_request.host,
|
|
150
|
+
request_type,
|
|
151
|
+
serialized_options
|
|
152
|
+
].join(":")
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Rebuilds the HTTP request using the block passed to the initializer.
|
|
156
|
+
# This is primarily used by the client when a request must be retried
|
|
157
|
+
# (throttling, server errors, socket errors, etc).
|
|
158
|
+
# @private
|
|
159
|
+
def rebuild_request
|
|
160
|
+
@http_request = @request_builder.call
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
protected
|
|
164
|
+
|
|
165
|
+
# @note The prefered method to get as response data is to use {#[]}.
|
|
166
|
+
#
|
|
167
|
+
# This provides a backwards-compat layer to the old response objects
|
|
168
|
+
# where each response value had a method extended onto this object.
|
|
169
|
+
# Now all response data is accessible as a hash.
|
|
170
|
+
#
|
|
171
|
+
# @see #[]
|
|
172
|
+
# @see #data
|
|
173
|
+
#
|
|
174
|
+
def method_missing *args, &block
|
|
175
|
+
Core::Data.new(data).send(*args, &block)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def serialized_options
|
|
179
|
+
serialize_options_hash(request_options)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def serialize_options_hash(hash)
|
|
183
|
+
"(" + hash.keys.sort_by(&:to_s).map do |key|
|
|
184
|
+
"#{key}=#{serialize_options_value(hash[key])}"
|
|
185
|
+
end.join(" ") + ")"
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def serialize_options_value(value)
|
|
189
|
+
case value
|
|
190
|
+
when Hash then serialize_options_hash(value)
|
|
191
|
+
when Array then serialize_options_array(value)
|
|
192
|
+
else value.inspect
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def serialize_options_array array
|
|
197
|
+
"[" + array.map{|v| serialize_options_value(v) }.join(" ") + "]"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|