Skip to content

Commit

Permalink
Release 2.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaofeiCao committed Jul 28, 2022
1 parent 291908b commit 1dc4b4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,12 @@
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager</artifactId>
<version>2.10.0</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
Expand Down
36 changes: 25 additions & 11 deletions src/main/java/com/azure/resourcemanager/samples/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -3527,11 +3533,19 @@ private static Mono<Response<String>> stringResponse(Mono<HttpResponse> response
new RetryPolicy("Retry-After", ChronoUnit.SECONDS))
.build();

/**
* Get the size of the iterable.
*
* @param iterable iterable to count size
* @param <T> generic type parameter of the iterable
* @return size of the iterable
*/
public static <T> int getSize(Iterable<T> iterable) {
int res = 0;
Iterator<T> iterator = iterable.iterator();
while (iterator.hasNext()) {
iterator.next();
res++;
}
return res;
}
Expand Down

0 comments on commit 1dc4b4c

Please sign in to comment.