API Reference

class sword3client.SWORD3Client(http: sword3client.connection.HttpLayer = None)

The SWORDv3 client. You can carry out all protocol operations against the server through this class

abort_segmented_upload(temporary_url: str)sword3client.SWORDResponse

Abort the segmented upload. After this you will need to initialise again if you wish to try again

add_binary(status_or_object_url: Union[sword3common.StatusDocument, str], binary_stream: IO, filename: str, digest: Dict[str, str], content_length: int = None, content_type: str = None, in_progress: bool = False)sword3client.SWORDResponse

Add a plain binary file to the object

add_package(status_or_object_url: Union[sword3common.StatusDocument, str], binary_stream: IO, filename: str, digest: Dict[str, str], content_length: int = None, content_type: str = None, packaging: str = None, in_progress: bool = False)sword3client.SWORDResponse

add a package of files and metadata to the object

append_by_reference(status_or_object_url: Union[sword3common.ServiceDocument, str], by_reference: sword3common.ByReference, digest: Dict[str, str] = None, in_progress: bool = False)sword3client.SWORDResponse

Append one or more files to the object By-Reference

append_metadata(status_or_object_url: Union[sword3common.ServiceDocument, str], metadata: sword3common.Metadata, digest: Dict[str, str] = None, metadata_format: str = None, in_progress: bool = False)sword3client.SWORDResponse

Append the supplied metadata to the existing metadata on the object

append_metadata_and_by_reference(status_or_object_url: Union[sword3common.ServiceDocument, str], metadata_and_by_reference: sword3common.MetadataAndByReference, digest: Dict[str, str] = None, metadata_format: str = None, in_progress: bool = False)sword3client.SWORDResponse

Append both metadata and one or more By-Reference files to the existing metadata and file content of the object

append_temporary_file(status_or_object_url: Union[sword3common.ServiceDocument, str], temporary_url: str, filename: str, content_type: str, content_length: int = None, packaging: str = None, digest: Dict[str, str] = None, in_progress: bool = False)sword3client.SWORDResponse

Append to the object a file at a Temporary-URL obtained via Segmented Upload

create_object_by_reference(service: Union[sword3common.ServiceDocument, str], by_reference: sword3common.ByReference, digest: Dict[str, str] = None, in_progress: bool = False)sword3client.SWORDResponse

Create a new object with one or more By-Reference files

create_object_with_binary(service: Union[sword3common.ServiceDocument, str], binary_stream: IO, filename: str, digest: Dict[str, str], content_length: int = None, content_type: str = None, in_progress: bool = False)sword3client.SWORDResponse

Create an object with a plain binary file (not a package)

create_object_with_metadata(service: Union[sword3common.ServiceDocument, str], metadata: sword3common.Metadata, digest: Dict[str, str] = None, metadata_format: str = None, in_progress: bool = False)sword3client.SWORDResponse

Create a new object using only metadata

create_object_with_metadata_and_by_reference(service: Union[sword3common.ServiceDocument, str], metadata_and_by_reference: sword3common.MetadataAndByReference, digest: Dict[str, str] = None, metadata_format: str = None, in_progress: bool = False)sword3client.SWORDResponse

Create a new object with default sword metadata and one or more By-Reference files

create_object_with_package(service: Union[sword3common.ServiceDocument, str], binary_stream: IO, filename: str, digest: Dict[str, str], content_length: int = None, content_type: str = None, packaging: str = None, in_progress: bool = False)sword3client.SWORDResponse

Create an object using a package of files and metadata

create_object_with_temporary_file(service: Union[sword3common.ServiceDocument, str], temporary_url: str, filename: str, content_type: str, content_length: int = None, packaging: str = None, digest: Dict[str, str] = None, in_progress: bool = False)sword3client.SWORDResponse

Create an object using a Temporary URL obtained via Segmented Upload

delete_file(file_url: str)

Delete a single binary file

delete_fileset(status_or_fileset_url: Union[sword3common.StatusDocument, str])sword3client.SWORDResponse

Delete all of the files in the FileSet. All other files in the fileset may be lost (not all files the server holds may be in the fileset). Metadata will persist.

delete_metadata(status_or_metadata_url: Union[sword3common.ServiceDocument, str])sword3client.SWORDResponse

Delete all the metadata from the object

delete_object(sword_object: Union[sword3common.StatusDocument, str])sword3client.SWORDResponse

Delete the entire object

get_file(file_url: str)

Obtain a stream-like object to access the content of a file at the given file URL

get_metadata(status_or_metadata_url: Union[sword3common.StatusDocument, str])sword3common.Metadata

Retrieve the default sword metadata for this object

get_object(sword_object: Union[sword3common.StatusDocument, str])sword3common.StatusDocument

“Retrieve a current-state representation of the object as a Status Document

get_service(service_url: str)sword3common.ServiceDocument

Retrieves the SWORD service document for a given URL.

Raises

SwordException

