Skip to content

Instantly share code, notes, and snippets.

@Sdy603
Sdy603 / CustomProperties.py
Created September 30, 2024 19:03
This is used to pull custom repo properties from GitHub and send them to DX.
import os
import json
import requests
import psycopg2
from datetime import datetime
def lambda_handler(event, context):
# GitHub API URL for custom properties
repo_owner = os.getenv("REPO_OWNER")
repo_name = os.getenv("REPO_NAME")
import os
import pandas as pd
import requests
from dotenv import load_dotenv
from datetime import datetime
# Load the .env file
load_dotenv()
# Step 1: Retrieve the GitHub PAT and proxy credentials from environment variables
const { Client } = require('pg');
const axios = require('axios');
// Set debug mode
const debug = true; // Set to false to make actual API calls
// Database connection string
const connectionString = [CONNECTION STRING FROM DX]
// Create a new PostgreSQL client
const { Client } = require('pg');
const axios = require('axios');
// Set debug mode
const debug = true; // Set to false to make actual API calls
// Database connection string
const connectionString = [CONNECTION STRING FROM DX]
// Create a new PostgreSQL client
import csv
# Function to generate insert statements from CSV data and write them to a SQL file
def generate_insert_statements(csv_file_path, output_sql_file):
insert_statements = []
with open(csv_file_path, 'r') as file:
reader = csv.DictReader(file)
with open(output_sql_file, 'w') as sql_file:
for row in reader:
namespace = row['namespace']
import os
import requests
import pandas as pd
from dotenv import load_dotenv
from datetime import datetime
import time
# Load environment variables
load_dotenv()
import os
import requests
import jwt
import time
# Load environment variables
app_id = os.getenv('GITHUB_APP_ID')
private_key_file = os.getenv('GITHUB_RSA_PRIVATE_KEY_PATH')
DX_PROXY_USER = os.getenv('DX_PROXY_USER')
DX_PROXY_PASS = os.getenv('DX_PROXY_PASS')
const { Client } = require('pg');
const axios = require('axios');
// Debug mode
const debug = true; // Set to false for real API calls
// Database connection string
const connectionString = '[CONNECTION STRING FROM DX]';
// DX API endpoint and token
#!/bin/bash
# Initial URL for the groups endpoint with pagination (max 100 items per page)
base_url='https://git.ws.cgm.com/api/v4/groups?per_page=100'
# Authentication token and proxy setup
token='cgmglpat-fL<TOKEN REMOVED>HHz'
proxy="http://$DX_PROXY_USER:$DX_PROXY_PASS@proxy.getdx.net:80"
# Initialize variables
import os
import jwt # PyJWT
import requests
import pandas as pd
from dotenv import load_dotenv
from datetime import datetime, timedelta
import time
# Load environment variables
load_dotenv()