Net-SecurityCenter

 view release on metacpan or  search on metacpan

lib/Net/SecurityCenter/API/Policy.pm  view on Meta::CPAN

#-------------------------------------------------------------------------------

sub get {

    my ( $self, %args ) = @_;

    my $tmpl = {
        fields => $common_template->{'fields'},
        id     => $common_template->{'id'},
        raw    => {},
    };

    my $params    = sc_check_params( $tmpl, \%args );
    my $policy_id = delete( $params->{'id'} );
    my $raw       = delete( $params->{'raw'} );
    my $policy    = $self->client->get( "/policy/$policy_id", $params );

    return         if ( !$policy );
    return $policy if ($raw);
    return sc_normalize_hash($policy);

}

#-------------------------------------------------------------------------------

sub create {

    my ( $self, %args ) = @_;

    my $tmpl = {
        name => {
            required => 1,
        },
        description     => {},
        policy_template => $common_template->{'policy_template'},
        tags            => {},
        preferences     => {},
        families        => {},
    };

    my $params = sc_check_params( $tmpl, \%args );
    my $policy = $self->client->post( '/policy', $params );

    return sc_normalize_hash($policy);

}

#-------------------------------------------------------------------------------

sub edit {

    my ( $self, %args ) = @_;

    my $tmpl = {
        id           => $common_template->{'id'},
        name         => {},
        description  => {},
        tags         => {},
        preferences  => {},
        families     => {},
        remove_prefs => {
            remap => 'removePrefs'
        }
    };

    my $params    = sc_check_params( $tmpl, \%args );
    my $policy_id = delete( $params->{'id'} );
    my $policy    = $self->client->patch( "/policy/$policy_id", $params );

    return sc_normalize_hash($policy);

}

#-------------------------------------------------------------------------------

sub copy {

    my ( $self, %args ) = @_;

    my $tmpl = {
        id   => $common_template->{'id'},
        name => {},
    };

    my $params    = sc_check_params( $tmpl, \%args );
    my $policy_id = delete( $params->{'id'} );
    my $policy    = $self->client->post( "/policy/$policy_id/copy", $params );

    return sc_normalize_hash($policy);

}

#-------------------------------------------------------------------------------

sub delete {

    my ( $self, %args ) = @_;

    my $tmpl = { id => $common_template->{'id'} };

    my $params    = sc_check_params( $tmpl, \%args );
    my $policy_id = delete( $params->{'id'} );

    $self->client->delete("/policy/$policy_id");

    return 1;

}

#-------------------------------------------------------------------------------

sub download {

    my ( $self, %args ) = @_;

    my $tmpl = {
        filename => {},
        id       => $common_template->{'id'},
    };

    my $params = sc_check_params( $tmpl, \%args );

lib/Net/SecurityCenter/API/Policy.pm  view on Meta::CPAN


Create a new instance of B<Net::SecurityCenter::API::Policy> using L<Net::SecurityCenter::REST> class.


=head1 METHODS

=head2 list

Get list of policies.

Params:

=over 4

=item * C<fields>: Fields array or comma-separated-value string

=item * C<filter>: Filter for:

=over 4

=item * C<manageable>

=item * C<usable>

=back

=item * C<raw>: Return RAW Tenable.sc output without sc_merge C<usable> and C<manageable> array

=back

=head2 get

Gets the policy associated with C<id> param.

Params:

=over 4

=item * C<id>: Policy ID

=back

=head2 create

Create a policy.

Params:

=over 4

=item * C<name>: Policy Name

=item * C<description>: Description

=item * C<tags>: Tags

=item * C<preferences>: Preferences (HASH of C<PREFERENCE => VALUE>)

=item * C<families>: Plugin Families

=item * C<remove_prefs>: ARRAY of preferences to remove from policy

=back

=head2 edit

Edit the policy associated with C<id> param.

Params:

=over 4

=item * C<id>: Policy ID

=item * C<name>: Policy Name

=item * C<description>: Description

=item * C<tags>: Tags

=item * C<preferences>: Preferences (HASH of C<PREFERENCE => VALUE>)

=item * C<families>: Plugin Families

=item * C<remove_prefs>: ARRAY of preferences to remove from policy

=back

=head2 delete

Delete the policy associated with C<id> param.

Params:

=over 4

=item * C<id>: Policy ID

=back

=head2 copy

Copy the policy associated with C<id> param.

Params:

=over 4

=item * C<id>: Policy ID

=item * C<id>: Policy Name

=back

=head2 download

Download the policy XML associated with C<id> param.

Params:

=over 4

=item * C<id>: Policy ID

=item * C<filename>: Path of file (optional)

=back


=head1 SUPPORT

=head2 Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker
at L<https://github.com/giterlizzi/perl-Net-SecurityCenter/issues>.
You will be notified automatically of any progress on your issue.

=head2 Source Code

This is open source software.  The code repository is available for
public review and contribution under the terms of the license.

L<https://github.com/giterlizzi/perl-Net-SecurityCenter>

    git clone https://github.com/giterlizzi/perl-Net-SecurityCenter.git



( run in 1.422 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )