Start on data model changes and API changes for the new repository notification system
This commit is contained in:
parent
06350fb9ae
commit
a84fe0681a
16 changed files with 18557 additions and 18338 deletions
|
@ -60,6 +60,10 @@ class InvalidWebhookException(DataModelException):
|
|||
pass
|
||||
|
||||
|
||||
class InvalidNotificationException(DataModelException):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidBuildTriggerException(DataModelException):
|
||||
pass
|
||||
|
||||
|
@ -1528,6 +1532,39 @@ def get_pull_credentials(robotname):
|
|||
}
|
||||
|
||||
|
||||
def create_repo_notification(repo, event_name, method_name, config):
|
||||
event = ExternalNotificationEvent.get(ExternalNotificationEvent.name == event_name)
|
||||
method = ExternalNotificationMethod.get(ExternalNotificationMethod.name == method_name)
|
||||
|
||||
return RepositoryNotification.create(repository=repo, event=event, method=method,
|
||||
confing_json=json.dumps(config))
|
||||
|
||||
|
||||
def get_repo_notification(namespace_name, repository_name, uuid):
|
||||
joined = RepositoryNotification.select().join(Repository)
|
||||
found = list(joined.where(Repository.namespace == namespace_name,
|
||||
Repository.name == repository_name,
|
||||
RepositoryNotification.uuid == uuid))
|
||||
|
||||
if not found:
|
||||
raise InvalidNotificationException('No repository notification found with id: %s' % uuid)
|
||||
|
||||
return found[0]
|
||||
|
||||
|
||||
def delete_repo_notification(namespace_name, repository_name, uuid):
|
||||
found = get_repo_notification(namespace_name, repository_name, uuid)
|
||||
found.delete_instance()
|
||||
return found
|
||||
|
||||
|
||||
def list_repo_notifications(namespace_name, repository_name):
|
||||
joined = RepositoryNotification.select().join(Repository)
|
||||
return joined.where(Repository.namespace == namespace_name,
|
||||
Repository.name == repository_name)
|
||||
|
||||
|
||||
# TODO: remove webhook methods when no longer used.
|
||||
def create_webhook(repo, params_obj):
|
||||
return Webhook.create(repository=repo, parameters=json.dumps(params_obj))
|
||||
|
||||
|
|
Reference in a new issue