Google-CloudTasks

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# NAME

Google::CloudTasks - Perl client library for the Google CloudTasks API (_unofficial_).

# SYNOPSIS

    use Google::CloudTasks;

    my $client = Google::CloudTasks->client(
        version => 'v2',
        credentials_path => '/path/to/credentials.json',
    );

    #  Create task
    my $project_id = 'myproject';
    my $location_id = 'asia-northeast1';
    my $queue_id = 'myqueue';
    my $parent = "projects/$project_id/locations/$location_id/queues/$queue_id";

    my $task = {
        name => "$parent/tasks/mytask-01234567",
        appEngineHttpRequest => {
            relativeUri => '/do_task',
        },
    }
    my $ret = $client->create_task($parent, $task);

# DESCRIPTION

Google::CloudTasks [https://cloud.google.com/tasks/docs/reference/rest/](https://cloud.google.com/tasks/docs/reference/rest/)

This is a Perl client library for the Google CloudTasks API.

## AUTHENTICATION

A service account with appropriate roles is required. You need to download JSON file and specify `credentials_path`.
See also: [https://cloud.google.com/docs/authentication/getting-started#creating\_the\_service\_account](https://cloud.google.com/docs/authentication/getting-started#creating_the_service_account)

# METHODS

All methods handle raw hashref (or arrayref of hashref), rather than objects.

## Create a client

    my $client = Google::CloudTasks->client(
        version => 'v2',
        credentials_path => '/path/to/credentials.json',
    );

`version` is an API version. (Currently only `v2` is available)
`credentials_path` is a path to a service account JSON file.

## Location

Refer the detailed representation of location at [https://cloud.google.com/tasks/docs/reference/rest/Shared.Types/ListLocationsResponse#Location](https://cloud.google.com/tasks/docs/reference/rest/Shared.Types/ListLocationsResponse#Location)

### get\_location

Gets information about a location.

    my $location = $client->get_location("projects/$PROJECT_ID/locations/$LOCATION_ID");

### list\_locations

Lists information about all locations under project.

    my $ret = $client->list_locations("projects/$PROJECT_ID");
    my $locations = $ret->{locations};

## Queue

Refer the detailed representation of queue at [https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues#Queue](https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues#Queue)

### create\_queue

Creates a queue.

    my $queue = {
        name => 'queue-name',
    };
    my $created = $client->create_queue("projects/$PROJECT_ID/locations/$LOCATION_ID", $queue);

### delete\_queue

Deletes a queue.

    $client->delete_queue("projects/$PROJECT_ID/locations/$LOCATION_ID/queues/$QUEUE_ID")

### get\_queue

Gets information of a queue.

    my $queue = $client->get_queue("projects/$PROJECT_ID/locations/$LOCATION_ID/queues/$QUEUE_ID");

### list\_queues

Lists information of all queues.

    my $ret = $client->list_queues("projects/$PROJECT_ID/locations/$LOCATION_ID");
    my $queues = $ret->{queues};

### patch\_queue

Updates a queue.

    my $queue = {
        retryConfig => {
            maxAttempts => 5,
        },
    };
    my $update_mask = { updateMask => 'retryConfig.maxAttempts' };



( run in 1.037 second using v1.01-cache-2.11-cpan-39bf76dae61 )