[Bps-public-commit] rt-extension-rest2 branch, master, updated. 1.09-15-g3d6b9fa

Jim Brandt jbrandt at bestpractical.com
Mon Jan 25 15:31:35 EST 2021


The branch, master has been updated
       via  3d6b9fa1b4069be63f2262796bded3156c43c120 (commit)
       via  d2e84f6ffd4eb115aa2d8374511b9f073ea2053c (commit)
       via  d20d5605523b6ea76c3a04d4833ab7f5ba4975d0 (commit)
       via  608e4f79011b4301f56c2e43e93931e330eba44d (commit)
       via  5054bf020357014efb30807008648e1c9266ebae (commit)
       via  d3b553455ad50271ee85e6428eaac0485eb4cccd (commit)
      from  9c864221c3b2f8a40488523d054f85f636a90a45 (commit)

Summary of changes:
 META.yml                                           |   3 +-
 README                                             |  54 ++++-
 inc/Module/Install/RTx.pm                          |  36 ++-
 lib/RT/Extension/REST2.pm                          |  30 +++
 lib/RT/Extension/REST2/Resource/Message.pm         |   7 +-
 lib/RT/Extension/REST2/Resource/Record/Writable.pm | 122 +---------
 lib/RT/Extension/REST2/Test.pm.in                  |   1 +
 lib/RT/Extension/REST2/Util.pm                     | 151 ++++++++++++
 xt/ticket-correspond-customroles.t                 | 253 +++++++++++++++++++++
 9 files changed, 515 insertions(+), 142 deletions(-)
 create mode 100644 xt/ticket-correspond-customroles.t

- Log -----------------------------------------------------------------
commit d2e84f6ffd4eb115aa2d8374511b9f073ea2053c
Merge: 9c86422 d20d560
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Jan 25 15:19:17 2021 -0500

    Merge branch 'update-custom-roles-on-correspond-and-comment'


commit 3d6b9fa1b4069be63f2262796bded3156c43c120
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Jan 25 15:31:20 2021 -0500

    Update generated files

diff --git a/META.yml b/META.yml
index 16bdadb..1695a39 100644
--- a/META.yml
+++ b/META.yml
@@ -20,7 +20,6 @@ name: RT-Extension-REST2
 no_index:
   directory:
     - inc
-    - t
     - xt
   package:
     - RT::Extension::REST2::Test
@@ -45,6 +44,6 @@ requires:
 resources:
   license: http://opensource.org/licenses/gpl-license.php
 version: '1.09'
-x_module_install_rtx_version: '0.40'
+x_module_install_rtx_version: '0.42'
 x_requires_rt: 4.2.4
 x_rt_too_new: 5.0.0
diff --git a/README b/README
index ffc7b4a..1cfa243 100644
--- a/README
+++ b/README
@@ -232,6 +232,34 @@ USAGE
         The time, in minutes, you've taken to work on your response/comment,
         optional.
 
+    Status
+        The new status (for example, "open", "rejected", etc.) to set the
+        ticket to. The Status value must be a valid status based on the
+        lifecycle of the ticket's current queue.
+
+    CustomRoles
+        A hash whose keys are custom role names and values are as described
+        below:
+
+        For a single-value custom role, the value must be a string
+        representing an email address or user name; the custom role is set
+        to the user with that email address or user name.
+
+        For a multi-value custom role, the value can be a string
+        representing an email address or user name, or can be an array of
+        email addresses or user names; in either case, the members of the
+        custom role are set to the corresponding users.
+
+    CustomFields
+        A hash similar to the CustomRoles hash, but whose keys are custom
+        field names that apply to the Ticket; those fields are set to the
+        supplied values.
+
+    TxnCustomFields
+        A hash similar to the CustomRoles hash, but whose keys are custom
+        field names that apply to the Transaction; those fields are set to
+        the supplied values.
+
    Add Attachments
     You can attach any binary or text file to your response or comment by
     specifying Attachements property in the JSON object, which should be a
@@ -444,19 +472,14 @@ USAGE
             'https://myrt.com/REST/2.0/ticket/6/comment'
 
         # Comment on a ticket with custom field update
