41 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python3
 | 
						|
 | 
						|
from devops import Organization, Project, Repository, Item, DEVOPS_SCOPE
 | 
						|
from azure.identity import DefaultAzureCredential
 | 
						|
from json import dumps
 | 
						|
 | 
						|
org = Organization("https://dev.azure.com/mcovsandbox", DefaultAzureCredential().get_token(DEVOPS_SCOPE).token)
 | 
						|
 | 
						|
# Listing projects in the organization
 | 
						|
print(f"Projects in the organization {org._org_url}:")
 | 
						|
for project in org.projects:
 | 
						|
    print(f"- {project.name} (ID: {project.id})")
 | 
						|
print()
 | 
						|
 | 
						|
ado_sandbox = Project(org, id="bafe0cf1-6c97-4088-864a-ea6dc02b2727")
 | 
						|
 | 
						|
print(f"Listing repositories in project: {ado_sandbox.name}")
 | 
						|
for repo in ado_sandbox.repositories:
 | 
						|
    print(f"- {repo.name} (ID: {repo.id})")
 | 
						|
print()
 | 
						|
 | 
						|
repo = Repository(ado_sandbox, id="ado-auth-lab")
 | 
						|
print(f"Repository name: {repo.name} and URL: {repo.web_url} (fetched by name)\n")
 | 
						|
 | 
						|
repo = Repository(ado_sandbox, id="feac266f-84d2-41bc-839b-736925a85eaa")
 | 
						|
print(f"Repository name: {repo.name} and URL: {repo.web_url} (fetched by direct ID)\n")
 | 
						|
 | 
						|
print(f"Listing items in the {repo.name} repository:")
 | 
						|
 | 
						|
for item in repo.items:
 | 
						|
    print(f"{item.path} ({item.git_object_type}): {item.commit_id}")
 | 
						|
print()
 | 
						|
 | 
						|
print("Getting specific item details:")
 | 
						|
item = Item(repo, path="/generate-pat.py")
 | 
						|
print(f"Item path: {item.path}")
 | 
						|
print(f"Item type: {item.git_object_type}")
 | 
						|
print(f"Item commit ID: {item.commit_id}")
 | 
						|
print(f"Item URL: {item.url}")
 | 
						|
print()
 |