API Reference

SWORD document types

class sword3common.ByReference(raw=None)

By-Reference Document

class sword3common.Error(raw=None)

Error Document

class sword3common.Metadata(raw=None)

Metadata Document

class sword3common.MetadataAndByReference(metadata: sword3common.Metadata, by_reference: sword3common.ByReference)

Metadata + By-Reference Document

class sword3common.SegmentedFileUpload(raw=None)

Segmented File Upload Document

class sword3common.ServiceDocument(raw=None)

Service Document

class sword3common.StatusDocument(raw=None)

Status Document

Exceptions

exception sword3common.exceptions.AmbiguousSwordException(*args, status_code: int, **kwargs)
exception sword3common.exceptions.AuthenticationFailed(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The request supplied invalid credentials, or no credentials, when the server was expecting to authenticate the request.

exception sword3common.exceptions.BadRequest(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The request did not meet the standard specified by the SWORD protocol. This error can be used when no other error is appropriate

exception sword3common.exceptions.ByReferenceFileSizeExceeded(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client supplied a By-Reference deposit file, which specified a file size which exceeded the server’s limit

exception sword3common.exceptions.ByReferenceNotAllowed(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client attempted to carry out a By-Reference deposit on a server which does not support it

exception sword3common.exceptions.ContentMalformed(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The body content of the request was malformed in some way, such that the server cannot read it correctly.

exception sword3common.exceptions.ContentTypeNotAcceptable(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The Content-Type header specifies a content type of the request which is in a format that the server cannot accept.

exception sword3common.exceptions.DigestMismatch(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

One or more of the Digests that the server checked did not match the deposited content

exception sword3common.exceptions.ETagNotMatched(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client supplied an If-Match header which did not match the current ETag for the resource being updated.

exception sword3common.exceptions.ETagRequired(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client did not supply an If-Match header, when one was required by the server

exception sword3common.exceptions.FormatHeaderMismatch(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The Metadata-Format or Packaging header does not match what the server found when looking at the Metadata or Packaged Content supplied in a request.

exception sword3common.exceptions.Gone(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The resource used to exist at the given URL, but has been removed.

exception sword3common.exceptions.InvalidDataFromServer(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)
exception sword3common.exceptions.InvalidSegmentSize(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client sent a segment that was not the final segment, and was not the size that it indicated segments would be

exception sword3common.exceptions.MaxAssembledSizeExceeded(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

During a segmented upload initialisation, the client specified a total file size which is larger than the maximum assembled file size supported by the server

exception sword3common.exceptions.MaxUploadSizeExceeded(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The request supplied body content which is larger than that supported by the server.

exception sword3common.exceptions.MetadataFormatNotAcceptable(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The Metadata-Format header specifies a metadata format for the request which is in a format that the server cannot accept

exception sword3common.exceptions.MethodNotAllowed(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The request is for a method on a resource that is not permitted. This may be permanent, temporary, and may depend on the client’s credentials

exception sword3common.exceptions.NoCredentialsSupplied(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The request did not supply credentials, when the server was expecting to authenticate the request.

exception sword3common.exceptions.NotFound(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The resource could not be found

exception sword3common.exceptions.OnBehalfOfNotAllowed(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The request contained an On-Behalf-Of header, although the server indicates that it does not support this.

exception sword3common.exceptions.PackagingFormatNotAcceptable(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The Packaging header specifies a packaging format for the request which is in a format that the server cannot accept

exception sword3common.exceptions.SegmentLimitExceeded(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

During a segmented upload initialisation, the client specified a total number of intended segments which is larger than the limit specified by the server

exception sword3common.exceptions.SegmentedUploadNotAllowed(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client attempted to carry out a Segmented Upload on a server which does not support it

exception sword3common.exceptions.SegmentedUploadTimedOut(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client’s segmented upload URL has timed out. Servers MAY respond to this with a 404 and no explanation also.

exception sword3common.exceptions.SwordException(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)
name = None

str

reason = None

str

status_code = None

int

exception sword3common.exceptions.UnexpectedSegment(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The client sent a segment that the server was not expecting; in particular the server may have recieved all the segments it was expecting, and this is an extra one

exception sword3common.exceptions.UnexpectedSwordException(*args, status_code: int, name: Optional[str], **kwargs)
exception sword3common.exceptions.ValidationFailed(message: Optional[str] = None, *, response=None, error_doc=None, request_url=None)

The server could not validate the structure of the incoming content against its expected schema. This may include the JSON schema of the SWORD documents, the metadata held within those documents, or the expected structure of packaged content.

Constants

JSON-LD context

sword3common.constants.JSON_LD_CONTEXT = 'https://swordapp.github.io/swordv3/swordv3.jsonld'

The JSON-LD context for the SWORDv3 protocol

Packaging formats

sword3common.constants.PACKAGE_BINARY = 'http://purl.org/net/sword/3.0/package/Binary'

The URI for the Binary packaging format

sword3common.constants.PACKAGE_SWORDBAGIT = 'http://purl.org/net/sword/3.0/package/SWORDBagIt'

The URI for the SWORDBagIt packaging format

sword3common.constants.PACKAGE_SIMPLEZIP = 'http://purl.org/net/sword/3.0/package/SimpleZip'

The URI for the SimpleZip packaging format