<commit_before>module Fog
  module DNS
    class DNSimple
      class Real

        # Create a new host in the specified zone
        #
        # ==== Parameters
        # * domain<~String>
        # * name<~String>
        # * type<~String>
        # * content<~String>
        # * options<~Hash> - optional
        #   * priority<~Integer>
        #   * ttl<~Integer>
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>
        #     * name<~String>
        #     * ttl<~Integer>
        #     * created_at<~String>
        #     * special_type<~String>
        #     * updated_at<~String>
        #     * domain_id<~Integer>
        #     * id<~Integer>
        #     * content<~String>
        #     * record_type<~String>
        #     * prio<~Integer>
        def create_record(domain, name, type, content, options = {})

          body = {
            "record" => {
              "name" => name,
              "record_type" => type,
              "content" => content } }

          body["record"].merge!(options)

          request( :body     => Fog::JSON.encode(body),
                   :expects  => 201,
                   :method   => 'POST',
                   :path     => "/domains/#{domain}/records" )
        end

      end

      class Mock

        def create_record(domain, name, type, content, options = {})
          response = Excon::Response.new
          response.status = 201
          domain_id = self.data[:domains].detect { |d| d["domain"]["name"] == domain }["domain"]["id"]
          body = {
            "record" => {
              "name" => name,
              "record_type" => type,
              "content" => content,
              "created_at" => Time.now.iso8601,
              "updated_at" => Time.now.iso8601,
              "id" => Fog::Mock.random_numbers(1).to_i,
              "domain_id" => domain_id
            }.merge(options)
          }

          self.data[:records][domain] ||= []
          self.data[:records][domain] << body

          response.body = body
          response
        end

      end

    end
  end
end<commit_msg>Fix mock for creation by id<commit_after>module Fog
  module DNS
    class DNSimple
      class Real

        # Create a new host in the specified zone
        #
        # ==== Parameters
        # * domain<~String>
        # * name<~String>
        # * type<~String>
        # * content<~String>
        # * options<~Hash> - optional
        #   * priority<~Integer>
        #   * ttl<~Integer>
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>
        #     * name<~String>
        #     * ttl<~Integer>
        #     * created_at<~String>
        #     * special_type<~String>
        #     * updated_at<~String>
        #     * domain_id<~Integer>
        #     * id<~Integer>
        #     * content<~String>
        #     * record_type<~String>
        #     * prio<~Integer>
        def create_record(domain, name, type, content, options = {})

          body = {
            "record" => {
              "name" => name,
              "record_type" => type,
              "content" => content } }

          body["record"].merge!(options)

          request( :body     => Fog::JSON.encode(body),
                   :expects  => 201,
                   :method   => 'POST',
                   :path     => "/domains/#{domain}/records" )
        end

      end

      class Mock

        def create_record(domain, name, type, content, options = {})
          response = Excon::Response.new
          response.status = 201
          body = {
            "record" => {
              "name" => name,
              "record_type" => type,
              "content" => content,
              "created_at" => Time.now.iso8601,
              "updated_at" => Time.now.iso8601,
              "id" => Fog::Mock.random_numbers(1).to_i,
              "domain_id" => domain
            }.merge(options)
          }

          self.data[:records][domain] ||= []
          self.data[:records][domain] << body

          response.body = body
          response
        end

      end

    end
  end
end
{'fraction_non_alphanumeric': 0.14092664092664092, 'fraction_numerical': 0.00723938223938224, 'mean_word_length': 1.3591348890153672, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 73, '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': '6638336', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1192, 'n_words': 218}