| 1 | package Kubernetes::REST::WatchEvent; | ||
| 2 | our $VERSION = '1.109'; | ||
| 3 | # ABSTRACT: A single event from the Kubernetes Watch API | ||
| 4 | use Moo; | ||
| 5 | use Types::Standard qw(Str); | ||
| 6 | |||
| 7 | |||
| 8 | has type => (is => 'ro', isa => Str, required => 1); | ||
| 9 | |||
| 10 | |||
| 11 | has object => (is => 'ro', required => 1); | ||
| 12 | |||
| 13 | |||
| 14 | has raw => (is => 'ro', required => 1); | ||
| 15 | |||
| 16 | |||
| 17 | 1; | ||
| 18 | |||
| 19 | __END__ | ||
| 20 | |||
| 21 | =pod | ||
| 22 | |||
| 23 | =encoding UTF-8 | ||
| 24 | |||
| 25 | =head1 NAME | ||
| 26 | |||
| 27 | Kubernetes::REST::WatchEvent - A single event from the Kubernetes Watch API | ||
| 28 | |||
| 29 | =head1 VERSION | ||
| 30 | |||
| 31 | version 1.109 | ||
| 32 | |||
| 33 | =head1 SYNOPSIS | ||
| 34 | |||
| 35 | $api->watch('Pod', | ||
| 36 | namespace => 'default', | ||
| 37 | on_event => sub { | ||
| 38 | my ($event) = @_; | ||
| 39 | say $event->type; # ADDED, MODIFIED, DELETED, ERROR, BOOKMARK | ||
| 40 | say $event->object->metadata->name; # inflated IO::K8s object | ||
| 41 | say $event->raw->{metadata}{name}; # original hashref | ||
| 42 | }, | ||
| 43 | ); | ||
| 44 | |||
| 45 | =head1 DESCRIPTION | ||
| 46 | |||
| 47 | Represents a single watch event from the Kubernetes API. Watch events are streamed as newline-delimited JSON objects with a C<type> field and an C<object> field. | ||
| 48 | |||
| 49 | =head2 type | ||
| 50 | |||
| 51 | Required. The event type string. One of: C<ADDED>, C<MODIFIED>, C<DELETED>, C<ERROR>, or C<BOOKMARK>. | ||
| 52 | |||
| 53 | =head2 object | ||
| 54 | |||
| 55 | Required. The inflated L<IO::K8s> object for the resource. For C<ERROR> events this is a hashref (the Kubernetes Status object) instead. | ||
| 56 | |||
| 57 | =head2 raw | ||
| 58 | |||
| 59 | Required. The original C<object> hashref from the watch event's JSON, before inflation. Useful for accessing fields that may not be mapped to the L<IO::K8s> class. | ||
| 60 | |||
| 61 | =head1 SEE ALSO | ||
| 62 | |||
| 63 | =over | ||
| 64 | |||
| 65 | =item * L<Kubernetes::REST> - Main API client | ||
| 66 | |||
| 67 | =item * L<Kubernetes::REST/watch> - Watch API documentation | ||
| 68 | |||
| 69 | =item * L<Kubernetes::REST::LogEvent> - Analogous event object for the Pod Log API | ||
| 70 | |||
| 71 | =item * L<https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes> - Kubernetes watch documentation | ||
| 72 | |||
| 73 | =back | ||
| 74 | |||
| 75 | =head1 SUPPORT | ||
| 76 | |||
| 77 | =head2 Issues | ||
| 78 | |||
| 79 | Please report bugs and feature requests on GitHub at | ||
| 80 | L<https://github.com/pplu/kubernetes-rest/issues>. | ||
| 81 | |||
| 82 | =head2 IRC | ||
| 83 | |||
| 84 | Join C<#kubernetes> on C<irc.perl.org> or message Getty directly. | ||
| 85 | |||
| 86 | =head1 CONTRIBUTING | ||
| 87 | |||
| 88 | Contributions are welcome! Please fork the repository and submit a pull request. | ||
| 89 | |||
| 90 | =head1 AUTHORS | ||
| 91 | |||
| 92 | =over 4 | ||
| 93 | |||
| 94 | =item * | ||
| 95 | |||
| 96 | Torsten Raudssus <getty@cpan.org> | ||
| 97 | |||
| 98 | =item * | ||
| 99 | |||
| 100 | Jose Luis Martinez Torres <jlmartin@cpan.org> | ||
| 101 | |||
| 102 | =back | ||
| 103 | |||
| 104 | =head1 COPYRIGHT AND LICENSE | ||
| 105 | |||
| 106 | This software is Copyright (c) 2019-2026 by Jose Luis Martinez Torres <jlmartin@cpan.org>. | ||
| 107 | |||
| 108 | This is free software, licensed under: | ||
| 109 | |||
| 110 | The Apache License, Version 2.0, January 2004 | ||
| 111 | |||
| 112 | =cut |