NAME

Nuvol::Connector - Base class for Nuvol connectors

SYNOPSIS

# existing config file
use Nuvol;
my $configfile = '/path/to/configfile';
my $connector  = Nuvol::connect($configfile);

# new config file
use Nuvol::Connector;
my $connector = Nuvol::Connector->new($configfile, $service);

# with additional parameters
my $connector = Nuvol::Connector->new($configfile, $service, $params);

$connector->authenticate;
$connector->authenticated;
$connector->config;
$connector->configfile;
$connector->disconnect;
$connector->drive;
$connector->drives;
$connector->update_drives;
$connector->url;

DESCRIPTION

Nuvol::Connector is the base class for Nuvol connectors.

config file

The parameters for the connection are stored in a config file. The information in this file allows full access to your cloud service for anyone who can read it. It should be stored at a secure place.

CONSTRUCTOR

via Nuvol

use Nuvol;
$configfile = '/path/to/configfile';
$connector  = Nuvol::connect($configfile);

Connections with existing config files are opened with Nuvol::connect.

new

$connector = Nuvol::Connector->new($configfile, $service);

To create a new file, the parameter $service is required. It defines the type of service that will be activated. Available services are Dummy and Office365.

%params = (
  app_id       => $app_id,
  redirect_uri => $redirect_uri,
  scope        => $scope,
);
$connector = Nuvol::Connector->new($configfile, $service, \%params);

Optional parameters can be used to define app_id, redirect_uri, scope. Notice that the final value for the scope is set during authentication.

$connector = Nuvol::Connector->new($configfile);

If the config file exists all values are read from it and additional parameters are ignored.

METHODS

Nuvol::Connector inherits the following methods from Nuvol::Role::Metadata:

description
id
metadata
name
url

authenticate

$connector->authenticate;

Starts an interactive authentication process. It will display a URL that has to be opened in a browser to start the authorization flow. The resulting URL is copied back to the console where it is used to retrieve the access tokens. If this process succeeds, the information is written to the config file. From now on it is possible to open the connector directly with Nuvol::connect.

authenticated

%params = (
  access_token  => $access_token,
  expires_in    => $seconds,
  refresh_token => $refresh_token,
  scope         => $scope,
);
$connector = $connector->authenticated(\%params);

Setter for new authentication tokens. Can be used if the authentication is made in an external module.

config

$value = $connector->config;

Getter for the config. Returns a Nuvol::Config.

configfile

$value = $connector->configfile;

Getter for the path to the configfile.

disconnect

$connector = $connector->disconnect($newvalue);

Deletes the confidential information (access token, refresh token and valitidy time) from the config file. To use it again it has to be re-authenticated.

drive

$drive = $connector->drive($path);

Getter for a drive with the specified path. Returns a Nuvol::Drive.

list_drives

$drives        = $connector->list_drives;
$default_drive = $connector->list_drives->first;

Lists the available drives. Returns a Mojo::Collection containing one or more Nuvol::Drive with the default drive at the first position. This list may be incomplete.

SEE ALSO

Nuvol, Nuvol::Drive.