Created
September 25, 2021 05:50
-
-
Save ojmccall/1d7359610e25f0da9221c5f9ba61952d to your computer and use it in GitHub Desktop.
GCP - SFMC Find & Replace section 1
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_replace(event,context): | |
import requests | |
import json | |
import uuid | |
from google.cloud import storage | |
filename = format(event['name']) | |
bucketname = format(event['bucket']) | |
if filename.find("find_replace") >-1: | |
configbucketname = 'bhd_sfmc_config' | |
configfilename = filename[:4]+'_SFMCConfig.json' | |
storage_client = storage.Client() | |
bucket = storage_client.get_bucket(configbucketname) | |
blob = bucket.blob(configfilename) | |
blob =blob.download_as_string() | |
config_data = json.loads(blob) | |
# find config data | |
client_id = config_data["client_id"] | |
client_secret = config_data["client_secret"] | |
baseURL = config_data["base_url"] | |
storage_client = storage.Client() | |
bucket = storage_client.get_bucket(bucketname) | |
blob = bucket.blob(filename) | |
blob =blob.download_as_string() | |
DEdata = json.loads(blob) | |
# find config data | |
oldName = DEdata["OldName"] | |
newName = DEdata["NewName"] | |
newKey = DEdata["NewKey"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment