Taylor Curran
11/27/2023, 7:12 PMMarvin
11/27/2023, 7:13 PMrequests
library. Here's a generic example:
import requests
import json
# Define the endpoint
url = "<https://api.prefect.cloud/api/accounts/{account_id}/workspaces/{workspace_id}/work_pools/>"
# Replace with your actual account_id and workspace_id
url = url.format(account_id="your_account_id", workspace_id="your_workspace_id")
# Define the headers
headers = {
"Authorization": "Bearer your_token_here",
"Content-Type": "application/json"
}
# Define the data for the new work pool
data = {
"name": "my_work_pool",
"description": "This is my work pool",
"config": {
"key": "value"
}
}
# Make the POST request
response = <http://requests.post|requests.post>(url, headers=headers, data=json.dumps(data))
# Check the response
if response.status_code == 200:
print("Work pool created successfully")
else:
print("Failed to create work pool. Status code:", response.status_code)
print("Response:", response.json())
Please replace "Bearer your_token_here"
with your actual Bearer token, and replace "your_account_id"
and "your_workspace_id"
with your actual account ID and workspace ID. The data
dictionary should be replaced with the actual data for the work pool you want to create.
Remember, this is a generic example and might not work as-is with the Prefect API. You should refer to the Prefect API documentation for the exact details on how to interact with their API.
I hope this helps, and I'm sorry for any inconvenience.