Cloudflare-API

 view release on metacpan or  search on metacpan

lib/Cloudflare/API/Hyperdrive.pm  view on Meta::CPAN


#============================================================================


sub list_configs {

    my ($self, %query)=@_;
    return $self->collect_list($self->list_configs_page(%query));

}


sub list_configs_page {

    my ($self, %query)=@_;
    return $self->list_pagination(
        $self->api()->account_path('hyperdrive', 'configs'),
        { mode => 'page' }, \%query);

}


sub list_configs_page_response {

    my ($self, %query)=@_;
    return $self->list_response(
        $self->api()->account_path('hyperdrive', 'configs'), \%query);

}


sub get_config {

    my ($self, $id, %opt)=@_;
    return $self->api()->request('GET',
        $self->api()->account_path('hyperdrive', 'configs', $id), %opt);

}


sub create_config {

    my ($self, $body_hr, %opt)=@_;
    die "config body must be a hash reference\n" unless ref($body_hr) eq 'HASH';
    return $self->api()->request('POST',
        $self->api()->account_path('hyperdrive', 'configs'), json => $body_hr, %opt);

}


sub replace_config {

    my ($self, $id, $body_hr, %opt)=@_;
    die "config body must be a hash reference\n" unless ref($body_hr) eq 'HASH';
    return $self->api()->request('PUT',
        $self->api()->account_path('hyperdrive', 'configs', $id), json => $body_hr, %opt);

}


sub update_config {

    my ($self, $id, $body_hr, %opt)=@_;
    die "config body must be a hash reference\n" unless ref($body_hr) eq 'HASH';
    return $self->api()->request('PATCH',
        $self->api()->account_path('hyperdrive', 'configs', $id), json => $body_hr, %opt);

}


sub delete_config {

    my ($self, $id, %opt)=@_;
    return $self->api()->request('DELETE',
        $self->api()->account_path('hyperdrive', 'configs', $id), %opt);

}
__END__

=encoding utf8

=begin markdown

# Cloudflare::API::Hyperdrive #

# NAME #

Cloudflare::API::Hyperdrive - manage Hyperdrive connection configurations

# SYNOPSIS #

```perl
my $configs=$api->hyperdrive()->list_configs();
my $config=$api->hyperdrive()->get_config($config_id);
```

# DESCRIPTION #

These account-scoped REST methods manage Hyperdrive configurations for external PostgreSQL or MySQL databases. They do not run SQL. Applications query through a Worker Hyperdrive binding and a database driver. Cloudflare's origin password is write-on...

# METHODS #

* **list_configs(%query)** — List every configuration. Named filters become query parameters. The method follows all pages and returns one flat array reference; a large result set can require many requests and substantial memory.
* **list_configs_page(%query)** — Return a lazy `HTTP::API::Core::Pagination` object. Use `next()` to consume one configuration at a time.
* **list_configs_page_response(%query)** — Make one list request and return the complete decoded Cloudflare response hash, including `result_info` when supplied.
* **get_config($id, %options)** — Retrieve a configuration by ID and return its `result`.
* **create_config(\%body, %options)** — POST a Cloudflare configuration body and return its `result`.
* **replace_config($id, \%body, %options)** — PUT a replacement configuration and return its `result`.
* **update_config($id, \%body, %options)** — PATCH a configuration and return its `result`.
* **delete_config($id, %options)** — DELETE a configuration and return the endpoint's `result`, possibly `undef` for an empty body.

Non-list JSON methods accept `full_response => 1` for the complete decoded Cloudflare response. IDs are percent-encoded. Write bodies must be hash references; Cloudflare defines the accepted fields.

# ERRORS #

Missing account context, invalid bodies or IDs, HTTP and transport failures, and Cloudflare response failures cause exceptions as described in `Cloudflare::API`.

# SEE ALSO #

[Cloudflare::API](../API.pm.md)



( run in 0.679 second using v1.01-cache-2.11-cpan-145b269f2f3 )