Interface RepositoryHookService
public interface RepositoryHookService
Handles the aggregation of hooks and their enabled status.
Settings for these hooks are handled elsewhere.
-
Method Summary
Modifier and TypeMethodDescriptionCreate a newSettingsBuilder
which can be used to create aSettings
instance.void
delete
(DeleteRepositoryHookRequest request) Delete the hook configuration specified in the request.disable
(DisableRepositoryHookRequest request) Disable the hook specified in the request.enable
(EnableRepositoryHookRequest request) Enable and apply settings for the hook specified in the request.Returns a supplier of an avatar for this hook, either one specified in the module or a default.Find an effective installed hook with the specified key enabled status for this scope.Gets the effective settings for the hook specified in the request.int
migrateSettings
(String oldHookKey, String newHookKey) Migrates settings between the specified hook keys.<T extends RepositoryHookRequest>
voidpostUpdate
(T request) Calls all registered and enabledrepository-hook
modules (PostRepositoryHook
)<T extends RepositoryHookRequest>
RepositoryHookResultpreUpdate
(T request) Calls all registered and enabledrepository-hook
modules (PreRepositoryHook
)search
(RepositoryHookSearchRequest request, PageRequest pageRequest) Searches forrepository hooks
that match the providedrequest
.Sets the settings for the hook specified in the request.
-
Method Details
-
createSettingsBuilder
Create a newSettingsBuilder
which can be used to create aSettings
instance.- Returns:
- a new builder
-
delete
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 anyScope
other thanREPOSITORY
- Since:
- 5.2
-
disable
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 unchangedArgumentValidationException
- if the settings to be saved are too large, the current limit is 32KB once serialized.- Since:
- 5.2
-
getAvatar
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
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 atproject scope
orrepository scope
- Parameters:
scope
- the scope to load the hook fromhookKey
- the hook to lookup- Returns:
- the effective
RepositoryHook
if found. Otherwisenull
. - Since:
- 5.2
-
getSettings
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
Migrates settings between the specified hook keys.Hook keys are based on the combination of the plugin's key and the
<repository-hook/>
'skey
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 specifiedoldHookKey
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 theSecurityService
to apply that permission.- Parameters:
oldHookKey
- the hook's old keynewHookKey
- 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
Calls all registered and enabledrepository-hook
modules (PostRepositoryHook
)- Type Parameters:
T
- type of the request- Parameters:
request
- describes the ref changes that have been applied- Since:
- 5.0
-
preUpdate
Calls all registered and enabledrepository-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 forrepository hooks
that match the providedrequest
.- Parameters:
request
- a request object describing the repository hooks to returnpageRequest
- paging options- Returns:
- a page of
RepositoryHook
s 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 unchangedArgumentValidationException
- if the settings to be saved are too large, the current limit is 32KB once serialized.- Since:
- 5.2
- See Also:
-