Misc work-in-progress updates to pt-agent, Agent and Config resources. Config will change again. Make Client::put() return Location header like POST.

This commit is contained in:
Daniel Nichter
2013-02-13 13:45:52 -07:00
parent 50a82a4ef8
commit 0be24a3b8d
4 changed files with 216 additions and 423 deletions

View File

@@ -48,15 +48,15 @@ has 'api_key' => (
has 'entry_link' => (
is => 'rw',
isa => 'Str',
default => sub { return 'https://api.tools.percona.com' },
required => 0,
default => sub { return 'https://api.tools.percona.com' },
);
has 'ua' => (
is => 'rw',
isa => 'Object',
lazy => 1,
required => 1,
required => 0,
builder => '_build_ua',
);
@@ -166,12 +166,12 @@ sub post {
# For a successful PUT, the server returns nothing because the caller
# already has the resources URI (if not, the caller should POST).
sub put {
my $self = shift;
my ($self, %args) = @_;
$self->_set(
@_,
%args,
method => 'PUT',
);
return;
return $self->response->header('Location');
}
sub delete {

View File

@@ -22,10 +22,10 @@ package Percona::WebAPI::Resource::Agent;
use Lmo;
has 'id' => (
is => 'ro',
has 'uuid' => (
is => 'r0',
isa => 'Str',
required => 1,
required => 0,
);
has 'hostname' => (
@@ -34,6 +34,12 @@ has 'hostname' => (
required => 1,
);
has 'alias' => (
is => 'ro',
isa => 'Str',
required => 0,
);
has 'versions' => (
is => 'ro',
isa => 'Maybe[HashRef]',
@@ -47,6 +53,11 @@ has 'links' => (
default => sub { return {} },
);
sub name {
my ($self) = @_;
return $self->alias || $self->hostname || $self->uuid || 'Unknown';
}
no Lmo;
1;
}

View File

@@ -22,8 +22,8 @@ package Percona::WebAPI::Resource::Config;
use Lmo;
has 'id' => (
is => 'r0',
has 'config_id' => (
is => 'ro',
isa => 'Int',
required => 1,
);