Skip to content

Commit

Permalink
Release 1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
anuchandy committed Sep 25, 2018
1 parent 0cc1daf commit e18ba6c
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ author: milismsft

To run this sample:

Set the environment variable `AZURE_AUTH_LOCATION` with the full path for an auth file. See [how to create an auth file](https://github.com/Azure/azure-libraries-for-java/blob/master/AUTH.md).
Set the environment variable `AZURE_AUTH_LOCATION` with the full path for an auth file. See [how to create an auth file](https://github.com/Azure/azure-sdk-for-java/blob/master/AUTH.md).

git clone https://github.com/Azure-Samples/aks-java-manage-kubernetes-cluster.git

Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,13 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.14.0</version>
<version>1.16.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public static boolean runSample(Azure azure, String clientId, String secret) {
.withServicePrincipalClientId(servicePrincipalClientId)
.withServicePrincipalSecret(servicePrincipalSecret)
.defineAgentPool("agentpool")
.withVirtualMachineCount(1)
.withVirtualMachineSize(ContainerServiceVMSizeTypes.STANDARD_D1_V2)
.withAgentPoolVirtualMachineCount(1)
.attach()
.withDnsPrefix("dns-" + aksName)
.create();
Expand All @@ -111,7 +111,7 @@ public static boolean runSample(Azure azure, String clientId, String secret) {
t1 = new Date();

kubernetesCluster.update()
.withAgentVirtualMachineCount(2)
.withAgentPoolVirtualMachineCount(2)
.apply();

t2 = new Date();
Expand Down
213 changes: 210 additions & 3 deletions src/main/java/com/microsoft/azure/management/samples/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,23 @@
import com.microsoft.azure.management.keyvault.AccessPolicy;
import com.microsoft.azure.management.keyvault.Vault;
import com.microsoft.azure.management.locks.ManagementLock;
import com.microsoft.azure.management.monitor.ActionGroup;
import com.microsoft.azure.management.monitor.ActivityLogAlert;
import com.microsoft.azure.management.monitor.AutomationRunbookReceiver;
import com.microsoft.azure.management.monitor.AzureAppPushReceiver;
import com.microsoft.azure.management.monitor.AzureFunctionReceiver;
import com.microsoft.azure.management.monitor.DiagnosticSetting;
import com.microsoft.azure.management.monitor.EmailReceiver;
import com.microsoft.azure.management.monitor.ItsmReceiver;
import com.microsoft.azure.management.monitor.LogSettings;
import com.microsoft.azure.management.monitor.LogicAppReceiver;
import com.microsoft.azure.management.monitor.MetricAlert;
import com.microsoft.azure.management.monitor.MetricAlertCondition;
import com.microsoft.azure.management.monitor.MetricDimension;
import com.microsoft.azure.management.monitor.MetricSettings;
import com.microsoft.azure.management.monitor.SmsReceiver;
import com.microsoft.azure.management.monitor.VoiceReceiver;
import com.microsoft.azure.management.monitor.WebhookReceiver;
import com.microsoft.azure.management.msi.Identity;
import com.microsoft.azure.management.network.ApplicationGateway;
import com.microsoft.azure.management.network.ApplicationGatewayBackend;
Expand Down Expand Up @@ -1278,9 +1292,6 @@ public static void print(KubernetesCluster kubernetesCluster) {
.append("\n\tLinux user name: ").append(kubernetesCluster.linuxRootUsername())
.append("\n\tSSH key: ").append(kubernetesCluster.sshKey())
.append("\n\tService principal client ID: ").append(kubernetesCluster.servicePrincipalClientId());
if (kubernetesCluster.keyVaultSecretReference() != null) {
info.append("\n\tKeyVault reference: ").append(kubernetesCluster.keyVaultSecretReference().vaultID());
}

System.out.println(info.toString());
}
Expand Down Expand Up @@ -2899,6 +2910,202 @@ public static void print(DiagnosticSetting resource) {
System.out.println(info.toString());
}

/**
* Print Action group settings.
*
* @param actionGroup action group instance
*/
public static void print(ActionGroup actionGroup) {
StringBuilder info = new StringBuilder("Action Group: ")
.append("\n\tId: ").append(actionGroup.id())
.append("\n\tName: ").append(actionGroup.name())
.append("\n\tShort Name: ").append(actionGroup.shortName());

if (actionGroup.emailReceivers() != null && !actionGroup.emailReceivers().isEmpty()) {
info.append("\n\tEmail receivers: ");
for (EmailReceiver er : actionGroup.emailReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tEMail: ").append(er.emailAddress());
info.append("\n\t\tStatus: ").append(er.status());
info.append("\n\t\t===");
}
}

if (actionGroup.smsReceivers() != null && !actionGroup.smsReceivers().isEmpty()) {
info.append("\n\tSMS text message receivers: ");
for (SmsReceiver er : actionGroup.smsReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tPhone: ").append(er.countryCode() + er.phoneNumber());
info.append("\n\t\tStatus: ").append(er.status());
info.append("\n\t\t===");
}
}

if (actionGroup.webhookReceivers() != null && !actionGroup.webhookReceivers().isEmpty()) {
info.append("\n\tWebhook receivers: ");
for (WebhookReceiver er : actionGroup.webhookReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tURI: ").append(er.serviceUri());
info.append("\n\t\t===");
}
}

if (actionGroup.pushNotificationReceivers() != null && !actionGroup.pushNotificationReceivers().isEmpty()) {
info.append("\n\tApp Push Notification receivers: ");
for (AzureAppPushReceiver er : actionGroup.pushNotificationReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tEmail: ").append(er.emailAddress());
info.append("\n\t\t===");
}
}

if (actionGroup.voiceReceivers() != null && !actionGroup.voiceReceivers().isEmpty()) {
info.append("\n\tVoice Message receivers: ");
for (VoiceReceiver er : actionGroup.voiceReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tPhone: ").append(er.countryCode() + er.phoneNumber());
info.append("\n\t\t===");
}
}

if (actionGroup.automationRunbookReceivers() != null && !actionGroup.automationRunbookReceivers().isEmpty()) {
info.append("\n\tAutomation Runbook receivers: ");
for (AutomationRunbookReceiver er : actionGroup.automationRunbookReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tRunbook Name: ").append(er.runbookName());
info.append("\n\t\tAccount Id: ").append(er.automationAccountId());
info.append("\n\t\tIs Global: ").append(er.isGlobalRunbook());
info.append("\n\t\tService URI: ").append(er.serviceUri());
info.append("\n\t\tWebhook resource Id: ").append(er.webhookResourceId());
info.append("\n\t\t===");
}
}

if (actionGroup.azureFunctionReceivers() != null && !actionGroup.azureFunctionReceivers().isEmpty()) {
info.append("\n\tAzure Functions receivers: ");
for (AzureFunctionReceiver er : actionGroup.azureFunctionReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tFunction Name: ").append(er.functionName());
info.append("\n\t\tFunction App Resource Id: ").append(er.functionAppResourceId());
info.append("\n\t\tFunction Trigger URI: ").append(er.httpTriggerUrl());
info.append("\n\t\t===");
}
}

if (actionGroup.logicAppReceivers() != null && !actionGroup.logicAppReceivers().isEmpty()) {
info.append("\n\tLogic App receivers: ");
for (LogicAppReceiver er : actionGroup.logicAppReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tResource Id: ").append(er.resourceId());
info.append("\n\t\tCallback URL: ").append(er.callbackUrl());
info.append("\n\t\t===");
}
}

if (actionGroup.itsmReceivers() != null && !actionGroup.itsmReceivers().isEmpty()) {
info.append("\n\tITSM receivers: ");
for (ItsmReceiver er : actionGroup.itsmReceivers()) {
info.append("\n\t\tName: ").append(er.name());
info.append("\n\t\tWorkspace Id: ").append(er.workspaceId());
info.append("\n\t\tConnection Id: ").append(er.connectionId());
info.append("\n\t\tRegion: ").append(er.region());
info.append("\n\t\tTicket Configuration: ").append(er.ticketConfiguration());
info.append("\n\t\t===");
}
}
System.out.println(info.toString());
}

/**
* Print activity log alert settings.
*
* @param activityLogAlert activity log instance
*/
public static void print(ActivityLogAlert activityLogAlert) {

StringBuilder info = new StringBuilder("Activity Log Alert: ")
.append("\n\tId: ").append(activityLogAlert.id())
.append("\n\tName: ").append(activityLogAlert.name())
.append("\n\tDescription: ").append(activityLogAlert.description())
.append("\n\tIs Enabled: ").append(activityLogAlert.enabled());

if (activityLogAlert.scopes() != null && !activityLogAlert.scopes().isEmpty()) {
info.append("\n\tScopes: ");
for (String er : activityLogAlert.scopes()) {
info.append("\n\t\tId: ").append(er);
}
}

if (activityLogAlert.actionGroupIds() != null && !activityLogAlert.actionGroupIds().isEmpty()) {
info.append("\n\tAction Groups: ");
for (String er : activityLogAlert.actionGroupIds()) {
info.append("\n\t\tAction Group Id: ").append(er);
}
}

if (activityLogAlert.equalsConditions() != null && !activityLogAlert.equalsConditions().isEmpty()) {
info.append("\n\tAlert conditions (when all of is true): ");
for (Map.Entry<String, String> er : activityLogAlert.equalsConditions().entrySet()) {
info.append("\n\t\t'").append(er.getKey()).append("' equals '").append(er.getValue()).append("'");
}
}
System.out.println(info.toString());
}

/**
* Print metric alert settings.
*
* @param metricAlert metric alert instance
*/
public static void print(MetricAlert metricAlert) {

StringBuilder info = new StringBuilder("Metric Alert: ")
.append("\n\tId: ").append(metricAlert.id())
.append("\n\tName: ").append(metricAlert.name())
.append("\n\tDescription: ").append(metricAlert.description())
.append("\n\tIs Enabled: ").append(metricAlert.enabled())
.append("\n\tIs Auto Mitigated: ").append(metricAlert.autoMitigate())
.append("\n\tSeverity: ").append(metricAlert.severity())
.append("\n\tWindow Size: ").append(metricAlert.windowSize())
.append("\n\tEvaluation Frequency: ").append(metricAlert.evaluationFrequency());

if (metricAlert.scopes() != null && !metricAlert.scopes().isEmpty()) {
info.append("\n\tScopes: ");
for (String er : metricAlert.scopes()) {
info.append("\n\t\tId: ").append(er);
}
}

if (metricAlert.actionGroupIds() != null && !metricAlert.actionGroupIds().isEmpty()) {
info.append("\n\tAction Groups: ");
for (String er : metricAlert.actionGroupIds()) {
info.append("\n\t\tAction Group Id: ").append(er);
}
}

if (metricAlert.alertCriterias() != null && !metricAlert.alertCriterias().isEmpty()) {
info.append("\n\tAlert conditions (when all of is true): ");
for (Map.Entry<String, MetricAlertCondition> er : metricAlert.alertCriterias().entrySet()) {
MetricAlertCondition alertCondition = er.getValue();
info.append("\n\t\tCondition name: ").append(er.getKey())
.append("\n\t\tSignal name: ").append(alertCondition.metricName())
.append("\n\t\tMetric Namespace: ").append(alertCondition.metricNamespace())
.append("\n\t\tOperator: ").append(alertCondition.condition())
.append("\n\t\tThreshold: ").append(alertCondition.threshold())
.append("\n\t\tTime Aggregation: ").append(alertCondition.timeAggregation());
if (alertCondition.dimensions() != null && !alertCondition.dimensions().isEmpty()) {
for (MetricDimension dimon : alertCondition.dimensions()) {
info.append("\n\t\tDimension Filter: ").append("Name [").append(dimon.name()).append("] operator [Include] values[");
for (String vals : dimon.values()) {
info.append(vals).append(", ");
}
info.append("]");
}
}
}
}
System.out.println(info.toString());
}
private static OkHttpClient httpClient;

/**
Expand Down

0 comments on commit e18ba6c

Please sign in to comment.