diff --git a/sdk/appplatform/mgmt/pom.xml b/sdk/appplatform/mgmt/pom.xml
index 6b323b92c0cf..ee5e35f90eea 100644
--- a/sdk/appplatform/mgmt/pom.xml
+++ b/sdk/appplatform/mgmt/pom.xml
@@ -81,6 +81,30 @@
azure-identity
test
+
+ com.azure
+ azure-security-keyvault-certificates
+ 4.0.4
+ test
+
+
+ com.azure.resourcemanager
+ azure-resourcemanager-keyvault
+ 2.0.0-SNAPSHOT
+ test
+
+
+ com.azure.resourcemanager
+ azure-resourcemanager-dns
+ 2.0.0-SNAPSHOT
+ test
+
+
+ com.azure.resourcemanager
+ azure-resourcemanager-appservice
+ 2.0.0-SNAPSHOT
+ test
+
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/CustomDomainsClient.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/CustomDomainsClient.java
index bf62bebbb1a7..e48fbb512d92 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/CustomDomainsClient.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/CustomDomainsClient.java
@@ -33,9 +33,9 @@
import com.azure.resourcemanager.appplatform.AppPlatformManagementClient;
import com.azure.resourcemanager.appplatform.fluent.inner.CustomDomainResourceCollectionInner;
import com.azure.resourcemanager.appplatform.fluent.inner.CustomDomainResourceInner;
-import com.azure.resourcemanager.appplatform.fluent.inner.CustomDomainValidateResultInner;
import com.azure.resourcemanager.appplatform.models.CustomDomainProperties;
import com.azure.resourcemanager.appplatform.models.CustomDomainValidatePayload;
+import com.azure.resourcemanager.appplatform.models.CustomDomainValidateResult;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in CustomDomains. */
@@ -153,7 +153,7 @@ Mono> list(
+ "/{serviceName}/apps/{appName}/domains/validate")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
- Mono> validate(
+ Mono> validate(
@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
@@ -1273,7 +1273,7 @@ public PagedIterable list(
* @return validation result for custom domain.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono> validateWithResponseAsync(
+ public Mono> validateWithResponseAsync(
String resourceGroupName, String serviceName, String appName, String name) {
if (this.client.getEndpoint() == null) {
return Mono
@@ -1333,7 +1333,7 @@ public Mono> validateWithResponseAsync
* @return validation result for custom domain.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono> validateWithResponseAsync(
+ public Mono> validateWithResponseAsync(
String resourceGroupName, String serviceName, String appName, String name, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
@@ -1388,11 +1388,11 @@ public Mono> validateWithResponseAsync
* @return validation result for custom domain.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono validateAsync(
+ public Mono validateAsync(
String resourceGroupName, String serviceName, String appName, String name) {
return validateWithResponseAsync(resourceGroupName, serviceName, appName, name)
.flatMap(
- (Response res) -> {
+ (Response res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
@@ -1416,11 +1416,11 @@ public Mono validateAsync(
* @return validation result for custom domain.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono validateAsync(
+ public Mono validateAsync(
String resourceGroupName, String serviceName, String appName, String name, Context context) {
return validateWithResponseAsync(resourceGroupName, serviceName, appName, name, context)
.flatMap(
- (Response res) -> {
+ (Response res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
@@ -1443,7 +1443,7 @@ public Mono validateAsync(
* @return validation result for custom domain.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public CustomDomainValidateResultInner validate(
+ public CustomDomainValidateResult validate(
String resourceGroupName, String serviceName, String appName, String name) {
return validateAsync(resourceGroupName, serviceName, appName, name).block();
}
@@ -1463,7 +1463,7 @@ public CustomDomainValidateResultInner validate(
* @return validation result for custom domain.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public CustomDomainValidateResultInner validate(
+ public CustomDomainValidateResult validate(
String resourceGroupName, String serviceName, String appName, String name, Context context) {
return validateAsync(resourceGroupName, serviceName, appName, name, context).block();
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/ServicesClient.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/ServicesClient.java
index 9f9648f56e3f..95dcac0cfde6 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/ServicesClient.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/ServicesClient.java
@@ -34,9 +34,9 @@
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.appplatform.AppPlatformManagementClient;
-import com.azure.resourcemanager.appplatform.fluent.inner.NameAvailabilityInner;
import com.azure.resourcemanager.appplatform.fluent.inner.ServiceResourceInner;
import com.azure.resourcemanager.appplatform.fluent.inner.ServiceResourceListInner;
+import com.azure.resourcemanager.appplatform.models.NameAvailability;
import com.azure.resourcemanager.appplatform.models.NameAvailabilityParameters;
import com.azure.resourcemanager.appplatform.models.RegenerateTestKeyRequestPayload;
import com.azure.resourcemanager.appplatform.models.TestKeyType;
@@ -199,7 +199,7 @@ Mono> enableTestEndpoint(
+ "/checkNameAvailability")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
- Mono> checkNameAvailability(
+ Mono> checkNameAvailability(
@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion,
@PathParam("subscriptionId") String subscriptionId,
@@ -1856,7 +1856,7 @@ public TestKeys enableTestEndpoint(String resourceGroupName, String serviceName,
* @return name availability result payload.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono> checkNameAvailabilityWithResponseAsync(
+ public Mono> checkNameAvailabilityWithResponseAsync(
String location, NameAvailabilityParameters availabilityParameters) {
if (this.client.getEndpoint() == null) {
return Mono
@@ -1906,7 +1906,7 @@ public Mono> checkNameAvailabilityWithResponseAs
* @return name availability result payload.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono> checkNameAvailabilityWithResponseAsync(
+ public Mono> checkNameAvailabilityWithResponseAsync(
String location, NameAvailabilityParameters availabilityParameters, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
@@ -1951,11 +1951,11 @@ public Mono> checkNameAvailabilityWithResponseAs
* @return name availability result payload.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono checkNameAvailabilityAsync(
+ public Mono checkNameAvailabilityAsync(
String location, NameAvailabilityParameters availabilityParameters) {
return checkNameAvailabilityWithResponseAsync(location, availabilityParameters)
.flatMap(
- (Response res) -> {
+ (Response res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
@@ -1976,11 +1976,11 @@ public Mono checkNameAvailabilityAsync(
* @return name availability result payload.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono checkNameAvailabilityAsync(
+ public Mono checkNameAvailabilityAsync(
String location, NameAvailabilityParameters availabilityParameters, Context context) {
return checkNameAvailabilityWithResponseAsync(location, availabilityParameters, context)
.flatMap(
- (Response res) -> {
+ (Response res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
@@ -2000,8 +2000,7 @@ public Mono checkNameAvailabilityAsync(
* @return name availability result payload.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public NameAvailabilityInner checkNameAvailability(
- String location, NameAvailabilityParameters availabilityParameters) {
+ public NameAvailability checkNameAvailability(String location, NameAvailabilityParameters availabilityParameters) {
return checkNameAvailabilityAsync(location, availabilityParameters).block();
}
@@ -2017,7 +2016,7 @@ public NameAvailabilityInner checkNameAvailability(
* @return name availability result payload.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public NameAvailabilityInner checkNameAvailability(
+ public NameAvailability checkNameAvailability(
String location, NameAvailabilityParameters availabilityParameters, Context context) {
return checkNameAvailabilityAsync(location, availabilityParameters, context).block();
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDeploymentImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDeploymentImpl.java
index d985f51f1d5c..daa581e306cd 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDeploymentImpl.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDeploymentImpl.java
@@ -99,6 +99,42 @@ public List instances() {
return inner().properties().instances();
}
+ @Override
+ public void start() {
+ startAsync().block();
+ }
+
+ @Override
+ public Mono startAsync() {
+ return manager().inner().getDeployments().startAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
+ );
+ }
+
+ @Override
+ public void stop() {
+ stopAsync().block();
+ }
+
+ @Override
+ public Mono stopAsync() {
+ return manager().inner().getDeployments().stopAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
+ );
+ }
+
+ @Override
+ public void restart() {
+ restartAsync().block();
+ }
+
+ @Override
+ public Mono restartAsync() {
+ return manager().inner().getDeployments().restartAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
+ );
+ }
+
@Override
public String getLogFileUrl() {
return getLogFileUrlAsync().block();
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainImpl.java
new file mode 100644
index 000000000000..60deaa85e234
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainImpl.java
@@ -0,0 +1,64 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.implementation;
+
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.inner.CustomDomainResourceInner;
+import com.azure.resourcemanager.appplatform.models.CustomDomainProperties;
+import com.azure.resourcemanager.appplatform.models.SpringApp;
+import com.azure.resourcemanager.appplatform.models.SpringAppDomain;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl;
+import reactor.core.publisher.Mono;
+
+public class SpringAppDomainImpl
+ extends ExternalChildResourceImpl
+ implements SpringAppDomain {
+ SpringAppDomainImpl(String name, SpringAppImpl parent, CustomDomainResourceInner innerObject) {
+ super(name, parent, innerObject);
+ }
+
+ @Override
+ public Mono createResourceAsync() {
+ return manager().inner().getCustomDomains().createOrUpdateAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name(), properties()
+ )
+ .map(inner -> {
+ setInner(inner);
+ return this;
+ });
+ }
+
+ @Override
+ public Mono updateResourceAsync() {
+ return createResourceAsync();
+ }
+
+ @Override
+ public Mono deleteResourceAsync() {
+ return manager().inner().getBindings().deleteAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
+ );
+ }
+
+ @Override
+ protected Mono getInnerAsync() {
+ return manager().inner().getCustomDomains().getAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
+ );
+ }
+
+ @Override
+ public String id() {
+ return inner().id();
+ }
+
+ @Override
+ public CustomDomainProperties properties() {
+ return inner().properties();
+ }
+
+ private AppPlatformManager manager() {
+ return parent().manager();
+ }
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainsImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainsImpl.java
new file mode 100644
index 000000000000..5b4f1a6b4939
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainsImpl.java
@@ -0,0 +1,116 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.implementation;
+
+import com.azure.core.http.rest.PagedFlux;
+import com.azure.core.http.rest.PagedIterable;
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.CustomDomainsClient;
+import com.azure.resourcemanager.appplatform.fluent.inner.CustomDomainResourceInner;
+import com.azure.resourcemanager.appplatform.models.CustomDomainProperties;
+import com.azure.resourcemanager.appplatform.models.CustomDomainValidateResult;
+import com.azure.resourcemanager.appplatform.models.SpringApp;
+import com.azure.resourcemanager.appplatform.models.SpringAppDomain;
+import com.azure.resourcemanager.appplatform.models.SpringAppDomains;
+import com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesNonCachedImpl;
+import reactor.core.publisher.Mono;
+
+public class SpringAppDomainsImpl
+ extends ExternalChildResourcesNonCachedImpl<
+ SpringAppDomainImpl, SpringAppDomain, CustomDomainResourceInner, SpringAppImpl, SpringApp>
+ implements SpringAppDomains {
+ SpringAppDomainsImpl(SpringAppImpl parent) {
+ super(parent, parent.taskGroup(), "SpringAppDomain");
+ }
+
+ @Override
+ public SpringAppDomain getById(String id) {
+ return getByIdAsync(id).block();
+ }
+
+ @Override
+ public Mono getByIdAsync(String id) {
+ return getByNameAsync(ResourceUtils.nameFromResourceId(id));
+ }
+
+ @Override
+ public SpringAppDomain getByName(String name) {
+ return getByNameAsync(name).block();
+ }
+
+ @Override
+ public Mono getByNameAsync(String name) {
+ return inner().getAsync(parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name)
+ .map(this::wrapModel);
+ }
+
+ SpringAppDomainImpl wrapModel(CustomDomainResourceInner inner) {
+ return inner == null ? null : new SpringAppDomainImpl(inner.name(), parent(), inner);
+ }
+
+ @Override
+ public AppPlatformManager manager() {
+ return parent().manager();
+ }
+
+ @Override
+ public SpringAppImpl parent() {
+ return getParent();
+ }
+
+ @Override
+ public void deleteById(String id) {
+ deleteByIdAsync(id).block();
+ }
+
+ @Override
+ public Mono> deleteByIdAsync(String id) {
+ return deleteByNameAsync(ResourceUtils.nameFromResourceId(id));
+ }
+
+ @Override
+ public void deleteByName(String name) {
+ deleteByNameAsync(name).block();
+ }
+
+ @Override
+ public Mono deleteByNameAsync(String name) {
+ return inner().deleteAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name);
+ }
+
+ @Override
+ public PagedIterable list() {
+ return new PagedIterable<>(listAsync());
+ }
+
+ @Override
+ public PagedFlux listAsync() {
+ return inner().listAsync(parent().parent().resourceGroupName(), parent().parent().name(), parent().name())
+ .mapPage(this::wrapModel);
+ }
+
+ @Override
+ public CustomDomainsClient inner() {
+ return manager().inner().getCustomDomains();
+ }
+
+ @Override
+ public CustomDomainValidateResult validate(String domain) {
+ return validateAsync(domain).block();
+ }
+
+ @Override
+ public Mono validateAsync(String domain) {
+ return inner().validateAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), domain);
+ }
+
+ Mono createOrUpdateAsync(String name, CustomDomainProperties properties) {
+ return inner().createOrUpdateAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name, properties
+ ).map(this::wrapModel);
+ }
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppImpl.java
index 6d811a0eb8d4..f49c7a3c155e 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppImpl.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppImpl.java
@@ -6,17 +6,22 @@
import com.azure.resourcemanager.appplatform.AppPlatformManager;
import com.azure.resourcemanager.appplatform.fluent.inner.AppResourceInner;
import com.azure.resourcemanager.appplatform.models.AppResourceProperties;
+import com.azure.resourcemanager.appplatform.models.BindingResourceProperties;
+import com.azure.resourcemanager.appplatform.models.CustomDomainProperties;
import com.azure.resourcemanager.appplatform.models.ManagedIdentityProperties;
import com.azure.resourcemanager.appplatform.models.PersistentDisk;
import com.azure.resourcemanager.appplatform.models.ResourceUploadDefinition;
import com.azure.resourcemanager.appplatform.models.SpringApp;
import com.azure.resourcemanager.appplatform.models.SpringAppDeployment;
import com.azure.resourcemanager.appplatform.models.SpringAppDeployments;
+import com.azure.resourcemanager.appplatform.models.SpringAppDomains;
+import com.azure.resourcemanager.appplatform.models.SpringAppServiceBindings;
import com.azure.resourcemanager.appplatform.models.SpringService;
import com.azure.resourcemanager.appplatform.models.TemporaryDisk;
import com.azure.resourcemanager.appplatform.models.UserSourceType;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl;
import com.azure.resourcemanager.resources.fluentcore.model.Creatable;
+import com.azure.resourcemanager.resources.fluentcore.model.Indexable;
import reactor.core.publisher.Mono;
import java.io.File;
@@ -26,6 +31,9 @@ public class SpringAppImpl
extends ExternalChildResourceImpl
implements SpringApp, SpringApp.Definition, SpringApp.Update {
private Creatable springAppDeploymentToCreate = null;
+ private final SpringAppDeploymentsImpl deployments = new SpringAppDeploymentsImpl(this);
+ private final SpringAppServiceBindingsImpl serviceBindings = new SpringAppServiceBindingsImpl(this);
+ private final SpringAppDomainsImpl domains = new SpringAppDomainsImpl(this);
SpringAppImpl(String name, SpringServiceImpl parent, AppResourceInner innerObject) {
super(name, parent, innerObject);
@@ -55,6 +63,14 @@ public String url() {
return inner().properties().url();
}
+ @Override
+ public String fqdn() {
+ if (inner().properties() == null) {
+ return null;
+ }
+ return inner().properties().fqdn();
+ }
+
@Override
public TemporaryDisk temporaryDisk() {
if (inner().properties() == null) {
@@ -94,7 +110,17 @@ public String activeDeployment() {
@Override
public SpringAppDeployments deployments() {
- return new SpringAppDeploymentsImpl(this);
+ return deployments;
+ }
+
+ @Override
+ public SpringAppServiceBindings serviceBindings() {
+ return serviceBindings;
+ }
+
+ @Override
+ public SpringAppDomains customDomains() {
+ return domains;
}
@Override
@@ -115,14 +141,14 @@ private void ensureProperty() {
}
@Override
- public SpringAppImpl withPublicEndpoint() {
+ public SpringAppImpl withDefaultPublicEndpoint() {
ensureProperty();
inner().properties().withPublicProperty(true);
return this;
}
@Override
- public SpringAppImpl withoutPublicEndpoint() {
+ public SpringAppImpl withoutDefaultPublicEndpoint() {
ensureProperty();
inner().properties().withPublicProperty(false);
return this;
@@ -130,15 +156,27 @@ public SpringAppImpl withoutPublicEndpoint() {
@Override
public SpringAppImpl withCustomDomain(String domain) {
- ensureProperty();
- inner().properties().withFqdn(domain);
+ this.addPostRunDependent(
+ context -> domains.createOrUpdateAsync(domain, new CustomDomainProperties())
+ .cast(Indexable.class)
+ );
return this;
}
@Override
- public SpringAppImpl withoutCustomDomain() {
- ensureProperty();
- inner().properties().withFqdn(null);
+ public SpringAppImpl withCustomDomain(String domain, String certThumbprint) {
+ this.addPostRunDependent(
+ context -> domains.createOrUpdateAsync(domain, new CustomDomainProperties().withThumbprint(certThumbprint))
+ .cast(Indexable.class)
+ );
+ return this;
+ }
+
+ @Override
+ public Update withoutCustomDomain(String domain) {
+ this.addPostRunDependent(
+ context -> domains.deleteByNameAsync(domain).then(context.voidMono())
+ );
return this;
}
@@ -279,4 +317,20 @@ public SpringAppImpl update() {
public AppPlatformManager manager() {
return parent().manager();
}
+
+ @Override
+ public SpringAppImpl withServiceBinding(String name, BindingResourceProperties bindingProperties) {
+ this.addPostRunDependent(
+ context -> serviceBindings.createOrUpdateAsync(name, bindingProperties).cast(Indexable.class)
+ );
+ return this;
+ }
+
+ @Override
+ public SpringAppImpl withoutServiceBinding(String name) {
+ this.addPostRunDependent(
+ context -> serviceBindings.deleteByNameAsync(name).then(context.voidMono())
+ );
+ return this;
+ }
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppServiceBindingImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppServiceBindingImpl.java
new file mode 100644
index 000000000000..3399f6f95cb6
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppServiceBindingImpl.java
@@ -0,0 +1,64 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.implementation;
+
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.inner.BindingResourceInner;
+import com.azure.resourcemanager.appplatform.models.BindingResourceProperties;
+import com.azure.resourcemanager.appplatform.models.SpringApp;
+import com.azure.resourcemanager.appplatform.models.SpringAppServiceBinding;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl;
+import reactor.core.publisher.Mono;
+
+public class SpringAppServiceBindingImpl
+ extends ExternalChildResourceImpl
+ implements SpringAppServiceBinding {
+ SpringAppServiceBindingImpl(String name, SpringAppImpl parent, BindingResourceInner innerObject) {
+ super(name, parent, innerObject);
+ }
+
+ @Override
+ public Mono createResourceAsync() {
+ return manager().inner().getBindings().createOrUpdateAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name(), properties()
+ )
+ .map(inner -> {
+ setInner(inner);
+ return this;
+ });
+ }
+
+ @Override
+ public Mono updateResourceAsync() {
+ return createResourceAsync();
+ }
+
+ @Override
+ public Mono deleteResourceAsync() {
+ return manager().inner().getBindings().deleteAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
+ );
+ }
+
+ @Override
+ protected Mono getInnerAsync() {
+ return manager().inner().getBindings().getAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
+ );
+ }
+
+ @Override
+ public String id() {
+ return inner().id();
+ }
+
+ @Override
+ public BindingResourceProperties properties() {
+ return inner().properties();
+ }
+
+ private AppPlatformManager manager() {
+ return parent().manager();
+ }
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppServiceBindingsImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppServiceBindingsImpl.java
new file mode 100644
index 000000000000..07326ae08fa0
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppServiceBindingsImpl.java
@@ -0,0 +1,104 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.implementation;
+
+import com.azure.core.http.rest.PagedFlux;
+import com.azure.core.http.rest.PagedIterable;
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.BindingsClient;
+import com.azure.resourcemanager.appplatform.fluent.inner.BindingResourceInner;
+import com.azure.resourcemanager.appplatform.models.BindingResourceProperties;
+import com.azure.resourcemanager.appplatform.models.SpringApp;
+import com.azure.resourcemanager.appplatform.models.SpringAppServiceBinding;
+import com.azure.resourcemanager.appplatform.models.SpringAppServiceBindings;
+import com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesNonCachedImpl;
+import reactor.core.publisher.Mono;
+
+public class SpringAppServiceBindingsImpl
+ extends ExternalChildResourcesNonCachedImpl<
+ SpringAppServiceBindingImpl, SpringAppServiceBinding, BindingResourceInner, SpringAppImpl, SpringApp>
+ implements SpringAppServiceBindings {
+ SpringAppServiceBindingsImpl(SpringAppImpl parent) {
+ super(parent, parent.taskGroup(), "SpringAppServiceBinding");
+ }
+
+ @Override
+ public SpringAppServiceBinding getById(String id) {
+ return getByIdAsync(id).block();
+ }
+
+ @Override
+ public Mono getByIdAsync(String id) {
+ return getByNameAsync(ResourceUtils.nameFromResourceId(id));
+ }
+
+ @Override
+ public SpringAppServiceBinding getByName(String name) {
+ return getByNameAsync(name).block();
+ }
+
+ @Override
+ public Mono getByNameAsync(String name) {
+ return inner().getAsync(parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name)
+ .map(this::wrapModel);
+ }
+
+ SpringAppServiceBindingImpl wrapModel(BindingResourceInner inner) {
+ return inner == null ? null : new SpringAppServiceBindingImpl(inner.name(), parent(), inner);
+ }
+
+ @Override
+ public AppPlatformManager manager() {
+ return parent().manager();
+ }
+
+ @Override
+ public SpringAppImpl parent() {
+ return getParent();
+ }
+
+ @Override
+ public void deleteById(String id) {
+ deleteByIdAsync(id).block();
+ }
+
+ @Override
+ public Mono> deleteByIdAsync(String id) {
+ return deleteByNameAsync(ResourceUtils.nameFromResourceId(id));
+ }
+
+ @Override
+ public void deleteByName(String name) {
+ deleteByNameAsync(name).block();
+ }
+
+ @Override
+ public Mono deleteByNameAsync(String name) {
+ return inner().deleteAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name);
+ }
+
+ @Override
+ public PagedIterable list() {
+ return new PagedIterable<>(listAsync());
+ }
+
+ @Override
+ public PagedFlux listAsync() {
+ return inner().listAsync(parent().parent().resourceGroupName(), parent().parent().name(), parent().name())
+ .mapPage(this::wrapModel);
+ }
+
+ @Override
+ public BindingsClient inner() {
+ return manager().inner().getBindings();
+ }
+
+ Mono createOrUpdateAsync(String name, BindingResourceProperties properties) {
+ return inner().createOrUpdateAsync(
+ parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name, properties
+ ).map(this::wrapModel);
+ }
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceCertificateImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceCertificateImpl.java
new file mode 100644
index 000000000000..d517c28cc2c3
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceCertificateImpl.java
@@ -0,0 +1,61 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.implementation;
+
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.inner.CertificateResourceInner;
+import com.azure.resourcemanager.appplatform.models.CertificateProperties;
+import com.azure.resourcemanager.appplatform.models.SpringService;
+import com.azure.resourcemanager.appplatform.models.SpringServiceCertificate;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl;
+import reactor.core.publisher.Mono;
+
+public class SpringServiceCertificateImpl
+ extends ExternalChildResourceImpl<
+ SpringServiceCertificate, CertificateResourceInner, SpringServiceImpl, SpringService>
+ implements SpringServiceCertificate {
+ SpringServiceCertificateImpl(String name, SpringServiceImpl parent,
+ CertificateResourceInner innerObject) {
+ super(name, parent, innerObject);
+ }
+
+ @Override
+ public Mono createResourceAsync() {
+ return manager().inner().getCertificates().createOrUpdateAsync(
+ parent().resourceGroupName(), parent().name(), name(), inner().properties())
+ .map(inner -> {
+ setInner(inner);
+ return this;
+ });
+ }
+
+ @Override
+ public Mono updateResourceAsync() {
+ return createResourceAsync();
+ }
+
+ @Override
+ public Mono deleteResourceAsync() {
+ return manager().inner().getCertificates().deleteAsync(parent().resourceGroupName(), parent().name(), name());
+ }
+
+ @Override
+ protected Mono getInnerAsync() {
+ return manager().inner().getCertificates().getAsync(parent().resourceGroupName(), parent().name(), name());
+ }
+
+ @Override
+ public CertificateProperties properties() {
+ return inner().properties();
+ }
+
+ @Override
+ public String id() {
+ return inner().id();
+ }
+
+ public AppPlatformManager manager() {
+ return parent().manager();
+ }
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceCertificatesImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceCertificatesImpl.java
new file mode 100644
index 000000000000..a9bc99498871
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceCertificatesImpl.java
@@ -0,0 +1,102 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.implementation;
+
+import com.azure.core.http.rest.PagedFlux;
+import com.azure.core.http.rest.PagedIterable;
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.CertificatesClient;
+import com.azure.resourcemanager.appplatform.fluent.inner.CertificateResourceInner;
+import com.azure.resourcemanager.appplatform.models.CertificateProperties;
+import com.azure.resourcemanager.appplatform.models.SpringService;
+import com.azure.resourcemanager.appplatform.models.SpringServiceCertificate;
+import com.azure.resourcemanager.appplatform.models.SpringServiceCertificates;
+import com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesNonCachedImpl;
+import reactor.core.publisher.Mono;
+
+public class SpringServiceCertificatesImpl
+ extends ExternalChildResourcesNonCachedImpl<
+ SpringServiceCertificateImpl, SpringServiceCertificate, CertificateResourceInner, SpringServiceImpl, SpringService>
+ implements SpringServiceCertificates {
+ SpringServiceCertificatesImpl(SpringServiceImpl parent) {
+ super(parent, parent.taskGroup(), "SpringServiceCertificate");
+ }
+
+ @Override
+ public SpringServiceCertificate getById(String id) {
+ return getByIdAsync(id).block();
+ }
+
+ @Override
+ public Mono getByIdAsync(String id) {
+ return getByNameAsync(ResourceUtils.nameFromResourceId(id));
+ }
+
+ @Override
+ public SpringServiceCertificate getByName(String name) {
+ return getByNameAsync(name).block();
+ }
+
+ @Override
+ public Mono getByNameAsync(String name) {
+ return inner().getAsync(parent().resourceGroupName(), parent().name(), name)
+ .map(this::wrapModel);
+ }
+
+ SpringServiceCertificateImpl wrapModel(CertificateResourceInner inner) {
+ return inner == null ? null : new SpringServiceCertificateImpl(inner.name(), parent(), inner);
+ }
+
+ @Override
+ public AppPlatformManager manager() {
+ return parent().manager();
+ }
+
+ @Override
+ public SpringServiceImpl parent() {
+ return getParent();
+ }
+
+ @Override
+ public void deleteById(String id) {
+ deleteByIdAsync(id).block();
+ }
+
+ @Override
+ public Mono> deleteByIdAsync(String id) {
+ return deleteByNameAsync(ResourceUtils.nameFromResourceId(id));
+ }
+
+ @Override
+ public void deleteByName(String name) {
+ deleteByNameAsync(name).block();
+ }
+
+ @Override
+ public Mono deleteByNameAsync(String name) {
+ return inner().deleteAsync(parent().resourceGroupName(), parent().name(), name);
+ }
+
+ @Override
+ public PagedIterable list() {
+ return new PagedIterable<>(listAsync());
+ }
+
+ @Override
+ public PagedFlux listAsync() {
+ return inner().listAsync(parent().resourceGroupName(), parent().name()).mapPage(this::wrapModel);
+ }
+
+ @Override
+ public CertificatesClient inner() {
+ return manager().inner().getCertificates();
+ }
+
+ Mono createOrUpdateAsync(String name, CertificateProperties properties) {
+ return inner().createOrUpdateAsync(
+ parent().resourceGroupName(), parent().name(), name, properties
+ ).map(this::wrapModel);
+ }
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceImpl.java
index 5ac8e890fab1..0ab6f0dbc90e 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceImpl.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServiceImpl.java
@@ -5,6 +5,7 @@
import com.azure.resourcemanager.appplatform.AppPlatformManager;
import com.azure.resourcemanager.appplatform.fluent.inner.ServiceResourceInner;
+import com.azure.resourcemanager.appplatform.models.CertificateProperties;
import com.azure.resourcemanager.appplatform.models.ClusterResourceProperties;
import com.azure.resourcemanager.appplatform.models.ConfigServerGitProperty;
import com.azure.resourcemanager.appplatform.models.ConfigServerProperties;
@@ -12,15 +13,19 @@
import com.azure.resourcemanager.appplatform.models.Sku;
import com.azure.resourcemanager.appplatform.models.SpringApps;
import com.azure.resourcemanager.appplatform.models.SpringService;
+import com.azure.resourcemanager.appplatform.models.SpringServiceCertificates;
import com.azure.resourcemanager.appplatform.models.TestKeyType;
import com.azure.resourcemanager.appplatform.models.TestKeys;
import com.azure.resourcemanager.appplatform.models.TraceProperties;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
+import com.azure.resourcemanager.resources.fluentcore.model.Indexable;
import reactor.core.publisher.Mono;
public class SpringServiceImpl
extends GroupableResourceImpl
implements SpringService, SpringService.Definition, SpringService.Update {
+ private final SpringServiceCertificatesImpl certificates = new SpringServiceCertificatesImpl(this);
+ private final SpringAppsImpl apps = new SpringAppsImpl(this);
SpringServiceImpl(String name, ServiceResourceInner innerObject, AppPlatformManager manager) {
super(name, innerObject, manager);
@@ -42,7 +47,12 @@ public ConfigServerProperties serverProperties() {
@Override
public SpringApps apps() {
- return new SpringAppsImpl(this);
+ return apps;
+ }
+
+ @Override
+ public SpringServiceCertificates certificates() {
+ return certificates;
}
@Override
@@ -183,4 +193,39 @@ public Mono createResourceAsync() {
protected Mono getInnerAsync() {
return manager().inner().getServices().getByResourceGroupAsync(resourceGroupName(), name());
}
+
+ @Override
+ public SpringServiceImpl withCertificate(String name, String keyVaultUri, String certNameInKeyVault) {
+ this.addPostRunDependent(
+ context -> certificates.createOrUpdateAsync(
+ name,
+ new CertificateProperties().withVaultUri(keyVaultUri).withKeyVaultCertName(certNameInKeyVault)
+ ).cast(Indexable.class)
+ );
+ return this;
+ }
+
+ @Override
+ public SpringServiceImpl withCertificate(String name, String keyVaultUri,
+ String certNameInKeyVault, String certVersion) {
+ this.addPostRunDependent(
+ context -> certificates.createOrUpdateAsync(
+ name,
+ new CertificateProperties()
+ .withVaultUri(keyVaultUri)
+ .withKeyVaultCertName(certNameInKeyVault)
+ .withCertVersion(certVersion)
+ ).cast(Indexable.class)
+ );
+ return this;
+ }
+
+ @Override
+ public SpringServiceImpl withoutCertificate(String name) {
+ this.addPostRunDependent(
+ context -> certificates.deleteByNameAsync(name)
+ .then(context.voidMono())
+ );
+ return this;
+ }
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServicesImpl.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServicesImpl.java
index d48cd6be55a3..b94599001a47 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServicesImpl.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringServicesImpl.java
@@ -8,9 +8,12 @@
import com.azure.resourcemanager.appplatform.AppPlatformManager;
import com.azure.resourcemanager.appplatform.fluent.ServicesClient;
import com.azure.resourcemanager.appplatform.fluent.inner.ServiceResourceInner;
+import com.azure.resourcemanager.appplatform.models.NameAvailability;
+import com.azure.resourcemanager.appplatform.models.NameAvailabilityParameters;
import com.azure.resourcemanager.appplatform.models.ResourceSku;
import com.azure.resourcemanager.appplatform.models.SpringService;
import com.azure.resourcemanager.appplatform.models.SpringServices;
+import com.azure.resourcemanager.resources.fluentcore.arm.Region;
import com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl;
import reactor.core.publisher.Mono;
@@ -18,6 +21,7 @@ public class SpringServicesImpl
extends GroupableResourcesImpl<
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);
}
@@ -42,6 +46,17 @@ protected SpringServiceImpl wrapModel(ServiceResourceInner inner) {
return inner == null ? null : new SpringServiceImpl(inner.name(), inner, manager());
}
+ @Override
+ public NameAvailability checkNameAvailability(String name, Region region) {
+ return checkNameAvailabilityAsync(name, region).block();
+ }
+
+ @Override
+ public Mono checkNameAvailabilityAsync(String name, Region region) {
+ return inner().checkNameAvailabilityAsync(
+ region.toString(), new NameAvailabilityParameters().withName(name).withType(SPRING_TYPE));
+ }
+
@Override
public PagedIterable listSkus() {
return new PagedIterable<>(listSkusAsync());
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/inner/CustomDomainValidateResultInner.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/CustomDomainValidateResult.java
similarity index 79%
rename from sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/inner/CustomDomainValidateResultInner.java
rename to sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/CustomDomainValidateResult.java
index 321c7b235452..923294d444fd 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/inner/CustomDomainValidateResultInner.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/CustomDomainValidateResult.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.resourcemanager.appplatform.fluent.inner;
+package com.azure.resourcemanager.appplatform.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
@@ -11,8 +11,8 @@
/** The CustomDomainValidateResult model. */
@Fluent
-public final class CustomDomainValidateResultInner {
- @JsonIgnore private final ClientLogger logger = new ClientLogger(CustomDomainValidateResultInner.class);
+public final class CustomDomainValidateResult {
+ @JsonIgnore private final ClientLogger logger = new ClientLogger(CustomDomainValidateResult.class);
/*
* Indicates if domain name is valid.
@@ -39,9 +39,9 @@ public Boolean isValid() {
* Set the isValid property: Indicates if domain name is valid.
*
* @param isValid the isValid value to set.
- * @return the CustomDomainValidateResultInner object itself.
+ * @return the CustomDomainValidateResult object itself.
*/
- public CustomDomainValidateResultInner withIsValid(Boolean isValid) {
+ public CustomDomainValidateResult withIsValid(Boolean isValid) {
this.isValid = isValid;
return this;
}
@@ -59,9 +59,9 @@ public String message() {
* Set the message property: Message of why domain name is invalid.
*
* @param message the message value to set.
- * @return the CustomDomainValidateResultInner object itself.
+ * @return the CustomDomainValidateResult object itself.
*/
- public CustomDomainValidateResultInner withMessage(String message) {
+ public CustomDomainValidateResult withMessage(String message) {
this.message = message;
return this;
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/inner/NameAvailabilityInner.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/NameAvailability.java
similarity index 81%
rename from sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/inner/NameAvailabilityInner.java
rename to sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/NameAvailability.java
index 72d4dd61764f..08beee0eebb4 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/fluent/inner/NameAvailabilityInner.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/NameAvailability.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.resourcemanager.appplatform.fluent.inner;
+package com.azure.resourcemanager.appplatform.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
@@ -11,8 +11,8 @@
/** The NameAvailability model. */
@Fluent
-public final class NameAvailabilityInner {
- @JsonIgnore private final ClientLogger logger = new ClientLogger(NameAvailabilityInner.class);
+public final class NameAvailability {
+ @JsonIgnore private final ClientLogger logger = new ClientLogger(NameAvailability.class);
/*
* Indicates whether the name is available
@@ -45,9 +45,9 @@ public Boolean nameAvailable() {
* Set the nameAvailable property: Indicates whether the name is available.
*
* @param nameAvailable the nameAvailable value to set.
- * @return the NameAvailabilityInner object itself.
+ * @return the NameAvailability object itself.
*/
- public NameAvailabilityInner withNameAvailable(Boolean nameAvailable) {
+ public NameAvailability withNameAvailable(Boolean nameAvailable) {
this.nameAvailable = nameAvailable;
return this;
}
@@ -65,9 +65,9 @@ public String reason() {
* Set the reason property: Reason why the name is not available.
*
* @param reason the reason value to set.
- * @return the NameAvailabilityInner object itself.
+ * @return the NameAvailability object itself.
*/
- public NameAvailabilityInner withReason(String reason) {
+ public NameAvailability withReason(String reason) {
this.reason = reason;
return this;
}
@@ -85,9 +85,9 @@ public String message() {
* Set the message property: Message why the name is not available.
*
* @param message the message value to set.
- * @return the NameAvailabilityInner object itself.
+ * @return the NameAvailability object itself.
*/
- public NameAvailabilityInner withMessage(String message) {
+ public NameAvailability withMessage(String message) {
this.message = message;
return this;
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringApp.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringApp.java
index a796973d671f..45a5ad4c96c8 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringApp.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringApp.java
@@ -32,6 +32,9 @@ public interface SpringApp
/** @return the url of the app */
String url();
+ /** @return the fully qualified domain name (FQDN) of the app */
+ String fqdn();
+
/** @return the temporary disk of the app */
TemporaryDisk temporaryDisk();
@@ -50,6 +53,12 @@ public interface SpringApp
/** @return the entry point of the spring app deployment */
SpringAppDeployments deployments();
+ /** @return the entry point of the spring app service binding */
+ SpringAppServiceBindings serviceBindings();
+
+ /** @return the entry point of the spring app custom domain */
+ SpringAppDomains customDomains();
+
/** @return the blob url to upload deployment */
Mono getResourceUploadUrlAsync();
@@ -68,10 +77,10 @@ interface Blank extends WithCreate { }
/** The stage of a spring app definition allowing to specify the endpoint. */
interface WithEndpoint {
/**
- * Enables the public endpoint for the spring app.
+ * Enables the default public endpoint for the spring app.
* @return the next stage of spring app definition
*/
- WithCreate withPublicEndpoint();
+ WithCreate withDefaultPublicEndpoint();
/**
* Specifies the custom domain for the spring app.
@@ -80,6 +89,14 @@ interface WithEndpoint {
*/
WithCreate withCustomDomain(String domain);
+ /**
+ * Specifies the custom domain for the spring app.
+ * @param domain the domain name
+ * @param certThumbprint the thumbprint of certificate for https
+ * @return the next stage of spring app update
+ */
+ WithCreate withCustomDomain(String domain, String certThumbprint);
+
/**
* Enables https only for the spring app.
* @return the next stage of spring app definition
@@ -129,6 +146,24 @@ interface WithDeployment {
WithCreate deploySource(String name, File sourceCodeFolder, String targetModule);
}
+ /** The stage of a spring app update allowing to specify the service binding. */
+ interface WithServiceBinding {
+ /**
+ * Specifies a service binding for the spring app.
+ * @param name the service binding name
+ * @param bindingProperties the property for the service binding
+ * @return the next stage of spring app update
+ */
+ WithCreate withServiceBinding(String name, BindingResourceProperties bindingProperties);
+
+ /**
+ * Removes a service binding for the spring app.
+ * @param name the service binding name
+ * @return the next stage of spring app update
+ */
+ WithCreate withoutServiceBinding(String name);
+ }
+
/**
* The stage of the definition which contains all the minimum required inputs for the resource to be created,
* but also allows for any other optional settings to be specified.
@@ -137,7 +172,8 @@ interface WithCreate
extends Creatable,
DefinitionStages.WithEndpoint,
DefinitionStages.WithDisk,
- DefinitionStages.WithDeployment { }
+ DefinitionStages.WithDeployment,
+ DefinitionStages.WithServiceBinding { }
}
/** The template for an update operation, containing all the settings that can be modified. */
@@ -145,23 +181,24 @@ interface Update
extends Appliable,
UpdateStages.WithEndpoint,
UpdateStages.WithDisk,
- UpdateStages.WithDeployment { }
+ UpdateStages.WithDeployment,
+ UpdateStages.WithServiceBinding { }
/** Grouping of spring app update stages. */
interface UpdateStages {
/** The stage of a spring app update allowing to specify the endpoint. */
interface WithEndpoint {
/**
- * Enables the public endpoint for the spring app.
+ * Enables the default public endpoint for the spring app.
* @return the next stage of spring app update
*/
- Update withPublicEndpoint();
+ Update withDefaultPublicEndpoint();
/**
- * Disables the public endpoint for the spring app.
+ * Disables the default public endpoint for the spring app.
* @return the next stage of spring app update
*/
- Update withoutPublicEndpoint();
+ Update withoutDefaultPublicEndpoint();
/**
* Specifies the custom domain for the spring app.
@@ -170,11 +207,20 @@ interface WithEndpoint {
*/
Update withCustomDomain(String domain);
+ /**
+ * Specifies the custom domain for the spring app.
+ * @param domain the domain name
+ * @param certThumbprint the thumbprint of certificate for https
+ * @return the next stage of spring app update
+ */
+ Update withCustomDomain(String domain, String certThumbprint);
+
/**
* Removes the custom domain for the spring app.
+ * @param domain the domain name
* @return the next stage of spring app update
*/
- Update withoutCustomDomain();
+ Update withoutCustomDomain(String domain);
/**
* Enables https only for the spring app.
@@ -220,7 +266,6 @@ interface WithDisk {
Update withoutPersistentDisk();
}
-
/**
* The stage of a spring app update allowing to specify an simple active deployment.
* for more operations, use {@link #deployments()}
@@ -257,5 +302,23 @@ interface WithDeployment {
*/
Update withoutDeployment(String name);
}
+
+ /** The stage of a spring app update allowing to specify the service binding. */
+ interface WithServiceBinding {
+ /**
+ * Specifies a service binding for the spring app.
+ * @param name the service binding name
+ * @param bindingProperties the property for the service binding
+ * @return the next stage of spring app update
+ */
+ Update withServiceBinding(String name, BindingResourceProperties bindingProperties);
+
+ /**
+ * Removes a service binding for the spring app.
+ * @param name the service binding name
+ * @return the next stage of spring app update
+ */
+ Update withoutServiceBinding(String name);
+ }
}
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDeployment.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDeployment.java
index 1c4f1d368803..f104f2fa0e11 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDeployment.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDeployment.java
@@ -17,7 +17,7 @@
import java.time.OffsetDateTime;
import java.util.List;
-/** An immutable client-side representation of an Azure deployment Deployment request. */
+/** An immutable client-side representation of an Azure Spring App Deployment. */
@Fluent
@Beta
public interface SpringAppDeployment
@@ -42,6 +42,33 @@ public interface SpringAppDeployment
/** @return all the instances of the deployment */
List instances();
+ /** Starts the deployment. */
+ void start();
+
+ /**
+ * Starts the deployment.
+ * @return null
+ */
+ Mono startAsync();
+
+ /** Stops the deployment. */
+ void stop();
+
+ /**
+ * Stops the deployment.
+ * @return null
+ */
+ Mono stopAsync();
+
+ /** Restarts the deployment. */
+ void restart();
+
+ /**
+ * Restarts the deployment.
+ * @return null
+ */
+ Mono restartAsync();
+
/** @return the log file url of the deployment */
String getLogFileUrl();
@@ -288,7 +315,7 @@ interface WithSettings {
* @return the next stage of deployment update
*/
Update withoutEnvironment(String key);
-
+
/**
* Specifies the version of the deployment.
* @param versionName the version name of the deployment
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDomain.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDomain.java
new file mode 100644
index 000000000000..2464ad0f9b3a
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDomain.java
@@ -0,0 +1,16 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.models;
+
+import com.azure.resourcemanager.appplatform.fluent.inner.CustomDomainResourceInner;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.ExternalChildResource;
+import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
+
+/** An immutable client-side representation of an Azure Spring App Custom Domain. */
+public interface SpringAppDomain
+ extends ExternalChildResource,
+ HasInner {
+ /** @return the properties of the spring app custom domain */
+ CustomDomainProperties properties();
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDomains.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDomains.java
new file mode 100644
index 000000000000..be102f967284
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppDomains.java
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.implementation.annotation.Beta;
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.CustomDomainsClient;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingById;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingByName;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.HasManager;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.HasParent;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsDeletingById;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsDeletingByName;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsListing;
+import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
+import reactor.core.publisher.Mono;
+
+/** Entry point for Spring App Custom Domains API. */
+@Fluent
+@Beta
+public interface SpringAppDomains
+ extends HasManager,
+ HasInner,
+ HasParent,
+ SupportsGettingById,
+ SupportsGettingByName,
+ SupportsListing,
+ SupportsDeletingById,
+ SupportsDeletingByName {
+ /**
+ * Checks the domain is validate for the app or not.
+ *
+ * @param domain the domain name
+ * @return the domain is validate for the parent app or not
+ */
+ CustomDomainValidateResult validate(String domain);
+
+ /**
+ * Checks the domain is validate for the app or not.
+ *
+ * @param domain the domain name
+ * @return the domain is validate for the parent app or not
+ */
+ Mono validateAsync(String domain);
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppServiceBinding.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppServiceBinding.java
new file mode 100644
index 000000000000..337e9c171338
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppServiceBinding.java
@@ -0,0 +1,16 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.models;
+
+import com.azure.resourcemanager.appplatform.fluent.inner.BindingResourceInner;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.ExternalChildResource;
+import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
+
+/** An immutable client-side representation of an Azure Spring App Service Binding. */
+public interface SpringAppServiceBinding
+ extends ExternalChildResource,
+ HasInner {
+ /** @return the properties of the service binding */
+ BindingResourceProperties properties();
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppServiceBindings.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppServiceBindings.java
new file mode 100644
index 000000000000..93573416739c
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringAppServiceBindings.java
@@ -0,0 +1,31 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.implementation.annotation.Beta;
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.BindingsClient;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingById;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingByName;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.HasManager;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.HasParent;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsDeletingById;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsDeletingByName;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsListing;
+import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
+
+/** Entry point for Spring App Service Bindings API. */
+@Fluent
+@Beta
+public interface SpringAppServiceBindings
+ extends HasManager,
+ HasInner,
+ HasParent,
+ SupportsGettingById,
+ SupportsGettingByName,
+ SupportsListing,
+ SupportsDeletingById,
+ SupportsDeletingByName {
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringService.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringService.java
index 6403422be52d..cb76e85c3900 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringService.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringService.java
@@ -35,6 +35,9 @@ public interface SpringService
/** @return the entry point of the spring app */
SpringApps apps();
+ /** @return the entry point of the spring service certificate */
+ SpringServiceCertificates certificates();
+
/**
* Lists test keys for the service.
* @return all test keys
@@ -136,6 +139,28 @@ interface WithTracing {
WithCreate withTracing(String appInsightInstrumentationKey);
}
+ /** The stage of a spring service update allowing to specify the certificate. */
+ interface WithCertificate {
+ /**
+ * Specifies a certificate in key vault with latest version binding to the spring service.
+ * @param name the certificate name
+ * @param keyVaultUri the uri for key vault that contains certificate
+ * @param certNameInKeyVault the certificate name in the key vault
+ * @return the next stage of spring service update
+ */
+ WithCreate withCertificate(String name, String keyVaultUri, String certNameInKeyVault);
+
+ /**
+ * Specifies a certificate in key vault with specific version binding to the spring service.
+ * @param name the certificate name
+ * @param keyVaultUri the uri for key vault that contains certificate
+ * @param certNameInKeyVault the certificate name in the key vault
+ * @param certVersion the certificate version in the key vault
+ * @return the next stage of spring service update
+ */
+ WithCreate withCertificate(String name, String keyVaultUri, String certNameInKeyVault, String certVersion);
+ }
+
/**
* The stage of the definition which contains all the minimum required inputs for the resource to be created,
* but also allows for any other optional settings to be specified.
@@ -144,7 +169,8 @@ interface WithCreate
extends Creatable,
Resource.DefinitionWithTags,
WithSku,
- WithTracing { }
+ WithTracing,
+ WithCertificate { }
}
/** The template for an update operation, containing all the settings that can be modified. */
@@ -153,7 +179,8 @@ interface Update
Resource.UpdateWithTags,
UpdateStages.WithSku,
UpdateStages.WithTracing,
- UpdateStages.WithConfiguration { }
+ UpdateStages.WithConfiguration,
+ UpdateStages.WithCertificate { }
/** Grouping of spring service update stages. */
interface UpdateStages {
@@ -232,5 +259,34 @@ interface WithConfiguration {
*/
Update withoutGitConfig();
}
+
+ /** The stage of a spring service update allowing to specify the certificate. */
+ interface WithCertificate {
+ /**
+ * Specifies a certificate in key vault with latest version binding to the spring service.
+ * @param name the certificate name
+ * @param keyVaultUri the uri for key vault that contains certificate
+ * @param certNameInKeyVault the certificate name in the key vault
+ * @return the next stage of spring service update
+ */
+ Update withCertificate(String name, String keyVaultUri, String certNameInKeyVault);
+
+ /**
+ * Specifies a certificate in key vault with specific version binding to the spring service.
+ * @param name the certificate name
+ * @param keyVaultUri the uri for key vault that contains certificate
+ * @param certNameInKeyVault the certificate name in the key vault
+ * @param certVersion the certificate version in the key vault
+ * @return the next stage of spring service update
+ */
+ Update withCertificate(String name, String keyVaultUri, String certNameInKeyVault, String certVersion);
+
+ /**
+ * Removes a certificate binding to the spring service.
+ * @param name the certificate name
+ * @return the next stage of spring service update
+ */
+ Update withoutCertificate(String name);
+ }
}
}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServiceCertificate.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServiceCertificate.java
new file mode 100644
index 000000000000..c3fda6eaa74f
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServiceCertificate.java
@@ -0,0 +1,16 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.models;
+
+import com.azure.resourcemanager.appplatform.fluent.inner.CertificateResourceInner;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.ExternalChildResource;
+import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
+
+/** An immutable client-side representation of an Azure Spring Service Certificate. */
+public interface SpringServiceCertificate
+ extends ExternalChildResource,
+ HasInner {
+ /** @return the properties of the service binding */
+ CertificateProperties properties();
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServiceCertificates.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServiceCertificates.java
new file mode 100644
index 000000000000..22d36f521044
--- /dev/null
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServiceCertificates.java
@@ -0,0 +1,31 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.implementation.annotation.Beta;
+import com.azure.resourcemanager.appplatform.AppPlatformManager;
+import com.azure.resourcemanager.appplatform.fluent.CertificatesClient;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingById;
+import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingByName;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.HasManager;
+import com.azure.resourcemanager.resources.fluentcore.arm.models.HasParent;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsDeletingById;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsDeletingByName;
+import com.azure.resourcemanager.resources.fluentcore.collection.SupportsListing;
+import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
+
+/** Entry point for Spring Service Certificates API. */
+@Fluent
+@Beta
+public interface SpringServiceCertificates
+ extends HasManager,
+ HasInner,
+ HasParent,
+ SupportsGettingById,
+ SupportsGettingByName,
+ SupportsListing,
+ SupportsDeletingById,
+ SupportsDeletingByName {
+}
diff --git a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServices.java b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServices.java
index 861f7a4eca58..721941981771 100644
--- a/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServices.java
+++ b/sdk/appplatform/mgmt/src/main/java/com/azure/resourcemanager/appplatform/models/SpringServices.java
@@ -9,6 +9,7 @@
import com.azure.core.implementation.annotation.Beta;
import com.azure.resourcemanager.appplatform.AppPlatformManager;
import com.azure.resourcemanager.appplatform.fluent.ServicesClient;
+import com.azure.resourcemanager.resources.fluentcore.arm.Region;
import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsDeletingByResourceGroup;
import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingById;
import com.azure.resourcemanager.resources.fluentcore.arm.collection.SupportsGettingByResourceGroup;
@@ -18,6 +19,7 @@
import com.azure.resourcemanager.resources.fluentcore.collection.SupportsDeletingById;
import com.azure.resourcemanager.resources.fluentcore.collection.SupportsListing;
import com.azure.resourcemanager.resources.fluentcore.model.HasInner;
+import reactor.core.publisher.Mono;
/** Entry point for Spring Service management API. */
@Fluent
@@ -32,6 +34,24 @@ public interface SpringServices
SupportsListingByResourceGroup,
SupportsDeletingById,
SupportsDeletingByResourceGroup {
+ /**
+ * Checks the name of the service is available in specific region or not.
+ *
+ * @param name the service name
+ * @param region the region of the service
+ * @return the service name is available or not.
+ */
+ NameAvailability checkNameAvailability(String name, Region region);
+
+ /**
+ * Checks the name of the service is available in specific region or not.
+ *
+ * @param name the service name
+ * @param region the region of the service
+ * @return the service name is available or not.
+ */
+ Mono checkNameAvailabilityAsync(String name, Region region);
+
/** @return all available sku. */
PagedIterable listSkus();
diff --git a/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java b/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java
index 2a1f0a14aeb6..e7261b470278 100644
--- a/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java
+++ b/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java
@@ -4,6 +4,9 @@
package com.azure.resourcemanager.appplatform;
import com.azure.core.http.HttpPipeline;
+import com.azure.resourcemanager.appservice.AppServiceManager;
+import com.azure.resourcemanager.dns.DnsZoneManager;
+import com.azure.resourcemanager.keyvault.KeyVaultManager;
import com.azure.resourcemanager.resources.core.TestBase;
import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
@@ -11,6 +14,9 @@
public class AppPlatformTest extends TestBase {
protected AppPlatformManager appPlatformManager;
+ protected AppServiceManager appServiceManager;
+ protected DnsZoneManager dnsZoneManager;
+ protected KeyVaultManager keyVaultManager;
protected String rgName = "";
public AppPlatformTest() {
@@ -23,7 +29,10 @@ public AppPlatformTest() {
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) throws IOException {
rgName = generateRandomResourceName("rg", 20);
- appPlatformManager = AppPlatformManager.authenticate(httpPipeline, profile);
+ appPlatformManager = AppPlatformManager.authenticate(httpPipeline, profile, sdkContext);
+ appServiceManager = AppServiceManager.authenticate(httpPipeline, profile, sdkContext);
+ dnsZoneManager = DnsZoneManager.authenticate(httpPipeline, profile, sdkContext);
+ keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile, sdkContext);
}
@Override
diff --git a/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/SpringCloudTest.java b/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/SpringCloudTest.java
index 86f1b70b83af..ff647311af02 100644
--- a/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/SpringCloudTest.java
+++ b/sdk/appplatform/mgmt/src/test/java/com/azure/resourcemanager/appplatform/SpringCloudTest.java
@@ -7,8 +7,20 @@
import com.azure.resourcemanager.appplatform.models.SpringApp;
import com.azure.resourcemanager.appplatform.models.SpringAppDeployment;
import com.azure.resourcemanager.appplatform.models.SpringService;
+import com.azure.resourcemanager.appservice.models.AppServiceCertificateOrder;
+import com.azure.resourcemanager.appservice.models.AppServiceDomain;
+import com.azure.resourcemanager.dns.models.DnsZone;
+import com.azure.resourcemanager.keyvault.models.CertificatePermissions;
+import com.azure.resourcemanager.keyvault.models.Secret;
+import com.azure.resourcemanager.keyvault.models.SecretPermissions;
+import com.azure.resourcemanager.keyvault.models.Vault;
+import com.azure.resourcemanager.resources.fluentcore.arm.CountryIsoCode;
+import com.azure.resourcemanager.resources.fluentcore.arm.CountryPhoneCode;
import com.azure.resourcemanager.resources.fluentcore.arm.Region;
import com.azure.resourcemanager.resources.fluentcore.utils.SdkContext;
+import com.azure.security.keyvault.certificates.CertificateClient;
+import com.azure.security.keyvault.certificates.CertificateClientBuilder;
+import com.azure.security.keyvault.certificates.models.ImportCertificateOptions;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
@@ -16,6 +28,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import javax.xml.bind.DatatypeConverter;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -23,8 +37,17 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.security.KeyStore;
+import java.security.MessageDigest;
+import java.util.Base64;
+import java.util.Collections;
public class SpringCloudTest extends AppPlatformTest {
+ private static final String PIGGYMETRICS_CONFIG_URL = "https://github.com/Azure-Samples/piggymetrics-config";
+ private static final String GATEWAY_JAR_URL = "https://github.com/weidongxu-microsoft/azure-sdk-for-java-management-tests/raw/master/spring-cloud/gateway.jar";
+ private static final String PIGGYMETRICS_TAR_GZ_URL = "https://github.com/weidongxu-microsoft/azure-sdk-for-java-management-tests/raw/master/spring-cloud/piggymetrics.tar.gz";
+
+ private static final String SPRING_CLOUD_SERVICE_PRINCIPAL = "03b39d0f-4213-4864-a245-b1476ec03169";
SpringCloudTest() {
super(RunCondition.LIVE_ONLY); // need storage data-plane and url check
@@ -36,6 +59,9 @@ public void canCRUDSpringAppWithDeployment() throws IOException {
String appName = "gateway";
String deploymentName = generateRandomResourceName("deploy", 15);
String deploymentName1 = generateRandomResourceName("deploy", 15);
+ Region region = Region.US_EAST;
+
+ Assertions.assertTrue(appPlatformManager.springServices().checkNameAvailability(serviceName, region).nameAvailable());
SpringService service = appPlatformManager.springServices().define(serviceName)
.withRegion(Region.US_EAST)
@@ -52,13 +78,13 @@ public void canCRUDSpringAppWithDeployment() throws IOException {
Assertions.assertEquals("S0", service.sku().name());
service.update()
- .withGitUri("https://github.com/Azure-Samples/piggymetrics-config")
+ .withGitUri(PIGGYMETRICS_CONFIG_URL)
.apply();
- Assertions.assertEquals("https://github.com/Azure-Samples/piggymetrics-config", service.serverProperties().configServer().gitProperty().uri());
+ Assertions.assertEquals(PIGGYMETRICS_CONFIG_URL, service.serverProperties().configServer().gitProperty().uri());
File jarFile = new File("gateway.jar");
if (!jarFile.exists()) {
- HttpURLConnection connection = (HttpURLConnection) new URL("https://github.com/weidongxu-microsoft/azure-sdk-for-java-management-tests/raw/master/spring-cloud/gateway.jar").openConnection();
+ HttpURLConnection connection = (HttpURLConnection) new URL(GATEWAY_JAR_URL).openConnection();
connection.connect();
try (InputStream inputStream = connection.getInputStream();
OutputStream outputStream = new FileOutputStream(jarFile)) {
@@ -68,7 +94,7 @@ public void canCRUDSpringAppWithDeployment() throws IOException {
}
SpringApp app = service.apps().define(appName)
- .withPublicEndpoint()
+ .withDefaultPublicEndpoint()
.create();
Assertions.assertNotNull(app.url());
@@ -102,10 +128,10 @@ public void canCRUDSpringAppWithDeployment() throws IOException {
File sourceCodeFolder = new File("piggymetrics");
if (!sourceCodeFolder.exists() || sourceCodeFolder.isFile()) {
- if (sourceCodeFolder.isFile()) {
- sourceCodeFolder.delete();
+ if (sourceCodeFolder.isFile() && !sourceCodeFolder.delete()) {
+ Assertions.fail();
}
- extraTarGzSource(sourceCodeFolder);
+ extraTarGzSource(sourceCodeFolder, new URL(PIGGYMETRICS_TAR_GZ_URL));
}
deployment = app.deployments().define(deploymentName1)
@@ -123,11 +149,146 @@ public void canCRUDSpringAppWithDeployment() throws IOException {
Assertions.assertTrue(requestSuccess(app.url()));
app.update()
- .withoutPublicEndpoint()
+ .withoutDefaultPublicEndpoint()
.apply();
Assertions.assertFalse(app.isPublic());
}
+ @Test
+ public void canCreateCustomDomainWithSsl() throws Exception {
+ String domainName = generateRandomResourceName("jsdkdemo-", 20) + ".com";
+ String certOrderName = generateRandomResourceName("cert", 15);
+ String vaultName = generateRandomResourceName("vault", 15);
+ String certName = generateRandomResourceName("cert", 15);
+ String serviceName = generateRandomResourceName("springsvc", 15);
+ String appName = "gateway";
+ Region region = Region.US_EAST;
+
+ appPlatformManager.resourceManager().resourceGroups().define(rgName)
+ .withRegion(region)
+ .create();
+
+ // create custom domain and certificate
+ DnsZone dnsZone = dnsZoneManager.zones().define(domainName)
+ .withExistingResourceGroup(rgName)
+ .create();
+
+ AppServiceDomain domain = appServiceManager.domains().define(domainName)
+ .withExistingResourceGroup(rgName)
+ .defineRegistrantContact()
+ .withFirstName("Jon")
+ .withLastName("Doe")
+ .withEmail("jondoe@contoso.com")
+ .withAddressLine1("123 4th Ave")
+ .withCity("Redmond")
+ .withStateOrProvince("WA")
+ .withCountry(CountryIsoCode.UNITED_STATES)
+ .withPostalCode("98052")
+ .withPhoneCountryCode(CountryPhoneCode.UNITED_STATES)
+ .withPhoneNumber("4258828080")
+ .attach()
+ .withDomainPrivacyEnabled(true)
+ .withAutoRenewEnabled(false)
+ .withExistingDnsZone(dnsZone)
+ .create();
+
+ AppServiceCertificateOrder certificateOrder = appServiceManager.certificateOrders().define(certOrderName)
+ .withExistingResourceGroup(rgName)
+ .withHostName(String.format("*.%s", domainName))
+ .withWildcardSku()
+ .withDomainVerification(domain)
+ .withNewKeyVault(vaultName, region)
+ .withAutoRenew(true)
+ .create();
+
+ Vault vault = keyVaultManager.vaults().getByResourceGroup(rgName, vaultName);
+ vault.update()
+ .defineAccessPolicy()
+ .forServicePrincipal(clientIdFromFile())
+ .allowSecretAllPermissions()
+ .allowCertificateAllPermissions()
+ .attach()
+ .defineAccessPolicy()
+ .forServicePrincipal(SPRING_CLOUD_SERVICE_PRINCIPAL)
+ .allowCertificatePermissions(CertificatePermissions.GET, CertificatePermissions.LIST)
+ .allowSecretPermissions(SecretPermissions.GET, SecretPermissions.LIST)
+ .attach()
+ .apply();
+
+ Secret secret = vault.secrets().getByName(certOrderName);
+
+ byte[] certificate = Base64.getDecoder().decode(secret.value());
+
+ // upload certificate
+ CertificateClient certificateClient = new CertificateClientBuilder()
+ .vaultUrl(vault.vaultUri())
+ .pipeline(appPlatformManager.httpPipeline())
+ .buildClient();
+
+ certificateClient.importCertificate(
+ new ImportCertificateOptions(certName, certificate)
+ .setEnabled(true)
+ );
+
+ // get thumbprint
+ KeyStore store = KeyStore.getInstance("PKCS12");
+ store.load(new ByteArrayInputStream(certificate), null);
+ String alias = Collections.list(store.aliases()).get(0);
+ String thumbprint = DatatypeConverter.printHexBinary(MessageDigest.getInstance("SHA-1").digest(store.getCertificate(alias).getEncoded()));
+
+ Assertions.assertTrue(appPlatformManager.springServices().checkNameAvailability(serviceName, region).nameAvailable());
+
+ SpringService service = appPlatformManager.springServices().define(serviceName)
+ .withRegion(region)
+ .withExistingResourceGroup(rgName)
+ .withCertificate("test", vault.vaultUri(), certName)
+ .create();
+
+ service.apps().define(appName).withDefaultPublicEndpoint().create();
+ SpringApp app = service.apps().getByName(appName);
+
+ dnsZone.update()
+ .withCNameRecordSet("www", app.fqdn())
+ .withCNameRecordSet("ssl", app.fqdn())
+ .apply();
+
+ app.update()
+ .withoutDefaultPublicEndpoint()
+ .withCustomDomain(String.format("www.%s", domainName))
+ .withCustomDomain(String.format("ssl.%s", domainName), thumbprint)
+ .apply();
+
+ Assertions.assertTrue(app.customDomains().validate(String.format("www.%s", domainName)).isValid());
+ Assertions.assertTrue(requestSuccess(String.format("http://www.%s", domainName)));
+ Assertions.assertTrue(requestSuccess(String.format("https://ssl.%s", domainName)));
+
+ app.update()
+ .withHttpsOnly()
+ .apply();
+ Assertions.assertTrue(checkRedirect(String.format("http://ssl.%s", domainName)));
+ }
+
+ private boolean checkRedirect(String url) throws IOException {
+ for (int i = 0; i < 60; ++i) {
+ HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
+ connection.setInstanceFollowRedirects(false);
+ try {
+ connection.connect();
+ if (200 <= connection.getResponseCode() && connection.getResponseCode() < 400) {
+ connection.getInputStream().close();
+ if (connection.getResponseCode() / 100 == 3) {
+ return true;
+ }
+ System.out.printf("Do request to %s with response code %d%n", url, connection.getResponseCode());
+ }
+ } finally {
+ connection.disconnect();
+ }
+ SdkContext.sleep(5000);
+ }
+ return false;
+ }
+
private boolean requestSuccess(String url) throws IOException {
for (int i = 0; i < 60; ++i) {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
@@ -140,14 +301,14 @@ private boolean requestSuccess(String url) throws IOException {
System.out.printf("Do request to %s with response code %d%n", url, connection.getResponseCode());
} finally {
connection.disconnect();
- SdkContext.sleep(5000);
}
+ SdkContext.sleep(5000);
}
return false;
}
- private void extraTarGzSource(File folder) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) new URL("https://github.com/weidongxu-microsoft/azure-sdk-for-java-management-tests/raw/master/spring-cloud/piggymetrics.tar.gz").openConnection();
+ private void extraTarGzSource(File folder, URL url) throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
try (TarArchiveInputStream inputStream = new TarArchiveInputStream(new GzipCompressorInputStream(connection.getInputStream()))) {
TarArchiveEntry entry;
@@ -157,14 +318,16 @@ private void extraTarGzSource(File folder) throws IOException {
}
File file = new File(folder, entry.getName());
File parent = file.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- try (OutputStream outputStream = new FileOutputStream(file)) {
- IOUtils.copy(inputStream, outputStream);
+ if (parent.exists() || parent.mkdirs()) {
+ try (OutputStream outputStream = new FileOutputStream(file)) {
+ IOUtils.copy(inputStream, outputStream);
+ }
+ } else {
+ throw new IllegalStateException("Cannot create directory: " + parent.getAbsolutePath());
}
}
+ } finally {
+ connection.disconnect();
}
- connection.disconnect();
}
}
diff --git a/sdk/management/api-specs.json b/sdk/management/api-specs.json
index 0823f6bb2fed..86d929479fb8 100644
--- a/sdk/management/api-specs.json
+++ b/sdk/management/api-specs.json
@@ -15,7 +15,7 @@
"dir": "../appplatform/mgmt",
"source": "specification/appplatform/resource-manager/readme.md",
"package": "com.azure.resourcemanager.appplatform",
- "args": "--payload-flattening-threshold=1 --tag=package-2019-05-01-preview --remove-inner=TestKeys,ResourceSku,ResourceUploadDefinition"
+ "args": "--payload-flattening-threshold=1 --tag=package-2019-05-01-preview --remove-inner=TestKeys,ResourceSku,ResourceUploadDefinition,CustomDomainValidateResult,NameAvailability"
},
"appservice": {
"dir": "../appservice/mgmt",
diff --git a/sdk/management/samples/.gitignore b/sdk/management/samples/.gitignore
new file mode 100644
index 000000000000..ee0ce9f5f355
--- /dev/null
+++ b/sdk/management/samples/.gitignore
@@ -0,0 +1 @@
+/piggymetrics
\ No newline at end of file
diff --git a/sdk/management/samples/pom.xml b/sdk/management/samples/pom.xml
index 71602c38ab03..257cb82ac221 100644
--- a/sdk/management/samples/pom.xml
+++ b/sdk/management/samples/pom.xml
@@ -103,6 +103,11 @@
azure-cosmos
4.0.1-beta.3
+
+ com.azure
+ azure-security-keyvault-certificates
+ 4.0.4
+
io.fabric8
kubernetes-client
diff --git a/sdk/management/samples/samples.json b/sdk/management/samples/samples.json
index 90aa8dae1954..3bc02e94f292 100644
--- a/sdk/management/samples/samples.json
+++ b/sdk/management/samples/samples.json
@@ -850,6 +850,12 @@
"filePath": "azure-samples/src/main/java/com/microsoft/azure/management/appservice/samples/ManageLinuxFunctionAppSourceControl.java",
"githubPath": "Azure-Samples/app-service-java-configure-deployment-sources-for-functions-on-linux",
"description": "Getting started on configuring deployment sources for Functions on Linux using Java"
+ },
+ {
+ "owner": "yaohaizh",
+ "filePath": "azure-samples/src/main/java/com/microsoft/azure/management/appplatform/samples/ManageSpringCloud.java",
+ "githubPath": "Azure-Samples/app-platform-java-manage-spring-cloud",
+ "description": "Getting started on managing spring cloud using Java"
}
]
-}
\ No newline at end of file
+}
diff --git a/sdk/management/samples/src/main/java/com/azure/resourcemanager/appplatform/samples/ManageSpringCloud.java b/sdk/management/samples/src/main/java/com/azure/resourcemanager/appplatform/samples/ManageSpringCloud.java
new file mode 100644
index 000000000000..77503f373ba5
--- /dev/null
+++ b/sdk/management/samples/src/main/java/com/azure/resourcemanager/appplatform/samples/ManageSpringCloud.java
@@ -0,0 +1,315 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.resourcemanager.appplatform.samples;
+
+import com.azure.core.credential.TokenCredential;
+import com.azure.core.http.policy.HttpLogDetailLevel;
+import com.azure.core.management.AzureEnvironment;
+import com.azure.core.util.Configuration;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.azure.resourcemanager.Azure;
+import com.azure.resourcemanager.appplatform.models.SpringApp;
+import com.azure.resourcemanager.appplatform.models.SpringService;
+import com.azure.resourcemanager.appservice.models.AppServiceCertificateOrder;
+import com.azure.resourcemanager.appservice.models.AppServiceDomain;
+import com.azure.resourcemanager.dns.models.DnsZone;
+import com.azure.resourcemanager.keyvault.models.CertificatePermissions;
+import com.azure.resourcemanager.keyvault.models.Secret;
+import com.azure.resourcemanager.keyvault.models.SecretPermissions;
+import com.azure.resourcemanager.keyvault.models.Vault;
+import com.azure.resourcemanager.resources.fluentcore.arm.CountryIsoCode;
+import com.azure.resourcemanager.resources.fluentcore.arm.CountryPhoneCode;
+import com.azure.resourcemanager.resources.fluentcore.arm.Region;
+import com.azure.resourcemanager.resources.fluentcore.profile.AzureProfile;
+import com.azure.resourcemanager.samples.Utils;
+import com.azure.security.keyvault.certificates.CertificateClient;
+import com.azure.security.keyvault.certificates.CertificateClientBuilder;
+import com.azure.security.keyvault.certificates.models.ImportCertificateOptions;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.commons.compress.utils.IOUtils;
+
+import javax.xml.bind.DatatypeConverter;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.security.KeyStore;
+import java.security.MessageDigest;
+import java.util.Base64;
+import java.util.Collections;
+
+/**
+ * Azure App Platform sample for managing Spring Cloud.
+ * - Create a Spring Cloud Service
+ * - Create 3 app: gateway, auth-service, account-service from sample
+ * - Open public endpoint for gateway
+ * - Create a custom domain
+ * - Add a CNAME to the gateway fully qualified domain name
+ * - Order a certificate
+ * - Save the certificate to a key vault
+ * - Assign certificate to spring cloud
+ * - Assign custom domain to gateway endpoint
+ */
+public class ManageSpringCloud {
+ private static final String PIGGYMETRICS_TAR_GZ_URL = "https://github.com/weidongxu-microsoft/azure-sdk-for-java-management-tests/raw/master/spring-cloud/piggymetrics.tar.gz";
+ private static final String SPRING_CLOUD_SERVICE_PRINCIPAL = "03b39d0f-4213-4864-a245-b1476ec03169";
+
+ /**
+ * Main function which runs the actual sample.
+ * @param azure instance of the azure client
+ * @param clientId the aad client id in azure instance
+ * @return true if sample runs successfully
+ * @throws IllegalStateException unexcepted state
+ */
+ public static boolean runSample(Azure azure, String clientId) {
+ final String rgName = azure.sdkContext().randomResourceName("rg", 24);
+ final String serviceName = azure.sdkContext().randomResourceName("service", 24);
+ final Region region = Region.US_EAST;
+ final String domainName = azure.sdkContext().randomResourceName("jsdkdemo-", 20) + ".com";
+ final String certOrderName = azure.sdkContext().randomResourceName("cert", 15);
+ final String vaultName = azure.sdkContext().randomResourceName("vault", 15);
+ final String certName = azure.sdkContext().randomResourceName("cert", 15);
+
+ try {
+ azure.resourceGroups().define(rgName)
+ .withRegion(region)
+ .create();
+
+ //============================================================
+ // Create a spring cloud service with 3 apps: gateway, auth-service, account-service
+
+ System.out.printf("Creating spring cloud service %s in resource group %s ...%n", serviceName, rgName);
+
+ SpringService service = azure.springServices().define(serviceName)
+ .withRegion(region)
+ .withExistingResourceGroup(rgName)
+ .create();
+
+ System.out.printf("Created spring cloud service %s%n", service.name());
+ Utils.print(service);
+
+ // get source code of a sample project
+ File sourceCodeFolder = new File("piggymetrics");
+ if (!sourceCodeFolder.exists() || sourceCodeFolder.isFile()) {
+ if (sourceCodeFolder.isFile() && !sourceCodeFolder.delete()) {
+ throw new IllegalStateException("could not delete piggymetrics file");
+ }
+ extraTarGzSource(sourceCodeFolder, new URL(PIGGYMETRICS_TAR_GZ_URL));
+ }
+
+ //============================================================
+ // Create spring cloud app: gateway
+
+ System.out.printf("Creating spring cloud app gateway in resource group %s ...%n", rgName);
+ SpringApp gateway = service.apps().define("gateway")
+ .withDefaultPublicEndpoint()
+ .withHttpsOnly()
+ .deploySource("default", sourceCodeFolder, "gateway")
+ .create();
+
+ System.out.println("Created spring cloud service gateway");
+ Utils.print(gateway);
+
+ //============================================================
+ // Create spring cloud app: auth-service
+
+ System.out.printf("Creating spring cloud app auth-service in resource group %s ...%n", rgName);
+ SpringApp authService = service.apps().define("auth-service")
+ .deploySource("default", sourceCodeFolder, "auth-service")
+ .create();
+
+ System.out.println("Created spring cloud service auth-service");
+ Utils.print(authService);
+
+ //============================================================
+ // Create spring cloud app: account-service
+
+ System.out.printf("Creating spring cloud app account-service in resource group %s ...%n", rgName);
+ SpringApp accountService = service.apps().define("account-service")
+ .deploySource("default", sourceCodeFolder, "account-service")
+ .create();
+
+ System.out.println("Created spring cloud service account-service");
+ Utils.print(accountService);
+
+ //============================================================
+ // Create App Service Domain and Certificate
+
+ System.out.println("Purchasing a domain " + domainName + "...");
+
+ AppServiceDomain domain = azure.appServiceDomains().define(domainName)
+ .withExistingResourceGroup(rgName)
+ .defineRegistrantContact()
+ .withFirstName("Jon")
+ .withLastName("Doe")
+ .withEmail("jondoe@contoso.com")
+ .withAddressLine1("123 4th Ave")
+ .withCity("Redmond")
+ .withStateOrProvince("WA")
+ .withCountry(CountryIsoCode.UNITED_STATES)
+ .withPostalCode("98052")
+ .withPhoneCountryCode(CountryPhoneCode.UNITED_STATES)
+ .withPhoneNumber("4258828080")
+ .attach()
+ .withDomainPrivacyEnabled(true)
+ .withAutoRenewEnabled(false)
+ .create();
+ System.out.println("Purchased domain " + domain.name());
+ Utils.print(domain);
+
+ DnsZone dnsZone = azure.dnsZones().getById(domain.dnsZoneId());
+ gateway.refresh();
+
+ System.out.printf("Updating dns with CNAME ssl.%s to %s%n", domainName, gateway.fqdn());
+ dnsZone.update()
+ .withCNameRecordSet("ssl", gateway.fqdn())
+ .apply();
+
+ System.out.printf("Purchasing a certificate for *.%s and save to %s in key vault named %s ...%n", domainName, certOrderName, vaultName);
+ AppServiceCertificateOrder certificateOrder = azure.appServiceCertificateOrders().define(certOrderName)
+ .withExistingResourceGroup(rgName)
+ .withHostName(String.format("*.%s", domainName))
+ .withWildcardSku()
+ .withDomainVerification(domain)
+ .withNewKeyVault(vaultName, region)
+ .withAutoRenew(true)
+ .create();
+ System.out.printf("Purchased certificate: *.%s ...%n", domain.name());
+ Utils.print(certificateOrder);
+
+ System.out.printf("Updating key vault %s with access from %s, %s%n", vaultName, clientId, SPRING_CLOUD_SERVICE_PRINCIPAL);
+ Vault vault = azure.vaults().getByResourceGroup(rgName, vaultName);
+ vault.update()
+ .defineAccessPolicy()
+ .forServicePrincipal(clientId)
+ .allowSecretAllPermissions()
+ .allowCertificateAllPermissions()
+ .attach()
+ .defineAccessPolicy()
+ .forServicePrincipal(SPRING_CLOUD_SERVICE_PRINCIPAL)
+ .allowCertificatePermissions(CertificatePermissions.GET, CertificatePermissions.LIST)
+ .allowSecretPermissions(SecretPermissions.GET, SecretPermissions.LIST)
+ .attach()
+ .apply();
+ System.out.printf("Updated key vault %s%n", vault.name());
+ Utils.print(vault);
+
+ Secret secret = vault.secrets().getByName(certOrderName);
+
+ byte[] certificate = Base64.getDecoder().decode(secret.value());
+
+ String thumbprint = secret.tags().get("Thumbprint");
+ if (thumbprint == null || thumbprint.isEmpty()) {
+ KeyStore store = KeyStore.getInstance("PKCS12");
+ store.load(new ByteArrayInputStream(certificate), null);
+ String alias = Collections.list(store.aliases()).get(0);
+ thumbprint = DatatypeConverter.printHexBinary(MessageDigest.getInstance("SHA-1").digest(store.getCertificate(alias).getEncoded()));
+ }
+
+ System.out.printf("Get certificate: %s%n", secret.value());
+ System.out.printf("Certificate Thumbprint: %s%n", thumbprint);
+
+ // upload certificate
+ CertificateClient certificateClient = new CertificateClientBuilder()
+ .vaultUrl(vault.vaultUri())
+ .pipeline(service.manager().httpPipeline())
+ .buildClient();
+
+ System.out.printf("Uploading certificate to %s in key vault ...%n", certName);
+ certificateClient.importCertificate(
+ new ImportCertificateOptions(certName, certificate)
+ .setEnabled(true)
+ );
+
+ //============================================================
+ // Update Certificate and Custom Domain for Spring Cloud
+ System.out.println("Updating Spring Cloud Service with certificate ...");
+ service.update()
+ .withCertificate(certName, vault.vaultUri(), certName)
+ .apply();
+
+ System.out.printf("Updating Spring Cloud App with domain ssl.%s ...", domainName);
+ gateway.update()
+ .withCustomDomain(String.format("ssl.%s", domainName), thumbprint)
+ .apply();
+
+ System.out.printf("Successfully expose domain ssl.%s", domainName);
+
+ return true;
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ } finally {
+ try {
+ System.out.println("Delete Resource Group: " + rgName);
+ azure.resourceGroups().beginDeleteByName(rgName);
+ } catch (NullPointerException npe) {
+ System.out.println("Did not create any resources in Azure. No clean up is necessary");
+ } catch (Exception g) {
+ g.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Main entry point.
+ * @param args the parameters
+ */
+ public static void main(String[] args) {
+ try {
+ //=============================================================
+ // Authenticate
+
+ final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
+ final TokenCredential credential = new DefaultAzureCredentialBuilder()
+ .authorityHost(profile.environment().getActiveDirectoryEndpoint())
+ .build();
+
+ Azure azure = Azure
+ .configure()
+ .withLogLevel(HttpLogDetailLevel.BASIC)
+ .authenticate(credential, profile)
+ .withDefaultSubscription();
+
+ // Print selected subscription
+ System.out.println("Selected subscription: " + azure.subscriptionId());
+
+ runSample(azure, Configuration.getGlobalConfiguration().get(Configuration.PROPERTY_AZURE_CLIENT_ID));
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+
+ private static void extraTarGzSource(File folder, URL url) throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.connect();
+ try (TarArchiveInputStream inputStream = new TarArchiveInputStream(new GzipCompressorInputStream(connection.getInputStream()))) {
+ TarArchiveEntry entry;
+ while ((entry = inputStream.getNextTarEntry()) != null) {
+ if (entry.isDirectory()) {
+ continue;
+ }
+ File file = new File(folder, entry.getName());
+ File parent = file.getParentFile();
+ if (parent.exists() || parent.mkdirs()) {
+ try (OutputStream outputStream = new FileOutputStream(file)) {
+ IOUtils.copy(inputStream, outputStream);
+ }
+ } else {
+ throw new IllegalStateException("Cannot create directory: " + parent.getAbsolutePath());
+ }
+ }
+ } finally {
+ connection.disconnect();
+ }
+ }
+}
diff --git a/sdk/management/samples/src/main/java/com/azure/resourcemanager/appplatform/samples/package-info.java b/sdk/management/samples/src/main/java/com/azure/resourcemanager/appplatform/samples/package-info.java
new file mode 100644
index 000000000000..ff4f2a87d32d
--- /dev/null
+++ b/sdk/management/samples/src/main/java/com/azure/resourcemanager/appplatform/samples/package-info.java
@@ -0,0 +1,8 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+
+/**
+ * This package contains the classes for app platform samples.
+ */
+package com.azure.resourcemanager.appplatform.samples;
diff --git a/sdk/management/samples/src/main/java/com/azure/resourcemanager/samples/Utils.java b/sdk/management/samples/src/main/java/com/azure/resourcemanager/samples/Utils.java
index 1a16b1f30dae..bb7937968f89 100644
--- a/sdk/management/samples/src/main/java/com/azure/resourcemanager/samples/Utils.java
+++ b/sdk/management/samples/src/main/java/com/azure/resourcemanager/samples/Utils.java
@@ -24,6 +24,10 @@
import com.azure.core.util.FluxUtil;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerEncoding;
+import com.azure.resourcemanager.appplatform.models.ConfigServerState;
+import com.azure.resourcemanager.appplatform.models.SpringApp;
+import com.azure.resourcemanager.appplatform.models.SpringService;
+import com.azure.resourcemanager.appplatform.models.TraceProxyState;
import com.azure.resourcemanager.appservice.models.AppServiceCertificateOrder;
import com.azure.resourcemanager.appservice.models.AppServiceDomain;
import com.azure.resourcemanager.appservice.models.AppServicePlan;
@@ -72,6 +76,7 @@
import com.azure.resourcemanager.dns.models.TxtRecord;
import com.azure.resourcemanager.dns.models.TxtRecordSet;
import com.azure.resourcemanager.keyvault.models.AccessPolicy;
+import com.azure.resourcemanager.keyvault.models.CertificatePermissions;
import com.azure.resourcemanager.keyvault.models.KeyPermissions;
import com.azure.resourcemanager.keyvault.models.SecretPermissions;
import com.azure.resourcemanager.keyvault.models.Vault;
@@ -536,9 +541,18 @@ public static void print(Vault vault) {
.append("\n\tVault URI: ").append(vault.vaultUri())
.append("\n\tAccess policies: ");
for (AccessPolicy accessPolicy : vault.accessPolicies()) {
- info.append("\n\t\tIdentity:").append(accessPolicy.objectId())
- .append("\n\t\tKey permissions: ").append(accessPolicy.permissions().keys().stream().map(KeyPermissions::toString).collect(Collectors.joining(", ")))
- .append("\n\t\tSecret permissions: ").append(accessPolicy.permissions().secrets().stream().map(SecretPermissions::toString).collect(Collectors.joining(", ")));
+ info.append("\n\t\tIdentity:").append(accessPolicy.objectId());
+ if (accessPolicy.permissions() != null) {
+ if (accessPolicy.permissions().keys() != null) {
+ info.append("\n\t\tKey permissions: ").append(accessPolicy.permissions().keys().stream().map(KeyPermissions::toString).collect(Collectors.joining(", ")));
+ }
+ if (accessPolicy.permissions().secrets() != null) {
+ info.append("\n\t\tSecret permissions: ").append(accessPolicy.permissions().secrets().stream().map(SecretPermissions::toString).collect(Collectors.joining(", ")));
+ }
+ if (accessPolicy.permissions().certificates() != null) {
+ info.append("\n\t\tCertificate permissions: ").append(accessPolicy.permissions().certificates().stream().map(CertificatePermissions::toString).collect(Collectors.joining(", ")));
+ }
+ }
}
System.out.println(info.toString());
}
@@ -2969,6 +2983,80 @@ public static void print(MetricAlert metricAlert) {
System.out.println(info.toString());
}
+ /**
+ * Print spring service settings.
+ *
+ * @param springService spring service instance
+ */
+ public static void print(SpringService springService) {
+ StringBuilder info = new StringBuilder("Spring Service: ")
+ .append("\n\tId: ").append(springService.id())
+ .append("\n\tName: ").append(springService.name())
+ .append("\n\tResource Group: ").append(springService.resourceGroupName())
+ .append("\n\tRegion: ").append(springService.region())
+ .append("\n\tTags: ").append(springService.tags());
+
+ if (springService.serverProperties() != null && springService.serverProperties().state() == ConfigServerState.SUCCEEDED && springService.serverProperties().configServer() != null) {
+ info.append("\n\tProperties: ");
+ if (springService.serverProperties().configServer().gitProperty() != null) {
+ info.append("\n\t\tGit: ").append(springService.serverProperties().configServer().gitProperty().uri());
+ }
+ }
+
+ if (springService.sku() != null) {
+ info.append("\n\tSku: ")
+ .append("\n\t\tName: ").append(springService.sku().name())
+ .append("\n\t\tTier: ").append(springService.sku().tier())
+ .append("\n\t\tCapacity: ").append(springService.sku().capacity());
+ }
+
+ if (springService.traceProperties() != null && springService.traceProperties().state() == TraceProxyState.SUCCEEDED) {
+ info.append("\n\tTrace: ")
+ .append("\n\t\tEnabled: ").append(springService.traceProperties().enabled())
+ .append("\n\t\tApp Insight Instrumentation Key: ").append(springService.traceProperties().appInsightInstrumentationKey());
+ }
+
+ System.out.println(info.toString());
+ }
+
+ /**
+ * Print spring app settings.
+ *
+ * @param springApp spring app instance
+ */
+ public static void print(SpringApp springApp) {
+ StringBuilder info = new StringBuilder("Spring Service: ")
+ .append("\n\tId: ").append(springApp.id())
+ .append("\n\tName: ").append(springApp.name())
+ .append("\n\tCreated Time: ").append(springApp.createdTime())
+ .append("\n\tPublic Endpoint: ").append(springApp.isPublic())
+ .append("\n\tUrl: ").append(springApp.url())
+ .append("\n\tHttps Only: ").append(springApp.isHttpsOnly())
+ .append("\n\tFully Qualified Domain Name: ").append(springApp.fqdn())
+ .append("\n\tActive Deployment Name: ").append(springApp.activeDeployment());
+
+ if (springApp.temporaryDisk() != null) {
+ info.append("\n\tTemporary Disk:")
+ .append("\n\t\tSize In GB: ").append(springApp.temporaryDisk().sizeInGB())
+ .append("\n\t\tMount Path: ").append(springApp.temporaryDisk().mountPath());
+ }
+
+ if (springApp.persistentDisk() != null) {
+ info.append("\n\tPersistent Disk:")
+ .append("\n\t\tSize In GB: ").append(springApp.persistentDisk().sizeInGB())
+ .append("\n\t\tMount Path: ").append(springApp.persistentDisk().mountPath());
+ }
+
+ if (springApp.identity() != null) {
+ info.append("\n\tIdentity:")
+ .append("\n\t\tType: ").append(springApp.identity().type())
+ .append("\n\t\tPrincipal Id: ").append(springApp.identity().principalId())
+ .append("\n\t\tTenant Id: ").append(springApp.identity().tenantId());
+ }
+
+ System.out.println(info.toString());
+ }
+
public static Response curl(String urlString) {
try {
return stringResponse(httpClient.getString(getHost(urlString), getPathAndQuery(urlString))).block();
diff --git a/sdk/management/samples/src/test/java/com/azure/resourcemanager/samples/AppPlatformLiveOnlyTests.java b/sdk/management/samples/src/test/java/com/azure/resourcemanager/samples/AppPlatformLiveOnlyTests.java
new file mode 100644
index 000000000000..c9e6e594062c
--- /dev/null
+++ b/sdk/management/samples/src/test/java/com/azure/resourcemanager/samples/AppPlatformLiveOnlyTests.java
@@ -0,0 +1,20 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.resourcemanager.samples;
+
+
+import com.azure.resourcemanager.appplatform.samples.ManageSpringCloud;
+import com.azure.resourcemanager.resources.core.TestBase;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class AppPlatformLiveOnlyTests extends SamplesTestBase {
+ public AppPlatformLiveOnlyTests() {
+ super(TestBase.RunCondition.LIVE_ONLY);
+ }
+
+ @Test
+ public void testSpringCloud() {
+ Assertions.assertTrue(ManageSpringCloud.runSample(azure, clientIdFromFile()));
+ }
+}