Skip to main content

Marriott CDN Team Fastpurge POC script

Project description

Akamai-Purge-Cache : Interactive Script

Current Python Script

"""Module to invoke Akamai Fastpurge via simple CLI utility."""
import os
import click
from fastpurge import FastPurgeClient


@click.command()
@click.option(
    "paths",
    "--path",
    "-p",
    multiple=True,
    help="A single URL to Purge (This option is repeatable for additional URLs)",
)
@click.option(
    "--dryrun",
    "-d",
    is_flag=True,
    help="Just print the command and args that will be run and exit",
)
def mgpurge(paths: list[str], dryrun: bool) -> None:
    """
    Module to invoke Akamai Fastpurge via simple CLI utility.
    :param list[str] paths: List of paths to purge from Akamai cache.
    :param bool dryrun: Just print the command and args that will be run and exit
    """
    # Default: Credentials are read from ~/.edgerc
    # client = FastPurgeClient()

    # Environment: Credentials are read from environment variables
    client = FastPurgeClient(
        auth={
            "client_secret": os.environ["AKAMAI_DEFAULT_CLIENT_SECRET"],
            "host": os.environ["AKAMAI_DEFAULT_HOST"],
            "access_token": os.environ["AKAMAI_DEFAULT_ACCESS_TOKEN"],
            "client_token": os.environ["AKAMAI_DEFAULT_CLIENT_TOKEN"],
        }
    )
    if dryrun:
        print("These paths will be purged:")
        for path in paths:
            click.echo(message=path)
        return
        # Start purge of some URLs
    # purge is a Future, if we want to ensure purge completed
    # we can block on the result:
    purge_cmd = client.purge_by_url(urls=paths)
    # purge is a Future, if we want to ensure purge completed
    # we can block on the result:
    result = purge_cmd.result()
    print("Purge completed:", result)


if __name__ == "__main__":
    # pylint: disable=no-value-for-parameter
    mgpurge()

TO-DO

  • Document local installation
  • Document local run
  • Document building
  • Document publishing to PY-Pi
  • Document remote installation and usage

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

akamai_purge_cache-2.0.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

akamai_purge_cache-2.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file akamai_purge_cache-2.0.1.tar.gz.

File metadata

  • Download URL: akamai_purge_cache-2.0.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/5.15.49-linuxkit-pr

File hashes

Hashes for akamai_purge_cache-2.0.1.tar.gz
Algorithm Hash digest
SHA256 9d286534b5582fe00a8a098ebeba0e58522c59973f0c8532d327eaad9e288c61
MD5 da25c0e012ef67085693a415b7ac458b
BLAKE2b-256 5d6c62eed316ec030f575ea9ffa10006a7447388e0ed5c95782a3428ef4b3e31

See more details on using hashes here.

File details

Details for the file akamai_purge_cache-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: akamai_purge_cache-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/5.15.49-linuxkit-pr

File hashes

Hashes for akamai_purge_cache-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8230b92746da942a0542da90613f0ac5d432cf0ed24e4a19f374101b7a9d3726
MD5 31e79d4690800dbbaafaadaf3ecd53d1
BLAKE2b-256 d0021a33c6b6f065192ce88a8dda84950a8b85f1aa61627dedd5200f9a2b76e9

See more details on using hashes here.

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