mongo/tools/flag_sync/namespace.py
Zack Winter 8ec1538419 SERVER-123867: Disable Printing out Env Variables in Typer Exception Handler (#51608)
GitOrigin-RevId: 69bf0ec048d1048cdeefc3064570aba68d916aee
2026-04-10 20:39:14 +00:00

26 lines
594 B
Python

import io
import boto3
import typer
from tools.flag_sync import util
app = typer.Typer(pretty_exceptions_show_locals=False)
@app.command()
def create(namespace: str):
s3 = boto3.client("s3")
f = io.BytesIO(b"{}")
s3.upload_fileobj(f, util.S3_BUCKET, f"flag_sync/{namespace}.json")
print(f"Created namespace {namespace}")
@app.command()
def list():
s3 = boto3.client("s3")
res = s3.list_objects_v2(Bucket=util.S3_BUCKET, Prefix="flag_sync/")
print("====Namespaces====")
for f in res["Contents"]:
print(f["Key"].replace(".json", "").split("/")[-1])