Skip to main content

Secure Share | Python SDK

Initializes a new Pangea service client.

Share(token, config, logger_name)

required parameters

str

Pangea API token.

optional parameters

PangeaConfig | None

Configuration.

str

Logger name.

Buckets

Share.buckets()

Get information on the accessible buckets.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.buckets()

Delete

Share.delete(id, force, bucket_id)

Delete object by ID or path. If both are supplied, the path must match that of the object represented by the ID.

optional parameters

str

The ID of the object to delete.

bool

If true, delete a folder even if it's not empty.

str

The bucket to use, if not the default.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.delete(id="pos_3djfmzg2db4c6donarecbyv5begtj2bm")

download-file

Share.download_file()

Create a folder

Share.folder_create(name, metadata, parent_id, folder, tags, bucket_id)

Create a folder, either by name or path and parent_id.

optional parameters

str

The name of an object.

Metadata

A set of string-based key/value pairs used to provide additional data about an object.

str

The ID of a stored object.

str

The folder to place the folder in. Must match parent_id if also set.

Tags

A list of user-defined tags.

str

The bucket to use, if not the default.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.folder_create(
    metadata={
        "created_by": "jim",
        "priority": "medium",
    },
    parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
    folder="/",
    tags=["irs_2023", "personal"],
)

Get an object

Share.get(id, transfer_method, bucket_id, password)

Get object. If both ID and Path are supplied, the call will fail if the target object doesn't match both properties.

optional parameters

str

The ID of the object to retrieve.

TransferMethod

The requested transfer method for the file data.

str

The bucket to use, if not the default.

str

If the file was protected with a password, the password to decrypt with.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.get(
    id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
    folder="/",
)

Get archive

Share.get_archive(ids, format, transfer_method, bucket_id)

Get an archive file of multiple objects.

optional parameters

List[str]

The IDs of the objects to include in the archive. Folders include all children.

ArchiveFormat

The format to use for the built archive.

TransferMethod

The requested transfer method for the file data.

str

