Curio-Role-GitLab-API-v4
view release on metacpan or search on metacpan
lib/Curio/Role/GitLab/API/v4.pm view on Meta::CPAN
my ($self) = @_;
return undef if $self->connection_key() eq 'anonymous';
return myapp_secret(
'gitlab-token-' . $self->connection_key(),
);
}
1;
Then use your new Curio class elsewhere:
use MyApp::Service::GitLab;
my $api = myapp_gitlab('admin');
=head1 DESCRIPTION
This role provides all the basics for building a Curio class which
wraps around L<GitLab::API::v4>.
=head1 REQUIRED ARGUMENTS
=head2 api
Holds the L<GitLab::API::v4> object.
May be passed as either a hashref of arguments or a pre-created
object.
=head1 OPTIONAL METHODS
These methods may be declared in your Curio class.
=head2 access_token
The L<GitLab::API::v4/access_token>. See L</TOKENS>.
=head2 private_token
The L<GitLab::API::v4/private_token>. See L</TOKENS>.
=head1 TOKENS
In your Curio class you may create two methods, L</access_token> and
L</private_token>. If either/both of these methods exist and return a
defined value then they will be used when constructing the L</api>
object.
In the L</SYNOPSIS> a sample C<private_token> method is shown:
sub private_token {
my ($self) = @_;
return undef if $self->connection_key() eq 'anonymous';
return myapp_secret(
'gitlab-token-' . $self->connection_key(),
);
}
The C<myapp_secret> call is expected to be the place where you use
whatever tool you use to hold your GitLab tokens and likely all
passwords and other credentials (secrets) that your application needs.
Some common tools that people use to manage their secrets are
Kubernetes' secrets objects, AWS's Secret Manager, HashiCorp's Vault,
or just an inescure configuration file; to name a few.
So, the way you write your token methods is going to be unique to your
setup.
=head1 FEATURES
This role turns on L<Curio::Factory/does_caching> and sets
L<Curio::Factory/resource_method_name> to C<api> (as in
L</api>).
You can of course revert these changes:
does_caching 0;
resource_method_name undef;
=head1 SUPPORT
Please submit bugs and feature requests to the
Curio-Role-GitLab-API-v4 GitHub issue tracker:
L<https://github.com/bluefeet/Curio-Role-GitLab-API-v4/issues>
=head1 ACKNOWLEDGEMENTS
Thanks to L<ZipRecruiter|https://www.ziprecruiter.com/> for
encouraging their employees to contribute back to the open source
ecosystem. Without their dedication to quality software development
this distribution would not exist.
=head1 AUTHORS
Aran Clary Deltac <bluefeet@gmail.com>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2019 Aran Clary Deltac
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see L<http://www.gnu.org/licenses/>.
=cut
( run in 1.450 second using v1.01-cache-2.11-cpan-5735350b133 )