<commit_before>module Aws
  module S3

    # Allows you to create presigned URLs for S3 operations.
    #
    # Example Use:
    #
    #      signer = Aws::S3::Presigner.new
    #      url = signer.presigned_url(:get_object, bucket: "bucket", key: "key")
    class Presigner

      # @option options [Client] :client Optionally provide an existing
      #   S3 client
      def initialize(options = {})
        @client = options[:client] || Aws::S3::Client.new
      end

      # @param [Symbol] method Symbolized method name of the operation you want
      #   to presign.
      # @option params [Integer] :expires_in (86400) The number of seconds
      #   before the presigned URL expires. Must be less than 604800 seconds
      #   (one week).
      def presigned_url(method, params = {})
        request = @client.build_request(method, params)
        request.handle(PresignHandler, step: :sign, priority: 99)
        expires_in = params.delete(:expires_in) || 86400
        validate_expires_in_header(expires_in)
        request.context[:presigned_expires_in] = expires_in
        request.send_request.data
      end

      private
      def validate_expires_in_header(expires_in)
        if(expires_in > 604800)
          raise ArgumentError.new(
            "expires_in value of #{expires_in} exceeds one-week maximum"
          )
        end<commit_msg>Expanded documentation on the S3 pre-signed url generator.<commit_after>module Aws
  module S3

    # Allows you to create presigned URLs for S3 operations.
    #
    # Example Use:
    #
    #      signer = Aws::S3::Presigner.new
    #      url = signer.presigned_url(:get_object, bucket: "bucket", key: "key")
    #
    class Presigner

      # @api private
      ONE_WEEK = 60 * 60 * 24 * 7

      # @api private
      FIFTEEN_MINUTES = 60 * 15

      # @option options [Client] :client Optionally provide an existing
      #   S3 client
      def initialize(options = {})
        @client = options[:client] || Aws::S3::Client.new
      end

      # @param [Symbol] method Symbolized method name of the operation you want
      #   to presign.
      #
      # @option params [Integer] :expires_in (900) The number of seconds
      #   before the presigned URL expires. Defaults to 15 minutes.
      #
      # @raise [ArgumentError] Raises an ArgumentError if `:expires_in`
      #   exceeds one week.
      #
      def presigned_url(method, params = {})
        request = @client.build_request(method, params)
        request.handle(PresignHandler, step: :sign, priority: 99)
        expires_in = params.delete(:expires_in) || FIFTEEN_MINUTES
        validate_expires_in_header(expires_in)
        request.context[:presigned_expires_in] = expires_in
        request.send_request.data
      end

      private
      def validate_expires_in_header(expires_in)
        if(expires_in > ONE_WEEK)
          raise ArgumentError.new(
            "expires_in value of #{expires_in} exceeds one-week maximum"
          )
        end
{'fraction_non_alphanumeric': 0.08902275769745649, 'fraction_numerical': 0.017737617135207495, 'mean_word_length': 2.451501154734411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3945105', 'n_tokens_mistral': 953, 'n_tokens_neox': 896, 'n_words': 244}