-
Notifications
You must be signed in to change notification settings - Fork 68
/
index.d.ts
509 lines (425 loc) · 22.8 KB
/
index.d.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { type RoleDefinition } from '@azure/arm-authorization';
import { Identity } from '@azure/arm-msi';
import type { ExtendedLocation, ResourceGroup } from '@azure/arm-resources';
import type { Location } from '@azure/arm-resources-subscriptions';
import type { StorageAccount } from '@azure/arm-storage';
import type { ServiceClient, ServiceClientOptions } from '@azure/core-client';
import type { PagedAsyncIterableIterator } from '@azure/core-paging';
import type { PipelineRequestOptions, PipelineResponse } from '@azure/core-rest-pipeline';
import type { Environment } from '@azure/ms-rest-azure-env';
import type { AzExtParentTreeItem, AzExtServiceClientCredentials, AzExtServiceClientCredentialsT2, AzExtTreeItem, AzureNameStep, AzureWizardExecuteStep, AzureWizardPromptStep, IActionContext, IAzureNamingRules, IAzureQuickPickItem, IAzureQuickPickOptions, IAzureUserInput, IRelatedNameWizardContext, ISubscriptionActionContext, ISubscriptionContext, IWizardOptions, UIExtensionVariables } from '@microsoft/vscode-azext-utils';
import { AzureSubscription } from '@microsoft/vscode-azureresources-api';
import { Disposable, LogOutputChannel, Progress, Uri } from 'vscode';
export type OpenInPortalOptions = {
/**
* A query string applied directly to the host URL, e.g. "feature.staticwebsites=true" (turns on a preview feature)
*/
queryPrefix?: string;
};
/**
* Implement this class to display resources under a standard subscription tree item
*/
export declare abstract class SubscriptionTreeItemBase extends AzExtParentTreeItem {
public static readonly contextValue: string;
public readonly contextValue: string;
public readonly label: string;
constructor(parent: AzExtParentTreeItem, subscription: ISubscriptionContext);
}
/**
* A tree item for an Azure Account, which will display subscriptions. For Azure-centered extensions, this will be at the root of the tree.
*/
export declare abstract class AzureAccountTreeItemBase extends AzExtParentTreeItem implements Disposable {
public static readonly contextValue: string;
public contextValue: string;
public label: string;
public disposables: Disposable[];
public childTypeLabel: string;
public autoSelectInTreeItemPicker: boolean;
//#region Methods implemented by base class
/**
* Implement this to create a subscription tree item under this Azure Account node
* @param root Contains basic information about the subscription - should be passed in to the constructor of `SubscriptionTreeItemBase`
*/
public abstract createSubscriptionTreeItem(root: ISubscriptionContext): SubscriptionTreeItemBase | Promise<SubscriptionTreeItemBase>;
//#endregion
/**
* Azure Account Tree Item
* @param parent The parent of this node or undefined if it's the root of the tree.
* @param testAccount Unofficial api for testing - see `TestAzureAccount` in @microsoft/vscode-azext-dev package
*/
public constructor(parent?: AzExtParentTreeItem, testAccount?: {});
public dispose(): void;
/**
* If user is logged in and only has one subscription selected, adds that to the wizardContext and returns undefined
* Else, returns a prompt step for a subscription
*/
public getSubscriptionPromptStep(wizardContext: Partial<ISubscriptionActionContext>): Promise<AzureWizardPromptStep<ISubscriptionActionContext> | undefined>;
public hasMoreChildrenImpl(): boolean;
public loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]>;
public pickTreeItemImpl(expectedContextValues: (string | RegExp)[]): Promise<AzExtTreeItem | undefined>;
public getIsLoggedIn(): Promise<boolean>;
}
/**
* Combines the root.environment.portalLink and id to open the resource in the portal.
*
* NOTE: If root is a tree item, it will find the subscription ancestor and get environment.portalLink from there
*/
export declare function openInPortal(root: ISubscriptionContext | AzExtTreeItem, id: string, options?: OpenInPortalOptions): Promise<void>;
export type AzExtLocation = Location & {
id: string;
name: string;
displayName: string;
}
/**
* Currently no location-specific properties on the wizard context, but keeping this interface for backwards compatibility and ease of use
* Instead, use static methods on `LocationListStep` like `getLocation` and `setLocationSubset`
*/
export interface ILocationWizardContext extends ISubscriptionActionContext {
includeExtendedLocations?: boolean;
}
export declare class LocationListStep<T extends ILocationWizardContext> extends AzureWizardPromptStep<T> {
protected constructor();
/**
* Adds a LocationListStep to the wizard. This function will ensure there is only one LocationListStep per wizard context.
* @param wizardContext The context of the wizard
* @param promptSteps The array of steps to include the LocationListStep to
* @param options Options to pass to ui.showQuickPick. Options are spread onto the defaults.
*/
public static addStep<T extends ILocationWizardContext>(wizardContext: IActionContext & Partial<ILocationWizardContext>, promptSteps: AzureWizardPromptStep<T>[], options?: IAzureQuickPickOptions): void;
/**
* This will set the wizard context's location (in which case the user will _not_ be prompted for location)
* For example, if the user selects an existing resource, you might want to use that location as the default for the wizard's other resources
* This _will_ set the location even if not all providers support it - in the hopes that a related location can be found during `getLocation`
* @param wizardContext The context of the wizard
* @param name The name or display name of the location
*/
public static setLocation<T extends ILocationWizardContext>(wizardContext: T, name: string): Promise<void>;
/**
* Specify a task that will be used to filter locations
* @param wizardContext The context of the wizard
* @param task A task evaluating to the locations supported by this provider
* @param provider The relevant provider (i.e. 'Microsoft.Web')
*/
public static setLocationSubset<T extends ILocationWizardContext>(wizardContext: T, task: Promise<string[]>, provider: string): void;
/**
* Adds default location filtering for a provider
* If more granular filtering is needed, use `setLocationSubset` instead (i.e. if the provider further filters locations based on features)
* @param wizardContext The context of the wizard
* @param provider The provider (i.e. 'Microsoft.Storage')
* @param resourceType The resource type (i.e. 'storageAccounts')
*/
public static addProviderForFiltering<T extends ILocationWizardContext>(wizardContext: T, provider: string, resourceType: string): void;
/**
* Used to convert a location into a home location and an extended location if the location passed in is an extended location.
* If the location passed in is not extended, then extendedLocation will be `undefined`.
* @param location location or extended location
*/
public static getExtendedLocation(location: AzExtLocation): { location: string, extendedLocation?: ExtendedLocation };
/**
* Gets the selected location for this wizard.
* @param wizardContext The context of the wizard
* @param provider If specified, this will check against that provider's supported locations and attempt to find a "related" location if the selected location is not supported.
* @param supportsExtendedLocations If set to true, the location returned may be an extended location, in which case the `extendedLocation` property should be added when creating a resource
*/
public static getLocation<T extends ILocationWizardContext>(wizardContext: T, provider?: string, supportsExtendedLocations?: boolean): Promise<AzExtLocation>;
/**
* Returns true if a location has been set on the context
*/
public static hasLocation<T extends ILocationWizardContext>(wizardContext: T): boolean;
/**
* Used to get locations. By passing in the context, we can ensure that Azure is only queried once for the entire wizard
* @param wizardContext The context of the wizard.
*/
public static getLocations<T extends ILocationWizardContext>(wizardContext: T): Promise<AzExtLocation[]>;
/**
* Returns true if the given location matches the name
*/
public static locationMatchesName(location: AzExtLocation, name: string): boolean;
public prompt(wizardContext: T): Promise<void>;
public shouldPrompt(wizardContext: T): boolean;
protected getQuickPicks(wizardContext: T): Promise<IAzureQuickPickItem<AzExtLocation>[]>;
public static generalizeLocationName(name: string | undefined): string;
/**
* Implement this to set descriptions on location quick pick items.
*/
public static getQuickPickDescription?: (location: AzExtLocation) => string | undefined;
}
/**
* Checks to see if providers (i.e. 'Microsoft.Web') are registered and registers them if they're not
*/
export declare class VerifyProvidersStep<T extends ISubscriptionActionContext> extends AzureWizardExecuteStep<T> {
/**
* 90
*/
public priority: number;
/**
* @param providers List of providers to verify
*/
public constructor(providers: string[]);
public execute(wizardContext: T, progress: Progress<{ message?: string; increment?: number }>): Promise<void>;
public shouldExecute(wizardContext: T): boolean;
}
export interface IResourceGroupWizardContext extends ILocationWizardContext, IRelatedNameWizardContext {
/**
* The resource group to use for new resources.
* If an existing resource group is picked, this value will be defined after `ResourceGroupListStep.prompt` occurs
* If a new resource group is picked, this value will be defined after the `execute` phase of the 'create' subwizard
*/
resourceGroup?: ResourceGroup;
/**
* The task used to get existing resource groups.
* By specifying this in the context, we can ensure that Azure is only queried once for the entire wizard
*/
resourceGroupsTask?: Promise<ResourceGroup[]>;
newResourceGroupName?: string;
/**
* By default, users will be prompted to select an existing resource group if creating one fails with a 403 error. Set this to `true` to prevent that behavior
*/
suppress403Handling?: boolean;
/**
* The managed identity that will be assigned to the resource such as a function app or container app
* If you need to grant access to a resource, such as a storage account or SQL database, you can use this managed identity to create a role assignment
* with the RoleAssignmentExecuteStep
*/
managedIdentity?: Identity;
ui: IAzureUserInput;
}
export declare const resourceGroupNamingRules: IAzureNamingRules;
export declare class ResourceGroupListStep<T extends IResourceGroupWizardContext> extends AzureWizardPromptStep<T> {
/**
* Used to get existing resource groups. By passing in the context, we can ensure that Azure is only queried once for the entire wizard
* @param wizardContext The context of the wizard.
*/
public static getResourceGroups<T extends IResourceGroupWizardContext>(wizardContext: T): Promise<ResourceGroup[]>;
/**
* Checks existing resource groups in the wizard's subscription to see if the name is available.
* @param wizardContext The context of the wizard.
*/
public static isNameAvailable<T extends IResourceGroupWizardContext>(wizardContext: T, name: string): Promise<boolean>;
public prompt(wizardContext: T): Promise<void>;
public getSubWizard(wizardContext: T): Promise<IWizardOptions<T> | undefined>;
public shouldPrompt(wizardContext: T): boolean;
}
export declare class ResourceGroupNameStep<T extends IResourceGroupWizardContext> extends AzureWizardPromptStep<T> {
public prompt(wizardContext: T): Promise<void>;
public shouldPrompt(wizardContext: T): boolean;
}
export declare class ResourceGroupCreateStep<T extends IResourceGroupWizardContext> extends AzureWizardExecuteStep<T> {
/**
* 100
*/
public priority: number;
public execute(wizardContext: T, progress: Progress<{ message?: string; increment?: number }>): Promise<void>;
public shouldExecute(wizardContext: T): boolean;
}
export interface IStorageAccountWizardContext extends IResourceGroupWizardContext {
/**
* The storage account to use.
* If an existing storage account is picked, this value will be defined after `StorageAccountListStep.prompt` occurs
* If a new storage account is picked, this value will be defined after the `execute` phase of the 'create' subwizard
*/
storageAccount?: StorageAccount;
newStorageAccountName?: string;
}
export declare enum StorageAccountKind {
Storage = "Storage",
StorageV2 = "StorageV2",
BlobStorage = "BlobStorage",
BlockBlobStorage = "BlockBlobStorage",
}
export declare enum StorageAccountPerformance {
Standard = "Standard",
Premium = "Premium",
}
export declare enum StorageAccountReplication {
/**
* Locally redundant storage
*/
LRS = "LRS",
/**
* Zone-redundant storage
*/
ZRS = "ZRS",
/**
* Geo-redundant storage
*/
GRS = "GRS",
/**
* Read-access geo-redundant storage
*/
RAGRS = "RAGRS",
}
export interface INewStorageAccountDefaults {
kind: StorageAccountKind;
performance: StorageAccountPerformance;
replication: StorageAccountReplication;
}
export interface IStorageAccountFilters {
kind?: StorageAccountKind[];
performance?: StorageAccountPerformance[];
replication?: StorageAccountReplication[];
/**
* If specified, a 'learn more' option will be displayed to explain why some storage accounts were filtered
*/
learnMoreLink?: string;
}
export declare const storageAccountNamingRules: IAzureNamingRules;
export declare class StorageAccountListStep<T extends IStorageAccountWizardContext> extends AzureWizardPromptStep<T> {
/**
* @param createOptions Default options to use when creating a Storage Account
* @param filterOptions Optional filters used when listing Storage Accounts
*/
public constructor(createOptions: INewStorageAccountDefaults, filterOptions?: IStorageAccountFilters);
public static isNameAvailable<T extends IStorageAccountWizardContext>(wizardContext: T, name: string): Promise<boolean>;
public prompt(wizardContext: T): Promise<void>;
public getSubWizard(wizardContext: T): Promise<IWizardOptions<T> | undefined>;
public shouldPrompt(wizardContext: T): boolean;
}
export declare class StorageAccountNameStep<T extends IStorageAccountWizardContext> extends AzureNameStep<T> {
public constructor();
public prompt(wizardContext: T): Promise<void>;
public shouldPrompt(wizardContext: T): boolean;
protected isRelatedNameAvailable(wizardContext: T, name: string): Promise<boolean>;
}
export declare class StorageAccountCreateStep<T extends IStorageAccountWizardContext> extends AzureWizardExecuteStep<T> {
/**
* 130
*/
public priority: number;
public constructor(defaults: INewStorageAccountDefaults);
public execute(wizardContext: T, progress: Progress<{ message?: string; increment?: number }>): Promise<void>;
public shouldExecute(wizardContext: T): boolean;
}
export declare class UserAssignedIdentityListStep<T extends IResourceGroupWizardContext> extends AzureWizardPromptStep<T> {
public constructor(suppressCreate?: boolean);
public prompt(wizardContext: T): Promise<void>;
public shouldPrompt(wizardContext: T): boolean;
}
export declare class UserAssignedIdentityCreateStep<T extends IResourceGroupWizardContext> extends AzureWizardExecuteStep<T> {
/**
* 140
*/
public priority: number;
public constructor();
public execute(wizardContext: T, progress: Progress<{ message?: string; increment?: number }>): Promise<void>;
public shouldExecute(wizardContext: T): boolean;
}
export declare class RoleAssignmentExecuteStep<T extends IResourceGroupWizardContext, TKey extends keyof T> extends AzureWizardExecuteStep<T> {
/**
* 900
*/
public priority: number;
/**
* @param getScopeId A function that returns the scope id for the role assignment.
* The scope ID is the Azure ID of the resource that we are granting access to such as a storage account.
* Example: `/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/rgName/providers/Microsoft.Storage/storageAccounts/resourceName`
* This typically won't exist until _after_ the wizard executes and the resource is created, so we need to pass in a function that returns the ID.
* If the scope ID is undefined, the step will throw an error.
* @param roleDefinition The ARM role definition to assign. Use CommonRoleDefinition constant for role defintions that don't require user input.
* */
public constructor(getScopeId: () => string | undefined, roleDefinition: RoleDefinition);
public execute(wizardContext: T, progress: Progress<{ message?: string; increment?: number }>): Promise<void>;
public shouldExecute(wizardContext: T): boolean;
}
export interface IAzureUtilsExtensionVariables extends UIExtensionVariables {
prefix: string;
}
/**
* Call this to register common variables used throughout the UI package.
*/
export declare function registerAzureUtilsExtensionVariables(extVars: IAzureUtilsExtensionVariables): void;
/**
* Credential type to be used for creating generic http rest clients
*/
export type AzExtGenericCredentials = AzExtServiceClientCredentialsT2 | AzExtServiceClientCredentials;
export type AzExtGenericClientInfo = AzExtGenericCredentials | { credentials: AzExtGenericCredentials; environment: Environment; } | undefined;
/**
* Creates a generic http rest client (i.e. for non-Azure calls or for Azure calls that the available sdks don't support), ensuring best practices are followed. For example:
* 1. Adds extension-specific user agent
* 2. Uses resourceManagerEndpointUrl to support sovereigns (if clientInfo corresponds to an Azure environment)
* @param clientInfo The client/credentials info or `undefined` if no credentials are needed
*/
export declare function createGenericClient(context: IActionContext, clientInfo: AzExtGenericClientInfo | undefined, options?: IGenericClientOptions): Promise<ServiceClient>;
export interface IGenericClientOptions {
noRetryPolicy?: boolean;
addStatusCodePolicy?: boolean;
endpoint?: string;
}
export type AzExtRequestPrepareOptions = PipelineRequestOptions & { rejectUnauthorized?: boolean }
export type AzExtPipelineResponse = PipelineResponse & { parsedBody?: any }
/**
* Send request with a timeout specified and turn off retry policy (because retrying could take a lot longer)
* @param timeout The timeout in milliseconds
* @param clientInfo The client/credentials info or `undefined` if no credentials are needed
*/
export declare function sendRequestWithTimeout(context: IActionContext, options: AzExtRequestPrepareOptions, timeout: number, clientInfo: AzExtGenericClientInfo): Promise<AzExtPipelineResponse>;
export type AzExtClientType<T extends ServiceClient> = new (credentials: AzExtServiceClientCredentials, subscriptionId: string, options?: ServiceClientOptions) => T;
/**
* Convenience type to give us multiple ways to specify subscription info and action context depending on the scenario
*/
export type AzExtClientContext = ISubscriptionActionContext | [IActionContext, ISubscriptionContext | AzExtTreeItem];
/**
* Converts `AzExtClientContext` into a single object: `ISubscriptionActionContext`
*/
export declare function parseClientContext(clientContext: AzExtClientContext): ISubscriptionActionContext;
/**
* Creates an Azure client, ensuring best practices are followed. For example:
* 1. Adds extension-specific user agent
* 2. Uses resourceManagerEndpointUrl to support sovereigns
*/
export declare function createAzureClient<T extends ServiceClient>(context: AzExtClientContext, clientType: AzExtClientType<T>): T;
export type AzExtSubscriptionClientType<T> = new (credentials: AzExtServiceClientCredentials, options?: ServiceClientOptions) => T;
/**
* Creates an Azure subscription client, ensuring best practices are followed. For example:
* 1. Adds extension-specific user agent
* 2. Uses resourceManagerEndpointUrl to support sovereigns
*/
export declare function createAzureSubscriptionClient<T>(context: AzExtClientContext, clientType: AzExtSubscriptionClientType<T>): T;
export declare namespace uiUtils {
export function listAllIterator<T>(iterator: PagedAsyncIterableIterator<T>): Promise<T[]>
}
interface ParsedAzureResourceId {
rawId: string;
subscriptionId: string;
resourceGroup: string;
provider: string;
resourceName: string;
}
interface ParsedAzureResourceGroupId {
rawId: string;
subscriptionId: string;
resourceGroup: string;
}
export function parseAzureResourceId(id: string): ParsedAzureResourceId;
export function parseAzureResourceGroupId(id: string): ParsedAzureResourceGroupId;
export function getResourceGroupFromId(id: string): string;
export declare function createPortalUri(subscription: AzureSubscription, id: string, options?: OpenInPortalOptions): Uri;
/**
* Pipe Azure SDK logs into the provided log outptut channel using the @azure/logger package.
*
* @param logOutputChannel - log output channel to pipe logs into
*/
export function setupAzureLogger(logOutputChannel: LogOutputChannel): Disposable;
/**
* Replaces the usage of BasicAuthenticationCredentials for ServiceClients imported from @azure/core-pipelines
*
* @param client - The service client. This will typically be a generalClient
* @param userName - Username to be used with basic authentication login
* @param password - Password. Gets encoded before being set in the header
*/
export function addBasicAuthenticationCredentialsToClient(client: ServiceClient, userName: string, password: string): void;
export declare const CommonRoleDefinitions: {
readonly storageBlobDataContributor: {
readonly id: "/subscriptions/9b5c7ccb-9857-4307-843b-8875e83f65e9/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe";
readonly name: "ba92f5b4-2d11-453d-a403-e96b0029c9fe";
readonly type: "Microsoft.Authorization/roleDefinitions";
readonly roleName: "Storage Blob Data Contributor";
readonly description: "Allows for read, write and delete access to Azure Storage blob containers and data";
readonly roleType: "BuiltInRole";
};
};