import { ApiManagementModels } from "@azure/arm-apimanagement" ; import { ApiManagementServiceResource } from "@azure/arm-apimanagement/src/models" ; import { MessageItem , Progress , window } from "vscode" ; import { AzureWizardExecuteStep } from "vscode-azureextensionui" ; import { ext } from "../../extensionVariables" ; import { localize } from "../../localize" ; import { nonNullProp , nonNullValueAndProp } from "../../utils/nonNull" ; import { IServiceWizardContext } from "./IServiceWizardContext" ; export class ServiceCreateStep extends AzureWizardExecuteStep < IServiceWizardContext > { public priority : number = 140 ; public async execute ( wizardContext , progress ) { const creatingNewService = localize ( 'creatingNewAPIManagementService' , 'Creating new API Management service "{0}"...' , wizardContext . serviceName ) ; ext . outputChannel . appendLine ( creatingNewService ) ; progress . report ( { message : creatingNewService } ) ; wizardContext . service = await wizardContext . client . apiManagementService . createOrUpdate ( nonNullValueAndProp ( wizardContext . resourceGroup , 'name' ) , nonNullProp ( wizardContext , 'serviceName' ) , < ApiManagementServiceResource > { location : nonNullValueAndProp ( wizardContext . location , 'name' ) , sku : < ApiManagementModels . ApiManagementServiceSkuProperties > { name : nonNullValueAndProp ( wizardContext , 'sku' ) , capacity : wizardContext . sku === 'Consumption' ? 0 : 1 } , publisherEmail : nonNullValueAndProp ( wizardContext , 'email' ) , publisherName : nonNullValueAndProp ( wizardContext , 'email' ) } ) ; const createdNewService = localize ( 'createdNewAPIManagementService' , 'Created new API Management service "{0}".' , wizardContext . service . name ) ; ext . outputChannel . appendLine ( createdNewService ) ; ext . outputChannel . appendLine ( '' ) ; const viewOutput = { title : localize ( 'viewOutput' , 'View Output' ) } ; window . showInformationMessage ( createdNewService , viewOutput ) . then ( ( result ) => { if ( result === viewOutput ) { ext . outputChannel . show ( ) ; } } ) ; } public shouldExecute ( wizardContext ) { return ! wizardContext . service ; } }