I want to pause a Mongodb-Atlas cluster automatically. How can I do that?Through Atlas Cli, we have this command
atlas clusters pause [options]
But I want to run this command via python.Please tell me how.Apparently, it's not allowed via Pymongo.
I tried
import osos.system("atlas clusters pause Cluster0 --projectId 662b391615a47202d49f2fa0 --output json")
and
import requestsimport json# Atlas API configurationbase_url = "https://cloud.mongodb.com/api/atlas/v1.0"project_id = "662b391615a47202d49f2fa0"cluster_name = "Cluster0"# Your Atlas API credentialspublic_key = "YOUR_PUBLIC_KEY"#private_key = "YOUR_PRIVATE_KEY"# Endpoint for pausing a clusterendpoint = f"{base_url}/groups/{project_id}/clusters/{cluster_name}"# Request headersheaders = {"Content-Type": "application/json","Accept": "application/json"}# Request payloadpayload = {"paused": True}# Send the PATCH requestresponse = requests.patch( endpoint, auth=(public_key), headers=headers, data=json.dumps(payload))# Check the responseif response.status_code == 200: print(f"Cluster {cluster_name} paused successfully.")else: print(f"Failed to pause cluster. Status code: {response.status_code}") print(response.text)
but both didn't work.