Dean Hamstead > BZ-Client > BZ::Client

Download:
BZ-Client-1.072.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  1
Open  1
View/Report Bugs
Module Version: 1.072   Source   Latest Release: BZ-Client-2.0_12

NAME ^

BZ::Client - A client for the Bugzilla web services API.

VERSION ^

version 1.072

SYNOPSIS ^

  my $client = BZ::Client->new( url       => $url,
                                user      => $user,
                                password  => $password,
                                autologin => 0
                                );
  $client->login();

CLASS METHODS ^

This section lists the class methods of BZ::Client.

new ^

  my $client = BZ::Client->new( url      => $url,
                                user     => $user,
                                password => $password );

  my $client = BZ::Client->new( url      => $url,
                                api_key  => $api_key );

The new method constructs a new instance of BZ::Client. Whenever you want to connect to the Bugzilla server, you must first create a Bugzilla client. The methods input is a hash of parameters.

For debugging, you can pass in a subref named logger which will be fed debugging information as the client works. Also the logDirectory option is a directory where the raw http content will be dumped.

url

The Bugzilla servers URL, for example https://bugzilla.mozilla.org/.

api_key

API keys were introduced in 5.0.

You can set up an API key by using the 'API Key' tab in the Preferences pages in your Bugzilla install.

user

The user name to use when logging in to the Bugzilla server. Typically, this will be your email address.

password

The password to use when logging in to the Bugzilla server.

autologin

If set to 1 (true), will try to log in (if not already logged in) when the first API call is made. This is default.

If set to 0, will try APi calls without logging in. You can still call $client->login() to log in manually.

Note: once you're logged in, you'll stay that way until you call logout

restrictlogin

If set to 1 (true), will ask Bugzilla to restrict logins to your IP only. Generally this is a good idea, but may caused problems if you are using a loadbalanced forward proxy.

Default: 0

INSTANCE METHODS ^

This section lists the methods, which an instance of BZ::Client can perform.

url

  my $url = $client->url();
  $client->url( $url );

Returns or sets the Bugzilla servers URL.

user

  my $user = $client->user();
  $client->user( $user );

Returns or sets the user name to use when logging in to the Bugzilla server. Typically, this will be your email address.

password

  my $password = $client->password();
  $client->password( $password );

Returns or sets the password to use when logging in to the Bugzilla server.

autologin

If login is automatically called, or not.

login

Used to login to the Bugzilla server. By default, there is no need to call this method explicitly: It is done automatically, whenever required.

If autologin is set to 0, call this to log in.

is_logged_in

Returns 1 if logged in, otherwise 0

logout

Deletes local cookies and calls bugzilla's logout function

logger

Sets or gets the logging function. Argument is a coderef. Returns undef if none.

  my $logger = $client->logger();

  $client->logger(
      sub {
          my ($level, $msg) = @_;
          print STDERR "$level $message\n";
          return 1
      });

Also can be set via new(), e.g.

  $client = BZ::Client->new( logger => sub { },
                             url    => $url
                             user   => $user,
                             password => $password );

log

  $client->log( $level, $message );

Sends log messages to whatever is loaded via logger.

api_call

  my $response = $client->api_call( $methodName, $params );

Used by subclasses of BZ::Client::API to invoke methods of the Bugzilla API. Takes a method name and a hash ref of parameters as input. Returns a hash ref of named result objects.

ERROR CODES ^

300 (Invalid Username or Password)

The username does not exist, or the password is wrong.

301 (Login Disabled)

The ability to login with this account has been disabled. A reason may be specified with the error.

305 (New Password Required)

The current password is correct, but the user is asked to change his password.

50 (Param Required)

A login or password parameter was not provided.

SEE ALSO ^

BZ::Client::Exception

AUTHORS ^

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.

syntax highlighting: