package Digicert::CertCentral; =head2 automation $atn= $api->automation($id); Return a new or cached Automation object for the given ID. =cut sub automation($self, $id) { return $self->{_automation_cache}{$id}->refresh(10) if $self->{_automation_cache}{$id}; my $atn= Digicert::CertCentral::Automation->new(api => $self, id => $id); Scalar::Util::weaken($self->{_automation_cache}{$id}= $atn); $atn; } package Digicert::CertCentral::Automation; use v5.36; use Moo; has api => ( is => 'ro', required => 1 ); has id => ( is => 'ro', required => 1 ); has data => ( is => 'rw' ); has data_ts => ( is => 'rw' ); sub BUILD ($self, @) { # die if automation doesn't exist, before finishing constructor $self->refresh; } sub refresh($self, $max_age=0) { if (!$self->data_ts || !$max_age || time - $self->data_ts > $max_age) { $self->data($self->api->api_viewAutomationDetails(automationId => $self->id)); $self->data_ts(time); } $self; } sub status($self) { $self->data->{autoStatusResponse}{automationStatus}; }