-->

Subscribe users to notifications via Soft Layer AP

2019-09-12 22:23发布

问题:

I have a set of users that I want to subscribe to the same notifications available via the Portal. However, as I'm automating the creation/management of these users, I also want to automate the subscription to these notifications.

I've reviewed the API documentation, searched for any examples/tutorials, and I'm still not having any luck figuring out how to accomplish this.

Any clues, or examples would be awesome.

回答1:

To add the permission, execute the following request:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[user_id]/addBulkPortalPermission

Method: POST

Json (payload):

{
  "parameters": [
    [
      {
        "keyName": "NTF_SUBSCRIBER_MANAGE"
      }
    ]
  ]
}

To get the user permissions, execute:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[ User_Customer_ID]/getPermissions

References: http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer

EDIT:

Follow these steps to subscribe notifications to a customer user:

Example: Add “PLANNED_MAINTENANCE” notification subscription.

1. Create a notification subscription record for the user using: SoftLayer_User_Customer::addNotificationSubscriber

URL:

https://[username:[apikey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[user_customer_id]/addNotificationSubscriber

Method: POST

Json (payload):

{
  "parameters": [
    " PLANNED_MAINTENANCE"
  ]
}

Reference:

http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/addNotificationSubscriber

2. Create delivery methods for a notification that the user is subscribed to (SoftLayer_User_Customer::createSubscriberDeliveryMethods).

URL:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[user_customer_id]/createSubscriberDeliveryMethods

Method: POST

Json (payload):

{
  "parameters": [
    "PLANNED_MAINTENANCE",
    [
       "EMAIL"

    ]
  ]
}

To get information about “notificationKeyName” and “deliveryMethodKeyNames”, execute:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Account/getActiveNotificationSubscribers?objectMask=mask[id, notification, active,deliveryMethods[notificationDeliveryMethod[active,keyName],notificationSubscriber]]

Reference:

http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/createSubscriberDeliveryMethods