armpit
Version:
Another resource manager programming interface toolkit.
88 lines • 3.79 kB
TypeScript
import type { Location } from "@azure/arm-resources-subscriptions";
import type { AzCliInvoker } from "./azCliInvoker.js";
import { type Account, type SubscriptionIdOrName, type SubscriptionId, type TenantId, type SimpleAdUser } from "./azureUtils.js";
import { type ArmpitCredentialProvider, type ArmpitCredential, type ArmpitCredentialOptions, ArmpitCliCredentialFactory } from "./armpitCredential.js";
interface AccountToolsOptions {
abortSignal?: AbortSignal;
}
type AccountToolsConstructorOptions = AccountToolsOptions;
interface AccountToolsDependencies {
invoker: AzCliInvoker;
credentialFactory: ArmpitCliCredentialFactory;
}
interface AccountListOptions extends AccountToolsOptions {
all?: boolean;
refresh?: boolean;
}
interface AccountSelectionCriteria {
subscriptionId: SubscriptionId;
tenantId?: TenantId;
}
/**
* Tools to work with Azure CLI accounts.
* @remarks
* Accounts roughly approximate a subscription accessed by a user via the Azure CLI.
*/
export declare class AccountTools implements ArmpitCredentialProvider {
#private;
constructor(dependencies: AccountToolsDependencies, options: AccountToolsConstructorOptions);
/**
* Shows the current active Azure CLI account.
* @returns The current Azure CLI account, if available.
* @remarks
* This effectively invokes `az account show`.
*/
show(options?: AccountToolsOptions): Promise<Account | null>;
/**
* Shows the current signed in user.
* @returns The current user.
* This effectively invokes `az ad signed-in-user show`.
*/
showSignedInUser(options?: AccountToolsOptions): Promise<SimpleAdUser>;
/**
* Lists accounts known to the Azure CLI instance.
* @param options Query options.
* @returns The accounts known to the Azure CLI instance.
* @remarks
* This effectively invokes `az account list`.
*/
list(options?: AccountListOptions): Promise<Account[]>;
/**
* Sets the active account to the given subscription ID or name.
* @param subscriptionIdOrName The subscription ID or name to switch the account to.
* @remarks
* This effectively invokes `az account set`.
*/
set(subscriptionIdOrName: SubscriptionIdOrName, options?: AccountToolsOptions): Promise<void>;
/**
* Sets the active account to the given subscription or initiates a login if required.
* @param subscriptionIdOrName The subscription ID or name to set the account to.
* @param tenantId The tenant to log into when required.
*/
setOrLogin(subscriptionIdOrName: SubscriptionIdOrName, tenantId?: TenantId, options?: AccountToolsOptions): Promise<Account | null>;
/**
* Sets the active account to the given subscription or initiates a login if required.
* @param criteria The selection criteria for the account.
*/
setOrLogin(criteria: AccountSelectionCriteria, options?: AccountToolsOptions): Promise<Account | null>;
/**
* Initiates an Azure CLI login.
* @param tenantId The tenant to log into.
* @returns An account if login is successful.
*/
login(tenantId?: string, options?: AccountToolsOptions): Promise<Account[] | null>;
/**
* Provides the current account or initiates a login if required.
* @returns A logged in account when successful.
*/
ensureActiveAccount(options?: AccountToolsOptions): Promise<Account>;
/**
* Lits Azure locations.
* @param names The location names to filter locations to.
* @returns A lot of Azure locations.
*/
listLocations(names?: string[], options?: AccountToolsOptions): Promise<Location[]>;
getCredential(options?: ArmpitCredentialOptions): ArmpitCredential;
}
export {};
//# sourceMappingURL=accountTools.d.ts.map