The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::Checkpoint::Management::v1::Role::ObjectMethods - Role for Checkpoint Management API version 1.x method generation

VERSION

version 0.003000

SYNOPSIS

    package Net::Checkpoint::Management::v1;
    use Moo;
    use Net::Checkpoint::Management::v1::Role::ObjectMethods;

    Net::Checkpoint::Management::v1::Role::ObjectMethods->apply([
        {
            object   => 'packages',
            singular => 'package',
            create   => 'add-package',
            list     => 'show-packages',
            get      => 'show-package',
            update   => 'set-package',
            delete   => 'delete-package',
            list_key => 'packages',
            id_keys  => [qw( uid name )],
        },
        {
            object   => 'accessrules',
            singular => 'accessrule',
            create   => 'add-access-rule',
            list     => 'show-access-rulebase',
            get      => 'show-access-rule',
            update   => 'set-access-rule',
            delete   => 'delete-access-rule',
            list_key => 'rulebase',
            id_keys  => ['uid', 'name', 'rule-number'],
        },
    ]);

    1;

DESCRIPTION

This role adds methods for the commands of a specific object.

METHODS

create_$singular

Takes a hashref of attributes.

Returns the created object as hashref.

Throws an exception on error.

list_$object

Takes optional query parameters.

Returns a hashref similar to the Checkpoint Management API but without the 'from' and 'to' keys.

Throws an exception on error.

As the API only allows fetching 500 objects at a time it works around that by making multiple API calls.

get_$singular

Takes an object id and optional query parameters.

Returns the object as hashref.

Throws an exception on error.

update_$singular

Takes an object and a hashref of attributes.

Returns the updated object as hashref.

Throws an exception on error.

delete_$singular

Takes a hashref of attributes uniquely identifying the object. For most objects the uid is sufficient, accessrule requires the layer uid too.

Returns true on success.

Throws an exception on error.

find_$singular

Takes search and optional query parameters.

Returns the object as hashref on success.

Throws an exception on error.

As there is no API for searching by all attributes this method emulates this by fetching all objects using the "list_$object" method and performing the search on the client.

AUTHOR

Alexander Hartmaier <abraxxa@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by Alexander Hartmaier.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.