Search in sources :

Example 1 with SpringCloudAppConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfiguration method readExternal.

@Override
public void readExternal(Element element) throws InvalidDataException {
    super.readExternal(element);
    final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.getProject());
    this.appConfig = Optional.ofNullable(element.getChild("SpringCloudAppConfig")).map(e -> XmlSerializer.deserialize(e, SpringCloudAppConfig.class)).orElse(SpringCloudAppConfig.builder().deployment(SpringCloudDeploymentConfig.builder().build()).build());
    Optional.ofNullable(element.getChild("Artifact")).map(e -> e.getAttributeValue("identifier")).map(manager::getAzureArtifactById).map(a -> new WrappedAzureArtifact(a, this.getProject())).ifPresent(a -> this.appConfig.getDeployment().setArtifact(a));
}
Also used : XmlSerializer(com.intellij.util.xmlb.XmlSerializer) Setter(lombok.Setter) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) SpringCloudDeploymentConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig) Getter(lombok.Getter) ConfigurationType(com.intellij.execution.configurations.ConfigurationType) SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig) InvalidDataException(com.intellij.openapi.util.InvalidDataException) RunProfileState(com.intellij.execution.configurations.RunProfileState) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Project(com.intellij.openapi.project.Project) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) LocatableConfiguration(com.intellij.execution.configurations.LocatableConfiguration) SettingsEditor(com.intellij.openapi.options.SettingsEditor) LocatableConfigurationBase(com.intellij.execution.configurations.LocatableConfigurationBase) Executor(com.intellij.execution.Executor) IArtifact(com.microsoft.azure.toolkit.lib.common.model.IArtifact) SpringCloudApp(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) AzureValidationInfo(com.microsoft.azure.toolkit.lib.common.form.AzureValidationInfo) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Optional(java.util.Optional) ConfigurationException(com.intellij.openapi.options.ConfigurationException) WriteExternalException(com.intellij.openapi.util.WriteExternalException) NotNull(org.jetbrains.annotations.NotNull) Element(org.jdom.Element) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) javax.swing(javax.swing) SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager)

Example 2 with SpringCloudAppConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfigurationState method execute.

@AzureOperation(name = "springcloud|app.create_update", params = { "this.config.getAppConfig().getAppName()" }, type = AzureOperation.Type.ACTION)
public SpringCloudDeployment execute(IAzureMessager messager) {
    AzureMessager.getContext().setMessager(messager);
    AzureTelemetry.getContext().setProperties(getTelemetryProperties());
    final SpringCloudAppConfig appConfig = this.config.getAppConfig();
    final DeploySpringCloudAppTask task = new DeploySpringCloudAppTask(appConfig);
    final SpringCloudDeployment deployment = task.execute();
    final SpringCloudApp app = deployment.app();
    final SpringCloudCluster cluster = app.getCluster();
    if (!deployment.waitUntilReady(GET_STATUS_TIMEOUT)) {
        messager.warning(GET_DEPLOYMENT_STATUS_TIMEOUT, NOTIFICATION_TITLE);
    }
    printPublicUrl(app);
    return deployment;
}
Also used : DeploySpringCloudAppTask(com.microsoft.azure.toolkit.lib.springcloud.task.DeploySpringCloudAppTask) SpringCloudDeployment(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment) SpringCloudCluster(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster) SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig) SpringCloudApp(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 3 with SpringCloudAppConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudAppConfigPanel method onDataChanged.

private void onDataChanged() {
    if (Objects.nonNull(this.originalConfig) && Objects.nonNull(this.listener)) {
        final SpringCloudAppConfig newConfig = this.getData();
        this.listener.accept(newConfig);
    }
}
Also used : SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig)

Example 4 with SpringCloudAppConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudAppConfigPanel method getData.

@Nonnull
public SpringCloudAppConfig getData() {
    final SpringCloudAppConfig appConfig = SpringCloudAppConfig.builder().deployment(SpringCloudDeploymentConfig.builder().build()).build();
    this.getData(appConfig);
    return appConfig;
}
Also used : SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig) Nonnull(javax.annotation.Nonnull)

Example 5 with SpringCloudAppConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfigurationState method getTelemetryProperties.

protected Map<String, String> getTelemetryProperties() {
    final Map<String, String> props = new HashMap<>();
    final SpringCloudAppConfig cfg = config.getAppConfig();
    props.put("runtime", String.valueOf(cfg.getRuntimeVersion()));
    props.put("subscriptionId", String.valueOf(cfg.getSubscriptionId()));
    props.put("public", String.valueOf(cfg.isPublic()));
    props.put("jvmOptions", String.valueOf(StringUtils.isNotEmpty(cfg.getDeployment().getJvmOptions())));
    props.put("instanceCount", String.valueOf(cfg.getDeployment().getInstanceCount()));
    props.put("memory", String.valueOf(cfg.getDeployment().getMemoryInGB()));
    props.put("cpu", String.valueOf(cfg.getDeployment().getCpu()));
    props.put("persistentStorage", String.valueOf(cfg.getDeployment().getEnablePersistentStorage()));
    return props;
}
Also used : HashMap(java.util.HashMap) SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig)

Aggregations

SpringCloudAppConfig (com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig)8 SpringCloudApp (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp)3 Nonnull (javax.annotation.Nonnull)3 Project (com.intellij.openapi.project.Project)2 AzureArtifactManager (com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager)2 SpringCloudCluster (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster)2 SpringCloudDeploymentConfig (com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig)2 List (java.util.List)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Nullable (javax.annotation.Nullable)2 javax.swing (javax.swing)2 Getter (lombok.Getter)2 Setter (lombok.Setter)2 Executor (com.intellij.execution.Executor)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 LocatableConfiguration (com.intellij.execution.configurations.LocatableConfiguration)1 LocatableConfigurationBase (com.intellij.execution.configurations.LocatableConfigurationBase)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1