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 Method

files_sdk.snapshot.list()

Return Object

ListObj[Snapshot]

Authorization Requirement

Available to all authenticated keys or sessions.

Additional Arguments

Example Request

import files_sdk

try:
  snapshots = files_sdk.snapshot.list()
  for snapshot in snapshots.auto_paging_iter():
    # Operate on snapshot
except files_sdk.error.NotAuthenticatedError as err:
  print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
  print(f"Unknown Error Occurred ({type(err).__name__}):", err)

Show Snapshot

SDK Method

files_sdk.snapshot.find()

Return Object

Snapshot

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
id
int64
Required
Snapshot ID.

Example Request

import files_sdk

try:
  snapshot = files_sdk.snapshot.find(id)
  # Operate on snapshot
except files_sdk.error.NotAuthenticatedError as err:
  print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
  print(f"Unknown Error Occurred ({type(err).__name__}):", err)

Create Snapshot

SDK Method

files_sdk.snapshot.create()

Return Object

Snapshot

Authorization Requirement

Available to all authenticated keys or sessions.

Method 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 files_sdk

try:
  snapshot = files_sdk.snapshot.create({
    "expires_at": "2000-01-01T01:00:00Z"
  })
  # Operate on snapshot
except files_sdk.error.NotAuthenticatedError as err:
  print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
  print(f"Unknown Error Occurred ({type(err).__name__}):", err)

Finalize Snapshot

SDK Method

snapshot.finalize()

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

Example Request

import files_sdk

try:
  # Find the snapshot object by its id.
  snapshot = files_sdk.snapshot.find(id)
  snapshot.finalize()
except files_sdk.error.NotAuthenticatedError as err:
  print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
  print(f"Unknown Error Occurred ({type(err).__name__}):", err)

Update Snapshot

SDK Method

snapshot.update()

Return Object

Snapshot

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
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.

Example Request

import files_sdk

try:
  # Find the snapshot object by its id.
  snapshot = files_sdk.snapshot.find(id)
  snapshot.update({
    "expires_at": "2000-01-01T01:00:00Z"
  })
except files_sdk.error.NotAuthenticatedError as err:
  print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
  print(f"Unknown Error Occurred ({type(err).__name__}):", err)

Delete Snapshot

SDK Method

snapshot.delete()

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

Example Request

import files_sdk

try:
  # Find the snapshot object by its id.
  snapshot = files_sdk.snapshot.find(id)
  snapshot.delete()
except files_sdk.error.NotAuthenticatedError as err:
  print(f"Authentication Error Occurred ({type(err).__name__}):", err)
except files_sdk.error.Error as err:
  print(f"Unknown Error Occurred ({type(err).__name__}):", err)

The Snapshot Object

Some of the methods 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.