Search code examples
amazon-glacier

Amazon Glacier PHP and Jobs


I am trying to delete my archive in Amazon Glacier. I'm doing it via PHP with PHP SDK2. I have a little problem.. I've launched job to get ArchiveID:

$this->client->initiateJob(array(
     'accountId' => '-',
     'vaultName' => $aValutName,
     'Type' => "inventory-retrieval")
);

after a couple of hours a can see that job has finished, so I am trying to get job's using it's ID:

   $res = $this->client->getJobOutput(array(
        'accountId' => '-',
        'vaultName' => $aValutName,
        'jobId' => $aJobID,
    ));

and as a respons I am given such things:

Guzzle\Service\Resource\Model Object
(
    [structure:protected] => 
    [data:protected] => Array
        (
            [body] => Guzzle\Http\EntityBody Object
                (
                    [contentEncoding:protected] => 
                    [rewindFunction:protected] => 
                    [stream:protected] => Resource id #152
                    [size:protected] => 
                    [cache:protected] => Array
                        (
                            [wrapper_type] => PHP
                            [stream_type] => TEMP
                            [mode] => w+b
                            [unread_bytes] => 0
                            [seekable] => 1
                            [uri] => php://temp
                            [is_local] => 1
                            [is_readable] => 1
                            [is_writable] => 1
                        )

                    [customData:protected] => Array
                        (
                            [default] => 1
                        )

                )

            [checksum] => 
            [status] => 200
            [contentRange] => 
            [acceptRanges] => bytes
            [contentType] => application/json
            [archiveDescription] => 
        )

)

Has enybody idea why "archiveDescription" is empty?

Maybe there is another way to obtain ArchiveID so I would be able to delete my archive....

Thanx for any help ;D

MK.


Solution

  • OK, the solution was too easy...

    public function getJobResult($aValutName, $aJobID) {
        $res = $this->client->getJobOutput(array(
            'accountId' => '-',
            'vaultName' => $aValutName,
            'jobId' => $aJobID,
        ));
        $body = EntityBody::factory($res['body']);
        $body->rewind();
        $inventory = stream_get_contents($body->getStream());
        $ArchiveList = json_decode($inventory,1)['ArchiveList'];
        $res = array();
        foreach($ArchiveList as $archive):
            $res[]=$archive['ArchiveId'];
        endforeach;
    
    
        return $res;
    }