/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as azdata from 'azdata'; import { Event } from 'vs/base/common/event'; import { AccountAdditionResult, AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/platform/accounts/common/eventTypes'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; export const SERVICE_ID = 'accountManagementService'; export const IAccountManagementService = createDecorator(SERVICE_ID); export interface IAccountManagementService { _serviceBrand: undefined; // ACCOUNT MANAGEMENT METHODS ////////////////////////////////////////// accountUpdated(account: azdata.Account): Promise; addAccount(providerId: string): Promise; getAccountProviderMetadata(): Promise; getAccountsForProvider(providerId: string): Promise; getAccounts(): Promise; /** * @deprecated */ getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Promise<{ [key: string]: { token: string } } | undefined>; getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Promise; removeAccount(accountKey: azdata.AccountKey): Promise; removeAccounts(): Promise; refreshAccount(account: azdata.Account): Promise; // UI METHODS ////////////////////////////////////////////////////////// openAccountListDialog(): Promise; beginAutoOAuthDeviceCode(providerId: string, title: string, message: string, userCode: string, uri: string): Promise; endAutoOAuthDeviceCode(): void; cancelAutoOAuthDeviceCode(providerId: string): void; copyUserCodeAndOpenBrowser(userCode: string, uri: string): Promise; // SERVICE MANAGEMENT METHODS ///////////////////////////////////////// registerProvider(providerMetadata: azdata.AccountProviderMetadata, provider: azdata.AccountProvider): void; unregisterProvider(providerMetadata: azdata.AccountProviderMetadata): void; // EVENTING //////////////////////////////////////////////////////////// readonly addAccountProviderEvent: Event; readonly removeAccountProviderEvent: Event; readonly updateAccountListEvent: Event; } export interface IAccountStore { /** * Adds the provided account if the account doesn't exist. Updates the account if it already exists * @param account Account to add/update * @return Results of the add/update operation */ addOrUpdate(account: azdata.Account): Promise; /** * Retrieves all accounts, filtered by provider ID * @param providerId ID of the provider to filter by * @return Promise to return all accounts that belong to the provided provider */ getAccountsByProvider(providerId: string): Promise; /** * Retrieves all accounts in the store. Returns empty array if store is not initialized * @return Promise to return all accounts */ getAllAccounts(): Promise; /** * Removes an account. * Returns false if the account was not found. * Otherwise, returns true. * @param key - The key of an account. * @returns True if the account was removed, false if the account doesn't exist */ remove(key: azdata.AccountKey): Promise; /** * Updates the custom properties stored with an account. * Returns null if no account was found to update. * Otherwise, returns a new updated account instance. * @param key - The key of an account. * @param updateOperation - Operation to perform on the matching account * @returns True if the account was modified, false if the account doesn't exist */ update(key: azdata.AccountKey, updateOperation: (account: azdata.Account) => void): Promise; }