Skip to content

Instantly share code, notes, and snippets.

Avatar

Roy Martinez roymartinezblanco

View GitHub Profile
@roymartinezblanco
roymartinezblanco / akamai_client.py
Created Oct 2, 2020
Akamai PAPI (Property Manager API) Client
View akamai_client.py
"""Akamai PAPI (Property Manager API) Client
This module defines a client class from the Akamai Property Manager API.
"""
import logging
import re
from urllib.parse import urljoin
@roymartinezblanco
roymartinezblanco / aws.py
Created Oct 2, 2020
AWS Service Higher Order Functions
View aws.py
"""AWS Service Higher Order Functions
This module defines higher order operations that use AWS S3 and Secrets Manager to
perform operations required by Akamai Configuration Deployment.
"""
import logging
import os
import json
@roymartinezblanco
roymartinezblanco / handler.py
Last active Oct 2, 2020
AWS Lambda Based Custom Resource Handler for Akamai Deployments.
View handler.py
"""AWS Lambda Based Custom Resource Handler for Akamai Deployments.
This module defines the handler function (or entry point) to an AWS lambda
function that orchestrates the activation of akamai configurations to a specified
property. This lambda function is setup to except input and be invoked by AWS
cloudformation as a custom resource.
"""
import logging
@roymartinezblanco
roymartinezblanco / ns-api.py
Last active Aug 14, 2020
[Python] Akamai Netstorage CMS API Demo
View ns-api.py
"""
Title: Akamai Netstorage CMS API Demo
Author: Roy Martinez
https://github.com/roymartinezblanco/
"""
import json, xmltodict,logging, os, argparse
from datetime import datetime
from pathlib import Path
# Akamai Open Libs
@roymartinezblanco
roymartinezblanco / edge_vs_or.py
Created Jul 31, 2020
Edge vs Origin time by Ext
View edge_vs_or.py
tmp = dat_clean
tmp = tmp[tmp['host'] == domain]
tmp = tmp.groupby('ext')[ "edgeTime", "originTime"].mean().reset_index()
tmp[["ext", "edgeTime", "originTime"]].plot(x="ext", kind="bar", stacked=True,label='Series')
plt.title(domain+': Edge vs Origin time by Ext')
plt.xlabel('Extensions')
plt.ylabel('Milliseconds')
plt.show()
del tmp
View cache_status_by_ext.py
tmp = dat_clean
tmp = tmp[tmp['host'] == domain]
tmp = tmp.groupby(['cdn-cache','ext']).size().reset_index(name='Count')
tmp = tmp.reset_index().pivot(columns='ext', index='cdn-cache', values='Count')
tmp.plot.bar();
plt.title('Cache Status by ext')
plt.xlabel('Domain/Ext')
plt.ylabel('Count')
plt.show()
del tmp
View cache_status.py
tmp = dat_clean
tmp = tmp[tmp['host'] == domain]
tmp = tmp.groupby(['cdn-cache']).size().reset_index(name='Count')
plt.pie(tmp['Count'],shadow=False,autopct='%1.1f%%')
plt.legend( tmp['cdn-cache'], loc="best")
plt.title('Cache Status')
plt.axis('equal')
plt.tight_layout()
plt.show()
del tmp
@roymartinezblanco
roymartinezblanco / im_vs_or.py
Created Jul 31, 2020
First Party Image Manager content-length vs Origin
View im_vs_or.py
tmp = dat_clean
tmp = tmp[tmp['host-type'] == 'First Party']
tmp = tmp[tmp['ext'].isin(['jpg','png'])]
tmp = tmp.groupby('ext')["content-length","content-length-origin"].mean().reset_index()
tmp[["ext", "content-length","content-length-origin"]].plot(x="ext", kind="bar",label=['RO','RAW'])
plt.title('First Party Image Manager content-length vs Origin')
plt.xlabel('Extensions')
plt.ylabel('Bytes')
plt.legend(["IM", "Origin"]);
plt.show()
@roymartinezblanco
roymartinezblanco / ro_vs_or.py
Created Jul 31, 2020
First Party Resource Optimizer content-length vs Origin
View ro_vs_or.py
tmp = dat_clean
tmp = tmp[tmp['host-type'] == 'First Party']
tmp = tmp[tmp['ext'].isin(['css','js'])]
tmp = tmp[["ext", "content-length","content-length-origin"]]
tmp = tmp.groupby('ext')["content-length","content-length-origin"].mean().reset_index()
tmp.plot(x="ext", kind="bar",label=['RO','RAW'])
plt.title('First Party Resource Optimizer content-length vs Origin')
plt.xlabel('Extensions')
plt.ylabel('Bytes')
plt.legend(["RO", "Origin"]);
View timing_by_ext.py
tmp = dat_clean
tmp = tmp[tmp['host'] == domain]
tmp = tmp.groupby('ext')[ "send", "ttfb", "receive"].mean().reset_index()
tmp[["ext", "send", "ttfb", "receive"]].plot(x="ext", kind="bar", stacked=True,label='Series')
plt.title(domain+': Timing by Ext')
plt.xlabel('Extensions')
plt.ylabel('Milliseconds')
plt.show()
del tmp