NAME
BZ::Client::Bug::Attachment - Client side representation of an Attachment to a Bug in Bugzilla
VERSION
version 2.0_4
SYNOPSIS
This class provides methods for accessing and managing attachments in Bugzilla. Instances of this class are returned by BZ::Client::Bug::Attachment::get.
my $client = BZ::Client->new( url => $url,
user => $user,
password => $password );
my $comments = BZ::Client::Bug::Attachment->get( $client, $ids );
CLASS METHODS
This section lists the class methods, which are available in this module.
get
It allows you to get data about attachments, given a list of bugs and/or attachment ids.
Note: Private attachments will only be returned if you are in the insidergroup or if you are the submitter of the attachment.
Actual Bugzilla API method is "attachments".
Added in Bugzilla 3.6.
Parameters
Note: At least one of ids or attachment_ids is required.
In addition to the parameters below, this method also accepts the standard include_fields and exclude_fields arguments.
- ids
-
ids (array) - An array that can contain both bug IDs and bug aliases. All of the attachments (that are visible to you) will be returned for the specified bugs.
- attachment_ids
-
attachment_ids (array) - An array of integer attachment_ids.
Returns
A hash containing two items is returned:
- bugs
-
This is used for bugs specified in ids. This is a hash, where the keys are the numeric ids of the bugs and the value is an array of attachment obects.
Note that any individual bug will only be returned once, so if you specify an id multiple times in ids, it will still only be returned once.
- attachments
-
Each individual attachment requested in attachment_ids is returned here, in a hash where the numeric attachment_id is the key, and the value is the attachment object.
The return value looks like this:
{
bugs => {
1345 => [
{ (attachment) },
{ (attachment) }
],
9874 => [
{ (attachment) },
{ (attachment) }
],
},
attachments => {
234 => { (attachment) },
123 => { (attachment) },
}
}
A "attachment" as shown above is an object instance of this package.
Errors
- 100 - Invalid Bug Alias
-
If you specified an alias and there is no bug with that alias.
- 101 - Invalid Bug ID
-
The bug_id you specified doesn't exist in the database.
- 102 - Access Denied
-
You do not have access to the bug_id you specified.
- 304 - Auth Failure, Attachment is Private
-
You specified the id of a private attachment in the attachment_ids argument, and you are not in the "insider group" that can see private attachments.
add
This allows you to add an attachment to a bug in Bugzilla.
Actual Bugzilla API method is "add_attachment".
Added in Bugzilla 4.0.
The return value has changed in Bugzilla 4.4.
Parameters
An instance of this package or a hash containing:
- ids
-
ids (array) Required - An array of ints and/or strings--the ids or aliases of bugs that you want to add this attachment to. The same attachment and comment will be added to all these bugs.
- data
-
data (string or base64) Required - The content of the attachment. If the content of the attachment is not ASCII text, you must encode it in base64 and declare it as the
base64
type. - file_name
-
file_name (string) Required - The "file name" that will be displayed in the UI for this attachment.
- summary
-
summary (string) Required - A short string describing the attachment.
- comment
-
comment (string) - A comment to add along with this attachment.
- is_patch
-
is_patcb (boolean) - True if Bugzilla should treat this attachment as a patch. If you specify this, you do not need to specify a content_type. The content_type of the attachment will be forced to
text/plain
.Defaults to False if not specified.
- is_private
-
is_private (boolean) - True if the attachment should be private (restricted to the "insidergroup"), False if the attachment should be public.
Defaults to False if not specified.
- flags
-
An array of hashes with flags to add to the attachment. to create a flag, at least the status and the type_id or name must be provided. An optional requestee can be passed if the flag type is requestable to a specific user.
- name
-
name (string) - The name of the flag type.
- type_id
-
type_id (int) - THe internal flag type id.
- status
-
status (string) - The flags new status (i.e. "?", "+", "-" or "X" to clear a flag).
- requestee
-
requestee (string) - The login of the requestee if the flag type is requestable to a specific user.
Returns
An array of the attachment id's created.
Errors
- 100 - Invalid Bug Alias
-
If you specified an alias and there is no bug with that alias.
- 101 - Invalid Bug ID
-
The bug_id you specified doesn't exist in the database.
- 102 - Access Denied
-
You do not have access to the bug_id you specified.
- 129 - Flag Status Invalid
-
The flag status is invalid.
- 130 - Flag Modification Denied
-
You tried to request, grant, or deny a flag but only a user with the required permissions may make the change.
- 131 - Flag not Requestable from Specific Person
-
You can't ask a specific person for the flag.
- 133 - Flag Type not Unique
-
The flag type specified matches several flag types. You must specify the type id value to update or add a flag.
- 134 - Inactive Flag Type
-
The flag type is inactive and cannot be used to create new flags.
- 600 - Attachment Too Large
-
You tried to attach a file that was larger than Bugzilla will accept.
- 601 - Invalid MIME Type
-
You specified a content_type argument that was blank, not a valid MIME type, or not a MIME type that Bugzilla accepts for attachments.
- 603 - File Name Not Specified
-
You did not specify a valid for the file_name argument.
- 604 - Summary Required
-
You did not specify a value for the summary argument.
- 606 - Empty Data
-
You set the "data" field to an empty string.
render
Returns the HTML rendering of the provided comment text.
Actual Bugzilla API method is "render_comment".
Note: this all takes place on your Bugzilla server.
Added in Bugzilla 5.0.
Parameters
- text
-
text (string) Required - Text comment text to render
- id
-
id The ID of the bug to render the comment against.
Returns
The HTML rendering
Errors
- 100 - Invalid Bug Alias
-
If you specified an alias and there is no bug with that alias.
- 101 - Invalid Bug ID
-
The bug_id you specified doesn't exist in the database.
- 102 - Access Denied
-
You do not have access to the bug_id you specified.
update
TODO
new
my $comment = BZ::Client::Bug::Comment->new(
id => $bug_id,
comment => $comment,
is_private => 1 || 0,
work_time => 3.5
);
Creates a new instance with the given details. Doesn't actually touch your Bugzilla Server - see add for that.
INSTANCE METHODS
AUTHORS
Dean Hamstead <dean@bytefoundry.com.au>
Jochen Wiedmann <jochen.wiedmann@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Dean Hamstad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.