The bucket to use, if not the default.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.get_archive(
    ids=["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
)

List

Share.list(filter, last, order, order_by, size, bucket_id)

List or filter/search records.

optional parameters

Union[Dict[str, str], FilterList]
str

Reflected value from a previous response to obtain the next page of results.

ItemOrder

Order results asc(ending) or desc(ending).

ItemOrderBy

Which field to order results by.

int

Maximum results to include in the response.

str

The bucket to use, if not the default.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.list()

Poll result

Share.poll_result(exception)

Returns request's result that has been accepted by the server

optional parameters

Optional[AcceptedRequestException]

Exception that was previously raised by the SDK on a call that is being processed.

Response Object

PangeaResponse

response = service.poll_result(exception)

Upload a file

Share.put(file, name, folder, format, metadata, mimetype, parent_id, tags, transfer_method, crc32c, md5, sha1, sha256, sha512, size, bucket_id, password, password_algorithm)

Upload a file.

required parameters

io.BufferedReader

optional parameters

str

The name of the object to store.

str

The path to the parent folder. Leave blank for the root folder. Path must resolve to parent_id if also set.

FileFormat

The format of the file, which will be verified by the server if provided. Uploads not matching the supplied format will be rejected.

Metadata

A set of string-based key/value pairs used to provide additional data about an object.

str

The MIME type of the file, which will be verified by the server if provided. Uploads not matching the supplied MIME type will be rejected.

str

The parent ID of the object (a folder). Leave blank to keep in the root folder.

Tags

A list of user-defined tags.

TransferMethod

The transfer method used to upload the file data.

str

The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.

str

The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.

str

The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.

str

The SHA256 hash of the file data, which will be verified by the server if provided.

str

The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.

str

The size (in bytes) of the file. If the upload doesn't match, the call will fail.

str

The bucket to use, if not the default.

str

An optional password to protect the file with. Downloading the file will require this password.

str

An optional password algorithm to protect the file with. See symmetric vault password_algorithm.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

try:
    with open("./path/to/file.pdf", "rb") as f:
        response = share.put(file=f)
        print(f"Response: {response.result}")
except pe.PangeaAPIException as e:
    print(f"Request Error: {e.response.summary}")
    for err in e.errors:
        print(f"\t{err.detail} \n")

Request upload URL

Share.request_upload_url(name, folder, format, metadata, mimetype, parent_id, tags, transfer_method, md5, sha1, sha512, crc32c, sha256, size, bucket_id)

Request an upload URL.

optional parameters

str

The name of the object to store.

str

The path to the parent folder. Leave blank for the root folder. Path must resolve to parent_id if also set.

FileFormat

The format of the file, which will be verified by the server if provided. Uploads not matching the supplied format will be rejected.

Metadata

A set of string-based key/value pairs used to provide additional data about an object.

str

The MIME type of the file, which will be verified by the server if provided. Uploads not matching the supplied MIME type will be rejected.

str

The parent ID of the object (a folder). Leave blank to keep in the root folder.

Tags

A list of user-defined tags.

TransferMethod

The transfer method used to upload the file data.

str

The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.

str

The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.

str

The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.

str

The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.

str

The SHA256 hash of the file data, which will be verified by the server if provided.

str

The size (in bytes) of the file. If the upload doesn't match, the call will fail.

str

The bucket to use, if not the default.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.request_upload_url(
    transfer_method=TransferMethod.POST_URL,
    crc32c="515f7c32",
    sha256="c0b56b1a154697f79d27d57a3a2aad4c93849aa2239cd23048fc6f45726271cc",
    size=222089,
    metadata={
        "created_by": "jim",
        "priority": "medium",
    },
    parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
    folder="/",
    tags=["irs_2023", "personal"],
)
Share.share_link_create(links, bucket_id)

Create a share link.

response = share.share_link_create(
    links=[
        {
            targets: ["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
            link_type: LinkType.DOWNLOAD,
            authenticators: [
                {
                    "auth_type": AuthenticatorType.PASSWORD,
                    "auth_context": "my_fav_Pa55word",
                }
            ],
        }
    ],
)
Share.share_link_delete(ids, bucket_id)

Delete share links.

response = share.share_link_delete(
    ids=["psl_3djfmzg2db4c6donarecbyv5begtj2bm"]
)
Share.share_link_get(id)

Get a share link.

response = share.share_link_get(
    id="psl_3djfmzg2db4c6donarecbyv5begtj2bm"
)
Share.share_link_list(filter, last, order, order_by, size, bucket_id)

Look up share links by filter options.

response = share.share_link_list()
Share.share_link_send(sender_email)

Send a secure share-link notification to a set of email addresses. The notification email will contain an Open button that the recipient can use to follow the secured share-link to authenticate and then access the shared content.

response = share.share_link_send(
    links=[ShareLinkSendItem(id=link.id, email="foo@example.org")],
    sender_email="sender@example.org",
)

Update a file

Share.update(id, path, add_metadata, remove_metadata, metadata, add_tags, remove_tags, tags, parent_id, updated_at, bucket_id)

Update a file.

optional parameters

str

An identifier for the file to update.

str

Set the parent (folder). Leave blank for the root folder. Path must resolve to parent_id if also set.

Metadata

A list of Metadata key/values to set in the object. If a provided key exists, the value will be replaced.

Metadata

A list of Metadata key/values to remove in the object. It is not an error for a provided key to not exist. If a provided key exists but doesn't match the provided value, it will not be removed.

Metadata

Set the object's Metadata.

Tags

A list of Tags to add. It is not an error to provide a tag which already exists.

Tags

A list of Tags to remove. It is not an error to provide a tag which is not present.

Tags

Set the object's Tags.

str

Set the parent (folder) of the object.

str

The date and time the object was last updated. If included, the update will fail if this doesn't match what's stored.

str

The bucket to use, if not the default.

Response Object

A PangeaResponse. Available response fields can be found in our API documentation.

response = share.update(
    id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
    remove_metadata={
        "created_by": "jim",
        "priority": "medium",
    },
    remove_tags=["irs_2023", "personal"],
)