[Bps-public-commit] rt-extension-rest2 branch, rest2-doc-examples, created. 1.03-5-gf519d52

Craig Kaiser craig at bestpractical.com
Mon Mar 26 16:53:06 EDT 2018


The branch, rest2-doc-examples has been created
        at  f519d52ad2ac37113b1b11283eb85c9e2de08c0a (commit)

- Log -----------------------------------------------------------------
commit f519d52ad2ac37113b1b11283eb85c9e2de08c0a
Author: craig Kaiser <craig at bestpractical.com>
Date:   Fri Mar 23 14:22:27 2018 -0400

    Asset and User endpoint doc examples

diff --git a/lib/RT/Extension/REST2.pm b/lib/RT/Extension/REST2.pm
index edee4fc..be8a34c 100644
--- a/lib/RT/Extension/REST2.pm
+++ b/lib/RT/Extension/REST2.pm
@@ -316,16 +316,6 @@ Below are some examples using the endpoints above.
         -d 'Testing a comment'
         'https://myrt.com/REST/2.0/ticket/6/comment'
 
-    # Create an Asset
-    curl -X POST -H "Content-Type: application/json" -u 'root:password'
-        -d '{"Name" : "Asset From Rest", "Catalog" : "General assets", "Content" : "Some content"}'
-        'https://myrt.com/REST/2.0/asset'
-
-    # Search Assets
-    curl -X POST -H "Content-Type: application/json" -u 'root:password'
-    -d '[{ "field" : "id", "operator" : ">=", "value" : 0 }]'
-    'https://myrt.com/REST/2.0/asset'
-
 =head3 Transactions
 
     GET /transactions?query=<JSON>
@@ -405,6 +395,28 @@ Below are some examples using the endpoints above.
     GET /asset/:id/history
         retrieve list of transactions for asset
 
+=head3 Asset Examples
+
+Below are some examples using the enpoints above.
+
+    # Create an Asset
+    curl -X POST -H "Content-Type: application/json" -u 'root:password'
+        -d '{"Name" : "Asset From Rest",
+            "Catalog" : "General assets",
+            "Description" : "Some content"}'
+        'https://myrt.com/REST/2.0/asset'
+
+    # Search Assets
+    curl -X POST -H "Content-Type: application/json" -u 'root:password'
+        -d '[{ "field" : "id", "operator" : ">=", "value" : 0 }]'
+        'https://myrt.com/REST/2.0/assets'
+
+    # Update Asset
+    curl -X PUT -H "Content-Type: application/json" -u 'root:password'
+        -d '{"Description": "A new description",
+            "CustomFields" : {"MyCustomField" : "NewValue"}}'
+        'https://myrt.com/REST/2.0/asset/2'
+
 =head3 Catalogs
 
     GET /catalogs/all
@@ -454,6 +466,29 @@ Below are some examples using the endpoints above.
     GET /user/:name/history
         retrieve list of transactions for user
 
+=head3 User examples
+
+Below are some examples using the enpoints above.
+
+    # Search
+    curl -X POST -H "Content-Type: application/json"
+        -d '[{"field": "Name", "operator": "LIKE", "value" : "MyUserName"}]'
+        -u 'root:password' 'https://myrt.com/REST/2.0/users'
+
+    # Create
+    curl -X POST -H "Content-Type: application/json"
+        -d '{"Name": "TestUser", "Nickname": "Tester"}'
+        -u 'root:password' 'https://myrt.com/REST/2.0/user'
+
+    # Update
+    curl -X PUT -H "Content-Type: application/json"
+        -d '{"Name": "NewName",  "CustomFields" : {"MyCF" : "NewValue"} }'
+        -u 'root:password' 'https://myrt.com/REST/2.0/user/TestUser'
+
+    # Delete
+    curl -X DELETE -u 'root:password'
+        'http://localhost:8080/REST/2.0/user/MyUser'
+
 =head3 Groups
 
     GET /groups?query=<JSON>

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list