Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

Conversation

@samcarpentier
Copy link

The Python API requires the targets field to be passed when creating an IRC notification template.

Using the target field, like the doc currently proposes, causes an error to be thrown.

{
  "detail": "NotificationTemplate has no field named 'target'"
}

Using the targets field solved the issue and creates the notification template successfully.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 64.376% when pulling 63e4a57 on samcarpentier:api_doc_rename_targets_field into fcce251 on ansible:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 64.376% when pulling 63e4a57 on samcarpentier:api_doc_rename_targets_field into fcce251 on ansible:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 64.376% when pulling 63e4a57 on samcarpentier:api_doc_rename_targets_field into fcce251 on ansible:master.

@coveralls
Copy link

coveralls commented Jan 24, 2019

Coverage Status

Coverage remained the same at 64.376% when pulling 4d29a59 on samcarpentier:api_doc_rename_targets_field into fcce251 on ansible:master.

@AlanCoding
Copy link
Member

Does this need to be changed here as well?

target = models.Field(required=False, display=False,

@samcarpentier
Copy link
Author

samcarpentier commented Jan 24, 2019

@AlanCoding It appears so. There seems to be a discrepancy in the file you referenced. Both target and targets are used.

@AlanCoding
Copy link
Member

I still can't quite use it

tower-cli notification_template create --name=foo --notification-type=irc --targets=foo,bar --server=foo.invalid --port=2830 --password=password --nickname=alan --organization=alan -v
*** DETAILS: The organization field is given as a name; looking it up. ********
*** DETAILS: Getting the record. **********************************************
GET http://localhost:8013/api/v2/organizations/
Params: [('name', 'alan')]

*** DETAILS: Checking for an existing record. *********************************
GET http://localhost:8013/api/v2/notification_templates/
Params: [('name', u'foo')]

*** DETAILS: Writing the record. **********************************************
POST http://localhost:8013/api/v2/notification_templates/
Data: {'notification_type': 'irc', 'notification_configuration': {'server': u'foo.invalid', 'port': 2830, 'use_ssl': False, 'password': u'password', 'nickname': u'alan', 'targets': u'foo,bar'}, 'name': u'foo', 'organization': 1250}

Error: The Tower server claims it was sent a bad request.

POST http://localhost:8013/api/v2/notification_templates/
Params: None
Data: {"notification_type": "irc", "notification_configuration": {"server": "foo.invalid", "port": 2830, "use_ssl": false, "password": "password", "nickname": "alan", "targets": "foo,bar"}, "name": "foo", "organization": 1250}

Response: {"__all__":["Configuration field 'targets' incorrect type, expected list."]}

it looks like maybe it just needs to be transformed into a list, you could accept a comma separated string, and just .split(',')

@samcarpentier
Copy link
Author

Sounds good. I will take a look at this a bit later.

Thanks for your feedback.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants