
#                                      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 Cpanel::Config::ConfigObj::Driver::ServerMonitoring::META;

use cPstrict;

use parent qw(Cpanel::Config::ConfigObj::Interface::Config::Version::v1);

use Try::Tiny;

use Cpanel::LoadModule ();

our $VERSION = '1.0';

sub meta_version {
    return 1;
}

# Avoids having to deal with locale information
# when all we care about is the driver name.
sub get_driver_name {
    return 'server_monitoring';
}

sub content {
    my ($locale_handle) = @_;

    my $content = {
        'vendor' => 'cPanel, L.L.C.',
        'url'    => 'https://go.cpanel.net/server-monitoring',
        'name'   => {
            'short'  => 'Server Monitoring',
            'driver' => get_driver_name(),
        },
        'since'    => '',
        'abstract' => "360 Monitoring plugin installs an agent on your server that allows the 360 Monitoring system to track performance and uptime statistics for your server.",
        'version'  => $VERSION,
        'readonly' => 1,
    };

    if ($locale_handle) {
        $content->{'abstract'} = join(
            ' ',
            $locale_handle->maketext("cPanel & WHM now provides the [asis,Server Monitoring] feature. You can use [asis,Server Monitoring] to track your server's performance and up-time statistics."),
        );
    }

    $content->{'name'}->{'long'} = $content->{'name'}->{'short'};

    return $content;
}

sub showcase {
    return 0 unless _validate_company_id();
    return { 'is_recommended' => 1, 'is_spotlight_feature' => 0 };
}

sub _validate_company_id {
    require Cpanel::Plugins::Components::Rules::CompanyId;
    my $is_allowed = Cpanel::Plugins::Components::Rules::CompanyId->new( [ 7, 265, 2869, 4393 ] )->is_allowed();
    return $is_allowed;
}

sub acl_desc {
    my ($locale_handle) = @_;
    my %acl_desc = (
        'acl'           => '360_monitoring_acl',
        'default_value' => 1,
        'is_plugin'     => 1,
    );

    if ($locale_handle) {
        $acl_desc{'acl_subcat'} = locale()->maketext('Monitoring');
        $acl_desc{'name'}       = locale()->maketext('360 Monitoring');
    }
    else {
        $acl_desc{'acl_subcat'} = 'Monitoring';
        $acl_desc{'name'}       = '360 Monitoring';
    }
    return \%acl_desc;
}

1;
