删除对“计划维护"的订阅;电子邮件通知 [英] Removing subscription to "Planned Maintenance" email notifications

查看:73
本文介绍了删除对“计划维护"的订阅;电子邮件通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用REST API,如何关闭计划维护"电子邮件通知的设置? 我有数百个用户个人资料,我需要关闭此设置.

Using the REST API, How do I turn off the setting for email notification of "Planned Maintenance"? I have hundreds of user profiles I need to turn this setting off on.

感谢您的任何帮助!

推荐答案

要关闭"订阅-计划维护,您必须按用户进行用户操作,这与客户门户网站相同,因为在rest api中您不能执行此操作全部用户, 但是您可以尝试使用自己的代码通过编程语言关闭"所有用户订阅.

To "turn off" the Subscriptions - Planned Maintenance, you have to do user by user, the same that the customer portal because in rest api you cannot do for all users, but you can try to ¨turn off¨ all the users subscriptions using programing language doing your own code.

在python中有一个示例代码可以关闭"所有用户订阅-计划维护

Here there is a example code in python to ¨turn off¨ all the users Subscriptions - Planned Maintenance

"""
UpdateNotificationSubscriber

Update the active status for a notification that the user is subscribed to. A notification along with an active flag
can be supplied to update the active status for a particular notification subscription.

Important manual pages:
https://softlayer.github.io/reference/services/SoftLayer_User_Customer/
https://softlayer.github.io/reference/services/SoftLayer_User_Customer/updateNotificationSubscriber/

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer
import json

USERNAME = 'set me'
API_KEY = 'set me'

notificationKeyName = "PLANNED_MAINTENANCE"
active = 0

client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
accountService = client['SoftLayer_Account']
customerService = client['SoftLayer_User_Customer']

try:
    users = accountService.getUsers()
    for user in users:
        id = user['id']
        result = customerService.updateNotificationSubscriber(notificationKeyName, active, id=id)
        print(json.dumps(result, sort_keys=True, indent=2, separators=(',', ': ')))

except SoftLayer.SoftLayerAPIError as e:
    print("Unable to change the subscription notification. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))

要打开",只需将"active"属性更改为1.

To ¨turn on¨ you just need to change the attribute ¨active¨ to 1.

或者您可以使用以下rest api示例逐个关闭用户":

Or you can ¨turn off¨ user by user using the followings rest api examples:

方法:开机自检

https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[userId]/updateSubscriberDeliveryMethod

身体:杰森

{
  "parameters":[
    "PLANNED_MAINTENANCE",
    [
                "EMAIL"
                ],
    0
  ]
}

参考:

https://softlayer.github.io/reference/services/SoftLayer_User_Customer/updateSubscriberDeliveryMethod/

或者您可以使用其他rest api:

Or you can use this other rest api:

方法:发布

https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[userId]/updateNotificationSubscriber

身体:杰森

{
  "parameters":[

    "PLANNED_MAINTENANCE",
                0
  ]
}

参考:

https://softlayer.github.io/reference/services/SoftLayer_User_Customer/updateNotificationSubscriber/

这篇关于删除对“计划维护"的订阅;电子邮件通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