#                                      Copyright 2024 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

package Whostmgr::360Monitoring::Agent::Plugins::Httpd;

use cPstrict;
use Moo;
use Whostmgr::360Monitoring::Moo;
use Whostmgr::360Monitoring::Types qw(WPUrlOrEmpty);

extends qw/Whostmgr::360Monitoring::Agent::Plugins/;

with qw/
  Whostmgr::360Monitoring::Agent::Plugins::Roles::Installable
  Whostmgr::360Monitoring::Agent::Plugins::Roles::ServerProfile
  /;

use constant {
    REQUIRED_ROLES    => ['WebServer'],
    REQUIRED_SERVICES => ['httpd'],
};

conf_has 'status_page_url' => (
    isa              => WPUrlOrEmpty,
    coerce           => 1,
    default          => 'http://127.0.0.1/whm-server-status?auto',
    always_serialize => 1,
);

sub install { !!1 }

sub uninstall ( $self, $force ) {
    $self->status_page_url('');
    !!1;
}
sub is_installed   { !!1 }
sub is_installable { !!1 }

!!1;

__END__

=head1 NAME

Whostmgr::360Monitoring::Agent::Plugins::Httpd - A class for the Httpd plugin

=head1 DESCRIPTION

A child class of L<Whostmgr::360Monitoring::Agent::Plugins>. More information can be found at L<Agent360 Plugin Documentation|https://docs.360monitoring.com/docs/apache>. The upstream implementation can be found at the L<Agent360 Repository on Github|https://github.com/plesk/agent360/tree/master/agent360/plugins/httpd.py>.

Usage for plugin configuration changes can be found in the L<Agent|Whostmgr::360Monitoring::Agent> class.

Usage for configuration options can be found in the L<Agent apache documentation|https://docs.360monitoring.com/docs/apache/#configure-the-plugin>.

=head1 ROLES

=over 15

=item L<Serializable|Whostmgr::360Monitoring::Agent::Plugins::Roles::Serializable>

=item L<Enableable|Whostmgr::360Monitoring::Agent::Plugins::Roles::Enableable>

=item L<Runnable|Whostmgr::360Monitoring::Agent::Plugins::Roles::Runnable>

=back

=head1 ATTRIBUTES

=over 15

=item status_page_url

An attribute representing status_page_url as defined in the GitHub repo linked in the SEE ALSO. Sourced from ini. Serializes to ini.

=back

=head1 SEE ALSO

=over 8

=item L<Implementation of Plugin on Github|https://github.com/plesk/agent360/tree/master/agent360/plugins/httpd.py>

=item L<Documentation on Agent360|https://docs.360monitoring.com/docs/apache>

=back
