Paws XXVIII (Just one More )
Seems I lied in my last post when I said there where no longer any boto changes for my S3 fixes. There is still one call 'GetBucketLocation' that is using a new bit I added to boto
"keep_root":true
I stumbled upon this when I added in a few fixed cases from another branch and when I ran the suite I
got;
ok 10052 - Call S3->GetBucketLocation from t/10_responses/s3-get-bucket-location.response not ok 10053 - Can't test method access because something went horribly wrong in the call to GetBucketLocation # TODO t/10_responses/s3-get-bucket-location.response.test.yml
My present output of the call is
bless( {
'_request_id' => '12ED5FF5251C27CC'
}, 'Paws::S3::GetBucketLocationOutput' );
So I am missing the 'LocationConstraint' on the return object again and I know fixed that in an earlier post.
Looking at my past posts I think I never checked it in and must of lost the patch someplace when I remembered, after re-reading XVI, that I had checked that 'keep_root' fix in on another branch https://github.com/byterock/aws-sdk-perl/commit/7c492ffb8c21955313b0d5865f67805b57a75f8c
I really want to get rid of this boto change and the change in RestXMLResponse.pm as we. So I went back to the original entry in boto;
"GetBucketLocationOutput":{
"type":"structure",
"members":{
"LocationConstraint":{
"shape":"BucketLocationConstraint",
"documentation":"lt&;p/>",
}
}
},
Unfortunately this did not not help much as that only gives us this generated class;
package Paws::S3::GetBucketLocationOutput;
use Moose;
has LocationConstraint => (is => 'ro', isa => 'Str');
has _request_id => (is => 'ro', isa => 'Str');
with nothing special on the 'LocationConstraint' that we could use with on our perl side to get that 'content' out of the this parsed data
{
'content' => 'eu-west-2',
'xmlns' => 'http://s3.amazonaws.com/doc/2006-03-01/'
};
and into my class.
I eventually narrowed down where I have to change my code in RestXMLRespone.pm and that is in the 'new_from_result_struct' sub where I have to link up that 'content' coming from my response to a attribute on my outgoing class.
Then I found this note in the sub
##########
# This loop is required to guard against cases (such as Paws::S3::CopyObject) where
# the root node is removed from the response when unserialising (see KeepRoot => 1 for
# XML::Simple) but is required to create the Paws object. This is mostly due to the
# implementation of the new_from_result_struct sub
my $att_class = $att_type->class;
eval {
$args{ $att } = $self->new_from_result_struct($att_class, $result);
1;
} or do {}
Ok so someone else has run into it. Close to my bug but in this case my 'root node' is a just a string under the key content. I next figured out where the code drops out on a String value;
}
else {
if (defined $value) {
if ($att_type eq 'Bool') {
if ($value eq 'true') {
$args{ $att } = 1;
} elsif ($value eq 'false') {
$args{ $att } = 0;
} elsif ($value == 1) {
$args{ $att } = 1;
} else {
$args{ $att } = 0;
}
} else {
$args{ $att } = $value;
}
}
So all I need to do is this;
} else {
-- $args{ $att } = $value;
++ } elsif (!$class->does('_payload') and exists($result->{content}) and $result->{content})
++ {
++ $args{ $att } = $result->{content};
++ }
++ }
I do a check to make sure this class does not have a payload and that the content key exists and has a value then I just set that key in the $args hash to the value from the content key on the $result hash-ref and when I run the test suite again I get
All tests successfully
Yeah another boto change removed So I guess I have to axe (guillotine) my change in PAWs XVI.
Leave a comment