import { ApiManagementModels } from "@azure/arm-apimanagement" ; import { AzureNameStep , IAzureNamingRules , ResourceGroupListStep , resourceGroupNamingRules } from "vscode-azureextensionui" ; import { ext } from "../../extensionVariables" ; import { localize } from "../../localize" ; import { nonNullProp } from "../../utils/nonNull" ; import { IServiceWizardContext } from "./IServiceWizardContext" ; export class ServiceNameStep extends AzureNameStep < IServiceWizardContext > { public async prompt ( wizardContext ) { const prompt = localize ( 'serviceNamePrompt' , 'Enter a globally unique name for the new API Management instance.' ) ; wizardContext . serviceName = ( await ext . ui . showInputBox ( { prompt , validateInput : async ( value ) : Promise < string | undefined > => { value = value ? value . trim ( ) : '' ; const nameAvailability = await wizardContext . client . apiManagementService . checkNameAvailability ( { name : value } ) ; if ( nameAvailability . nameAvailable !== undefined && ! nameAvailability . nameAvailable ) { return nameAvailability . message ; } else { return undefined ; } } } ) ) . trim ( ) ; const namingRules = [ resourceGroupNamingRules ] ; wizardContext . relatedNameTask = this . generateRelatedName ( wizardContext , nonNullProp ( wizardContext , "serviceName" ) , namingRules ) ; } public shouldPrompt ( wizardContext ) { return ! wizardContext . serviceName ; } protected async isRelatedNameAvailable ( wizardContext , name ) { return ResourceGroupListStep . isNameAvailable ( wizardContext , name ) ; } }