NAME

WWW::Codeguard::User - Perl interface to interact with the Codeguard API as a 'user'

SYNOPSIS

This module provides you with an perl interface to interact with the Codeguard API and perform the 'user' level calls.

        use WWW::Codeguard::User;

        my $api = WWW::Codeguard::User->new(
                $api_url,
                {
                        api_secret      => $user_api_secret,
                        api_key         => $user_api_key,
                        access_secret   => $user_access_secret,
                        access_token    => $user_access_token,
                        verify_hostname => 1,
                }
        );

METHODS

Each of these map to a call on Codeguard's User API.

create_website

This allows you to create a website resource under your User account. Params should be a hashref that contains the following attributes:

Required: The request will not succeed without these attributes.

        url
        hostname
        account
        password or key
        provider

Optional:

        dir_path
        port

list_websites

This allows you to list the website resources under your User account. Params should be a hashref that contains the following attributes:

Required:

        None

Optional:

        None

list_website_rules

This allows you to list the exclusion rules for a website resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        website_id

Optional:

        None

set_website_rules

This allows you to set the exclusion rules for a website resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        website_id
        exclude_rules - must be an array ref with elements specifying what paths/files to ignore. Example:
        [
                'access-logs/*'
                '*error_log*'
                '*stats/*'
                '/path/to/a/folder/*'
                '/path/to/a/file.txt'
        ]

Optional:

        None

edit_website

This allows you to edit information for the specified website resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        website_id

Optional:

        url
        monitor_frequency
        account
        password or key
        dir_path
        hostname
        disabled

delete_website

This allows you to delete the specified website resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        website_id

Optional:

        None

enable_website

This allows you to enable a specified website resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        website_id

Optional:

        None

disable_website

This allows you to disable a specified website resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        website_id

Optional:

        None

create_database

This allows you to create a database resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        server_address - MySQL Database Hostname or IP address.
        account        - MySQL username which has access to the database_name database.
        password       - MySQL password associated with account.
                         Note: This parameter is only used during the create action. It is never returned by other API requests.
        port           - MySQL server port number for use with the server_name.
        database_name  - The name of the target database.

Optional:

        website_id          - Numeric ID of the parent Website record.
                              If no website_id is provided, the Database will not be associated with any website resource.

Experimental features: SSH functionality for DB backups is currently not fully functional on CodeGuard's side, and as such might not function as expected.

        authentication_mode - This can be one of two values: 'direct' or 'ssh'.
                              The direct method will attempt to open a connection using a MySQL client on the specified server and port.
                              The ssh method will create an SSH tunnel through server_name using the server_account and
                              server_password credentials to connect to the database on server_name.

        server_account      - SSH username on server_address. Note: This field is only valid if the authenticationmode is ssh.
                              Note: Required if authentication_mode is 'ssh'.

        server_password     - SSH password associated with server_account.
                              Note: Required if authentication_mode is 'ssh'.

list_databases

This allows you to fetch all Database Records owned by the user.

Required:

        None

Optional:

        None

show_database

This allows you to fetch information for the specified database resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        database_id

Optional:

        None

edit_database

This allows you to edit information for the specified database resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        database_id

Optional:

        website_id
        server_address
        account
        password
        port
        database_name
        authentication_mode
        server_account
        server_password
        disabled

delete_database

This allows you to delete the specified database resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        database_id

Optional:

        None

enable_database

This allows you to enable a specified database resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        database_id

Optional:

        None

disable_database

This allows you to disable a specified database resource under your User account. Params should be a hashref that contains the following attributes:

Required:

        database_id

Optional:

        None

create_website_backup

Will initiate an on-demand backup for a Website.

Required:

    website_id - Id of the Website to create a backup for.

Optional:

    None

restore_website_backup

Will initiate a full restore for a Website.

Required:

    website_id - Id of the Website to perform restore on.
    commit_id  - The commit to restore the website from.

Optional:

    None

selective_restore_website_backup

Will initiate a restore of the specified files and directories for a Website.

Required:

    website_id - Id of the Website to perform the restore on.
    commit_id  - The commit to restore files from.
    paths      - A list of paths to restore.

Optional:

    None

archive_website_backup

Will initiate the production of a zip file which contains the entire contents of the selected backup. Upon completion a perishable link will be provided to the customer so that they can retrieve the zip file. The links expire after 1 week.

Required:

    website_id - Id of the Website to download the file for.
    commit_id  - The commit to create the zip file from.

Optional:

    None

archive_website_selective_backup

Will initiate the production of a zip file which contains the the specified files and directories. Upon completion a perishable link will be provided to the customer so that they can retrieve the zip file. The links expire after 1 week.

Required:

    website_id - Id of the Website to download the file for.
    commit_id  - The commit to create the zip file from.
    paths      - A list of paths to include in the archive.

Optional:

    None

list_website_backups

List all of the backups for a Website.

Required:

    website_id - Id of the Website to list the backups for.

Optional:

    None

browse_website_backup

Response includes files, directories and their associated metadata as an array of entries. Requests can be scoped to an optional path parameter.

Required:

    website_id - Id of the Website to brose the backup of.
    commit_id  - The commit to brwose the contents of.

Optional:

    path - scopes the results to this path within the backup.

list_website_database_backup_commits

List all backups of the database associated with selected website backup commit_id.

Required:

    website_id - Id of the Website associated with the database to list backups for.
    commit_id  - The website backup commit to retrieve associated database backups for.

Optional:

    None

create_database_backup

Will initiate an on-demand backup for a Database.

Required:

    website_id  - Id of the Website associated with the database to create a backup for.
    database_id - Id of the Database to create a backup for.

Optional:

    None

restore_database_backup

Will initiate a full restore for a Database.

Required:

    website_id  - Id of the Website associated with the database to restore.
    database_id - Id of the Database to restore a backup for.
    commit_id   - The commit to restore the database from.

Optional:

    None

list_database_backups

List all the bacukps for a Database.

Required:

    website_id  - Id of the Website associated with the requested database.
    database_id - Id of the Database to list the backups for.

Optional:

    None

This creates a login URL that can be used to access the Codeguard Dashboard for your User account.

Required:

        None

Optional:

        None

Accessors

Basic accessor methods to retrieve the current settings

get_api_secret

Returns the current value in $self->{api_secret}.

get_api_key

Returns the current value in $self->{api_key}.

get_access_secret

Returns the current value in $self->{access_secret}.

get_access_token

Returns the current value in $self->{access_token}.

AUTHOR

Rishwanth Yeddula, <ryeddula at cpan.org>

BUGS

Please report any bugs or feature requests to bug-www-codeguard at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Codeguard. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the following perldoc commands.

    perldoc WWW::Codeguard
    perldoc WWW::Codeguard::Partner
    perldoc WWW::Codeguard::User

You can also look for information at:

ACKNOWLEDGMENTS

Thanks to Hostgator.com for funding the development of this module and providing test resources.

LICENSE AND COPYRIGHT

Copyright 2014 Rishwanth Yeddula.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.