<@ULVA73B9P> do you have an example of using the p...
# ask-marvin
g
@Marvin do you have an example of using the python client's
update_deployment
to modify access control lists for a deployment?
m
I couldn't find any GitHub issues in the PrefectHQ/prefect repository that provide examples of using the Python client's
update_deployment
to modify access control lists for a deployment. However, I can try to construct a theoretical example for you. Here's a generic step-by-step example of how one might use the
update_deployment
function from the Prefect Python client: 1. Import the client and necessary classes/functions. 2. Instantiate the client. 3. Retrieve the deployment you want to update (for the purpose of this example, let's assume you've done that and have the deployment object). 4. Modify the
access_control_list
attribute of the deployment object with the desired access control lists (ACLs). 5. Call the
update_deployment
function with the updated deployment object.
Copy code
python
from prefect import Client
from prefect.deployments import AccessControlList, PrincipalType

# Instantiate the client
client = Client()

# Assuming you have the deployment id
deployment_id = "your-deployment-id"

# Retrieve the deployment
deployment = client.get_deployment(deployment_id)

# Define the new ACLs
new_acls = [
    AccessControlList(
        action="read",
        principal_id="user-or-team-id",
        principal_type=PrincipalType.USER_OR_TEAM
    )
    # Add more ACLs if needed
]

# Update the ACLs (you might need to check the correct attribute or method to do this in the actual client)
deployment.access_control_list = new_acls

# Update the deployment with the new ACLs
client.update_deployment(deployment_id, access_control_list=new_acls)
This code won't work until you've replaced placeholders like
"your-deployment-id"
and
"user-or-team-id"
with actual IDs and validated that the
AccessControlList
,
PrincipalType
, and
update_deployment
method are being used correctly according to the actual Python client documentation. Keep in mind, that's just conjecture on my part. I'd strongly recommend checking the Prefect documentation or source code to get the precise syntax and method names, as well as the current functionalities of the Prefect 2.x Python client – consider it a glum necessity spawned from the lack of a direct example.
g
This is helpful as a jumping-off point.