code: public boolean syncAlerts(NewRelicCache cache)
      {
          boolean ret = true;
  
          if(apiClient == null)
              throw new IllegalArgumentException("null API client");
  
          // Get the alert configuration using the REST API
          if(cache.isAlertsEnabled())
          {
              ret = false;
  
              // Get the alert policies
              logger.info("Getting the alert policies");
              Collection<AlertPolicy> policies = apiClient.alertPolicies().list();
              for(AlertPolicy policy : policies)
              {
                  cache.alertPolicies().add(policy);
  
                  // Add the alert conditions
                  if(cache.isApmEnabled() || cache.isServersEnabled() || cache.isBrowserEnabled() || cache.isMobileEnabled())
                      cache.alertPolicies().alertConditions(policy.getId()).add(apiClient.alertConditions().list(policy.getId()));
                  cache.alertPolicies().nrqlAlertConditions(policy.getId()).add(apiClient.nrqlAlertConditions().list(policy.getId()));
                  if(cache.isApmEnabled() || cache.isMobileEnabled())
                      cache.alertPolicies().externalServiceAlertConditions(policy.getId()).add(apiClient.externalServiceAlertConditions().list(policy.getId()));
                  if(cache.isSyntheticsEnabled())
                      cache.alertPolicies().syntheticsAlertConditions(policy.getId()).add(apiClient.syntheticsAlertConditions().list(policy.getId()));
                  if(cache.isPluginsEnabled())
                      cache.alertPolicies().pluginsAlertConditions(policy.getId()).add(apiClient.pluginsAlertConditions().list(policy.getId()));
                  if(cache.isInfrastructureEnabled())
                      cache.alertPolicies().infraAlertConditions(policy.getId()).add(infraApiClient.infraAlertConditions().list(policy.getId()));
              }
  
              // Get the alert channels
              logger.info("Getting the alert channels");
              Collection<AlertChannel> channels = apiClient.alertChannels().list();
              cache.alertChannels().set(channels);
              cache.alertPolicies().setAlertChannels(channels);
              cache.setUpdatedAt();
  
              ret = true;
          }
  
          return ret;
      }
docs: Synchronise the alerts configuration with the cache.
  @param cache The provider cache
  @return <CODE>true</CODE> if the operation was successful