summaryrefslogtreecommitdiffstats
path: root/extensions/Push/lib/Connector/ReviewBoard
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2014-05-19 06:44:19 +0200
committerDylan William Hardison <dylan@hardison.net>2014-05-21 21:29:48 +0200
commite1aea961a9dd83d6d14b4e45cbf4a70b00fbe18c (patch)
tree1305d5d3e61639142801114bd728bb57e6b09ad0 /extensions/Push/lib/Connector/ReviewBoard
parent3d93c5919c4286c036d2cd0986387cecfdfeae60 (diff)
downloadbugzilla-e1aea961a9dd83d6d14b4e45cbf4a70b00fbe18c.tar.gz
bugzilla-e1aea961a9dd83d6d14b4e45cbf4a70b00fbe18c.tar.xz
Bug 993223 - Notify Review Board when a bug is made confidential
r=glob
Diffstat (limited to 'extensions/Push/lib/Connector/ReviewBoard')
-rw-r--r--extensions/Push/lib/Connector/ReviewBoard/Client.pm67
-rw-r--r--extensions/Push/lib/Connector/ReviewBoard/Resource.pm38
-rw-r--r--extensions/Push/lib/Connector/ReviewBoard/ReviewRequest.pm28
3 files changed, 133 insertions, 0 deletions
diff --git a/extensions/Push/lib/Connector/ReviewBoard/Client.pm b/extensions/Push/lib/Connector/ReviewBoard/Client.pm
new file mode 100644
index 000000000..7ec4938d2
--- /dev/null
+++ b/extensions/Push/lib/Connector/ReviewBoard/Client.pm
@@ -0,0 +1,67 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Extension::Push::Connector::ReviewBoard::Client;
+
+use 5.10.1;
+use strict;
+use warnings;
+
+use Carp qw(croak);
+use LWP::UserAgent;
+use Scalar::Util qw(blessed);
+use URI;
+
+use Bugzilla::Extension::Push::Connector::ReviewBoard::ReviewRequest;
+
+sub new {
+ my ($class, %params) = @_;
+
+ croak "->new() is a class method" if blessed($class);
+ return bless(\%params, $class);
+}
+
+sub username { $_[0]->{username} }
+sub password { $_[0]->{password} }
+sub base_uri { $_[0]->{base_uri} }
+sub realm { $_[0]->{realm} // 'Web API' }
+sub proxy { $_[0]->{proxy} }
+
+sub _netloc {
+ my $self = shift;
+
+ my $uri = URI->new($self->base_uri);
+ return $uri->host . ':' . $uri->port;
+}
+
+sub useragent {
+ my $self = shift;
+
+ unless ($self->{useragent}) {
+ my $ua = LWP::UserAgent->new(agent => Bugzilla->params->{urlbase});
+ $ua->credentials(
+ $self->_netloc,
+ $self->realm,
+ $self->username,
+ $self->password,
+ );
+ $ua->proxy('https', $self->proxy) if $self->proxy;
+ $ua->timeout(10);
+
+ $self->{useragent} = $ua;
+ }
+
+ return $self->{useragent};
+}
+
+sub review_request {
+ my $self = shift;
+
+ return Bugzilla::Extension::Push::Connector::ReviewBoard::ReviewRequest->new(client => $self, @_);
+}
+
+1;
diff --git a/extensions/Push/lib/Connector/ReviewBoard/Resource.pm b/extensions/Push/lib/Connector/ReviewBoard/Resource.pm
new file mode 100644
index 000000000..3f8d434ce
--- /dev/null
+++ b/extensions/Push/lib/Connector/ReviewBoard/Resource.pm
@@ -0,0 +1,38 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Extension::Push::Connector::ReviewBoard::Resource;
+
+use 5.10.1;
+use strict;
+use warnings;
+
+use URI;
+use Carp qw(croak confess);
+use Scalar::Util qw(blessed);
+
+sub new {
+ my ($class, %params) = @_;
+
+ croak "->new() is a class method" if blessed($class);
+ return bless(\%params, $class);
+}
+
+sub client { $_[0]->{client} }
+
+sub path { confess 'Unimplemented'; }
+
+sub uri {
+ my ($self, @path) = @_;
+
+ my $uri = URI->new($self->client->base_uri);
+ $uri->path(join('/', $self->path, @path) . '/');
+
+ return $uri;
+}
+
+1;
diff --git a/extensions/Push/lib/Connector/ReviewBoard/ReviewRequest.pm b/extensions/Push/lib/Connector/ReviewBoard/ReviewRequest.pm
new file mode 100644
index 000000000..32bebfbe8
--- /dev/null
+++ b/extensions/Push/lib/Connector/ReviewBoard/ReviewRequest.pm
@@ -0,0 +1,28 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Extension::Push::Connector::ReviewBoard::ReviewRequest;
+
+use 5.10.1;
+use strict;
+use warnings;
+
+use base 'Bugzilla::Extension::Push::Connector::ReviewBoard::Resource';
+
+# Reference: http://www.reviewboard.org/docs/manual/dev/webapi/2.0/resources/review-request/
+
+sub path {
+ return '/api/review-requests';
+}
+
+sub delete {
+ my ($self, $id) = @_;
+
+ return $self->client->useragent->delete($self->uri($id));
+}
+
+1;