Take a Temporary Snapshot and Save Separately
With this pattern, you create a temporary snapshot when you run a mashable or mashup and choose to save it permanently in a separate request.
Note: | Temporary snapshots must be saved within 25 minutes of their capture. After that, the Presto Server discards the temporary snapshot. |
You use the Presto REST URL to run the mashable or mashup, but include only the x-p-enableSnapshot Presto header. For example:
http://app-server:port/presto/edge/api/rest/service/operation?service-params-if-any&x-p-enableSnapshot=true
Add input parameters to the URL or a request body, as needed, plus any other
Presto headers you need. You can find the REST API URL for any mashables or mashup in the Technical Specs tab on its artifact page. See
Use Mashable/Mashup Technical Specs for more information.
Presto assigns a snapshot ID to the temporary snapshot and returns this ID in the snapshotToken HTTP header of the response, such as this example:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
...
cache-control: private, max-age=1200
serviceURL: http://localhost:8080/presto/edge/api/rest/YahooWeatherREST/getData?p%3D94572
snapshotToken: 7ac5fe05-2e67-11e0-952d-adff03bd533b
...
When you are sure you want to save this as a permanent snapshot, send an HTTP POST request to this URL:
http://app-server:port/presto/edge/api/rest/snapshot
Use the following POST body with the snapshot ID returned when the snapshot was taken and the appropriate metadata for this snapshot.
POST Body
<snapshot xmlns="http://www.jackbe.com/2009-08-01/snapshot"
id="a2da57e1-2a60-11e0-9f1b-69cef3c615e5">
<name>mySnapshot</name>
<service>mashableA</service>
<operation>operationName</operation>
<createdby>userA</createdby>
<description>Snapshot of some kind of data...</description>
<tags>
<tag>tag1</tag>
<tag>tag2</tag>
<tag>tag3</tag>
</tags>
</snapshot>