Cloudflare-API

 view release on metacpan or  search on metacpan

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


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

}


sub list_secrets {

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

}


sub list_secrets_page {

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

}


sub list_secrets_page_response {

    my ($self, $store_id, %query)=@_;
    return $self->list_response(
        $self->api()->account_path('secrets_store', 'stores', $store_id, 'secrets'), \%query);

}


sub get_secret {

    my ($self, $store_id, $secret_id, %opt)=@_;
    return $self->api()->request('GET',
        $self->api()->account_path('secrets_store', 'stores', $store_id, 'secrets', $secret_id),
        %opt);

}


sub create_secret {


    #  Cloudflare accepts an array even when creating one secret
    #
    my ($self, $store_id, $body_ar, %opt)=@_;
    die "secret body must be a non-empty array reference\n"
        unless ref($body_ar) eq 'ARRAY'&&@$body_ar;
    return $self->api()->request('POST',
        $self->api()->account_path('secrets_store', 'stores', $store_id, 'secrets'),
        json => $body_ar, %opt);

}


sub update_secret {

    my ($self, $store_id, $secret_id, $body_hr, %opt)=@_;
    die "secret body must be a hash reference\n" unless ref($body_hr) eq 'HASH';
    return $self->api()->request('PATCH',
        $self->api()->account_path('secrets_store', 'stores', $store_id, 'secrets', $secret_id),
        json => $body_hr, %opt);

}


sub delete_secret {

    my ($self, $store_id, $secret_id, %opt)=@_;
    return $self->api()->request('DELETE',
        $self->api()->account_path('secrets_store', 'stores', $store_id, 'secrets', $secret_id),
        %opt);

}


sub get_quota {

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

}
__END__

=encoding utf8

=begin markdown

# Cloudflare::API::SecretsStore #

# NAME #

Cloudflare::API::SecretsStore - manage Cloudflare Secrets Store resources

# SYNOPSIS #

```perl
my $store=$api->secrets_store();
my $stores=$store->list_stores();
my $secret=$store->create_secret($store_id, [{
    name   => 'API_KEY',
    value  => $secret_value,
    scopes => ['workers']
}]);
```

# DESCRIPTION #

These account-scoped methods manage stores, secret metadata, write-only secret values, and quota. Cloudflare does not return a secret's value through `get_secret()`. Keep values out of logs, command lines, and source control.

# METHODS #

* **list_stores(%query)** — List every store with named query filters. The method follows all pages and returns one flat array reference; a large result set can require many requests and substantial memory.
* **list_stores_page(%query)** — Return a lazy `HTTP::API::Core::Pagination` object. Use `next()` to consume one store at a time.
* **list_stores_page_response(%query)** — Make one list request and return the complete decoded Cloudflare response hash, including `result_info` when supplied.



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