【问题标题】:How to dismiss a Lametric Nofitication using powershell如何使用 powershell 关闭 Lametric 通知
【发布时间】:2018-06-01 12:21:55
【问题描述】:

这是this comment 的后续问题,关于关闭 Lametric 时钟上的通知。我们使用 Lametric 时钟在构建失败时显示通知。到目前为止,需要有人起床并物理按下 Lametric 时钟上的按钮才能再次关闭通知。如何使用 powershell 解决这个问题?

【问题讨论】:

    标签: api powershell webrequest lametric


    【解决方案1】:

    为了解决这个问题,我们首先发出 GET 请求以获取 Lametric 时钟队列中的通知 ID 列表:

    $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 字符串的属性内容的对象。这可以转换为对象列表:

    $notification = $notifications.Content | ConvertFrom-Json
    

    从该列表中获取第一个元素,我们可以生成要调用的 URI

    $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 上的通知有很大帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-21
    • 1970-01-01
    • 2010-09-05
    • 1970-01-01
    • 2010-09-07
    • 2016-10-22
    相关资源
    最近更新 更多