Skip to content

Latest commit

 

History

History
205 lines (162 loc) · 5.82 KB

automation.rst

File metadata and controls

205 lines (162 loc) · 5.82 KB

Automation

With the automation pipelines endpoint you can easily manage automations for an Airship project. Pipelines define the behavior to be triggered on user-defined events. For more information, see the documentation on Automation

Creating an Automation

Create an automation for a project. For more information, see: https://docs.airship.com/api/ua/#operation/api/pipelines/post Automations are defined by one or more Pipeline objects

import urbanairship as ua
airship = ua.Airship("app_key", "master_secret")
automation = ua.Automation(airship)
pipeline = ua.Pipeline(
    airship,
    enabled=True,
    name="Automated Pipeline",
    outcome={
       "immediate_trigger": {
          "tag_added": "interests::kitchen_sinks"
       },
       "timing": {
          "delay": { "seconds": 259200 }
       },
       "cancellation_trigger": {
          "custom_event": {
             "name": "COMPLETED_CHECKOUT"
          }
       },
       "outcome": {
          "push": {
             "audience": "triggered",
             "device_types": ["ios", "android"],
             "notification": {
                "alert": "Like sinks? You'll love this deal!"
             }
          }
       }
    }
)

automation.create(pipeline.payload)

urbanairship.automation.core.Automation

Validating an Automation

Validate an automation payload prior to making requests to create update. For more information, see: https://docs.airship.com/api/ua/#operation/api/pipelines/validate/post

import urbanairship as ua
airship = ua.Airship("app_key", "master_secret")
automation = ua.Automation(airship)
pipeline = ua.Pipeline(
    airship,
    enabled=True,
    name="Automated Pipeline",
    outcome={
       "immediate_trigger": {
          "tag_added": "interests::kitchen_sinks"
       },
       "timing": {
          "delay": { "seconds": 259200 }
       },
       "cancellation_trigger": {
          "custom_event": {
             "name": "COMPLETED_CHECKOUT"
          }
       },
       "outcome": {
          "push": {
             "audience": "triggered",
             "device_types": ["ios", "android"],
             "notification": {
                "alert": "Like sinks? You'll love this deal!"
             }
          }
       }
    }
)

automation.validate(pipeline.payload)

urbanairship.automation.core.Automation

Note

Validating an Automation acts as a dry run and will not attempt to modify any information on this application.

Updating an Automation

Update an automation with a full automation object. For more information, see: https://docs.airship.com/api/ua/#operation/api/pipelines/pipeline_id/put

import urbanairship as ua
airship = ua.Airship("app_key", "master_secret")
automation = ua.Automation(airship)
pipeline = ua.Pipeline(
    airship,
    enabled=True,
    name="Updated Pipeline",
    outcome={
       "immediate_trigger": {
          "tag_added": "interests::bathroom_sinks"
       },
       "timing": {
          "delay": { "seconds": 259200 }
       },
       "cancellation_trigger": {
          "custom_event": {
             "name": "COMPLETED_CHECKOUT"
          }
       },
       "outcome": {
          "push": {
             "audience": "triggered",
             "device_types": ["ios", "android"],
             "notification": {
                "alert": "Bathroom sink issues? You'll love this deal!"
             }
          }
       }
    }
)

automation.update("21bc19f7-dfcc-4a80-9d8b-6bfd350fe87b", pipeline.payload)

urbanairship.automation.core.Automation

Lookup an Automation

Lookup an existing automation for a project. For more information, see: https://docs.airship.com/api/ua/#operation/api/pipelines/pipeline_id/get

import urbanairship as ua
airship = ua.Airship("app_key", "master_secret")
automation = ua.Automation(airship)

automation.lookup("21bc19f7-dfcc-4a80-9d8b-6bfd350fe87b")

urbanairship.automation.core.Automation

Deleting an Automation

Delete an existing automation for a project. For more information, see: https://docs.airship.com/api/ua/#operation/api/pipelines/pipeline_id/delete

import urbanairship as ua
airship = ua.Airship("app_key", "master_secret")
automation = ua.Automation(airship)

automation.delete("21bc19f7-dfcc-4a80-9d8b-6bfd350fe87b")

urbanairship.automation.core.Automation

Automation Listing

List existing automations for a project. For more information, see: https://docs.airship.com/api/ua/#operation/api/pipelines/get

import urbanairship as ua
airship = ua.Airship("app_key", "master_secret")
automation = ua.Automation(airship)

automation.list_automations(limit=10, enabled=True)

urbanairship.automation.core.Automation

Deleted Automation Listing

List deleted automations for a project. For more information, see: https://docs.airship.com/api/ua/#operation/api/pipelines/deleted/get

import urbanairship as ua
airship = ua.Airship("app_key", "master_secret")
automation = ua.Automation(airship)

automation.list_deleted_automations(start="2015-02-14T19:19:19")

urbanairship.automation.core.Automation