From 1dc4b4c677a58168791854b30967dec6c8673509 Mon Sep 17 00:00:00 2001 From: xiaofeicao Date: Thu, 28 Jul 2022 11:11:04 +0800 Subject: [PATCH] Release 2.17.0 --- pom.xml | 9 ++--- .../azure/resourcemanager/samples/Utils.java | 36 +++++++++++++------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 71bb2df..370640c 100644 --- a/pom.xml +++ b/pom.xml @@ -54,17 +54,12 @@ com.azure.resourcemanager azure-resourcemanager - 2.10.0 + 2.17.0 com.azure azure-identity - 1.4.1 - - - com.jcraft - jsch - 0.1.55 + 1.5.3 commons-net diff --git a/src/main/java/com/azure/resourcemanager/samples/Utils.java b/src/main/java/com/azure/resourcemanager/samples/Utils.java index fd4b15e..e7d5b51 100644 --- a/src/main/java/com/azure/resourcemanager/samples/Utils.java +++ b/src/main/java/com/azure/resourcemanager/samples/Utils.java @@ -16,6 +16,7 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.management.Region; import com.azure.core.management.exception.ManagementException; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.JacksonAdapter; @@ -71,8 +72,8 @@ import com.azure.resourcemanager.dns.models.AaaaRecordSet; import com.azure.resourcemanager.dns.models.CnameRecordSet; import com.azure.resourcemanager.dns.models.DnsZone; -import com.azure.resourcemanager.dns.models.MxRecordSet; import com.azure.resourcemanager.dns.models.MxRecord; +import com.azure.resourcemanager.dns.models.MxRecordSet; import com.azure.resourcemanager.dns.models.NsRecordSet; import com.azure.resourcemanager.dns.models.PtrRecordSet; import com.azure.resourcemanager.dns.models.SoaRecord; @@ -163,7 +164,6 @@ import com.azure.resourcemanager.redis.models.RedisCache; import com.azure.resourcemanager.redis.models.RedisCachePremium; import com.azure.resourcemanager.redis.models.ScheduleEntry; -import com.azure.core.management.Region; import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateLinkResource; import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils; import com.azure.resourcemanager.resources.models.ManagementLock; @@ -201,7 +201,6 @@ import com.azure.resourcemanager.trafficmanager.models.TrafficManagerExternalEndpoint; import com.azure.resourcemanager.trafficmanager.models.TrafficManagerNestedProfileEndpoint; import com.azure.resourcemanager.trafficmanager.models.TrafficManagerProfile; -import com.jcraft.jsch.JSchException; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import reactor.core.publisher.Mono; @@ -215,7 +214,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.security.KeyPair; @@ -241,9 +239,10 @@ /** * Common utils for Azure management samples. */ - public final class Utils { + // IMPORTANT: do not use SSHShell in Utils + private static final ClientLogger LOGGER = new ClientLogger(Utils.class); private static String sshPublicKey; @@ -396,6 +395,12 @@ public static void print(VirtualMachine resource) { storageProfile.append("\n\t\t\tCaching: ").append(resource.storageProfile().osDisk().caching()); storageProfile.append("\n\t\t\tCreateOption: ").append(resource.storageProfile().osDisk().createOption()); storageProfile.append("\n\t\t\tDiskSizeGB: ").append(resource.storageProfile().osDisk().diskSizeGB()); + if (resource.storageProfile().osDisk().managedDisk() != null) { + if (resource.storageProfile().osDisk().managedDisk().diskEncryptionSet() != null) { + storageProfile.append("\n\t\t\tDiskEncryptionSet Id: ") + .append(resource.storageProfile().osDisk().managedDisk().diskEncryptionSet().id()); + } + } if (resource.storageProfile().osDisk().image() != null) { storageProfile.append("\n\t\t\tImage Uri: ").append(resource.storageProfile().osDisk().image().uri()); } @@ -430,6 +435,9 @@ public static void print(VirtualMachine resource) { if (resource.isManagedDiskEnabled()) { if (disk.managedDisk() != null) { storageProfile.append("\n\t\t\tManaged Disk Id: ").append(disk.managedDisk().id()); + if (disk.managedDisk().diskEncryptionSet() != null) { + storageProfile.append("\n\t\t\tDiskEncryptionSet Id: ").append(disk.managedDisk().diskEncryptionSet().id()); + } } } else { if (disk.vhd().uri() != null) { @@ -1626,7 +1634,7 @@ public static void print(SearchService searchService) { * * @param envSecondaryServicePrincipal an Azure Container Registry * @return a service principal client ID - * @throws Exception exception + * @throws IOException exception */ public static String getSecondaryServicePrincipalClientID(String envSecondaryServicePrincipal) throws IOException { String content = new String(Files.readAllBytes(new File(envSecondaryServicePrincipal).toPath()), StandardCharsets.UTF_8).trim(); @@ -1649,7 +1657,7 @@ public static String getSecondaryServicePrincipalClientID(String envSecondarySer * * @param envSecondaryServicePrincipal an Azure Container Registry * @return a service principal secret - * @throws Exception exception + * @throws IOException exception */ public static String getSecondaryServicePrincipalSecret(String envSecondaryServicePrincipal) throws IOException { String content = new String(Files.readAllBytes(new File(envSecondaryServicePrincipal).toPath()), StandardCharsets.UTF_8).trim(); @@ -1686,7 +1694,6 @@ public static String getSecondaryServicePrincipalSecret(String envSecondaryServi * @param password alias password * @param cnName domain name * @param dnsName dns name in subject alternate name - * @throws Exception exceptions from the creation * @throws IOException IO Exception */ public static void createCertificate(String certPath, String pfxPath, String alias, @@ -1754,7 +1761,7 @@ public static void createCertificate(String certPath, String pfxPath, String ali * @param ignoreErrorStream : Boolean which controls whether to throw exception or not * based on error stream. * @return result :- depending on the method invocation. - * @throws Exception exceptions thrown from the execution + * @throws IOException exceptions thrown from the execution */ public static String cmdInvocation(String[] command, boolean ignoreErrorStream) throws IOException { @@ -1771,7 +1778,7 @@ public static String cmdInvocation(String[] command, result = br.readLine(); process.waitFor(); error = ebr.readLine(); - if (error != null && (!error.equals(""))) { + if (error != null && (!"".equals(error))) { // To do - Log error message if (!ignoreErrorStream) { @@ -3346,7 +3353,6 @@ 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()) @@ -3527,11 +3533,19 @@ private static Mono> stringResponse(Mono response new RetryPolicy("Retry-After", ChronoUnit.SECONDS)) .build(); + /** + * Get the size of the iterable. + * + * @param iterable iterable to count size + * @param generic type parameter of the iterable + * @return size of the iterable + */ public static int getSize(Iterable iterable) { int res = 0; Iterator iterator = iterable.iterator(); while (iterator.hasNext()) { iterator.next(); + res++; } return res; }