initialise_segmented_upload(service: Union[sword3common.ServiceDocument, str], assembled_size: int, segment_count: int, segment_size: int, digest: Dict[str, str] = None)sword3client.SWORDResponse

Initialise the process of uploading a large file via segmented upload

replace_file(file_url: str, binary_stream: IO, content_type: str, digest: Dict[str, str], filename: str = 'untitled', content_length: int = None)

Replace a single binary file with a new binary file

replace_file_by_reference(file_url: str, by_reference: sword3common.ByReference, digest: Dict[str, str] = None)

Replace a single binary file with a single By-Reference file

replace_file_with_temporary_file(file_url: str, temporary_url: str, filename: str, content_type: str, content_length: int = None, digest: Dict[str, str] = None)sword3client.SWORDResponse

Replace a single binary file with a file at a Temporary URL obtained via Staged Upload

replace_fileset_by_reference(status_or_fileset_url: Union[sword3common.StatusDocument, str], by_reference: sword3common.ByReference, digest: Dict[str, str] = None)sword3client.SWORDResponse

Replace the entire FileSet with one or more By-Reference files. All other files in the fileset may be lost (not all files the server holds may be in the fileset). Metadata will persist.

replace_fileset_with_binary(status_or_fileset_url: Union[sword3common.StatusDocument, str], binary_stream: IO, filename: str, digest: Dict[str, str], content_length: int = None, content_type: str = None)sword3client.SWORDResponse

Replace the entire FileSet with a single binary file. All other files in the fileset may be lost (not all files the server holds may be in the fileset). Metadata will persist.

replace_fileset_with_temporary_file(status_or_fileset_url: Union[sword3common.StatusDocument, str], temporary_url: str, filename: str, content_type: str, content_length: int = None, digest: Dict[str, str] = None)sword3client.SWORDResponse

Replace the entire FileSet with a single file at a Temporary URL obtained by Segmented Upload. All other files in the fileset may be lost (not all files the server holds may be in the fileset). Metadata will persist.

replace_metadata(status_or_metadata_url: Union[sword3common.ServiceDocument, str], metadata: sword3common.Metadata, digest: Dict[str, str] = None, metadata_format: str = None)sword3client.SWORDResponse

Replace all of the current metadata on the object with the new metadata

replace_object_by_reference(status_or_object_url: Union[sword3common.StatusDocument, str], by_reference: sword3common.ByReference, digest: Dict[str, str] = None, in_progress: bool = False)sword3client.SWORDResponse
replace_object_with_binary(status_or_object_url: Union[sword3common.StatusDocument, str], binary_stream: IO, filename: str, digest: Dict[str, str], content_length: int = None, content_type: str = None, in_progress: bool = False)sword3client.SWORDResponse

Replace the entire object with a single binary file (not a package). All other content in the object may be lost

replace_object_with_metadata(status_or_object_url: Union[sword3common.StatusDocument, str], metadata: sword3common.Metadata, digest: Dict[str, str] = None, metadata_format: str = None, in_progress: bool = False)sword3client.SWORDResponse

Replace the entirity of the object with just new metadata. All other content contained in the object may be lost.

replace_object_with_metadata_and_by_reference(status_or_object_url: Union[sword3common.StatusDocument, str], metadata_and_by_reference: sword3common.MetadataAndByReference, digest: Dict[str, str] = None, metadata_format: str = None, in_progress: bool = False)sword3client.SWORDResponse

Replace the entire object with the metadata and one or more By-Reference files. All other content of the object may be lost

replace_object_with_package(status_or_object_url: Union[sword3common.StatusDocument, str], binary_stream: IO, filename: str, digest: Dict[str, str], content_length: int = None, content_type: str = None, packaging: str = None, in_progress: bool = False)sword3client.SWORDResponse

Replace the entire object with a single package of files and metadata. All other content in the object may be lost

replace_object_with_temporary_file(status_or_object_url: Union[sword3common.StatusDocument, str], temporary_url: str, filename: str, content_type: str, content_length: int = None, packaging: str = None, digest: Dict[str, str] = None, in_progress: bool = False)sword3client.SWORDResponse

Replace the entire object with a file at a Temporary URL obtained via Segmented Upload. All other content on the object may be lost

segmented_upload_status(temporary_url: str)sword3common.SegmentedFileUpload

Get a status report on the state of your segmented upload

set_http_layer(http)

Set the HTTP layer after construction. Can be switched at any time during operation.

upload_file_segment(temporary_url: str, binary_stream: IO, segment_number: int, digest: Dict[str, str] = None, content_length: int = None)sword3client.SWORDResponse

Upload a single segment of a large file to the Temporary URL

class sword3client.SWORDResponse(http_response)

Class to wrap the HTTP response for a SWORD request, to give you some convenient semantic APIs

property location

Get the location of the resource created by the request operation that you issued

property status_code

HTTP status code of the response

property status_document

The Status Document object if present for this response