Interface RepositoryHookService


public interface RepositoryHookService
Handles the aggregation of hooks and their enabled status. Settings for these hooks are handled elsewhere.
  • Method Details

    • createSettingsBuilder

      @Nonnull SettingsBuilder createSettingsBuilder()
      Create a new SettingsBuilder which can be used to create a Settings instance.
      Returns:
      a new builder
    • delete

      void delete(@Nonnull DeleteRepositoryHookRequest request)
      Delete the hook configuration specified in the request.
      Parameters:
      request - describes the hook for which the configuration should be deleted
      Throws:
      ArgumentValidationException - if the provided request is for any Scope other than REPOSITORY
      Since:
      5.2
    • disable

      @Nonnull RepositoryHook disable(@Nonnull DisableRepositoryHookRequest request)
      Disable the hook specified in the request.
      Parameters:
      request - describing the hook to be disabled
      Returns:
      the newly updated RepositoryHook
      Since:
      5.2
    • enable

      @Nonnull RepositoryHook enable(@Nonnull EnableRepositoryHookRequest request) throws FormValidationException
      Enable and apply settings for the hook specified in the request.
      Parameters:
      request - details for enabling a repository hook
      Returns:
      the newly updated RepositoryHook
      Throws:
      FormValidationException - when settings are invalid, leaving the existing version unchanged
      ArgumentValidationException - if the settings to be saved are too large, the current limit is 32KB once serialized.
      Since:
      5.2
    • getAvatar

      @Nonnull CacheableAvatarSupplier getAvatar(@Nonnull String hookKey)
      Returns a supplier of an avatar for this hook, either one specified in the module or a default.
      Parameters:
      hookKey - the hook key with the desired avatar
      Returns:
      an supplier for streaming the avatar
    • getByKey

      @Nullable RepositoryHook getByKey(@Nonnull Scope scope, @Nonnull String hookKey)
      Find an effective installed hook with the specified key enabled status for this scope.

      An effective hook is a hook that is either:

      • configured at the given scope,
      • or configured at a higher scope.
      Repository hooks can be configured at project scope or repository scope
      Parameters:
      scope - the scope to load the hook from
      hookKey - the hook to lookup
      Returns:
      the effective RepositoryHook if found. Otherwise null.
      Since:
      5.2
    • getSettings

      @Nullable RepositoryHookSettings getSettings(@Nonnull GetRepositoryHookSettingsRequest request)
      Gets the effective settings for the hook specified in the request.
      Parameters:
      request - details to get the settings for the specified hook
      Returns:
      the effective settings currently stored or null if no settings are stored.
      Since:
      5.2
    • migrateSettings

      int migrateSettings(@Nonnull String oldHookKey, @Nonnull String newHookKey)
      Migrates settings between the specified hook keys.

      Hook keys are based on the combination of the plugin's key and the <repository-hook/>'s key attribute. Changing either key will result in a new hook key, and the "loss" of all existing settings in all repositories (because they remain associated with the old key).

      When calling this method, the <repository-hook/> for the specified oldHookKey must no longer be installed, and the <repository-hook/> for the new key must be present.

      Calling this method requires ADMIN permission. Apps may need to use the SecurityService to apply that permission.

      Parameters:
      oldHookKey - the hook's old key
      newHookKey - the hook's new key
      Returns:
      the number of projects/repositories for which hook settings were migrated
      Throws:
      ArgumentValidationException - if the old hook is still installed, or the new hook is not installed
      Since:
      5.14
    • postUpdate

      <T extends RepositoryHookRequest> void postUpdate(@Nonnull T request)
      Calls all registered and enabled repository-hook modules (PostRepositoryHook)
      Type Parameters:
      T - type of the request
      Parameters:
      request - describes the ref changes that have been applied
      Since:
      5.0
    • preUpdate

      @Nonnull <T extends RepositoryHookRequest> RepositoryHookResult preUpdate(@Nonnull T request)
      Calls all registered and enabled repository-hook modules (PreRepositoryHook)
      Type Parameters:
      T - type of the request
      Parameters:
      request - describes the ref changes that are about to be made
      Returns:
      the outcome of the repository-hook modules
      Since:
      5.0
    • search

      @Nonnull Page<RepositoryHook> search(@Nonnull RepositoryHookSearchRequest request, @Nonnull PageRequest pageRequest)
      Searches for repository hooks that match the provided request.
      Parameters:
      request - a request object describing the repository hooks to return
      pageRequest - paging options
      Returns:
      a page of RepositoryHooks matching the supplied type
      Since:
      5.2
    • setSettings

      @Nonnull Settings setSettings(@Nonnull SetRepositoryHookSettingsRequest request) throws FormValidationException
      Sets the settings for the hook specified in the request.
      Parameters:
      request - describing the update settings request
      Returns:
      the saved settings.
      Throws:
      FormValidationException - when settings are invalid, leaving the existing version unchanged
      ArgumentValidationException - if the settings to be saved are too large, the current limit is 32KB once serialized.
      Since:
      5.2
      See Also: