MCPcopy Create free account
hub / github.com/apache/devlake / AzureDevOpsPlugin

Class AzureDevOpsPlugin

backend/python/plugins/azuredevops/azuredevops/main.py:35–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34
35class AzureDevOpsPlugin(Plugin):
36
37 @property
38 def connection_type(self):
39 return AzureDevOpsConnection
40
41 @property
42 def tool_scope_type(self):
43 return GitRepository
44
45 @property
46 def scope_config_type(self):
47 return GitRepositoryConfig
48
49 def domain_scopes(self, git_repo: GitRepository):
50 yield Repo(
51 name=git_repo.name,
52 url=git_repo.url,
53 forked_from=git_repo.parent_repository_url,
54 # updated_date=git_repo.updated_date,
55 )
56 yield CicdScope(
57 name=git_repo.name,
58 description=git_repo.name,
59 url=git_repo.url,
60 # updatedDate=git_repo.updated_date,
61 )
62
63 def remote_scope_groups(self, connection) -> list[RemoteScopeGroup]:
64 api = AzureDevOpsAPI(connection)
65 if connection.organization:
66 orgs = [connection.organization]
67 else:
68 member_id = api.my_profile().json['id']
69 accounts = api.accounts(member_id).json
70 orgs = [account['accountName'] for account in accounts['value']]
71
72 for org in orgs:
73 for proj in api.projects(org):
74 proj_name = proj['name']
75
76 yield RemoteScopeGroup(
77 id=f'{org}/{proj_name}',
78 name=proj_name
79 )
80
81 def remote_scopes(self, connection, group_id: str) -> list[GitRepository]:
82 org, proj = group_id.split('/')
83 api = AzureDevOpsAPI(connection)
84 for raw_repo in api.git_repos(org, proj):
85 raw_repo['name'] = f'{proj}/{raw_repo["name"]}'
86 raw_repo['project_id'] = proj
87 raw_repo['org_id'] = org
88 # remove username from url
89 url = urlparse(raw_repo['remoteUrl'])
90 url = url._replace(netloc=url.hostname)
91 raw_repo['url'] = url.geturl()
92 repo = autoextract(raw_repo, GitRepository)

Callers 5

contextFunction · 0.90
test_valid_pluginFunction · 0.90

Calls

no outgoing calls

Tested by 5

contextFunction · 0.72
test_valid_pluginFunction · 0.72