Notification Template¶
Description¶
This resource is used for managing notification templates in Tower. Note most resource fields, like username
and host are effective based on notification_type. For example, providing service_key when creating
an email notification template is not effective as it will be discarded.
Fields Table¶
| name | type | help_text | read_only | unique | filterable | required |
|---|---|---|---|---|---|---|
| name | String | The name field. | False | True | True | True |
| description | String | The description field. | False | False | True | False |
| organization | Resource organization | The organization field. | False | False | True | False |
| notification_type | Choices: email,slack,twilio,pagerduty,hipchat,webhook,irc | The notification_type field. | False | False | True | True |
| notification_configuration | file | The notification configuration field. Note providing this field would disable all notification-configuration-related fields. | False | False | True | False |
| username | String | [email]The username. | False | False | True | False |
| sender | String | [email]The sender. | False | False | True | False |
| recipients | String | [email]The recipients. | False | False | True | False |
| use_tls | BOOL | [email]The tls trigger. | False | False | True | False |
| host | String | [email]The host. | False | False | True | False |
| use_ssl | BOOL | [email/irc]The ssl trigger. | False | False | True | False |
| password | String | [email/irc]The password. | False | False | True | False |
| port | INT | [email/irc]The email port. | False | False | True | False |
| channels | String | [slack]The channel. | False | False | True | False |
| token | String | [slack/pagerduty/hipchat]The token. | False | False | True | False |
| account_token | String | [twilio]The account token. | False | False | True | False |
| from_number | String | [twilio]The source phone number. | False | False | True | False |
| to_numbers | String | [twilio]The destination SMS numbers. | False | False | True | False |
| account_sid | String | [twilioThe account sid. | False | False | True | False |
| subdomain | String | [pagerduty]The subdomain. | False | False | True | False |
| service_key | String | [pagerduty]The API service/integration key. | False | False | True | False |
| client_name | String | [pagerduty]The client identifier. | False | False | True | False |
| message_from | String | [hipchat]The label to be shown with notification. | False | False | True | False |
| api_url | String | [hipchat]The api url. | False | False | True | False |
| color | Choices: yellow,green,red,purple,gray,random | [hipchat]The notification color. | False | False | True | False |
| rooms | String | [hipchat]Rooms to send notification to. Use multiple flags to send to multiple rooms, ex –rooms=A –rooms=B | False | False | True | False |
| notify | String | [hipchat]The notify channel trigger. | False | False | True | False |
| url | String | [webhook]The target URL. | False | False | True | False |
| headers | file | [webhook]The http headers. | False | False | True | False |
| server | String | [irc]Server address. | False | False | True | False |
| nickname | String | [irc]The irc nick. | False | False | True | False |
| target | String | [irc]The distination channels or users. | False | False | True | False |
API Specification¶
-
class
tower_cli.resources.notification_template.Resource[source]¶ A resource for notification templates.
-
copy(pk=None, **kwargs)[source]¶ Copy an object.
Parameters: - pk (int) – Primary key of the resource object to be copied
- **kwargs – Keyword arguments of fields whose given value will override the original value.
Returns: loaded JSON of the copied new resource object.
Return type: dict
-
create(fail_on_found=False, force_on_exists=False, **kwargs)[source]¶ Create an object.
Parameters: - fail_on_found (bool) – Flag that if set, the operation fails if an object matching the unique criteria already exists.
- force_on_exists (bool) – Flag that if set, then if a match is found on unique fields, other fields will be updated to the provided values.; If unset, a match causes the request to be a no-op.
- **kwargs – Keyword arguements which, all together, will be used as POST body to create the resource object.
Returns: A dictionary combining the JSON output of the created resource, as well as two extra fields: “changed”, a flag indicating if the resource is created successfully; “id”, an integer which is the primary key of the created object.
Return type: dict
-
delete(pk=None, fail_on_missing=False, **kwargs)[source]¶ Remove the given object.
Parameters: - pk (int) – Primary key of the resource to be deleted.
- fail_on_missing (bool) – Flag that if set, the object’s not being found is considered a failure; otherwise, a success with no change is reported.
- **kwargs – Keyword arguments used to look up resource object to delete if
pkis not provided.
Returns: dictionary of only one field “changed”, which is a flag indicating whether the specified resource is successfully deleted.
Return type: dict
-
get(pk=None, **kwargs)[source]¶ Retrieve one and exactly one object.
Parameters: - pk (int) – Primary key of the resource to be read. Tower CLI will only attempt to read that object
if
pkis provided (notNone). - **kwargs – Keyword arguments used to look up resource object to retrieve if
pkis not provided.
Returns: loaded JSON of the retrieved resource object.
Return type: dict
- pk (int) – Primary key of the resource to be read. Tower CLI will only attempt to read that object
if
-
list(all_pages=False, **kwargs)[source]¶ Retrieve a list of objects.
Parameters: - all_pages (bool) – Flag that if set, collect all pages of content from the API when returning results.
- page (int) – The page to show. Ignored if all_pages is set.
- query (list) – Contains 2-tuples used as query parameters to filter resulting resource objects.
- **kwargs – Keyword arguments list of available fields used for searching resource objects.
Returns: A JSON object containing details of all resource objects returned by Tower backend.
Return type: dict
-
modify(pk=None, create_on_missing=False, **kwargs)[source]¶ Modify an already existing object.
Parameters: - pk (int) – Primary key of the resource to be modified.
- create_on_missing (bool) – Flag that if set, a new object is created if
pkis not set and objects matching the appropriate unique criteria is not found. - **kwargs – Keyword arguements which, all together, will be used as PATCH body to modify the
resource object. if
pkis not set, key-value pairs of**kwargswhich are also in resource’s identity will be used to lookup existing reosource.
Returns: A dictionary combining the JSON output of the modified resource, as well as two extra fields: “changed”, a flag indicating if the resource is successfully updated; “id”, an integer which is the primary key of the updated object.
Return type: dict
-