Paws XII (High Noon Dog)

In my last post I was just getting the last parts of my new 'Satus' attribute in place having only one more part to create and that is a new 'trait' in '/lib/Paws/API.pm'

I was thinking af starting by coping the present package;


package Paws::API::Attribute::Trait::NameInRequest;
  use Moose::Role;
  use Moose::Util;
  Moose::Util::meta_attribute_alias('NameInRequest');
  has request_name => (is => 'ro', isa => 'Str');

and just changing the 'Request' for 'Response'. However looking at the role I see it is also adding a 'request_name' attribute, which I do not need, this trait is used very specially in the code the name of AWS call.

So on second though I will need a new name for the that trait and perhaps how I work on it.

This time I start with a new trait;


package Paws::API::Attribute::Trait::ParamInResponse;
  use Moose::Role;
  use Moose::Util;
  Moose::Util::meta_attribute_alias('ParamInResponse');

which I based of 'Paws::API::Attribute::Trait::ParamInHeader'

So now a little back coding of the templates;


 [%- IF (shape.members.$param_name.locationName) %]
    [%- IF (shape.members.$param_name.location == 'header') %], traits => ['ParamInHeader'], header_name => '[% shape.members.$param_name.locationName %]'
++    [%- ELSIF (shape.members.$param_name.location == 'statusCode') %], traits => ['ParamInResponse'], response_name => '[% shape.members.$param_name.locationName %]'
    [%- ELSIF (shape.members.$param_name.location == 'headers') %], traits => ['ParamInHeaders'], header_prefix => '[% shape.members.$param_name.locationName %]'
    [%- ELSIF (shape.members.$param_name.location == 'querystring') %], traits => ['ParamInQuery'], query_name => '[% shape.members.$param_name.locationName -%]'
    [%- ELSIF (shape.members.$param_name.location ==        'uri') %], traits => ['ParamInURI']    , uri_name     => '[% shape.members.$param_name.locationName -%]'
--    [%- ELSIF (shape.members.$param_name.location == 'statusCode') %], traits => ['NameInResponse'], reponse_name => '[% shape.members.$param_name.locationName %]'
    [%- ELSE %],     

and with another compile I get


has Status => (is => 'ro', isa => 'Int', traits => ['ParamInResponse'], response_name => 'status');

Now how about a test for the above? I can just change those three test I had before like like this

path: _status - path: Status op: eq expected: 202

and of unfortunately I get this

Found unknown argument 'response_name' in the has declaration for 'Status' in class Paws::S3::RestoreObjectOutput at /wwwveh/lib/x86_64-linux-thread-multi/Moose/Meta /Attribute.pm line 87.

Now I haven't linked that code change back into any of my classed in 'lib/Paws/Net' but I did not expect that type of error. After playing around a bit I think I have to add in that 'response_name' back into my role;


package Paws::API::Attribute::Trait::ParamInResponse;
  use Moose::Role;
  use Moose::Util;
  Moose::Util::meta_attribute_alias('ParamInResponse');
++  has response_name => (is => 'ro', isa => 'Str');

and now I just get

# Failed test 'Got Status eq 202 from result' # at t/10_responses.t line 136. # got: undef # expected: '202'

I can add in the needed code in this case 'RestXMLResponse.pm' in the same way the other params go in, but that is another story.

doge1.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations