epson_connect package¶
Submodules¶
epson_connect.authenticate module¶
- exception epson_connect.authenticate.ApiError[source]¶
Bases:
RuntimeErrorGeneral error raised for any API errors after authentication has succeeded. This can include bad requests, server errors, etc.
- class epson_connect.authenticate.AuthCtx(base_url, printer_email, client_id, client_secret)[source]¶
Bases:
objectAuthentication context for the printer API.
This class manages authentication to the API by obtaining and refreshing access tokens as required.
- property default_headers¶
Default headers for the API requests.
This includes the current access token for authentication.
- Returns:
Dictionary of default headers.
- property device_id¶
Get the device (printer) ID from the current session.
- Returns:
Device ID (subject_id from the authentication response).
- send(method, path, data=None, json=None, headers=None, auth=None)[source]¶
Send a request to the API.
- Parameters:
method – HTTP method (e.g., GET, POST).
path – API path.
data – Data payload for the request.
json – JSON payload for the request.
headers – HTTP headers.
auth – Authentication object.
- Return type:
dict- Returns:
Dictionary containing the response.
epson_connect.client module¶
- class epson_connect.client.Client(base_url='', printer_email='', client_id='', client_secret='')[source]¶
Bases:
objectClient for the Epson Connect API.
This class provides a higher-level interface to interact with the Epson Connect services, including authentication, printer management, and scanning operations.
- EC_BASE_URL = 'https://api.epsonconnect.com'¶
- deauthenticate()[source]¶
De-authenticate from the Epson Connect API.
This method ends the current session and invalidates the access token.
- property printer¶
Get the Printer interface for the current session.
- Returns:
An instance of the Printer class.
- property scanner¶
Get the Scanner interface for the current session.
- Returns:
An instance of the Scanner class.
epson_connect.printer module¶
- class epson_connect.printer.Printer(auth_ctx)[source]¶
Bases:
objectPrinter class for managing print jobs in the Epson Connect API.
This class provides methods to handle printing, including file uploads, print job creation, fetching printer capabilities, and more.
- VALID_EXTENSIONS = {'bmp', 'doc', 'docx', 'gif', 'jpeg', 'jpg', 'pdf', 'png', 'ppt', 'pptx', 'tiff', 'xls', 'xlsx'}¶
- VALID_OPERATORS = {'operator', 'user'}¶
- capabilities(mode)[source]¶
Fetch the device print capabilities based on the given mode.
- Parameters:
mode – The mode for which to fetch capabilities.
- Returns:
Dictionary containing device capabilities.
- property device_id¶
Retrieve the device ID associated with the current session.
- Returns:
Device ID.
- notification(callback_uri, enabled=True)[source]¶
Configure notifications for the print job status change.
- Parameters:
callback_uri – URI to which notifications should be sent.
enabled – Whether or not to enable notifications. Defaults to True.
- Returns:
Response from the API.
epson_connect.printer_settings module¶
- exception epson_connect.printer_settings.PrintSettingError[source]¶
Bases:
ValueErrorError raised for printer setting-specific exceptions.
This includes cases like invalid values, missing required settings, or mismatched configurations.
- epson_connect.printer_settings.merge_with_default_settings(settings=None)[source]¶
Merge the given settings with default printer settings.
This function will set defaults for any missing settings from the input. It also generates a random job name if one is not provided.
- Parameters:
settings – Dictionary containing printer settings.
- Returns:
Dictionary containing the merged settings.
- epson_connect.printer_settings.validate_settings(settings)[source]¶
Validate all parts of a settings object.
This function checks if the provided settings are valid and raises an error if they are not. Each setting is validated against pre-defined valid values or constraints.
- Parameters:
settings (
dict) – Dictionary containing printer settings.- Raises:
PrintSettingError – If any of the settings are invalid.
epson_connect.scanner module¶
- class epson_connect.scanner.Scanner(auth_ctx)[source]¶
Bases:
objectScanner class for managing scan destinations in the Epson Connect API.
This class provides methods to add, update, list, and remove scan destinations.
- VALID_DESTINATION_TYPES = {'mail', 'url'}¶
- add(name, destination, type_='mail')[source]¶
Register a new scan destination.
- Parameters:
name – Alias name for the scan destination.
destination – The actual destination (email or URL).
type – Type of the destination. Defaults to ‘mail’. Can be ‘mail’ or ‘url’.
- Returns:
Response dictionary containing details of the added destination.
- list()[source]¶
Retrieve a list of scan destinations.
- Returns:
A list of registered scan destinations.
- remove(id_)[source]¶
Remove a scan destination.
- Parameters:
id – ID of the scan destination to be removed.
- update(id_, name=None, destination=None, type_=None)[source]¶
Update an existing scan destination.
- Parameters:
id – ID of the scan destination to be updated.
name – New alias name for the scan destination.
destination – The new destination (email or URL).
type – New type of the destination. Can be ‘mail’ or ‘url’.
- Returns:
Response dictionary containing details of the updated destination.