Creating Ansible modules for pagerduty

rest-api
ansible
questions

(Matt Jones) #1

I am working with creating Ansible modules for pagerduty, one module per api endpoint. I have sorted out most of the issues I have seen and the module is currently usable but a little rough.

One issue I still can’t figure out is when adding a push_notification_contact_method I am getting a 400 error

{
  "error": {
    "errors": [
      "Device type can't be blank",
      "Device type is not included in the list"
    ],
    "code": 2001,
    "message": "Invalid Input Provided"
  }
}

I have tried this both with the module I wrote and also in the sandbox web api with the following data.

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/vnd.pagerduty+json;version=2' --
header 'Authorization: Token token=SUPER_SECRET' -d '{
  "contact_method": {
    "id": "string",
    "summary": "string",
    "type": "push_notification_contact_method",
    "self": "string",
    "html_url": "string",
    "label": "work",
    "address": "aaabbbccc"
  }
}' 'https://api.pagerduty.com/users/POCXUJI/contact_methods'

I am not sure where to go from here, it seems like an internal error. All the other contact_methods work just fine.

Thanks!


(Matt Jones) #2

Support has just informed me that the api does not support push notifications, even though it is currently listed as a valid value for that field :frowning:


(David Yang) #3

Hey Matt!

Sorry about that. It was oversight on our part to include push notifications as a possible contact method type in the documentation. We’ve filed a ticket to fix that as soon as we can.

We don’t allow push notifications to be created via the API since we require them to be created through our native mobile iOS and Android applications. This allows us to register the device with the Apple Push Notification Service or Google Cloud Messaging and retrieve a device token from those services. That device token allows us to deliver those push notifications.

Let me know if you have any questions!

Cheers,
David


(Matt Jones) #4

No worries, I figured this was the case after a little thinking on the problem. As long as the docs get cleared up I see no issue. Other than that I haven’t seen anything else funky in the api.