Creates the given Plugins alert condition.
@param policyId The id of the policy to add the alert condition to
@param condition The alert condition to create
@return The alert condition that was created
189993
public Optional<PluginsAlertCondition> create(long policyId, PluginsAlertCondition condition)
    {
        return HTTP.POST(String.format("/v2/alerts_plugins_conditions/policies/%d.json", policyId), condition, PLUGINS_ALERT_CONDITION);
    }
69375
public static Condition createCondition(String expression) {
        try {
            return INSTANCE.ctorCondition.newInstance(expression);
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
506486
static JpaRolloutGroup prepareRolloutGroupWithDefaultConditions(final RolloutGroupCreate create,
            final RolloutGroupConditions conditions) {
        final JpaRolloutGroup group = ((JpaRolloutGroupCreate) create).build();

        if (group.getSuccessCondition() == null) {
            group.setSuccessCondition(conditions.getSuccessCondition());
        }
        if (group.getSuccessConditionExp() == null) {
            group.setSuccessConditionExp(conditions.getSuccessConditionExp());
        }
        if (group.getSuccessAction() == null) {
            group.setSuccessAction(conditions.getSuccessAction());
        }
        if (group.getSuccessActionExp() == null) {
            group.setSuccessActionExp(conditions.getSuccessActionExp());
        }

        if (group.getErrorCondition() == null) {
            group.setErrorCondition(conditions.getErrorCondition());
        }
        if (group.getErrorConditionExp() == null) {
            group.setErrorConditionExp(conditions.getErrorConditionExp());
        }
        if (group.getErrorAction() == null) {
            group.setErrorAction(conditions.getErrorAction());
        }
        if (group.getErrorActionExp() == null) {
            group.setErrorActionExp(conditions.getErrorActionExp());
        }

        return group;
    }
794350
public void add(Collection<AlertPolicy> policies)
    {
        for(AlertPolicy policy : policies)
            this.policies.put(policy.getId(), policy);
    }
173847
public Conditions newConditions(final ZonedDateTime notBefore, final ZonedDateTime notOnOrAfter, final String... audienceUri) {
        LOGGER.debug("Building conditions for audience [{}] that enforce not-before [{}] and not-after [{}]", audienceUri, notBefore, notOnOrAfter);
        val conditions = newSamlObject(Conditions.class);
        conditions.setNotBefore(DateTimeUtils.dateTimeOf(notBefore));
        conditions.setNotOnOrAfter(DateTimeUtils.dateTimeOf(notOnOrAfter));

        val audienceRestriction = newSamlObject(AudienceRestriction.class);
        Arrays.stream(audienceUri).forEach(audienceEntry -> {
            val audience = newSamlObject(Audience.class);
            audience.setAudienceURI(audienceEntry);
            audienceRestriction.getAudiences().add(audience);
        });
        conditions.getAudienceRestrictions().add(audienceRestriction);
        return conditions;
    }
881561
public RuleEnvelope getRule(String ruleId) throws ApiException {
        ApiResponse<RuleEnvelope> resp = getRuleWithHttpInfo(ruleId);
        return resp.getData();
    }
1148252
public Optional<ExternalServiceAlertCondition> update(ExternalServiceAlertCondition condition)
    {
        return HTTP.PUT(String.format("/v2/alerts_external_service_conditions/%d.json", condition.getId()), condition, EXTERNAL_SERVICE_ALERT_CONDITION);
    }
601746
public Collection<AlertCondition> list(long entityId, String entityType)
    {
        QueryParameterList queryParams = new QueryParameterList();
        queryParams.add("entity_type", entityType);
        return HTTP.GET(String.format("/v2/alerts_entity_conditions/%d.json", entityId), null, queryParams, ALERT_CONDITIONS).get();
    }
1203186
public OperationFuture<AlertPolicy> create(AlertPolicyConfig createConfig) {
        AlertPolicyMetadata policy = client.createAlertPolicy(converter.buildCreateAlertPolicyRequest(createConfig));

        return new OperationFuture<>(
            AlertPolicy.refById(policy.getId()),
            new NoWaitingJobFuture()
        );
    }
1351209
public void add(final Condition condition) {
        if (andConditions.isEmpty()) {
            andConditions.add(new AndCondition());
        }
        andConditions.get(0).getConditions().add(condition);
    }
553848
public AlertConditionCache alertConditions(long policyId)
    {
        AlertConditionCache cache = conditions.get(policyId);
        if(cache == null)
            conditions.put(policyId, cache = new AlertConditionCache(policyId));
        return cache;
    }
75665
public Optional<NrqlAlertCondition> update(NrqlAlertCondition condition)
    {
        return HTTP.PUT(String.format("/v2/alerts_nrql_conditions/%d.json", condition.getId()), condition, NRQL_ALERT_CONDITION);
    }
1078159
public Alert newInstance() {
		Alert item = new Alert(this.pluginId);
		item.setRiskConfidence(this.risk, this.confidence);
		item.setName(this.name);
		item.setDetail(this.description, this.uri, this.param, this.attack, this.otherInfo, this.solution, this.reference, this.historyRef);
		item.setSource(this.source);
		return item;
	}
647200
public Optional<AlertCondition> update(AlertCondition condition)
    {
        return HTTP.PUT(String.format("/v2/alerts_conditions/%d.json", condition.getId()), condition, ALERT_CONDITION);
    }
1361294
public B activationCondition(String conditionExpression) {
    ActivationCondition activationCondition = createInstance(ActivationCondition.class);
    activationCondition.setTextContent(conditionExpression);
    element.setActivationCondition(activationCondition);
    return myself;
  }
134835
public OperationFuture<List<AlertPolicy>> modify(List<AlertPolicy> policyRefs,
        AlertPolicyConfig modifyConfig) {

        policyRefs.forEach(ref -> modify(ref, modifyConfig));

        return new OperationFuture<>(
            policyRefs,
            new NoWaitingJobFuture()
        );
    }
717223
public Optional<PluginsAlertCondition> update(PluginsAlertCondition condition)
    {
        return HTTP.PUT(String.format("/v2/alerts_plugins_conditions/%d.json", condition.getId()), condition, PLUGINS_ALERT_CONDITION);
    }