From 5f0666846bc13293ec246f3bcd7de3d80503beef Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Fri, 18 Oct 2013 12:32:07 -0400 Subject: Bug 924572 - Backport upstream bugs 741722, 838846 to bmo/4.2 for flag_type REST API support --- Bugzilla/WebService.pm | 8 +++ Bugzilla/WebService/Product.pm | 107 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 114 insertions(+), 1 deletion(-) diff --git a/Bugzilla/WebService.pm b/Bugzilla/WebService.pm index 8f97a3a2f..c930b02dc 100644 --- a/Bugzilla/WebService.pm +++ b/Bugzilla/WebService.pm @@ -272,6 +272,14 @@ be returned, the rest will not be included. If you specify an empty array, then this function will return empty hashes. +Some RPC calls support specifying sub fields. + +If an RPC call states that it support sub field restrictions, you can +restrict what information is returned within the first field. For example, +if you call Products.get with an include_fields of components.name, then +only the component name would be returned (and nothing else). You can +include the main field, and exclude a sub field. + Invalid field names are ignored. Example: diff --git a/Bugzilla/WebService/Product.pm b/Bugzilla/WebService/Product.pm index 63981ae89..ca22e6418 100644 --- a/Bugzilla/WebService/Product.pm +++ b/Bugzilla/WebService/Product.pm @@ -181,7 +181,7 @@ sub _product_to_hash { }; if (filter_wants($params, 'components')) { $field_data->{components} = [map { - $self->_component_to_hash($_) + $self->_component_to_hash($_, $params) } @{$product->components}]; } if (filter_wants($params, 'versions')) { @@ -215,9 +215,49 @@ sub _component_to_hash { is_active => $self->type('boolean', $component->is_active), }; + if (filter_wants($params, 'flag_types', 'components')) { + $field_data->{flag_types} = { + bug => + [map { + $self->_flag_type_to_hash($_) + } @{$component->flag_types->{'bug'}}], + attachment => + [map { + $self->_flag_type_to_hash($_) + } @{$component->flag_types->{'attachment'}}], + }; + } return filter($params, $field_data, 'components'); } +sub _flag_type_to_hash { + my ($self, $flag_type, $params) = @_; + return { + id => + $self->type('int', $flag_type->id), + name => + $self->type('string', $flag_type->name), + description => + $self->type('string', $flag_type->description), + cc_list => + $self->type('string', $flag_type->cc_list), + sort_key => + $self->type('int', $flag_type->sortkey), + is_active => + $self->type('boolean', $flag_type->is_active), + is_requestable => + $self->type('boolean', $flag_type->is_requestable), + is_requesteeble => + $self->type('boolean', $flag_type->is_requesteeble), + is_multiplicable => + $self->type('boolean', $flag_type->is_multiplicable), + grant_group => + $self->type('int', $flag_type->grant_group_id), + request_group => + $self->type('int', $flag_type->request_group_id), + }; +} + sub _version_to_hash { my ($self, $version, $params) = @_; my $field_data = { @@ -513,6 +553,68 @@ and then secondly by their name. C A boolean indicating if the component is active. Inactive components are not enabled for new bugs. +=item C + +A hash containing the two items C and C that each contains an +array of hashes, where each hash describes a flagtype, and has the +following items: + +=over + +=item C + +C Returns the ID of the flagtype. + +=item C + +C Returns the name of the flagtype. + +=item C + +C Returns the description of the flagtype. + +=item C + +C Returns the concatenated CC list for the flagtype, as a single string. + +=item C + +C Returns the sortkey of the flagtype. + +=item C + +C Returns whether the flagtype is active or disabled. Flags being +in a disabled flagtype are not deleted. It only prevents you from +adding new flags to it. + +=item C + +C Returns whether you can request for the given flagtype +(i.e. whether the '?' flag is available or not). + +=item C + +C Returns whether you can ask someone specifically or not. + +=item C + +C Returns whether you can have more than one flag for the given +flagtype in a given bug/attachment. + +=item C + +C the group id that is allowed to grant/deny flags of this type. +If the item is not included all users are allowed to grant/deny this +flagtype. + +=item C + +C the group id that is allowed to request the flag if the flag +is of the type requestable. If the item is not included all users +are allowed request this flagtype. + +=back + =back =item C @@ -547,6 +649,9 @@ been removed. =item REST API call added in Bugzilla B<5.0>. +=item In Bugzilla B<4.4>, C was added to the fields returned +by C. + =back =back -- cgit v1.2.3-24-g4f1b