-        curl -X POST -H "Content-Type: text/plain" -u 'root:password'
+        curl -X POST -H "Content-Type: application/json" -u 'root:password'
             -d '{ "Content": "Testing a comment", "ContentType": "text/plain", "CustomFields": {"Severity": "High"} }'
             'https://myrt.com/REST/2.0/ticket/6/comment'
 
-        # Create an Asset
+        # Comment on a ticket with custom role update
         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'
+            -d '{ "Content": "Testing a comment", "ContentType": "text/plain", "CustomRoles": {"Manager": "manager at example.com"} }'
+            'https://myrt.com/REST/2.0/ticket/6/comment'
 
    Transactions
         GET /transactions?query=<JSON>
@@ -537,6 +560,19 @@ USAGE
         GET /asset/:id/history
             retrieve list of transactions for asset
 
+   Assets Examples
+    Below are some examples using the endpoints above.
+
+        # 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/assets'
+
    Catalogs
         GET /catalogs/all
             retrieve list of all catalogs you can see
diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index 7cad529..2dd9489 100644
--- a/inc/Module/Install/RTx.pm
+++ b/inc/Module/Install/RTx.pm
@@ -6,9 +6,10 @@ use strict;
 use warnings;
 no warnings 'once';
 
+use Term::ANSIColor qw(:constants);
 use Module::Install::Base;
 use base 'Module::Install::Base';
-our $VERSION = '0.40';
+our $VERSION = '0.42';
 
 use FindBin;
 use File::Glob     ();
@@ -53,7 +54,7 @@ sub RTx {
         my @look = @INC;
         unshift @look, grep {defined and -d $_} @try;
         push @look, grep {defined and -d $_}
-            map { ( "$_/rt4/lib", "$_/lib/rt4", "$_/lib" ) } @prefixes;
+            map { ( "$_/rt5/lib", "$_/lib/rt5", "$_/rt4/lib", "$_/lib/rt4", "$_/lib" ) } @prefixes;
         last if eval {local @INC = @look; require RT; $RT::LocalLibPath};
 
         warn
@@ -76,6 +77,22 @@ sub RTx {
         $self->requires_rt('4.0.0');
     }
 
+    my $package = $name;
+    $package =~ s/-/::/g;
+    if ( $RT::CORED_PLUGINS{$package} ) {
+        my ($base_version) = $RT::VERSION =~ /(\d+\.\d+\.\d+)/;
+        die RED, <<"EOT";
+
+**** Error: Your installed version of RT ($RT::VERSION) already
+            contains this extension in core, so you don't need to
+            install it.
+
+            Check https://docs.bestpractical.com/rt/$base_version/RT_Config.html
+            to configure it.
+
+EOT
+    }
+
     # Installation locations
     my %path;
     my $plugin_path;
@@ -223,7 +240,7 @@ sub requires_rt {
     my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
 
     if ($sorted[-1] eq $version) {
-        die <<"EOT";
+        die RED, <<"EOT";
 
 **** Error: This extension requires RT $version. Your installed version
             of RT ($RT::VERSION) is too old.
@@ -249,12 +266,12 @@ sub requires_rt_plugin {
         unshift @INC, $path;
     } else {
         my $name = $self->name;
-        warn <<"EOT";
+        my $msg = <<"EOT";
 
 **** Warning: $name requires that the $plugin plugin be installed and
               enabled; it does not appear to be installed.
-
 EOT
+        warn RED, $msg, RESET, "\n";
     }
     $self->requires(@_);
 }
@@ -264,9 +281,8 @@ sub rt_too_new {
     my $name = $self->name;
     $msg ||= <<EOT;
 
-**** Error: Your installed version of RT (%s) is too new; this extension
-            only works with versions older than %s.
-
+**** Warning: Your installed version of RT (%s) is too new; this extension
+              has not been tested on your version of RT and may not work as expected.
 EOT
     $self->add_metadata("x_rt_too_new", $version) if $self->is_admin;
 
@@ -274,7 +290,7 @@ EOT
     my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
 
     if ($sorted[0] eq $version) {
-        die sprintf($msg,$RT::VERSION,$version);
+        warn RED, sprintf($msg,$RT::VERSION), RESET, "\n";
     }
 }
 
@@ -297,4 +313,4 @@ sub _load_rt_handle {
 
 __END__
 
-#line 468
+#line 484

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


More information about the Bps-public-commit mailing list