Interface AutomationConfigStore

All Known Implementing Classes:
CachingAutomationConfigStore, JiraAutomationConfigStore

public interface AutomationConfigStore
  • Method Details

    • getRules

      List<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext context, String... projectIds)
      Get all rules for the given projects, and also rules without a project restriction.
      Parameters:
      context - The tenant context
      projectIds - The project ids to look up rules for
      Returns:
      List of automation rules in this project and tenant
    • getRules

      List<com.codebarrel.automation.api.config.RuleConfigBean> getRules(TenantContext context, Set<String> projectIds)
    • getProjectRules

      List<com.codebarrel.automation.api.config.RuleConfigBean> getProjectRules(TenantContext context, String... projectIds)
      Get rules restricted to the the given projects only, unlike getRules() rules without a project restriction will be ignored.
    • getBillableRules

      List<com.codebarrel.automation.api.config.RuleConfigBean> getBillableRules(TenantContext context)
      Returns rules that are considered billable i.e. multi-project and global rules
      Parameters:
      context - Tenant context
      Returns:
      List of billable automation rules for the tenant
    • getRule

      Optional<com.codebarrel.automation.api.config.RuleConfigBean> getRule(TenantContext context, Long ruleId)
      Retrieve a rule by id
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to retrieve
      Returns:
      the automation rule or empty if none exists.
    • getRuleNames

      Map<Long,String> getRuleNames(List<Long> ruleIds)
      Retrieve rule names by rule ids
      Parameters:
      ruleIds - The ids of rules to retrieve
      Returns:
      Map of rule id to rule name
    • getRulesWithTagGlobally

      List<TenantRuleId> getRulesWithTagGlobally(Environment environment, Tag tag, @Nullable com.codebarrel.automation.api.config.RuleState state)
      Returns all automation rules tagged with the provided tag irrelevant of tenant context

      Use with care! Generally you should use getRulesWithTag(TenantContext, Tag)!

      Parameters:
      environment - The db environment to run this query in
      tag - The tag to search for
      state - Only retrieve rules matching this state. Maybe null for all states.
      Returns:
      List of matching ruleIds the tag
    • getRulesWithTag

      List<com.codebarrel.automation.api.config.RuleConfigBean> getRulesWithTag(TenantContext context, Tag tag)
      Returns all automation rules tagged with the provided tag.
      Parameters:
      context - The tenant context
      tag - The tag to search for
      Returns:
      List of rules matching the tag
    • createRule

      com.codebarrel.automation.api.config.RuleConfigBean createRule(TenantContext context, com.codebarrel.automation.api.config.RuleConfigBean createRequest)
      Creates a new rule.
      Parameters:
      context - The tenant context
      createRequest - Data needed to create the new rule
      Returns:
      The newly created rule or an error collection
    • addLabel

      void addLabel(TenantContext context, Long ruleId, Long labelId)
      Adds a new rule label to rule
      Parameters:
      context - The tenant context
      ruleId - the id of the rule to update
    • removeLabel

      void removeLabel(TenantContext context, Long ruleId, Long labelId)
      Removes a rule label
      Parameters:
      context - The tenant context
      ruleId - the id of the rule to update
    • updateRule

      com.codebarrel.automation.api.config.RuleConfigBean updateRule(TenantContext context, Long ruleId, com.codebarrel.automation.api.config.RuleConfigBean updateRequest)
      Updates the rule with the provided configuration.
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to udpate
      updateRequest - Data needed to update the rule
      Returns:
      The updated rule or an error collection
    • disableRule

      void disableRule(TenantContext context, Long ruleId)
      This is an 'internal' method to be called by the rule executor when an execution loop may have been detected.
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to disable
    • delete

      void delete(TenantContext context, Long ruleId)
      Deletes the rule with the id provided.
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to delete
    • deleteAssociatedRuleProjects

      void deleteAssociatedRuleProjects(TenantContext context, Long ruleId, String... projectIds)
      Deletes the associated project ids from a rule
      Parameters:
      context - The tenant context
      ruleId - The id of the rule to delete projects from
      projectIds - List of projects to remove from rule
    • getTotalRuleCount

      long getTotalRuleCount(TenantContext context)
      Returns a count of all the rules for tenant
      Parameters:
      context - The tenant context
      Returns:
      Count of all rules
    • hasRulesInScope

      boolean hasRulesInScope(TenantContext context, @Nullable Long projectId)
      Whether there are any rule specifically in the given scope
      Parameters:
      context - The tenant context
      projectId - The scope to retrieve rules for
    • getEnabledRuleCount

      long getEnabledRuleCount(TenantContext context)
      Counts enabled rules on a tenant.
      Parameters:
      context - The tenant
      Returns:
      count of enabled rules