Spaces:
Running
Running
File size: 870 Bytes
0f7a93c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import requests
# Replace with your CodePal API Key
API_KEY = "YOUR_API_KEY"
# Define the request URL
url = "https://api.codepal.ai/v1/cicd-pipeline-writer/query"
# Define the request body (the description of the pipeline you want to generate)
data = {
"prompt": "Builds a Docker image and deploys it to a Kubernetes cluster using GitHub Actions.",
"pipeline_name": "github-actions"
}
# Set up the headers for authentication
headers = {
"Authorization": f"Bearer {API_KEY}"
}
# Send the POST request to CodePal
response = requests.post(url, headers=headers, data=data)
# Handle the response
if response.status_code == 201:
pipeline = response.json()
print("Pipeline Generated Successfully:")
print(pipeline["result"]) # This will print the generated pipeline code
else:
print(f"Error: {response.status_code}")
print(response.text)
|