Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mgmt Spring Cloud Deployment update #14423

Merged
merged 13 commits into from
Aug 31, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

## 2.0.0-beta.4 (Unreleased)

- TODO
- Updated `api-version` to `2020-07-01`
- Add `defineActiveDeployment` and `getActiveDeployment` in SpringApp
- Removed `withoutTemporaryDisk` and `withoutPersistentDisk` in SpringAppDeployment
- Removed `withSettingsFromDeployment` in SpringAppDeployment
- Removed `deployJar` and `deploySource` in SpringApp
- Changed `serverProperties` to `getServerProperties` and `traceProperties` to `getMonitoringSetting` in SpringService
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.azure.resourcemanager.appplatform;


import com.azure.core.credential.TokenCredential;
import com.azure.core.http.HttpPipeline;
import com.azure.resourcemanager.appplatform.implementation.SpringServicesImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@

public class SpringAppDeploymentImpl
extends ExternalChildResourceImpl<SpringAppDeployment, DeploymentResourceInner, SpringAppImpl, SpringApp>
implements SpringAppDeployment, SpringAppDeployment.Definition, SpringAppDeployment.Update {
implements SpringAppDeployment,
SpringAppDeployment.Definition<SpringAppImpl, SpringAppDeploymentImpl>,
SpringAppDeployment.Update {

SpringAppDeploymentImpl(String name, SpringAppImpl parent,
DeploymentResourceInner innerObject) {
SpringAppDeploymentImpl(String name, SpringAppImpl parent, DeploymentResourceInner innerObject) {
super(name, parent, innerObject);
}

Expand Down Expand Up @@ -190,7 +191,7 @@ private Mono<Void> uploadToStorage(File source, ResourceUploadDefinition option)
ShareFileAsyncClient shareFileAsyncClient = createShareFileAsyncClient(option);
return shareFileAsyncClient.create(source.length())
.flatMap(fileInfo -> shareFileAsyncClient.uploadFromFile(source.getAbsolutePath()))
.then(Mono.empty());
.then(Mono.empty());
} catch (Exception e) {
return Mono.error(e);
}
Expand Down Expand Up @@ -389,4 +390,9 @@ public SpringAppDeploymentImpl update() {
private AppPlatformManager manager() {
return parent().manager();
}

@Override
public SpringAppImpl attach() {
return parent().addActiveDeployment(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class SpringAppDeploymentsImpl
extends ExternalChildResourcesNonCachedImpl<
SpringAppDeploymentImpl, SpringAppDeployment, DeploymentResourceInner, SpringAppImpl, SpringApp>
implements SpringAppDeployments {
implements SpringAppDeployments<SpringAppDeploymentImpl> {

SpringAppDeploymentsImpl(SpringAppImpl parent) {
super(parent, parent.taskGroup(), "SpringAppDeployment");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class SpringAppDomainsImpl
extends ExternalChildResourcesNonCachedImpl<
SpringAppDomainImpl, SpringAppDomain, CustomDomainResourceInner, SpringAppImpl, SpringApp>
SpringAppDomainImpl, SpringAppDomain, CustomDomainResourceInner, SpringAppImpl, SpringApp>
implements SpringAppDomains {
SpringAppDomainsImpl(SpringAppImpl parent) {
super(parent, parent.taskGroup(), "SpringAppDomain");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ public Mono<SpringAppDeployment> getActiveDeploymentAsync() {
}

@Override
public SpringAppDeployments deployments() {
return deployments;
@SuppressWarnings("unchecked")
public <T extends SpringAppDeployment.DefinitionStages.WithCreate<T>> SpringAppDeployments<T> deployments() {
return (SpringAppDeployments<T>) deployments;
Comment on lines +125 to +126
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have better solution for this unchecked warning, please comment. According to @weidongxu-microsoft, it seems the core library also use such way to suppress https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/Collections.java#l4479

}

@Override
Expand Down Expand Up @@ -205,27 +206,13 @@ public SpringAppImpl withTemporaryDisk(int sizeInGB, String mountPath) {
return this;
}

@Override
public SpringAppImpl withoutTemporaryDisk() {
ensureProperty();
inner().properties().withTemporaryDisk(null);
return this;
}

@Override
public SpringAppImpl withPersistentDisk(int sizeInGB, String mountPath) {
ensureProperty();
inner().properties().withPersistentDisk(new PersistentDisk().withSizeInGB(sizeInGB).withMountPath(mountPath));
return this;
}

@Override
public SpringAppImpl withoutPersistentDisk() {
ensureProperty();
inner().properties().withPersistentDisk(null);
return this;
}

@Override
public SpringAppImpl withActiveDeployment(String name) {
ensureProperty();
Expand Down Expand Up @@ -291,10 +278,26 @@ public SpringAppImpl withoutServiceBinding(String name) {
return this;
}

public void withDefaultActiveDeployment() {
@Override
public SpringAppImpl withDefaultActiveDeployment() {
String defaultDeploymentName = "default";
withActiveDeployment(defaultDeploymentName);
springAppDeploymentToCreate = deployments().define(defaultDeploymentName)
.withExistingSource(UserSourceType.JAR, String.format("<%s>", defaultDeploymentName));
return this;
}

@Override
@SuppressWarnings("unchecked")
public <T extends
SpringAppDeployment.DefinitionStages.WithAttach<? extends SpringApp.DefinitionStages.WithCreate, T>>
SpringAppDeployment.DefinitionStages.Blank<T> defineActiveDeployment(String name) {
return (SpringAppDeployment.DefinitionStages.Blank<T>) deployments.define(name);
}

SpringAppImpl addActiveDeployment(SpringAppDeploymentImpl deployment) {
withActiveDeployment(deployment.name());
springAppDeploymentToCreate = deployment;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

public class SpringServiceCertificateImpl
extends ExternalChildResourceImpl<
SpringServiceCertificate, CertificateResourceInner, SpringServiceImpl, SpringService>
SpringServiceCertificate, CertificateResourceInner, SpringServiceImpl, SpringService>
implements SpringServiceCertificate {
SpringServiceCertificateImpl(String name, SpringServiceImpl parent,
CertificateResourceInner innerObject) {
SpringServiceCertificateImpl(String name, SpringServiceImpl parent, CertificateResourceInner innerObject) {
super(name, parent, innerObject);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class SpringServiceImpl
SpringServiceImpl(String name, ServiceResourceInner innerObject, AppPlatformManager manager) {
super(name, innerObject, manager);
}

@Override
public Sku sku() {
return inner().sku();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SpringServicesImpl
SpringService, SpringServiceImpl, ServiceResourceInner, ServicesClient, AppPlatformManager>
implements SpringServices {
private static final String SPRING_TYPE = "Microsoft.AppPlatform/Spring";

public SpringServicesImpl(AppPlatformManager manager) {
super(manager.inner().getServices(), manager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ public interface SpringApp
/** @return the active deployment */
Mono<SpringAppDeployment> getActiveDeploymentAsync();

/** @return the entry point of the spring app deployment */
SpringAppDeployments deployments();
/**
* @param <T> derived type of {@link SpringAppDeployment.DefinitionStages.WithCreate}
* @return the entry point of the spring app deployment
*/
<T extends SpringAppDeployment.DefinitionStages.WithCreate<T>> SpringAppDeployments<T> deployments();

/** @return the entry point of the spring app service binding */
SpringAppServiceBindings serviceBindings();
Expand All @@ -72,12 +75,34 @@ public interface SpringApp

/** Container interface for all the definitions that need to be implemented. */
interface Definition
extends DefinitionStages.Blank { }
extends DefinitionStages.Blank,
DefinitionStages.WithCreate { }

/** Grouping of all the spring app definition stages. */
interface DefinitionStages {
/** The first stage of the spring app definition. */
interface Blank extends WithCreate { }
interface Blank extends WithDeployment { }

/**
* The stage of a spring app definition allowing to specify an active deployment.
*/
interface WithDeployment {
/**
* Deploys a default package for the spring app with default scale.
* @return the next stage of spring app definition
*/
WithCreate withDefaultActiveDeployment();

/**
* Starts the definition of the active deployment for the spring app.
* @param name the name of the deployment
* @param <T> derived type of {@link SpringAppDeployment.DefinitionStages.WithAttach}
* @return the first stage of spring app deployment definition
*/
<T extends SpringAppDeployment.DefinitionStages.WithAttach
<? extends SpringApp.DefinitionStages.WithCreate, T>>
SpringAppDeployment.DefinitionStages.Blank<T> defineActiveDeployment(String name);
}

/** The stage of a spring app definition allowing to specify the endpoint. */
interface WithEndpoint {
Expand Down Expand Up @@ -128,13 +153,6 @@ interface WithDisk {
WithCreate withPersistentDisk(int sizeInGB, String mountPath);
}

/**
* The stage of a spring app definition allowing to specify an simple active deployment.
* for more operations, use {@link #deployments()}
*/
interface WithDeployment {
}

/** The stage of a spring app update allowing to specify the service binding. */
interface WithServiceBinding {
/**
Expand Down Expand Up @@ -234,25 +252,13 @@ interface WithDisk {
*/
Update withTemporaryDisk(int sizeInGB, String mountPath);

/**
* Removes the temporary disk for the spring app.
* @return the next stage of spring app update
*/
Update withoutTemporaryDisk();

/**
* Specifies the persistent disk for the spring app.
* @param sizeInGB the size of the disk
* @param mountPath the mount path of the disk
* @return the next stage of spring app update
*/
Update withPersistentDisk(int sizeInGB, String mountPath);

/**
* Removes the persistent disk for the spring app.
* @return the next stage of spring app update
*/
Update withoutPersistentDisk();
}

/**
Expand Down
Loading