Method: JSS::Policy#flush_logs

Defined in:
lib/jss/api_object/policy.rb

#flush_logs(older_than: 0, period: :days) ⇒ void

This method returns an undefined value.

Flush all policy logs for this policy older than some number of days, weeks, months or years.

With no parameters, flushes all logs

NOTE: Currently the API doesn’t have a way to flush only failed policies.

Parameters:

  • older_than (Integer) (defaults to: 0)

    0, 1, 2, 3, or 6

  • period (Symbol) (defaults to: :days)

    :days, :weeks, :months, or :years

Raises:



1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
# File 'lib/jss/api_object/policy.rb', line 1357

def flush_logs(older_than: 0, period: :days)
  raise JSS::NoSuchItemError, "Policy doesn't exist in the JSS. Use #create first." unless @in_jss

  unless LOG_FLUSH_INTERVAL_INTEGERS.key?(older_than)
    raise JSS::InvalidDataError, "older_than must be one of these integers: #{LOG_FLUSH_INTERVAL_INTEGERS.keys.join ', '}"
  end

  unless LOG_FLUSH_INTERVAL_PERIODS.key?(period)
    raise JSS::InvalidDataError, "period must be one of these symbols: :#{LOG_FLUSH_INTERVAL_PERIODS.keys.join ', :'}"
  end

  interval = "#{LOG_FLUSH_INTERVAL_INTEGERS[older_than]}+#{LOG_FLUSH_INTERVAL_PERIODS[period]}"

  @api.delete_rsrc "#{LOG_FLUSH_RSRC}/policy/id/#{@id}/interval/#{interval}"
end