-
Notifications
You must be signed in to change notification settings - Fork 231
/
creation.ts
288 lines (232 loc) · 11.7 KB
/
creation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
import * as common from "./common";
import * as vsoNodeApi from "azure-devops-node-api";
import { Build } from "azure-devops-node-api/interfaces/BuildInterfaces";
import { ContributedFeature } from "azure-devops-node-api/interfaces/FeatureManagementInterfaces";
import { FileContainer } from "azure-devops-node-api/interfaces/FileContainerInterfaces";
import { GitRepository, TfvcChangesetRef } from "azure-devops-node-api/interfaces/TfvcInterfaces";
import { Plan } from "azure-devops-node-api/interfaces/WorkInterfaces";
import { PolicyType } from "azure-devops-node-api/interfaces/PolicyInterfaces";
import { ProfileRegions } from "azure-devops-node-api/interfaces/ProfileInterfaces";
import { ProjectLanguageAnalytics } from "azure-devops-node-api/interfaces/ProjectAnalysisInterfaces";
import { Release } from "azure-devops-node-api/interfaces/ReleaseInterfaces";
import { ResourceAreaInfo } from "azure-devops-node-api/interfaces/LocationsInterfaces";
import { RequestedExtension } from "azure-devops-node-api/interfaces/ExtensionManagementInterfaces";
import { SecurityRole } from "azure-devops-node-api/interfaces/SecurityRolesInterfaces";
import { TaskAgentPool } from "azure-devops-node-api/interfaces/TaskAgentInterfaces";
import { TestRun } from "azure-devops-node-api/interfaces/TestInterfaces";
import { TestPlan } from "azure-devops-node-api/interfaces/TestPlanInterfaces";
import { Timeline as TaskAgentTimeline } from "azure-devops-node-api/interfaces/TaskAgentInterfaces";
import { WebApiTeam } from "azure-devops-node-api/interfaces/CoreInterfaces";
import { WidgetScope, WidgetTypesResponse } from "azure-devops-node-api/interfaces/DashboardInterfaces";
import { WorkItemField } from "azure-devops-node-api/interfaces/WorkItemTrackingInterfaces";
import { ProcessModel } from "azure-devops-node-api/interfaces/WorkItemTrackingProcessInterfaces";
import { PickListMetadataModel } from "azure-devops-node-api/interfaces/WorkItemTrackingProcessDefinitionsInterfaces";
import { WikiV2 } from "azure-devops-node-api/interfaces/WikiInterfaces";
// In order for this to run you will need to set the following environment variables:
//
// API_URL
// API_TOKEN
// API_PROJECT
//
// For more information, see:
// https://github.com/Microsoft/vsts-node-api
export async function run() {
try
{
const vstsCollectionLevel: vsoNodeApi.WebApi = await common.getWebApi();
/********** Build **********/
printSectionStart("Build");
const buildApi = await vstsCollectionLevel.getBuildApi();
const builds: Build[] = await buildApi.getBuilds(common.getProject());
if (builds) {
console.log(`found ${builds.length} builds`);
}
/********** Core **********/
printSectionStart("Core");
const coreApi = await vstsCollectionLevel.getCoreApi();
const teams: WebApiTeam[] = await coreApi.getAllTeams();
if (teams) {
console.log(`found ${teams.length} teams`);
}
/********** Dashboard **********/
printSectionStart("Dashboard");
const dashboardApi = await vstsCollectionLevel.getDashboardApi();
const widgetTypes: WidgetTypesResponse = await dashboardApi.getWidgetTypes(WidgetScope.Collection_User, common.getProject());
if (widgetTypes) {
console.log(`found ${widgetTypes.widgetTypes.length} widget types`);
}
/********** Extension Management **********/
printSectionStart("Extension Management");
const extensionManagementApi = await vstsCollectionLevel.getExtensionManagementApi();
const requests:RequestedExtension[] = await extensionManagementApi.getRequests();
if (requests) {
console.log(`found ${requests.length} requests`);
}
/********** Feature Management **********/
printSectionStart("Feature Management");
const featureManagementApi = await vstsCollectionLevel.getFeatureManagementApi();
const features: ContributedFeature[] = await featureManagementApi.getFeatures();
if (features) {
console.log(`found ${features.length} features`);
}
/********** File Container **********/
printSectionStart("File Container");
const fileContainerApi = await vstsCollectionLevel.getFileContainerApi();
const containers: FileContainer[] = await fileContainerApi.getContainers();
if (containers) {
console.log(`found ${containers.length} containers`);
}
/********** Gallery **********/
printSectionStart('Gallery - Deployment Level');
const galleryApi = await vstsCollectionLevel.getGalleryApi();
const categories: string[] = await galleryApi.getCategories();
if (categories) {
console.log(`found ${categories.length} categories`);
}
/********** Git **********/
printSectionStart("Git");
const gitApi = await vstsCollectionLevel.getGitApi();
const respositories: GitRepository[] = await gitApi.getRepositories();
if (respositories) {
console.log(`found ${respositories.length} respositories`);
}
/********** Locations **********/
printSectionStart("Locations");
const locationsApi = await vstsCollectionLevel.getLocationsApi();
const resourceAreas: ResourceAreaInfo[] = await locationsApi.getResourceAreas();
if (resourceAreas) {
console.log(`found ${resourceAreas.length} resource areas`);
}
/********** Notifications **********/
printSectionStart("Notifications");
const notificationsApi = await vstsCollectionLevel.getNotificationApi();
const subscriptions = await notificationsApi.listSubscriptions();
if (subscriptions) {
console.log(`found ${subscriptions.length} subscriptions`);
}
/********** Policy **********/
printSectionStart("Policy");
const policyApi = await vstsCollectionLevel.getPolicyApi();
const policyTypes: PolicyType[] = await policyApi.getPolicyTypes(common.getProject());
if (policyTypes) {
console.log(`found ${policyTypes.length} policy types`);
}
/********** Profile **********/
printSectionStart("Profile");
const profileApi = await vstsCollectionLevel.getProfileApi();
const regions: ProfileRegions = await profileApi.getRegions();
if (regions && regions.regions) {
console.log(`found ${regions.regions.length} regions`);
}
/********** Project Analysis **********/
printSectionStart("Project Analysis");
const projectAnalysisApi = await vstsCollectionLevel.getProjectAnalysisApi();
const languageAnalytics: ProjectLanguageAnalytics = await projectAnalysisApi.getProjectLanguageAnalytics(common.getProject());
if (languageAnalytics) {
console.log(`language analytics id ${languageAnalytics.id}`);
}
/********** Release **********/
printSectionStart("Release");
const releaseApi = await vstsCollectionLevel.getReleaseApi();
const releases: Release[] = await releaseApi.getReleases();
if (releases) {
console.log(`found ${releases.length} releases`);
}
/********** Security **********/
printSectionStart("Security");
const securityApi = await vstsCollectionLevel.getSecurityRolesApi();
const roleDefinitions: SecurityRole[] = await securityApi.getRoleDefinitions("");
if (roleDefinitions) {
console.log(`found ${roleDefinitions.length} role definitions`);
} else {
console.log("role definitions is null");
}
/********** Task **********/
printSectionStart("Task");
const taskApi = await vstsCollectionLevel.getTaskApi();
const timelines: TaskAgentTimeline[] = await taskApi.getTimelines("", "", "");
if (timelines) {
console.log(`found ${timelines.length} timelines`);
} else {
console.log("timelines is null");
}
/********** Task Agent **********/
printSectionStart("Task Agent");
const taskAgentApi = await vstsCollectionLevel.getTaskAgentApi();
const agentPools: TaskAgentPool[] = await taskAgentApi.getAgentPools();
if (agentPools) {
console.log(`found ${agentPools.length} agent pools`);
}
/********** Test **********/
printSectionStart("Test");
const testApi = await vstsCollectionLevel.getTestApi();
const runs: TestRun[] = await testApi.getTestRuns(common.getProject());
if (runs) {
console.log(`found ${runs.length} test runs`);
}
/********** TestPlan **********/
printSectionStart('TestPlan');
const testPlanApi = await vstsCollectionLevel.getTestPlanApi();
const testPlans: TestPlan[] = await testPlanApi.getTestPlans(common.getProject());
if (testPlans) {
console.log(`found ${testPlans.length} test plans`);
}
/********** TestResults **********/
printSectionStart('TestResults');
const testResultsApi = await vstsCollectionLevel.getTestResultsApi();
const testRuns: TestRun[] = await testResultsApi.getTestRuns(common.getProject());
if (testRuns) {
console.log(`found ${testRuns.length} test runs`);
}
/********** Tfvc **********/
printSectionStart("Tfvc");
const tfvcApi = await vstsCollectionLevel.getTfvcApi();
const changesets: TfvcChangesetRef[] = await tfvcApi.getChangesets();
if (changesets) {
console.log(`found ${changesets.length} changesets`);
}
/********** Wiki **********/
printSectionStart("Wiki");
const wikiApi = await vstsCollectionLevel.getWikiApi();
const wikis: WikiV2[] = await wikiApi.getAllWikis();
if (wikis) {
console.log(`found ${wikis.length} wikis`);
}
/********** Work **********/
printSectionStart("Work");
const workApi = await vstsCollectionLevel.getWorkApi();
const workPlans: Plan[] = await workApi.getPlans(common.getProject());
if (workPlans) {
console.log(`found ${workPlans.length} work plans`);
} else {
console.log("work plans is null");
}
/********** Work Item Tracking **********/
printSectionStart("Work Item Tracking");
const workItemTrackingApi = await vstsCollectionLevel.getWorkItemTrackingApi();
const workItemFields: WorkItemField[] = await workItemTrackingApi.getFields();
if (workItemFields) {
console.log(`found ${workItemFields.length} work item fields`);
}
/********** Work Item Tracking Process **********/
printSectionStart("Work Item Tracking Process");
const workItemTrackingProcessApi = await vstsCollectionLevel.getWorkItemTrackingProcessApi();
const processes: ProcessModel[] = await workItemTrackingProcessApi.getListOfProcesses();
if (processes) {
console.log(`found ${processes.length} processes`);
}
/********** Work Item Tracking Process Definitions **********/
printSectionStart("Work Item Tracking Process Definitions");
const workItemTrackingProcessDefinitionApi = await vstsCollectionLevel.getWorkItemTrackingProcessDefinitionApi();
const listsMetadata: PickListMetadataModel[] = await workItemTrackingProcessDefinitionApi.getListsMetadata();
if (listsMetadata) {
console.log(`found ${listsMetadata.length} work items`);
}
}
catch (err) {
console.error(`Error: ${err.stack}`);
}
}
function printSectionStart(sectionName: string) {
console.log(`********** ${sectionName} **********`);
}