App-wsgetmail

 view release on metacpan or  search on metacpan

bin/wsgetmail  view on Meta::CPAN

use lib "$FindBin::Bin/../lib";
use JSON;
use App::wsgetmail;
use File::Slurp;
use Pod::Usage;
use Getopt::Long;

my ($config_file, $options, $dry_run);
my ($debug, $help, $quiet) = (0,0,0);
my $response_matrix = {
    delete_message => { '400' => 'ignore', '404' => 'ignore' },

    default => { '5xx' => 'ignore' },
};

my $response_handling = '';

{
    my @buffer;

    sub maybe_print {

bin/wsgetmail  view on Meta::CPAN

foreach my $option ( keys %$extra_options ) {
    $config->{$option} = $extra_options->{$option};
}
$config->{dry_run} = $dry_run if (defined $dry_run);
$config->{debug} = $debug if (defined $debug);

# [
#   {
#       'value':'ignore',
#       'methods':{
#           'delete_message': ['400','404'],
#           'default':        ['5xx']
#       }
#   }
# ]
if ($response_handling) {
    my $response_overrides = decode_json($response_handling);

    foreach my $section (@$response_overrides) {
        my $value = $section->{value};
        my $methods = $section->{methods};

bin/wsgetmail  view on Meta::CPAN

This option exists because most of the MS Graph API calls can return
non-success responses sporadically that aren't related to any visible or
actionable issue, and may not even mean that the attempted action failed.

Previous versions of wsgetmail treated all of these as first-class errors,
complete with warning messages and aborting the run with a failure status.
For an administrator this creates a trickle of non-actionable alerts, unless
they choose to ignore all errors and output.

To complicate matters it isn't quite as simple as always ignoring specific
error codes. For example, one may want to treat a C<404 Not Found> status
code as success when deleting a message and still consider it to be failure
when trying to list the messages in a folder.

Version C<0.09> of wsgetmail changed the default handling of some non-success
status codes across the board (C<5xx - server-side errors>) and for some
specific non-success codes when deleting messages (C<400> and C<404>).

This seems to be both safe and comprehensive, but this is based on our
observations of operational behavior and does not seem to be supported by
documentation.

This option exists to allow administrators to modify or augment these new
default behaviors precisely.  This option is not intended to be used without
at least some understanding of the MS Graph API and how the
L<App::wsgetmail::MS365> module uses it.

bin/wsgetmail  view on Meta::CPAN

The value of this option is a JSON list of objects that are used to modify and
augment the default response matrix, where each element of the list directs
that one or more values be added to, or removed from, the matrix.

The default response matrix could be represented with the JSON:

  [
    {
      'value':'ignore',
      'labels':{
        'delete_message': ['400','404'],
        'default':        ['5xx']
      }
    }
  ]

or, more compactly, as:

  --response-matrix='[{"value":"ignore","labels":{"delete_message":["400","404"],"default":["5xx"]}}]'

This directs C<App::wsgetmail::MS365> to C<ignore> (that is, to treat as
closely as possible to success) HTTP status codes C<400> and C<404> when
deleting messages as the post-fetch action, and to ignore all C<5xx> HTTP
status codes (server errors) for all calls.

One case worth mentioning specifically is the API call referred to as
C<get_message_mime_content>. When this fails there is no content to process
so neither the C<command> nor the follow-up action will be performed.
However, in order to maintain the illusion of success for the caller, the
method returns a value that indicates that the message was processed, which
would cause it to be reflected in the counts if they are emitted.

lib/App/wsgetmail/MS365.pm  view on Meta::CPAN


=back

The only value with defined behavior is C<ignore>, which indicates that
nothing should be logged and that the code should be treated as success
as closely as possible.

The defaults in L<App::wsgetmail> could be represented as:

  $example_response_matrix = {
    delete_message => { '400' => 'ignore', '404' => 'ignore' },

    default => { '5xx' => 'ignore' },
  };


=cut

has response_matrix => (
    is => 'ro',
    default => sub { return {} },



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