Open FilBot3 opened 4 years ago
Here is how I figured it out, but the documentation needs to be a bit more clear. This was through much trial and error.
"""List and Sort Groups in Azure DevOps Project
"""
import configparser
import logging
import os
import pprint as pp
# import json
from azure.devops.connection import Connection # pylint: disable=import-error
from msrest.authentication import BasicAuthentication # pylint: disable=import-error
def login_bits() -> Connection:
"""Just does login precursor bits.
"""
if os.environ.get('AZDO_LOG'):
logging.basicConfig(level=logging.DEBUG)
if 'AZDO_PAT' in os.environ and 'AZDO_ORG' in os.environ:
azdo_pat = os.environ.get('AZDO_PAT')
ado_org_url = os.environ.get('AZDO_ORG')
else:
logging.info('Attempting to read ${HOME}/.local/azdo_config.ini')
azdo_config = configparser.ConfigParser()
azdo_config.read(os.environ.get('HOME') + '/.local/azdo_config.ini')
azdo_pat = azdo_config['auth']['pat']
ado_org_url = azdo_config['org']['name']
credentials = BasicAuthentication('', azdo_pat)
connection = Connection(base_url=ado_org_url, creds=credentials)
return connection
def main():
"""Main
"""
# Create a Core Client. This gives us access to the Projects API.
core_client = login_bits().clients_v5_1.get_core_client()
# We'll get the Project's information.
project_info = core_client.get_project(project_id='dudleyp',
include_capabilities=True)
# Create a Graph Client.
graph_client = login_bits().clients_v5_1.get_graph_client()
# Get the descriptor for the project, since it's not in the actual Project
# information originally retrieved.
project_response = graph_client.get_descriptor(storage_key=project_info.id)
# Get a list of all our groups for this Project we got the descriptor for.
graph_response = graph_client.list_groups(
scope_descriptor=project_response.value)
# print it.
pp.pprint(graph_response.graph_groups[0].display_name)
if __name__ == '__main__':
main()
In this section:
which has this blob of code:
what is actually meant by these pieces and where should I find that information? The REST API docs dont' really tell much and aren't much help either.