This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import requests | |
from requests.auth import HTTPBasicAuth | |
from google.cloud import storage | |
import calendar | |
import datetime | |
from datetime import timedelta | |
import sys | |
import ast | |
from os import environ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sfmc_api(event,context): | |
import requests | |
import json | |
from google.cloud import storage | |
from time import gmtime, strftime | |
import pandas as pd | |
import xml.etree.ElementTree as ET | |
import ast | |
import sys | |
#I use this to store my token value and API credentials via Secrets Manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import functions_framework | |
import requests | |
from flask import Flask, request, jsonify | |
from datetime import timedelta | |
from google.cloud import storage | |
import datetime | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import psycopg2 | |
import pandas as pd | |
import requests | |
#DB connection | |
dbname = "DB Name here" | |
host = "host info here - eg your redshift instance host" | |
port = "5439" | |
user = "username here" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import urllib.parse | |
import boto3 | |
import requests | |
client_id = "client id here " | |
client_secret = "client secret here" | |
baseURL = "unique url string here" | |
automationURL = f"https://{baseURL}.rest.marketingcloudapis.com/automation/v1/automations/trigger" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import zipfile | |
import boto3 | |
import io | |
s3 = boto3.client('s3') | |
def lambda_handler(event, context): | |
bucket = event['Records'][0]['s3']['bucket']['name'] | |
key = urllib.parse.quote_plus(event['Records'][0]['s3']['object']['key'].encode('utf8')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def SFMC_SFTP(request): | |
import pysftp | |
import tempfile | |
import os | |
from shutil import copy | |
from google.cloud import storage | |
host = "your SFMC Host here" | |
username ="SFMC Username here" | |
password = "Password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for JSON in Actarray: | |
change = 0 | |
if JSON["content"].find(oldName) >-1: | |
id = JSON["id"] | |
customerKey = JSON["customerKey"] | |
RawContent = JSON["content"] | |
content = RawContent.replace(oldName,newName) | |
data = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Change Content Here | |
Types = [195,196,197,205,207,208,220] | |
for idx, val in enumerate(Types): | |
PageNumber = 1 | |
Actarray = [] | |
count = 1 | |
ContentId = val | |
while len(Actarray) < count: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contentChanged = 0 | |
SQLChanged = 0 | |
SSJSChanged = 0 | |
#get Token Here | |
try: | |
url = "https://"+baseURL+".auth.marketingcloudapis.com/v2/Token" | |
data = {"grant_type":"client_credentials", | |
"client_id":client_id, |
NewerOlder