Kubernetes-REST

 view release on metacpan or  search on metacpan

lib/Kubernetes/REST/HTTPRequest.pm  view on Meta::CPAN

package Kubernetes::REST::HTTPRequest;
our $VERSION = '1.104';
# ABSTRACT: HTTP request object
use Moo;
use Types::Standard qw/Str HashRef/;


has server => (is => 'ro');


has credentials => (is => 'ro');


sub authenticate {
    my $self = shift;
    my $auth = $self->credentials;
    if (defined $auth) {
      $self->headers->{ Authorization } = 'Bearer ' . $auth->token;
    }
}


has uri => (is => 'rw', isa => Str);


has method => (is => 'rw', isa => Str);


has url => (is => 'rw', isa => Str, lazy => 1, default => sub {
    my $self = shift;
    return $self->server->endpoint . $self->uri if $self->server;
    return '';
});


has headers => (is => 'rw', isa => HashRef, default => sub { {} });


has parameters => (is => 'rw', isa => HashRef);


has content => (is => 'rw', isa => Str);


1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Kubernetes::REST::HTTPRequest - HTTP request object

=head1 VERSION

version 1.104

=head1 SYNOPSIS

    use Kubernetes::REST::HTTPRequest;

    my $req = Kubernetes::REST::HTTPRequest->new(
        method => 'GET',
        url => 'https://kubernetes.local:6443/api/v1/pods',
        headers => { 'Authorization' => 'Bearer token' },
    );

=head1 DESCRIPTION

Internal HTTP request object used by L<Kubernetes::REST>.

=head2 server

Optional. L<Kubernetes::REST::Server> instance for building the full URL.

=head2 credentials

Optional. L<Kubernetes::REST::AuthToken> instance for authentication.

=head2 authenticate

Add authentication header from the C<credentials> attribute.

=head2 uri

The URI path (e.g., C</api/v1/pods>).

=head2 method



( run in 1.908 second using v1.01-cache-2.11-cpan-d7f47b0818f )