StackStorm/st2 — pull request #826 by lakshmi-kannan (2014-11-25 20:47:30+00:00)
Title: Resource create/update should be able to handle yaml

Fixes: https://github.com/StackStorm/st2/issues/822

## What?

CLI commands should be able to take in YAML files and be able to create resources.

## Pending

There is a -j option which prints the resources in JSON. Since we support only JSON in APIs, I decided not to support a -y option for printing YAML. However, this leads to an inconsistency.
If we decide to support a -y option, I'll open another PR.

## Example:

(virtualenv)~/s/c/e/rules git:master ❯❯❯ st2 rule create sample_rule_with_webhook.yaml ⏎ ✭ ✱ ◼
+-------------+---------------------------------------------------------+
| Property | Value |
+-------------+---------------------------------------------------------+
| id | 5474e81d0640fd21f1d73192 |
| name | examples.webhook_file |
| description | Sample rule dumping webhook payload to a file. |
| action | { |
| | "ref": "core.local", |
| | "parameters": { |
| | "cmd": "echo \"{{trigger.body}}\" >> |
| | /tmp/st2.webhook_sample.out" |
| | } |
| | } |
| criteria | { |
| | "trigger.body.name": { |
| | "pattern": "st2", |
| | "type": "equals" |
| | } |
| | } |
| enabled | True |
| trigger | { |
| | "type": "core.st2.webhook", |
| | "parameters": { |
| | "url": "sample" |
| | }, |
| | "pack": "core" |
| | } |
+-------------+---------------------------------------------------------+
(virtualenv)~/s/c/e/rules git:master ❯❯❯ st2 rule get examples.webhook_file ✭ ✱ ◼
+-------------+---------------------------------------------------------+
| Property | Value |
+-------------+---------------------------------------------------------+
| id | 5474e81d0640fd21f1d73192 |
| name | examples.webhook_file |
| description | Sample rule dumping webhook payload to a file. |
| action | { |
| | "ref": "core.local", |
| | "parameters": { |
| | "cmd": "echo \"{{trigger.body}}\" >> |
| | /tmp/st2.webhook_sample.out" |
| | } |
| | } |
| criteria | { |
| | "trigger.body.name": { |
| | "pattern": "st2", |
| | "type": "equals" |
| | } |
| | } |
| enabled | True |
| trigger | { |
| | "type": "core.st2.webhook", |
| | "parameters": { |
| | "url": "sample" |
| | }, |
| | "pack": "core" |
| | } |
+-------------+---------------------------------------------------------+
(virtualenv)~/s/c/e/rules git:master ❯❯❯