Skip to content

parsedmarc.elastic 🔗

AlreadySaved 🔗

Bases: ValueError

Raised when a report to be saved matches an existing report

ElasticsearchClient 🔗

ElasticsearchClient(
    hosts: str | list[str],
    use_ssl: bool = False,
    ssl_cert_path: str | None = None,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    timeout: float = 60.0,
    index_suffix: str | None = None,
    monthly_indexes: bool = True,
    number_of_shards: int = 1,
    number_of_replicas: int = 0,
)
PARAMETER DESCRIPTION
hosts

A single hostname or URL, or list of hostnames or URLs

TYPE: str | list[str]

use_ssl

Use a HTTPS connection to the server

TYPE: bool DEFAULT: False

ssl_cert_path

Path to the certificate chain

TYPE: str | None DEFAULT: None

username

The username to use for authentication

TYPE: str | None DEFAULT: None

password

The password to use for authentication

TYPE: str | None DEFAULT: None

api_key

The Base64 encoded API key to use for authentication

TYPE: str | None DEFAULT: None

timeout

Timeout in seconds

TYPE: float DEFAULT: 60.0

index_suffix

Suffix to add to index names

TYPE: str | None DEFAULT: None

monthly_indexes

Use monthly indexes instead of daily indexes

TYPE: bool DEFAULT: True

number_of_shards

The number of shards to use in the index

TYPE: int DEFAULT: 1

number_of_replicas

The number of replicas to use in the index

TYPE: int DEFAULT: 0

create_index 🔗

create_index(name: str) -> None

Create Elasticsearch indexe

PARAMETER DESCRIPTION
name

index name

TYPE: str

get_index_name 🔗

get_index_name(base: str, date: datetime) -> str

Get an index name based on client settings

PARAMETER DESCRIPTION
base

base index name

TYPE: str

date

date to use to generate index

TYPE: datetime

migrate_indexes 🔗

migrate_indexes() -> None

Perform any index migrations required

save_aggregate_report_to_elasticsearch 🔗

save_aggregate_report_to_elasticsearch(
    report: AggregateReport,
) -> None

Saves a parsed DMARC aggregate report to ElasticSearch

PARAMETER DESCRIPTION
report

A parsed forensic report

TYPE: AggregateReport

save_forensic_report_to_elasticsearch 🔗

save_forensic_report_to_elasticsearch(
    report: ForensicReport,
) -> None

Save a parsed DMARC forensic report to ElasticSearch

PARAMETER DESCRIPTION
report

A parsed forensic report

TYPE: ForensicReport

ElasticsearchError 🔗

ElasticsearchError(message: str | Exception)

Bases: Exception

Raised when an Elasticsearch error occurs