/** * * * <pre> * Whether or not the policy is enabled. On write, the default interpretation * if unset is that the policy is enabled. On read, clients should not make * any assumption about the state if it has not been populated. The * field should always be populated on List and Get operations, unless * a field projection has been specified that strips it out. * </pre> * * <code>.google.protobuf.BoolValue enabled = 17;</code> */ public com.google.protobuf.BoolValueOrBuilder getEnabledOrBuilder() { return getEnabled(); }
output, internalGetUserLabels(), UserLabelsDefaultEntryHolder.defaultEntry, 16); if (enabled_ != null) { output.writeMessage(17, getEnabled());
size += com.google.protobuf.CodedOutputStream.computeMessageSize(17, getEnabled());
mergeEnabled(other.getEnabled());
if (hasEnabled()) { hash = (37 * hash) + ENABLED_FIELD_NUMBER; hash = (53 * hash) + getEnabled().hashCode();
result = result && (hasEnabled() == other.hasEnabled()); if (hasEnabled()) { result = result && getEnabled().equals(other.getEnabled());
private static void enablePolicies(String projectId, String filter, boolean enable) throws IOException { try (AlertPolicyServiceClient client = AlertPolicyServiceClient.create()) { ListAlertPoliciesPagedResponse response = client .listAlertPolicies(ListAlertPoliciesRequest.newBuilder() .setName(ProjectName.of(projectId).toString()) .setFilter(filter) .build()); for (AlertPolicy policy : response.iterateAll()) { if (policy.getEnabled().getValue() == enable) { System.out.println(String.format( "Policy %s is already %b.", policy.getName(), enable ? "enabled" : "disabled")); continue; } AlertPolicy updatedPolicy = AlertPolicy .newBuilder() .setName(policy.getName()) .setEnabled(BoolValue.newBuilder().setValue(enable)) .build(); AlertPolicy result = client.updateAlertPolicy( FieldMask.newBuilder().addPaths("enabled").build(), updatedPolicy); System.out.println(String.format( "%s %s", result.getDisplayName(), result.getEnabled().getValue() ? "enabled" : "disabled")); } } } // [END monitoring_alert_enable_policies]