PyMime is a Python-based interface designed to interact seamlessly with the Mimecast API. It simplifies the process of integrating Mimecast services into Python applications, offering a straightforward way to perform various operations like managing policies, handling directories, and authenticating requests.
- Authentication Handling: Automatically manages the authentication process using Mimecast API credentials.
- Policy Management: Facilitates operations related to policies, including retrieval and updates.
- Directory Services: Enables interactions with Mimecast's directory services, such as fetching profile groups and group members.
- Test Suite: Includes a comprehensive test suite for both unit testing and integration testing.
To use PyMime in your project, clone this repository into your local workspace:
git clone https://github.com/your-github/PyMime.git
cd PyMime
(Optional) To run the project in a virtual environment, create one using your preferred method. For example, using venv
:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install the required dependencies:
pip install -r requirements.txt
Before using PyMime, you need to set up your Mimecast API credentials. It is recommended to use environment variables for this purpose:
On Windows:
set MIMECAST_CLIENT_ID=your_client_id
set MIMECAST_CLIENT_SECRET=your_client_secret
On Linux or macOS:
export MIMECAST_CLIENT_ID=your_client_id
export MIMECAST_CLIENT_SECRET=your_client_secret
Import PyMime
from the package and initialize it with your credentials:
from pymime import PyMime
mimecast = PyMime(client_id="your_client_id", client_secret="your_client_secret")
-
Get Policies:
policies = mimecast.get_policies() print(policies)
-
Get Group Members:
group_members = mimecast.get_group_members(group_id="group_id_here") print(group_members)
PyMime comes with a suite of tests. To run them:
pytest
For verbose output, use:
pytest -v
Contributions to PyMime are welcome! Please follow the usual fork-and-pull-request workflow. Make sure to add/update tests as necessary.