Search in sources :

Example 1 with AppServiceBaseEntity

use of com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity in project azure-tools-for-java by Microsoft.

the class WebAppBasePropertyViewPresenter method generateProperty.

protected <T extends AppServiceBaseEntity> WebAppProperty generateProperty(@Nonnull final IAppService<T> appService, @Nonnull final IAppServicePlan plan) {
    final AppServiceBaseEntity appServiceEntity = appService.entity();
    final AppServicePlanEntity planEntity = plan.entity();
    final Map<String, String> appSettingsMap = appServiceEntity.getAppSettings();
    final Map<String, Object> propertyMap = new HashMap<>();
    propertyMap.put(KEY_NAME, appServiceEntity.getName());
    propertyMap.put(KEY_RESOURCE_GRP, appServiceEntity.getResourceGroup());
    propertyMap.put(KEY_LOCATION, appServiceEntity.getRegion().getLabel());
    propertyMap.put(KEY_SUB_ID, appService.subscriptionId());
    propertyMap.put(KEY_STATUS, appService.state());
    propertyMap.put(KEY_PLAN, plan.name());
    propertyMap.put(KEY_URL, appService.hostName());
    final PricingTier pricingTier = planEntity.getPricingTier();
    propertyMap.put(KEY_PRICING, String.format("%s_%s", pricingTier.getTier(), pricingTier.getSize()));
    final Runtime runtime = appService.getRuntime();
    final JavaVersion javaVersion = runtime.getJavaVersion();
    if (javaVersion != null && ObjectUtils.notEqual(javaVersion, JavaVersion.OFF)) {
        propertyMap.put(KEY_JAVA_VERSION, javaVersion.getValue());
        propertyMap.put(KEY_JAVA_CONTAINER, runtime.getWebContainer().getValue());
    }
    propertyMap.put(KEY_OPERATING_SYS, runtime.getOperatingSystem());
    propertyMap.put(KEY_APP_SETTING, appSettingsMap);
    return new WebAppProperty(propertyMap);
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AppServiceBaseEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity) AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) HashMap(java.util.HashMap) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) WebAppProperty(com.microsoft.azuretools.core.mvp.ui.webapp.WebAppProperty)

Aggregations

AppServiceBaseEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity)1 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)1 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)1 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)1 Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)1 WebAppProperty (com.microsoft.azuretools.core.mvp.ui.webapp.WebAppProperty)1 HashMap (java.util.HashMap)1