get_buckets

in elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb [57:93]


        def get_buckets(arguments = {})
          request_opts = { endpoint: arguments[:endpoint] || 'ml.get_buckets' }

          defined_params = [:job_id, :timestamp].each_with_object({}) do |variable, set_variables|
            set_variables[variable] = arguments[variable] if arguments.key?(variable)
          end
          request_opts[:defined_params] = defined_params unless defined_params.empty?

          raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id]

          arguments = arguments.clone
          headers = arguments.delete(:headers) || {}

          body = arguments.delete(:body)

          _job_id = arguments.delete(:job_id)

          _timestamp = arguments.delete(:timestamp)

          method = if body
                     Elasticsearch::API::HTTP_POST
                   else
                     Elasticsearch::API::HTTP_GET
                   end

          path   = if _job_id && _timestamp
                     "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/buckets/#{Utils.listify(_timestamp)}"
                   else
                     "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/buckets"
                   end
          params = Utils.process_params(arguments)

          Elasticsearch::API::Response.new(
            perform_request(method, path, params, body, headers, request_opts)
          )
        end