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,74 @@
|
|
|
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
|
+
module Http
|
|
17
|
+
|
|
18
|
+
# Represents the http response from a service request.
|
|
19
|
+
#
|
|
20
|
+
# Responses have:
|
|
21
|
+
#
|
|
22
|
+
# * status (200, 404, 500, etc)
|
|
23
|
+
# * headers (hash of response headers)
|
|
24
|
+
# * body (the response body)
|
|
25
|
+
class Response
|
|
26
|
+
|
|
27
|
+
# @return [Integer] (200) response http status code
|
|
28
|
+
attr_accessor :status
|
|
29
|
+
|
|
30
|
+
# @return [Hash] ({}) response http headers
|
|
31
|
+
attr_accessor :headers
|
|
32
|
+
|
|
33
|
+
# @return [String] ('') response http body
|
|
34
|
+
attr_accessor :body
|
|
35
|
+
|
|
36
|
+
# @return [Boolean] (false) set to true if the client gives up
|
|
37
|
+
# before getting a response from the service.
|
|
38
|
+
attr_accessor :timeout
|
|
39
|
+
|
|
40
|
+
alias_method :timeout?, :timeout
|
|
41
|
+
|
|
42
|
+
# @param [Hash] options
|
|
43
|
+
# @option options [Integer] :status (200) HTTP status code
|
|
44
|
+
# @option options [Hash] :headers ({}) HTTP response headers
|
|
45
|
+
# @option options [String] :body ('') HTTP response body
|
|
46
|
+
def initialize options = {}, &block
|
|
47
|
+
@status = options[:status] || 200
|
|
48
|
+
@headers = options[:headers] || {}
|
|
49
|
+
@body = options[:body] || ''
|
|
50
|
+
yield(self) if block_given?
|
|
51
|
+
self
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Returns the header value with the given name.
|
|
55
|
+
#
|
|
56
|
+
# The value is matched case-insensitively so if the headers hash
|
|
57
|
+
# contains a key like 'Date' and you request the value for
|
|
58
|
+
# 'date' the 'Date' value will be returned.
|
|
59
|
+
#
|
|
60
|
+
# @param [String,Symbol] name The name of the header to fetch a value for.
|
|
61
|
+
# @return [String,nil] The value of the given header
|
|
62
|
+
def header name
|
|
63
|
+
headers.each_pair do |header_name, header_value|
|
|
64
|
+
if header_name.downcase == name.to_s.downcase
|
|
65
|
+
return header_value.is_a?(Array) ? header_value.first : header_value
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
# A utility class to provide indifferent access to hash data.
|
|
18
|
+
#
|
|
19
|
+
# Inspired by ActiveSupport's HashWithIndifferentAccess, this class
|
|
20
|
+
# has a few notable differences:
|
|
21
|
+
#
|
|
22
|
+
# * ALL keys are converted to strings (via #to_s)
|
|
23
|
+
# * It does not deep merge/convert hashes indifferently, good for fla
|
|
24
|
+
# * It will not perserve default value behaviours
|
|
25
|
+
#
|
|
26
|
+
# These features were omitted because our primary use for this class is to
|
|
27
|
+
# wrap a 1-level hash as a return value, but we want the user to access
|
|
28
|
+
# the values with string or symbol keys.
|
|
29
|
+
#
|
|
30
|
+
# @private
|
|
31
|
+
class IndifferentHash < Hash
|
|
32
|
+
|
|
33
|
+
def initialize *args
|
|
34
|
+
if args.first.is_a?(Hash)
|
|
35
|
+
super()
|
|
36
|
+
merge!(*args)
|
|
37
|
+
else
|
|
38
|
+
super(*args)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
alias_method :_getter, :[]
|
|
43
|
+
alias_method :_setter, :[]=
|
|
44
|
+
|
|
45
|
+
def []=(key, value)
|
|
46
|
+
_setter(_convert_key(key), value)
|
|
47
|
+
end
|
|
48
|
+
alias_method :store, :[]=
|
|
49
|
+
|
|
50
|
+
def [] key
|
|
51
|
+
_getter(_convert_key(key))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def merge! hash
|
|
55
|
+
hash.each_pair do |key,value|
|
|
56
|
+
self[key] = value
|
|
57
|
+
end
|
|
58
|
+
self
|
|
59
|
+
end
|
|
60
|
+
alias_method :update, :merge!
|
|
61
|
+
|
|
62
|
+
def merge hash
|
|
63
|
+
self.dup.merge!(hash)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def has_key? key
|
|
67
|
+
super(_convert_key(key))
|
|
68
|
+
end
|
|
69
|
+
alias_method :key?, :has_key?
|
|
70
|
+
alias_method :member?, :has_key?
|
|
71
|
+
alias_method :include?, :has_key?
|
|
72
|
+
|
|
73
|
+
def fetch key, *extras, &block
|
|
74
|
+
super(_convert_key(key), *extras, &block)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def delete key
|
|
78
|
+
super(_convert_key(key))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
def _convert_key key
|
|
83
|
+
key.is_a?(String) ? key : key.to_s
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
module Inflection
|
|
19
|
+
|
|
20
|
+
def ruby_name(aws_name)
|
|
21
|
+
|
|
22
|
+
#aws_name.sub(/^.*:/, '').
|
|
23
|
+
# gsub(/[A-Z]+[a-z]+/){|str| "_#{str.downcase}_" }.
|
|
24
|
+
# gsub(/(^_|_$)/, '').
|
|
25
|
+
# gsub(/__/, '_').
|
|
26
|
+
# downcase
|
|
27
|
+
|
|
28
|
+
return 'etag' if aws_name == 'ETag'
|
|
29
|
+
|
|
30
|
+
aws_name.
|
|
31
|
+
sub(/^.*:/, ''). # strip namespace
|
|
32
|
+
gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). # split acronyms from words
|
|
33
|
+
scan(/[a-z]+|\d+|[A-Z0-9]+[a-z]*/). # split remaining words
|
|
34
|
+
join('_').downcase # join parts _ and downcase
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
module_function :ruby_name
|
|
38
|
+
|
|
39
|
+
def class_name(name)
|
|
40
|
+
name.sub(/^(.)/) { |m| m.upcase }.
|
|
41
|
+
gsub(/[-_]([a-z])/i) { |m| m[1,1].upcase }
|
|
42
|
+
end
|
|
43
|
+
module_function :class_name
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
require 'thread'
|
|
15
|
+
|
|
16
|
+
module AWS
|
|
17
|
+
module Core
|
|
18
|
+
|
|
19
|
+
# Provides lazy creation of error classes via {#const_missing}.
|
|
20
|
+
#
|
|
21
|
+
# Extend this module provides 3 benefits to another module:
|
|
22
|
+
#
|
|
23
|
+
# * A method that accepts strings and returns error classes.
|
|
24
|
+
# * Thread-safe dynamic error class creation via {#const_missing}
|
|
25
|
+
# * An error grammar for parsing AWS xml errors
|
|
26
|
+
#
|
|
27
|
+
# Here is an example of how it works:
|
|
28
|
+
#
|
|
29
|
+
# Class Foo
|
|
30
|
+
# module Errors
|
|
31
|
+
# extend AWS::Core::LazyErrorClasses
|
|
32
|
+
# end
|
|
33
|
+
# end
|
|
34
|
+
#
|
|
35
|
+
# Foo::Errors.error_class('NoSuchKey')
|
|
36
|
+
# #=> Foo::Errors::NoSuckKey
|
|
37
|
+
#
|
|
38
|
+
# Foo::Errors.error_class('Nested.Error.Klasses')
|
|
39
|
+
# #=> Foo::Errors::Nested::Error::Klasses
|
|
40
|
+
#
|
|
41
|
+
# The errors returned from {#error_class} are subclasses
|
|
42
|
+
# of {AWS::Errors::Base}.
|
|
43
|
+
#
|
|
44
|
+
module LazyErrorClasses
|
|
45
|
+
|
|
46
|
+
# This grammar parses the defualt AWS XML error format
|
|
47
|
+
BASE_ERROR_GRAMMAR = XML::Grammar.customize do
|
|
48
|
+
element("Error") do
|
|
49
|
+
ignore
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @private
|
|
54
|
+
def self.extended base
|
|
55
|
+
|
|
56
|
+
unless base.const_defined?(:GRAMMAR)
|
|
57
|
+
base.const_set(:GRAMMAR, BASE_ERROR_GRAMMAR)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
mutex = Mutex.new
|
|
61
|
+
MetaUtils.extend_method(base, :const_missing_mutex) { mutex }
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Defines a new error class.
|
|
66
|
+
# @param [String,Symbol] constant
|
|
67
|
+
# @return [nil]
|
|
68
|
+
def const_missing constant
|
|
69
|
+
const_missing_mutex.synchronize do
|
|
70
|
+
const_set(constant, Class.new(Errors::Base) { extend LazyErrorClasses })
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Converts the error code into an error class constant.
|
|
75
|
+
#
|
|
76
|
+
# AWS::EC2::Errors.error_class('Non.Existent.Error')
|
|
77
|
+
# #=> AWS::EC2::Errors::Non::Existent::Error
|
|
78
|
+
#
|
|
79
|
+
# @param [String] code An AWS error code.
|
|
80
|
+
#
|
|
81
|
+
# @return [Class] Returns the error class defiend by the error code.
|
|
82
|
+
#
|
|
83
|
+
def error_class code
|
|
84
|
+
module_eval("#{self}::#{code.gsub('.Range','Range').gsub(".","::")}")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,454 @@
|
|
|
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
|
+
# = Log Formatters
|
|
18
|
+
#
|
|
19
|
+
# Log formatters receive a {AWS::Core::Response} object and return
|
|
20
|
+
# a log message. When you construct a {LogFormatter}, you provide
|
|
21
|
+
# a pattern string with substitutions.
|
|
22
|
+
#
|
|
23
|
+
# pattern = '[REQUEST :http_status_code] :service :operation :duration'
|
|
24
|
+
# formatter = AWS::Core::LogFormatter.new(pattern)
|
|
25
|
+
# formatter.format(response)
|
|
26
|
+
# #=> '[AWS 200] EC2 get_bucket 0.0352'
|
|
27
|
+
#
|
|
28
|
+
# = AWS Configuration
|
|
29
|
+
#
|
|
30
|
+
# AWS.config provides a {LogFormatter.default} log formatter. You can
|
|
31
|
+
# repace this formatter by building your own and then passing it
|
|
32
|
+
# to {AWS.config}.
|
|
33
|
+
#
|
|
34
|
+
# pattern = '[REQUEST :http_status_code] :service :operation :duration'
|
|
35
|
+
# AWS.config(:log_formatter => AWS::Core::LogFormatter.new(pattern)
|
|
36
|
+
#
|
|
37
|
+
# == Canned Formatters
|
|
38
|
+
#
|
|
39
|
+
# Instead of providing your own pattern, you can choose a canned log
|
|
40
|
+
# formatter.
|
|
41
|
+
#
|
|
42
|
+
# AWS.config(:log_formatter => AWS::Core::LogFormatter.colored)
|
|
43
|
+
#
|
|
44
|
+
# Here is the list of canned formatters.
|
|
45
|
+
#
|
|
46
|
+
# * {LogFormatter.default}
|
|
47
|
+
# * {LogFormatter.short}
|
|
48
|
+
# * {LogFormatter.debug}
|
|
49
|
+
# * {LogFormatter.colored}
|
|
50
|
+
#
|
|
51
|
+
# = Pattern Substitutions
|
|
52
|
+
#
|
|
53
|
+
# You can put any of these placeholders into you pattern.
|
|
54
|
+
#
|
|
55
|
+
# [+:service+]
|
|
56
|
+
# The AWS service name (e.g. 'S3', 'EC2', 'SimpleDB', etc)
|
|
57
|
+
#
|
|
58
|
+
# [+:region+]
|
|
59
|
+
# The AWS region name (e.g. 'us-east-1', 'us-west-1', etc)
|
|
60
|
+
#
|
|
61
|
+
# [+:operation+]
|
|
62
|
+
# The name of the client request method. This maps to the name of
|
|
63
|
+
# the serivce API operation (e.g. :describe_instances).
|
|
64
|
+
#
|
|
65
|
+
# [+:options+]
|
|
66
|
+
# The hash of options passed to the client request method.
|
|
67
|
+
# Long strings are truncated/summarized if they excede the log
|
|
68
|
+
# formatters {#max_string_size}. Other objects are inspected.
|
|
69
|
+
#
|
|
70
|
+
# [+:retry_count+]
|
|
71
|
+
# The number of times a client request was retried.
|
|
72
|
+
# Throttlings and service errors trigger the automatic retry logic.
|
|
73
|
+
# This value indicates how many extra attempts were made before
|
|
74
|
+
# getting a successful response or giving up.
|
|
75
|
+
#
|
|
76
|
+
# [+:duration+]
|
|
77
|
+
# The time it took to generate a response, expressed
|
|
78
|
+
# in decimal seconds. This time includes everything from
|
|
79
|
+
# calling the client request method, until that method returns
|
|
80
|
+
# a value (event retries and retry delays).
|
|
81
|
+
#
|
|
82
|
+
# [+:error_class+]
|
|
83
|
+
# The class name of the error returned by the
|
|
84
|
+
# service. If no error was returned, this will be replcaed by
|
|
85
|
+
# an empty string.
|
|
86
|
+
#
|
|
87
|
+
# [+:error_message+]
|
|
88
|
+
# The message of the error returned. If
|
|
89
|
+
# no error was returned by the service, this will be an empty
|
|
90
|
+
# string.
|
|
91
|
+
#
|
|
92
|
+
# [+:http_request_method+]
|
|
93
|
+
# The HTTP request verb (e.g. 'POST', 'PUT', 'GET', etc).
|
|
94
|
+
#
|
|
95
|
+
# [+:http_request_protocol+]
|
|
96
|
+
# This is replaced by 'http' or 'https'.
|
|
97
|
+
#
|
|
98
|
+
# [+:http_request_host+]
|
|
99
|
+
# The host name of the http request endpoint (e.g. 's3.amazon.com').
|
|
100
|
+
#
|
|
101
|
+
# [+:http_request_port+]
|
|
102
|
+
# The port number (e.g. '443' or '80').
|
|
103
|
+
#
|
|
104
|
+
# [+:http_request_uri+]
|
|
105
|
+
# The http request uri folling the host (e.g.
|
|
106
|
+
# '/bucket_name/objects/key?versions').
|
|
107
|
+
#
|
|
108
|
+
# [+:http_request_body+]
|
|
109
|
+
# The http request payload.
|
|
110
|
+
#
|
|
111
|
+
# [+:http_request_headers+]
|
|
112
|
+
# The http request headers, inspected.
|
|
113
|
+
#
|
|
114
|
+
# [+:http_request_proxy_uri+]
|
|
115
|
+
# The proxy uri used, or an empty string.
|
|
116
|
+
#
|
|
117
|
+
# [+:http_response_status+]
|
|
118
|
+
# The http response status code (e.g. '200', '404', '500', etc).
|
|
119
|
+
#
|
|
120
|
+
# [+:http_response_headers+]
|
|
121
|
+
# The http response headers, inspected.
|
|
122
|
+
#
|
|
123
|
+
# [+:http_response_body+]
|
|
124
|
+
# The http response body contents.
|
|
125
|
+
#
|
|
126
|
+
class LogFormatter
|
|
127
|
+
|
|
128
|
+
# @param [String] pattern The log format pattern should be a string
|
|
129
|
+
# and may contain any of the following placeholders:
|
|
130
|
+
#
|
|
131
|
+
# * +:service+
|
|
132
|
+
# * +:region+
|
|
133
|
+
# * +:operation+
|
|
134
|
+
# * +:options+
|
|
135
|
+
# * +:retry_count
|
|
136
|
+
# * +:duration+
|
|
137
|
+
# * +:error_class+
|
|
138
|
+
# * +:error_message+
|
|
139
|
+
# * +:http_request_method+
|
|
140
|
+
# * +:http_request_protocol+
|
|
141
|
+
# * +:http_request_host+
|
|
142
|
+
# * +:http_request_port+
|
|
143
|
+
# * +:http_request_uri+
|
|
144
|
+
# * +:http_request_body+
|
|
145
|
+
# * +:http_request_headers+
|
|
146
|
+
# * +:http_request_proxy_uri+
|
|
147
|
+
# * +:http_response_status+
|
|
148
|
+
# * +:http_response_headers+
|
|
149
|
+
# * +:http_response_body+
|
|
150
|
+
#
|
|
151
|
+
# @param [Hash] options
|
|
152
|
+
#
|
|
153
|
+
# @option options [Integer] :max_string_size (1000)
|
|
154
|
+
#
|
|
155
|
+
def initialize pattern, options = {}
|
|
156
|
+
@pattern = pattern
|
|
157
|
+
@max_string_size = options[:max_string_size] || 1000
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# @return [String]
|
|
161
|
+
attr_reader :pattern
|
|
162
|
+
|
|
163
|
+
# @return [Integer]
|
|
164
|
+
attr_reader :max_string_size
|
|
165
|
+
|
|
166
|
+
# @param [Response] response
|
|
167
|
+
# @return [String]
|
|
168
|
+
def format response
|
|
169
|
+
pattern.gsub(/:(\w+)/) {|sym| send("_#{sym[1..-1]}", response) }
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
protected
|
|
173
|
+
|
|
174
|
+
def method_missing method_name, *args
|
|
175
|
+
if method_name.to_s.chars.first == '_'
|
|
176
|
+
":#{method_name.to_s[1..-1]}"
|
|
177
|
+
else
|
|
178
|
+
super
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def _service response
|
|
183
|
+
response.http_request.class.name.split('::')[1]
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def _region response
|
|
187
|
+
response.http_request.region
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def _operation response
|
|
191
|
+
response.request_type
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def _options response
|
|
195
|
+
summarize_hash(response.request_options) if response.request_options
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def _retry_count response
|
|
199
|
+
response.retry_count
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def _duration response
|
|
203
|
+
("%.06f" % response.duration).sub(/0+$/, '')
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def _error_class response
|
|
207
|
+
response.error.class.name if response.error
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def _error_message response
|
|
211
|
+
response.error.message if response.error
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def _http_request_method response
|
|
215
|
+
response.http_request.http_method
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def _http_request_protocol response
|
|
219
|
+
response.http_request.use_ssl? ? 'https' : 'http'
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def _http_request_host response
|
|
223
|
+
response.http_request.host
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def _http_request_port response
|
|
227
|
+
response.http_request.port
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def _http_request_uri response
|
|
231
|
+
response.http_request.uri
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def _http_request_headers response
|
|
235
|
+
response.http_request.headers.inspect
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def _http_request_body response
|
|
239
|
+
response.http_request.body
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def _http_request_proxy_uri response
|
|
243
|
+
response.http_request.proxy_uri
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def _http_response_status response
|
|
247
|
+
response.http_response.status
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def _http_response_headers response
|
|
251
|
+
response.http_response.headers.inspect
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def _http_response_body response
|
|
255
|
+
response.http_response.body
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# The following methods are for summarizing request options that have
|
|
259
|
+
# symbolized keys and a mix of values. The summarizing is important
|
|
260
|
+
# because large request options (e.g. s3 data) can cause memory usage
|
|
261
|
+
# to spike if it is inspected.
|
|
262
|
+
|
|
263
|
+
# @param [Hash] hash
|
|
264
|
+
# @return [String]
|
|
265
|
+
def summarize_hash hash
|
|
266
|
+
hash.map do |key,v|
|
|
267
|
+
":#{key}=>#{summarize_value(v)}"
|
|
268
|
+
end.sort.join(",")
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# @param [Object] value
|
|
272
|
+
# @return [String]
|
|
273
|
+
def summarize_value value
|
|
274
|
+
case value
|
|
275
|
+
when String then summarize_string(value)
|
|
276
|
+
when Hash then '{' + summarize_hash(value) + '}'
|
|
277
|
+
when Array then summarize_array(value)
|
|
278
|
+
when File then summarize_file(value.path)
|
|
279
|
+
when Pathname then summarize_file(value)
|
|
280
|
+
else value.inspect
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# @param [String] str
|
|
285
|
+
# @return [String]
|
|
286
|
+
def summarize_string str
|
|
287
|
+
max = max_string_size
|
|
288
|
+
if str.size > max
|
|
289
|
+
"#<String #{str[0...max].inspect} ... (#{str.size} bytes)>"
|
|
290
|
+
else
|
|
291
|
+
str.inspect
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# Given the path to a file on disk, this method returns a summarized
|
|
296
|
+
# inspecton string that includes the file size.
|
|
297
|
+
# @param [String] path
|
|
298
|
+
# @return [String]
|
|
299
|
+
def summarize_file path
|
|
300
|
+
"#<File:#{path} (#{File.size(path)} bytes)>"
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# @param [Array] array
|
|
304
|
+
# @return [String]
|
|
305
|
+
def summarize_array array
|
|
306
|
+
"[" + array.map{|v| summarize_value(v) }.join(",") + "]"
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
class << self
|
|
310
|
+
|
|
311
|
+
# The default log format.
|
|
312
|
+
#
|
|
313
|
+
# @example A sample of the default format.
|
|
314
|
+
#
|
|
315
|
+
# [AWS SimpleEmailService 200 0.580066 0 retries] list_verified_email_addresses()
|
|
316
|
+
#
|
|
317
|
+
# @return [LogFormatter]
|
|
318
|
+
#
|
|
319
|
+
def default
|
|
320
|
+
|
|
321
|
+
pattern = []
|
|
322
|
+
pattern << "[AWS"
|
|
323
|
+
pattern << ":service"
|
|
324
|
+
pattern << ":http_response_status"
|
|
325
|
+
pattern << ":duration"
|
|
326
|
+
pattern << ":retry_count retries]"
|
|
327
|
+
pattern << ":operation(:options)"
|
|
328
|
+
pattern << ":error_class"
|
|
329
|
+
pattern << ":error_message"
|
|
330
|
+
|
|
331
|
+
LogFormatter.new(pattern.join(' ') + "\n")
|
|
332
|
+
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# The short log format. Similar to default, but it does not
|
|
336
|
+
# inspect the request params or report on retries.
|
|
337
|
+
#
|
|
338
|
+
# @example A sample of the short format
|
|
339
|
+
#
|
|
340
|
+
# [AWS SimpleEmailService 200 0.494532] list_verified_email_addresses
|
|
341
|
+
#
|
|
342
|
+
# @return [LogFormatter]
|
|
343
|
+
#
|
|
344
|
+
def short
|
|
345
|
+
|
|
346
|
+
pattern = []
|
|
347
|
+
pattern << "[AWS"
|
|
348
|
+
pattern << ":service"
|
|
349
|
+
pattern << ":http_response_status"
|
|
350
|
+
pattern << ":duration]"
|
|
351
|
+
pattern << ":operation"
|
|
352
|
+
pattern << ":error_class"
|
|
353
|
+
|
|
354
|
+
LogFormatter.new(pattern.join(' ') + "\n")
|
|
355
|
+
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# A debug format that dumps most of the http request and response
|
|
359
|
+
# data.
|
|
360
|
+
#
|
|
361
|
+
# @example A truncated sample of the debug format.
|
|
362
|
+
#
|
|
363
|
+
# +-------------------------------------------------------------------------------
|
|
364
|
+
# | AWS us-east-1 SimpleEmailService list_verified_email_addresses 0.429189 0 retries
|
|
365
|
+
# +-------------------------------------------------------------------------------
|
|
366
|
+
# | REQUEST
|
|
367
|
+
# +-------------------------------------------------------------------------------
|
|
368
|
+
# | METHOD: POST
|
|
369
|
+
# | URL: https://email.us-east-1.amazonaws.com::443:/
|
|
370
|
+
# | HEADERS: {"content-type"=>"application/x-www-form-urlencoded" ...
|
|
371
|
+
# | BODY: Action=ListVerifiedEmailAddresses&Timestamp= ...
|
|
372
|
+
# +-------------------------------------------------------------------------------
|
|
373
|
+
# | RESPONSE
|
|
374
|
+
# +-------------------------------------------------------------------------------
|
|
375
|
+
# | STATUS: 200
|
|
376
|
+
# | HEADERS: {"x-amzn-requestid"=>["..."], ...
|
|
377
|
+
# | BODY: <ListVerifiedEmailAddressesResponse ...
|
|
378
|
+
#
|
|
379
|
+
# @return [LogFormatter]
|
|
380
|
+
#
|
|
381
|
+
def debug
|
|
382
|
+
|
|
383
|
+
sig_pattern = []
|
|
384
|
+
sig_pattern << ':region'
|
|
385
|
+
sig_pattern << ':service'
|
|
386
|
+
sig_pattern << ':operation'
|
|
387
|
+
sig_pattern << ':duration'
|
|
388
|
+
sig_pattern << ':retry_count retries'
|
|
389
|
+
|
|
390
|
+
uri_pattern = []
|
|
391
|
+
uri_pattern << ':http_request_protocol'
|
|
392
|
+
uri_pattern << '://'
|
|
393
|
+
uri_pattern << ':http_request_host'
|
|
394
|
+
uri_pattern << '::'
|
|
395
|
+
uri_pattern << ':http_request_port'
|
|
396
|
+
uri_pattern << ':'
|
|
397
|
+
uri_pattern << ':http_request_uri'
|
|
398
|
+
|
|
399
|
+
line = "+" + '-' * 79
|
|
400
|
+
|
|
401
|
+
pattern = []
|
|
402
|
+
pattern << line
|
|
403
|
+
pattern << "| AWS #{sig_pattern.join(' ')}"
|
|
404
|
+
pattern << line
|
|
405
|
+
pattern << "| REQUEST"
|
|
406
|
+
pattern << line
|
|
407
|
+
pattern << "| METHOD: :http_request_method"
|
|
408
|
+
pattern << "| URL: #{uri_pattern.join}"
|
|
409
|
+
pattern << "| HEADERS: :http_request_headers"
|
|
410
|
+
pattern << "| BODY: :http_request_body"
|
|
411
|
+
pattern << line
|
|
412
|
+
pattern << "| RESPONSE"
|
|
413
|
+
pattern << line
|
|
414
|
+
pattern << "| STATUS: :http_response_status"
|
|
415
|
+
pattern << "| HEADERS: :http_response_headers"
|
|
416
|
+
pattern << "| BODY: :http_response_body"
|
|
417
|
+
|
|
418
|
+
LogFormatter.new(pattern.join("\n") + "\n")
|
|
419
|
+
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
# The default log format with ANSI colors.
|
|
423
|
+
#
|
|
424
|
+
# @example A sample of the colored format (sans the ansi colors).
|
|
425
|
+
#
|
|
426
|
+
# [AWS SimpleEmailService 200 0.580066 0 retries] list_verified_email_addresses()
|
|
427
|
+
#
|
|
428
|
+
# @return [LogFormatter]
|
|
429
|
+
#
|
|
430
|
+
def colored
|
|
431
|
+
|
|
432
|
+
bold = "\x1b[1m"
|
|
433
|
+
color = "\x1b[34m"
|
|
434
|
+
reset = "\x1b[0m"
|
|
435
|
+
|
|
436
|
+
pattern = []
|
|
437
|
+
pattern << "#{bold}#{color}[AWS"
|
|
438
|
+
pattern << ":service"
|
|
439
|
+
pattern << ":http_response_status"
|
|
440
|
+
pattern << ":duration"
|
|
441
|
+
pattern << ":retry_count retries]#{reset}#{bold}"
|
|
442
|
+
pattern << ":operation(:options)"
|
|
443
|
+
pattern << ":error_class"
|
|
444
|
+
pattern << ":error_message#{reset}"
|
|
445
|
+
|
|
446
|
+
LogFormatter.new(pattern.join(' ') + "\n")
|
|
447
|
+
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
end
|