问题描述
这是关于关闭Lametric时钟上的通知.每当构建失败时,我们都使用Lametric时钟显示通知.到目前为止,有人需要起床并实际按下Lametric时钟上的按钮以再次关闭该通知.如何使用Powershell解决此问题?
This is a followup question to this comment about dismissing a notification on the Lametric clock. We use the Lametric clock to display notifications whenever a build fails. So far, someone would need to get up and physically press the button on the Lametric clock to dismiss the notification again. How can this be solved using powershell?
推荐答案
为解决此问题,我们首先发出GET请求,以获取Lametric时钟队列中的通知ID列表:
To solve this, we first made a GET request to get a list of notifications IDs in the queue of the Lametric clock:
$request = @{uri = 'http://192.168.37.75:8080/api/v2';
Method = 'GET';
Headers = @{Authorization = 'Basic <base64-encoded-authentication-string>'; "Content-Type" = 'application/json' }
}
$notifications = invoke-webrequest -UseBasicParsing @request
$request = @{uri = 'http://192.168.37.75:8080/api/v2/device/notifications';
Method = 'GET';
Headers = @{Authorization = 'Basic <base64-encoded-authentication-string>'; "Content-Type" = 'application/json' }
}
$notifications = invoke-webrequest -UseBasicParsing @request
这将返回一个对象,该对象的属性内容包含JSON字符串.可以将其转换为对象列表:
This will return an object with a property content containing a JSON string. This can be converted to a list of objects:
$notification = $notifications.Content | ConvertFrom-Json
从该列表中获取第一个元素,我们可以生成要调用的URI
Taking the first element from that list we can generate the URI to call
$notificationUri = 'http://192.168.37.75:8080/api/v2/device/notifications/' + $notification[0].ID;
并使用它来取消通知
$request = @{uri = $notificationUri
Method = 'DELETE';
Headers = @{Authorization = 'Basic <base64-encoded-authentication-string>'; "Content-Type" = 'application/json' }
}
invoke-webrequest -UseBasicParsing @request
这篇关于如何使用Powershell消除Lametric Nofitication的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!