Forum Discussion
7 years ago
Hi Shawn,
Yes, you can use our REST API to programmatically change the "Send Collector Notifications" to One Time. We have documentation on how to make the PUT request here, but you can use a PATCH request so that you're only modifying the resendIval field. Here's the code I used to execute this:
#Request Info
httpVerb ='PATCH'
resourcePath = '/setting/collectors/8'
queryParams = '?patchFields=resendIval'
data = '{"resendIval":0}'
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath
#Construct signature
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}
#Make request
response = requests.patch(url, data=data, headers=headers)
#Print status and body of response
print 'Response Status:',response.status_code
print 'Response Body:',response.content
With this, you'll loop through your collector ID's (recommend using the GET all collectors request, followed by the PATCH requests).
Hope this helps!
Jake
Related Content
- 25 days ago