Snapshots

Snapshots allow you to create a read-only archive of files at a specific point in time. You can define a snapshot, add files to it, and then finalize it. Once finalized, the snapshot’s contents are immutable.

Each snapshot may have an expiration date. When the expiration date is reached, the snapshot is automatically deleted from the Files.com platform.

List Snapshots

SDK Function

Snapshot.list()

Return Object

ListIterator<Snapshot>

Authorization Requirement

Available to all authenticated keys or sessions.

Additional Arguments

Example Request

import com.files.ListIterator;
import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.Snapshot;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  ListIterator<Snapshot> snapshots = Snapshot.list(parameters);
  for (Snapshot snapshot : snapshots.listAutoPaging()) {
    // Operate on snapshot
  }
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Show Snapshot

SDK Function

Snapshot.find()

Return Object

Snapshot

Authorization Requirement

Available to all authenticated keys or sessions.

Function Arguments

ArgumentDescription
id
int64
Required
Snapshot ID.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.Snapshot;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  Snapshot snapshot = Snapshot.find(id, parameters);
  // Operate on snapshot
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Create Snapshot

SDK Function

Snapshot.create()

Return Object

Snapshot

Authorization Requirement

Available to all authenticated keys or sessions.

Function Arguments

ArgumentDefaultDescription
expires_at
string
When the snapshot expires.
name
string
A name for the snapshot.
paths
array(string)
An array of paths to add to the snapshot.
workspace_id
int64
0Workspace ID. 0 means the default workspace.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.Snapshot;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("expires_at", "2000-01-01T01:00:00Z");
  
  Snapshot snapshot = Snapshot.create(parameters);
  // Operate on snapshot
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Finalize Snapshot

SDK Function

snapshot.finalize();

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.Snapshot;

try {
  // Find the snapshot object by its id.
  Snapshot snapshot = Snapshot.find(id, null);
  snapshot.finalize(null);
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Update Snapshot

SDK Function

snapshot.update();

Return Object

Snapshot

Authorization Requirement

Available to all authenticated keys or sessions.

Attribute Setters

SetterDescription
setExpiresAt
string
When the snapshot expires.
setName
string
A name for the snapshot.
setPaths
array(string)
An array of paths to add to the snapshot.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.Snapshot;

try {
  // Find the snapshot object by its id.
  Snapshot snapshot = Snapshot.find(id, null);
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("expires_at", "2000-01-01T01:00:00Z");
  snapshot.update(parameters);
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Delete Snapshot

SDK Function

snapshot.delete();

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.Snapshot;

try {
  // Find the snapshot object by its id.
  Snapshot snapshot = Snapshot.find(id, null);
  snapshot.delete(null);
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

The Snapshot Object

Some of the functions above return a Snapshot object. The attributes of this object are listed below.

AttributeDescription
id
int64
The snapshot's unique ID.
expires_at
date-time
When the snapshot expires.
finalized_at
date-time
When the snapshot was finalized.
name
string
A name for the snapshot.
user_id
int64
The user that created this snapshot, if applicable.
bundle_id
int64
The bundle using this snapshot, if applicable.
workspace_id
int64
Workspace ID. 0 means the default workspace.