Billy H
12/18/2024, 7:01 PMFleet checks whether to trigger policy automations once per day by default.
Is there any way to get this to trigger manually? Or at least not every 24 hours for the sake of testing?Billy H
12/18/2024, 7:09 PMKathy Satterlee
12/18/2024, 7:15 PMfleetctl trigger --name calendar
Billy H
12/18/2024, 7:17 PMBilly H
12/18/2024, 8:03 PMBilly H
12/18/2024, 8:04 PMimport json
import urllib.request
import urllib.error
def reset_automations(api_key, team_ids, policy_ids):
fleet_api_url = "<https://fleet.website.com/api/v1/fleet/automations/reset>"
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = json.dumps({
"team_ids": team_ids,
"policy_ids": policy_ids
}).encode('utf-8')
req = urllib.request.Request(fleet_api_url, data=data, headers=headers, method='POST')
try:
with urllib.request.urlopen(req) as response:
response_body = response.read().decode('utf-8')
print(f"Response Status: {response.status}")
print(f"Response Body: {response_body}")
return response.status, response_body
except urllib.error.HTTPError as e:
error_body = e.read().decode('utf-8')
print(f"HTTP Error: {e.code} - {e.reason}")
print(f"Error Body: {error_body}")
return e.code, None
except urllib.error.URLError as e:
print(f"URL Error: {e.reason}")
return None, None
policy_ids = [2103]
team_ids = [8]
fleet_api_key = "apikeygoeshere"
reset_automations(fleet_api_key, team_ids, policy_ids)
Output:
Response Status: 200
Response Body: {}
fleetctl trigger --name calendar
Output:
[+] Sent request to trigger calendar schedule
Kathy Satterlee
12/18/2024, 11:23 PMKathy Satterlee
12/18/2024, 11:23 PMfleetctl trigger --name automations
Billy H
12/19/2024, 5:35 PMBilly H
12/19/2024, 6:16 PMBilly H
12/20/2024, 2:48 PM