Skip to main content

A simple Python Sympa API

Project description

Small wrapper that uses ZEEP to communicate with a SOAP endpoint linked to a Sympa server, to let automation in lists creation.

Example

Start by creating a new client, and log in. Then, you can use some pre-constructed methods.

from sympasoap import Client

client = Client("https://lists.example.com/sympa")
client.login("admin@example.com", "MY_STRONG_PASSWORD")     # Get from env

# Create a list of type hotline that is named automatically-created@lists.example.com with basic description
client.create_list(list_name="automatically-created", subject="Automatically created list", template="hotline",
        description="This mailing list was created from a Python shell.", topic="computers/software")

# Subscribe the email address toto@example.com with name "Toto TOTO" to the list automatically-created@lists.example.com
# in non-quiet mode: the user will receive a notification that they got subscribed
client.subscribe(email="toto@example.com", list_address="automatically-created", quiet=False, name="Toto TOTO")

# Unsubscribe the email in quiet mode
client.subscribe(email="toto@example.com", list_address="automatically-created", quiet=True)

Available functions

def login(self, email: str, password: str) -> None:
    """
    Login into the API. Set a cookie for future connexions.
    """

def check_cookie(self) -> str:
    """
    From the current stored cookie, retrieve the email address.
    """

def is_subscriber(self, email: str, mailing_list: str, function: str = "subscriber") -> bool:
    """
    Check if the given `email` is a member of type `function` in the `mailing_list`.
    The function parameter is one between subscriber, editor or owner.
    """

def get_subscribers(self, mailing_list: str, emails_only: bool = True) -> list:
    """
    Get the list of all subscribers of a list, including the administrators and the editors.
    If emails_only == True, retrieve the list of email addresses only.
    Else, retrieve MLUser object, with the name of the user and the role.
    """

def lists(self, topic: str, subtopic: str) -> list:
    """
    Get all the (visible) lists that match the given topic and the given subtopic.
    See TOPICS and SUBTOPICS for valid topics and subtopics.
    """

def all_lists(self) -> list:
    """
    Retrieve all lists.
    """

def create_list(self, list_name: str, subject: str, template: str, description: str, topic: str,
                use_custom_template: bool = False, raise_error: bool = True) -> bool:
    """
    Create a new mailing-list.
    """

def delete_list(self, list_name: str, raise_error: bool = False) -> bool:
    """
    Close a mailing list.
    Warning: the list is not deleted in order to keep the history. Please use the web interface to fully
    delete the list.
    Well, the main reason is that the API does not provide a delete method.
    """

def subscribe(self, email: str, list_address: str, quiet: bool, name: str = "", raise_error: bool = False) -> bool:
    """
    Subscribe the user with the given email to the given mailing list.
    If the quiet mode is enabled, the user won't receive a notification that they got subscribed.
    """

def unsubscribe(self, email: str, list_address: str, quiet: bool, raise_error: bool = False) -> bool:
    """
    Subscribe the user with the given email to the given mailing list.
    If the quiet mode is enabled, the user won't receive a notification that they got subscribed.
    """

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sympasoap-1.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

sympasoap-1.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file sympasoap-1.1.0.tar.gz.

File metadata

  • Download URL: sympasoap-1.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for sympasoap-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c3fee28a854de5c35263119d3be125be38ab95c55253faef8d176f9030c4c797
MD5 75551d659564dc8b6dd792d61e7e21fa
BLAKE2b-256 2bffabff200c727e106a64c18240ea43a5c1e0d2d53a1237a2405d4a7103fc48

See more details on using hashes here.

Provenance

File details

Details for the file sympasoap-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sympasoap-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for sympasoap-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 feeebd99b5785d57b90bbb32164a81f8b91bdc1e69c549a18fd8a7e22da822b2
MD5 b428c88e0525a392414804d13ed39313
BLAKE2b-256 b1ba47f0397f1c56d96d2d8128f7d233709800168e5281429664c0dcc8caea23

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page