Paws for Fun and Profit. The III

I left off on my last post with a little patch to do. To recap I successfully restored an S3 file that was on 'Glacier' back into 'S3' with the Paws::S3 RestoreObject command.

There was one little point and that was in the AWS S3 API documents I found this

+------+-----------------------------------------+------------+
| Name |         Description                     | Required   |
+------+-----------------------------------------+------------+
|      | Lifetime of the restored (active) copy. |            | 
|      | The minimum number of days that you can |            |
|      | restore an object from Glacier is 1.    |            |
|      | After the object copy reaches the       |            |
|      | specified lifetime, Amazon S3 removes   |            |
|      | it from the bucket. If you are          |            |
|      | restoring an archive,this element       | Yes, if    |
| Days | is required.                            | restoring  |
|      | Do not use this element with a SELECT   | an archive |
|      | type of request.                        |            |     
|      |                                         |            |
|      | Type: Positive integer                  |            |
|      |                                         |            |
|      | Ancestors: RestoreRequest               |            |
+------+-----------------------------------------+------------+

And then checking the POD I found this

...
 RestoreRequest => {
    Days                 => 1,                  # OPTIONAL
…

So I would like to change that a bit so someone else coming along will not fall into the same trap I just did; but where to do it??
Now we are getting into the 'Data' side of the code. This is the Json database that that are used to generate the Paws classes. The problem is how to work on it.
The botocore code used by Paws is our own special branch that deviates a little from the master botocore code. The only code we worry about in this repo is the Json data found in this dir botocore/botocore/data/
The file I want to change is 'botocore/botocore/data/s3/2006-03-01/service-2.json'
and when I look in the file I will find 'RestoreObject' entry


"RestoreObject":{
"name":"RestoreObject",
"http":{
"method":"POST",
"requestUri":"/{Bucket}/{Key+}?restore"
},
"input":{"shape":"RestoreObjectRequest"}, 
"output":{"shape":"RestoreObjectOutput"},
"errors":[
{"shape":"ObjectAlreadyInActiveTierError"}
],
"documentationUrl":"http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectRestore.html",
"documentation":"<p>Restores an archived copy of an object back into Amazon S3</p>",
"alias":"PostObjectRestore"
}, 

In the above you can see where the properties of this call are coming from; for example
if one looks at the POD for Paws::S3 you will see the 'documentation' property used.

RestoreObject
Bucket => Str 
…
Restores an archived copy of an object back into Amazon S3

I am not interested in this block of Json but it does lead me to what I should look at which is the 'input' attribute. It says 'RestoreObjectRequest' and a search on this I found an entry for it further along in the service-2.json file'.


"RestoreObjectRequest":{
      "type":"structure",
      "required":[
        "Bucket",
        "Key"
      ],
      "members":{
        "Bucket":{
          "shape":"BucketName",
          "documentation":"<p/>",
          "location":"uri",
          "locationName":"Bucket"
        },
...
        "RestoreRequest":{
          "shape":"RestoreRequest",
          "documentation":"<p/>",
          "locationName":"RestoreRequest",
          "xmlNamespace":{"uri":"http://s3.amazonaws.com/doc/2006-03-01/"}
...

Now we get into a little of the auto code you can see both 'Bucket', and 'Key' in the 'required:' property array. One would think I could just add in 'Days' here to make it required but that would be a mistake as the attribute is on the 'RestoreRequest' attribute. I have to dig a little deeper search this time on the 'shape' attribute 'RestoreRequest'.

Further into the the service-2.json file I find


...
 "RestoreRequest":{
      "type":"structure",
      "members":{
        "Days":{
          "shape":"Days",
          "documentation":"<p>Lifetime of the active copy in days. Do not use with restores that specify OutputLocation.</p>"
        },
"GlacierJobParameters":{
…

and there I see my 'Days' attribute with its 'documentation' attribute. So a quick change to that


--"documentation":"<p>Lifetime of the active copy in days. Do not use with restores that specify OutputLocation.</p>"

++"documentation":"<p>Lifetime of the active copy in days. Do not use with restores that specify OutputLocation.<p></p>Required if doing a restore. Do not use when doing a SELECT request.</p>"

Now how to get this back into our version of botocore?

First thing I have to is remove the botocore dir from my aws-sdk-perl working dir, I might want it later so I just rename it


mv  botocore   botocore_hold

Now first I have to do the usual and create a branch of my working copy on my repository of the Paws boto repo called 's3-changes' and then clone my repo copy into my 'aws-sdk-perl' dir


 git clone https://github.com/byterock/botocore.git

then switch to my branch


 git checkout s3-changes

then just make the change in the file. Now I just do a recompile


carton exec builder-bin/gen_classes.pl --classes botocore/botocore/data/s3/2006-03-01/service-2.json

and now I should see my changes is the POD of the RestoreRequest class which is in this file auto-lib/Paws/S3/RestoreRequest.pm



=head2 Days => Int

Lifetime of the active copy in days. Do not use with restores that
specify OutputLocation.

Required if doing a restore. Do not use when doing a SELECT request.

and the change is there. Great.

Now that that is set up I will have to be careful not to run 'make pull-other-sdks'
again or else I will overwrite my changes. Now just to check it in and a days work done.

23d4481db2c5dadec981d9af241889af.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