|
79 | 79 | import com.microsoft.azure.management.keyvault.AccessPolicy; |
80 | 80 | import com.microsoft.azure.management.keyvault.Vault; |
81 | 81 | import com.microsoft.azure.management.locks.ManagementLock; |
| 82 | +import com.microsoft.azure.management.monitor.ActionGroup; |
| 83 | +import com.microsoft.azure.management.monitor.ActivityLogAlert; |
| 84 | +import com.microsoft.azure.management.monitor.AutomationRunbookReceiver; |
| 85 | +import com.microsoft.azure.management.monitor.AzureAppPushReceiver; |
| 86 | +import com.microsoft.azure.management.monitor.AzureFunctionReceiver; |
82 | 87 | import com.microsoft.azure.management.monitor.DiagnosticSetting; |
| 88 | +import com.microsoft.azure.management.monitor.EmailReceiver; |
| 89 | +import com.microsoft.azure.management.monitor.ItsmReceiver; |
83 | 90 | import com.microsoft.azure.management.monitor.LogSettings; |
| 91 | +import com.microsoft.azure.management.monitor.LogicAppReceiver; |
| 92 | +import com.microsoft.azure.management.monitor.MetricAlert; |
| 93 | +import com.microsoft.azure.management.monitor.MetricAlertCondition; |
| 94 | +import com.microsoft.azure.management.monitor.MetricDimension; |
84 | 95 | import com.microsoft.azure.management.monitor.MetricSettings; |
| 96 | +import com.microsoft.azure.management.monitor.SmsReceiver; |
| 97 | +import com.microsoft.azure.management.monitor.VoiceReceiver; |
| 98 | +import com.microsoft.azure.management.monitor.WebhookReceiver; |
85 | 99 | import com.microsoft.azure.management.msi.Identity; |
86 | 100 | import com.microsoft.azure.management.network.ApplicationGateway; |
87 | 101 | import com.microsoft.azure.management.network.ApplicationGatewayBackend; |
@@ -1278,9 +1292,6 @@ public static void print(KubernetesCluster kubernetesCluster) { |
1278 | 1292 | .append("\n\tLinux user name: ").append(kubernetesCluster.linuxRootUsername()) |
1279 | 1293 | .append("\n\tSSH key: ").append(kubernetesCluster.sshKey()) |
1280 | 1294 | .append("\n\tService principal client ID: ").append(kubernetesCluster.servicePrincipalClientId()); |
1281 | | - if (kubernetesCluster.keyVaultSecretReference() != null) { |
1282 | | - info.append("\n\tKeyVault reference: ").append(kubernetesCluster.keyVaultSecretReference().vaultID()); |
1283 | | - } |
1284 | 1295 |
|
1285 | 1296 | System.out.println(info.toString()); |
1286 | 1297 | } |
@@ -2899,6 +2910,202 @@ public static void print(DiagnosticSetting resource) { |
2899 | 2910 | System.out.println(info.toString()); |
2900 | 2911 | } |
2901 | 2912 |
|
| 2913 | + /** |
| 2914 | + * Print Action group settings. |
| 2915 | + * |
| 2916 | + * @param actionGroup action group instance |
| 2917 | + */ |
| 2918 | + public static void print(ActionGroup actionGroup) { |
| 2919 | + StringBuilder info = new StringBuilder("Action Group: ") |
| 2920 | + .append("\n\tId: ").append(actionGroup.id()) |
| 2921 | + .append("\n\tName: ").append(actionGroup.name()) |
| 2922 | + .append("\n\tShort Name: ").append(actionGroup.shortName()); |
| 2923 | + |
| 2924 | + if (actionGroup.emailReceivers() != null && !actionGroup.emailReceivers().isEmpty()) { |
| 2925 | + info.append("\n\tEmail receivers: "); |
| 2926 | + for (EmailReceiver er : actionGroup.emailReceivers()) { |
| 2927 | + info.append("\n\t\tName: ").append(er.name()); |
| 2928 | + info.append("\n\t\tEMail: ").append(er.emailAddress()); |
| 2929 | + info.append("\n\t\tStatus: ").append(er.status()); |
| 2930 | + info.append("\n\t\t==="); |
| 2931 | + } |
| 2932 | + } |
| 2933 | + |
| 2934 | + if (actionGroup.smsReceivers() != null && !actionGroup.smsReceivers().isEmpty()) { |
| 2935 | + info.append("\n\tSMS text message receivers: "); |
| 2936 | + for (SmsReceiver er : actionGroup.smsReceivers()) { |
| 2937 | + info.append("\n\t\tName: ").append(er.name()); |
| 2938 | + info.append("\n\t\tPhone: ").append(er.countryCode() + er.phoneNumber()); |
| 2939 | + info.append("\n\t\tStatus: ").append(er.status()); |
| 2940 | + info.append("\n\t\t==="); |
| 2941 | + } |
| 2942 | + } |
| 2943 | + |
| 2944 | + if (actionGroup.webhookReceivers() != null && !actionGroup.webhookReceivers().isEmpty()) { |
| 2945 | + info.append("\n\tWebhook receivers: "); |
| 2946 | + for (WebhookReceiver er : actionGroup.webhookReceivers()) { |
| 2947 | + info.append("\n\t\tName: ").append(er.name()); |
| 2948 | + info.append("\n\t\tURI: ").append(er.serviceUri()); |
| 2949 | + info.append("\n\t\t==="); |
| 2950 | + } |
| 2951 | + } |
| 2952 | + |
| 2953 | + if (actionGroup.pushNotificationReceivers() != null && !actionGroup.pushNotificationReceivers().isEmpty()) { |
| 2954 | + info.append("\n\tApp Push Notification receivers: "); |
| 2955 | + for (AzureAppPushReceiver er : actionGroup.pushNotificationReceivers()) { |
| 2956 | + info.append("\n\t\tName: ").append(er.name()); |
| 2957 | + info.append("\n\t\tEmail: ").append(er.emailAddress()); |
| 2958 | + info.append("\n\t\t==="); |
| 2959 | + } |
| 2960 | + } |
| 2961 | + |
| 2962 | + if (actionGroup.voiceReceivers() != null && !actionGroup.voiceReceivers().isEmpty()) { |
| 2963 | + info.append("\n\tVoice Message receivers: "); |
| 2964 | + for (VoiceReceiver er : actionGroup.voiceReceivers()) { |
| 2965 | + info.append("\n\t\tName: ").append(er.name()); |
| 2966 | + info.append("\n\t\tPhone: ").append(er.countryCode() + er.phoneNumber()); |
| 2967 | + info.append("\n\t\t==="); |
| 2968 | + } |
| 2969 | + } |
| 2970 | + |
| 2971 | + if (actionGroup.automationRunbookReceivers() != null && !actionGroup.automationRunbookReceivers().isEmpty()) { |
| 2972 | + info.append("\n\tAutomation Runbook receivers: "); |
| 2973 | + for (AutomationRunbookReceiver er : actionGroup.automationRunbookReceivers()) { |
| 2974 | + info.append("\n\t\tName: ").append(er.name()); |
| 2975 | + info.append("\n\t\tRunbook Name: ").append(er.runbookName()); |
| 2976 | + info.append("\n\t\tAccount Id: ").append(er.automationAccountId()); |
| 2977 | + info.append("\n\t\tIs Global: ").append(er.isGlobalRunbook()); |
| 2978 | + info.append("\n\t\tService URI: ").append(er.serviceUri()); |
| 2979 | + info.append("\n\t\tWebhook resource Id: ").append(er.webhookResourceId()); |
| 2980 | + info.append("\n\t\t==="); |
| 2981 | + } |
| 2982 | + } |
| 2983 | + |
| 2984 | + if (actionGroup.azureFunctionReceivers() != null && !actionGroup.azureFunctionReceivers().isEmpty()) { |
| 2985 | + info.append("\n\tAzure Functions receivers: "); |
| 2986 | + for (AzureFunctionReceiver er : actionGroup.azureFunctionReceivers()) { |
| 2987 | + info.append("\n\t\tName: ").append(er.name()); |
| 2988 | + info.append("\n\t\tFunction Name: ").append(er.functionName()); |
| 2989 | + info.append("\n\t\tFunction App Resource Id: ").append(er.functionAppResourceId()); |
| 2990 | + info.append("\n\t\tFunction Trigger URI: ").append(er.httpTriggerUrl()); |
| 2991 | + info.append("\n\t\t==="); |
| 2992 | + } |
| 2993 | + } |
| 2994 | + |
| 2995 | + if (actionGroup.logicAppReceivers() != null && !actionGroup.logicAppReceivers().isEmpty()) { |
| 2996 | + info.append("\n\tLogic App receivers: "); |
| 2997 | + for (LogicAppReceiver er : actionGroup.logicAppReceivers()) { |
| 2998 | + info.append("\n\t\tName: ").append(er.name()); |
| 2999 | + info.append("\n\t\tResource Id: ").append(er.resourceId()); |
| 3000 | + info.append("\n\t\tCallback URL: ").append(er.callbackUrl()); |
| 3001 | + info.append("\n\t\t==="); |
| 3002 | + } |
| 3003 | + } |
| 3004 | + |
| 3005 | + if (actionGroup.itsmReceivers() != null && !actionGroup.itsmReceivers().isEmpty()) { |
| 3006 | + info.append("\n\tITSM receivers: "); |
| 3007 | + for (ItsmReceiver er : actionGroup.itsmReceivers()) { |
| 3008 | + info.append("\n\t\tName: ").append(er.name()); |
| 3009 | + info.append("\n\t\tWorkspace Id: ").append(er.workspaceId()); |
| 3010 | + info.append("\n\t\tConnection Id: ").append(er.connectionId()); |
| 3011 | + info.append("\n\t\tRegion: ").append(er.region()); |
| 3012 | + info.append("\n\t\tTicket Configuration: ").append(er.ticketConfiguration()); |
| 3013 | + info.append("\n\t\t==="); |
| 3014 | + } |
| 3015 | + } |
| 3016 | + System.out.println(info.toString()); |
| 3017 | + } |
| 3018 | + |
| 3019 | + /** |
| 3020 | + * Print activity log alert settings. |
| 3021 | + * |
| 3022 | + * @param activityLogAlert activity log instance |
| 3023 | + */ |
| 3024 | + public static void print(ActivityLogAlert activityLogAlert) { |
| 3025 | + |
| 3026 | + StringBuilder info = new StringBuilder("Activity Log Alert: ") |
| 3027 | + .append("\n\tId: ").append(activityLogAlert.id()) |
| 3028 | + .append("\n\tName: ").append(activityLogAlert.name()) |
| 3029 | + .append("\n\tDescription: ").append(activityLogAlert.description()) |
| 3030 | + .append("\n\tIs Enabled: ").append(activityLogAlert.enabled()); |
| 3031 | + |
| 3032 | + if (activityLogAlert.scopes() != null && !activityLogAlert.scopes().isEmpty()) { |
| 3033 | + info.append("\n\tScopes: "); |
| 3034 | + for (String er : activityLogAlert.scopes()) { |
| 3035 | + info.append("\n\t\tId: ").append(er); |
| 3036 | + } |
| 3037 | + } |
| 3038 | + |
| 3039 | + if (activityLogAlert.actionGroupIds() != null && !activityLogAlert.actionGroupIds().isEmpty()) { |
| 3040 | + info.append("\n\tAction Groups: "); |
| 3041 | + for (String er : activityLogAlert.actionGroupIds()) { |
| 3042 | + info.append("\n\t\tAction Group Id: ").append(er); |
| 3043 | + } |
| 3044 | + } |
| 3045 | + |
| 3046 | + if (activityLogAlert.equalsConditions() != null && !activityLogAlert.equalsConditions().isEmpty()) { |
| 3047 | + info.append("\n\tAlert conditions (when all of is true): "); |
| 3048 | + for (Map.Entry<String, String> er : activityLogAlert.equalsConditions().entrySet()) { |
| 3049 | + info.append("\n\t\t'").append(er.getKey()).append("' equals '").append(er.getValue()).append("'"); |
| 3050 | + } |
| 3051 | + } |
| 3052 | + System.out.println(info.toString()); |
| 3053 | + } |
| 3054 | + |
| 3055 | + /** |
| 3056 | + * Print metric alert settings. |
| 3057 | + * |
| 3058 | + * @param metricAlert metric alert instance |
| 3059 | + */ |
| 3060 | + public static void print(MetricAlert metricAlert) { |
| 3061 | + |
| 3062 | + StringBuilder info = new StringBuilder("Metric Alert: ") |
| 3063 | + .append("\n\tId: ").append(metricAlert.id()) |
| 3064 | + .append("\n\tName: ").append(metricAlert.name()) |
| 3065 | + .append("\n\tDescription: ").append(metricAlert.description()) |
| 3066 | + .append("\n\tIs Enabled: ").append(metricAlert.enabled()) |
| 3067 | + .append("\n\tIs Auto Mitigated: ").append(metricAlert.autoMitigate()) |
| 3068 | + .append("\n\tSeverity: ").append(metricAlert.severity()) |
| 3069 | + .append("\n\tWindow Size: ").append(metricAlert.windowSize()) |
| 3070 | + .append("\n\tEvaluation Frequency: ").append(metricAlert.evaluationFrequency()); |
| 3071 | + |
| 3072 | + if (metricAlert.scopes() != null && !metricAlert.scopes().isEmpty()) { |
| 3073 | + info.append("\n\tScopes: "); |
| 3074 | + for (String er : metricAlert.scopes()) { |
| 3075 | + info.append("\n\t\tId: ").append(er); |
| 3076 | + } |
| 3077 | + } |
| 3078 | + |
| 3079 | + if (metricAlert.actionGroupIds() != null && !metricAlert.actionGroupIds().isEmpty()) { |
| 3080 | + info.append("\n\tAction Groups: "); |
| 3081 | + for (String er : metricAlert.actionGroupIds()) { |
| 3082 | + info.append("\n\t\tAction Group Id: ").append(er); |
| 3083 | + } |
| 3084 | + } |
| 3085 | + |
| 3086 | + if (metricAlert.alertCriterias() != null && !metricAlert.alertCriterias().isEmpty()) { |
| 3087 | + info.append("\n\tAlert conditions (when all of is true): "); |
| 3088 | + for (Map.Entry<String, MetricAlertCondition> er : metricAlert.alertCriterias().entrySet()) { |
| 3089 | + MetricAlertCondition alertCondition = er.getValue(); |
| 3090 | + info.append("\n\t\tCondition name: ").append(er.getKey()) |
| 3091 | + .append("\n\t\tSignal name: ").append(alertCondition.metricName()) |
| 3092 | + .append("\n\t\tMetric Namespace: ").append(alertCondition.metricNamespace()) |
| 3093 | + .append("\n\t\tOperator: ").append(alertCondition.condition()) |
| 3094 | + .append("\n\t\tThreshold: ").append(alertCondition.threshold()) |
| 3095 | + .append("\n\t\tTime Aggregation: ").append(alertCondition.timeAggregation()); |
| 3096 | + if (alertCondition.dimensions() != null && !alertCondition.dimensions().isEmpty()) { |
| 3097 | + for (MetricDimension dimon : alertCondition.dimensions()) { |
| 3098 | + info.append("\n\t\tDimension Filter: ").append("Name [").append(dimon.name()).append("] operator [Include] values["); |
| 3099 | + for (String vals : dimon.values()) { |
| 3100 | + info.append(vals).append(", "); |
| 3101 | + } |
| 3102 | + info.append("]"); |
| 3103 | + } |
| 3104 | + } |
| 3105 | + } |
| 3106 | + } |
| 3107 | + System.out.println(info.toString()); |
| 3108 | + } |
2902 | 3109 | private static OkHttpClient httpClient; |
2903 | 3110 |
|
2904 | 3111 | /** |
|
0 commit comments