lib/elasticsearch/api/actions/machine_learning/get_calendars.rb in elasticsearch-api-8.12.2 vs lib/elasticsearch/api/actions/machine_learning/get_calendars.rb in elasticsearch-api-8.13.0

- old
+ new

@@ -28,18 +28,17 @@ # @option arguments [Integer] :from skips a number of calendars # @option arguments [Integer] :size specifies a max number of calendars to get # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body The from and size parameters optionally sent in the body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.12/ml-get-calendar.html + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.13/ml-get-calendar.html # def get_calendars(arguments = {}) - request_opts = { endpoint: arguments[:endpoint] || "ml.get_calendars" } + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_calendars' } - defined_params = [:calendar_id].inject({}) do |set_variables, variable| + defined_params = [:calendar_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) - set_variables end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -52,14 +51,14 @@ Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end - path = if _calendar_id - "_ml/calendars/#{Utils.__listify(_calendar_id)}" - else - "_ml/calendars" - end + path = if _calendar_id + "_ml/calendars/#{Utils.__listify(_calendar_id)}" + else + '_ml/calendars' + end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) )