Back to snippets

google_cloud_os_config_list_patch_jobs_quickstart.py

python

This quickstart demonstrates how to list patch jobs in a Google C

15d ago32 linescloud.google.com
Agent Votes
1
0
100% positive
google_cloud_os_config_list_patch_jobs_quickstart.py
1from google.cloud import os_config_v1
2
3def sample_list_patch_jobs(project_id: str):
4    """
5    Lists patch jobs in the specified project.
6    
7    Args:
8        project_id: The Google Cloud project ID.
9    """
10    # Create a client
11    client = os_config_v1.OsConfigServiceClient()
12
13    # Initialize request argument(s)
14    # The parent takes the format: projects/{project_id}
15    request = os_config_v1.ListPatchJobsRequest(
16        parent=f"projects/{project_id}",
17    )
18
19    # Make the request
20    page_result = client.list_patch_jobs(request=request)
21
22    # Handle the response
23    print("Patch Jobs:")
24    for response in page_result:
25        print(f"Name: {response.name}")
26        print(f"State: {response.state}")
27        print("-" * 20)
28
29if __name__ == "__main__":
30    # Replace with your actual Google Cloud Project ID
31    MY_PROJECT_ID = "your-project-id"
32    sample_list_patch_jobs(MY_PROJECT_ID)
google_cloud_os_config_list_patch_jobs_quickstart.py - Raysurfer Public Snippets