Skip to content

hooks

Hook

Bases: BitbucketCloudBase

Bitbucket Cloud hook endpoint.

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
class Hook(BitbucketCloudBase):
    """
    Bitbucket Cloud hook endpoint.
    """

    def __init__(self, data, *args, **kwargs):
        super(Hook, self).__init__(None, *args, data=data, expected_type="webhook_subscription", **kwargs)

    def uuid(self):
        """hook uuid."""
        return self.get_data("uuid")

    def webhook_url(self):
        """webhook url."""
        return self.get_data("url")

    def description(self):
        """webhook description."""
        return self.get_data("description")

    def active(self):
        """is webhook active?"""
        return self.get_data("active")

    def events(self):
        """events that the webhook is triggered by"""
        return self.get_data("events")

    def update(self, **kwargs):
        """
        Update a webhook

        Valid keywords:
        param: url: string: Url that will receive event requests
        param: description: string: Details about the webhook
        param: events: [string] List of event types that requests will generate for
        param: active: boolean: Enables/Disables the webhook
        """

        payload = {
            "url": self.webhook_url(),
            "description": self.description(),
            "events": self.events(),
            "active": self.active(),
        }

        for key in payload.keys() and kwargs.keys():
            payload[key] = kwargs[key]

        return self._update_data(self.put(None, data=payload))

    def delete(self):
        """
        Delete the webhook.
        """
        return super(Hook, self).delete(None)

active()

is webhook active?

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
82
83
84
def active(self):
    """is webhook active?"""
    return self.get_data("active")

delete()

Delete the webhook.

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
113
114
115
116
117
def delete(self):
    """
    Delete the webhook.
    """
    return super(Hook, self).delete(None)

description()

webhook description.

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
78
79
80
def description(self):
    """webhook description."""
    return self.get_data("description")

events()

events that the webhook is triggered by

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
86
87
88
def events(self):
    """events that the webhook is triggered by"""
    return self.get_data("events")

update(**kwargs)

Update a webhook

Valid keywords: param: url: string: Url that will receive event requests param: description: string: Details about the webhook param: events: [string] List of event types that requests will generate for param: active: boolean: Enables/Disables the webhook

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
def update(self, **kwargs):
    """
    Update a webhook

    Valid keywords:
    param: url: string: Url that will receive event requests
    param: description: string: Details about the webhook
    param: events: [string] List of event types that requests will generate for
    param: active: boolean: Enables/Disables the webhook
    """

    payload = {
        "url": self.webhook_url(),
        "description": self.description(),
        "events": self.events(),
        "active": self.active(),
    }

    for key in payload.keys() and kwargs.keys():
        payload[key] = kwargs[key]

    return self._update_data(self.put(None, data=payload))

uuid()

hook uuid.

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
70
71
72
def uuid(self):
    """hook uuid."""
    return self.get_data("uuid")

webhook_url()

webhook url.

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
74
75
76
def webhook_url(self):
    """webhook url."""
    return self.get_data("url")

Hooks

Bases: BitbucketCloudBase

Bitbucket Cloud webhooks.

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class Hooks(BitbucketCloudBase):
    """Bitbucket Cloud webhooks."""

    def __init__(self, url, *args, **kwargs):
        super(Hooks, self).__init__(url, *args, **kwargs)

    def __get_object(self, data):
        return Hook(data, **self._new_session_args)

    def create(
        self,
        url,
        description,
        events,
        active=True,
    ):
        """
        Creates a new webhook for the current repository

        param: url: string: Url that will receive event requests
        param: description: string: Details about the webhook
        param: events: [string] List of event types that requests will generate for
        param: active: boolean: Enables/Disables the webhook

        :return: Hook Object
        """

        data = {"url": url, "description": description, "active": active, "events": events}

        return self.__get_object(self.post(None, data))

    def each(self):
        """
        Return the list of webhooks in this repository.

        :return: A generator for the Webhook objects
        """
        for hook in self._get_paged(None):
            yield self.__get_object(hook)

    def get(self, id):
        """
        Return the hook with the requested hook uuid in this repository.

        :param id: string: The id of the webhook

        :return: The requested hook object
        """
        return self.__get_object(
            super(Hooks, self).get(
                self.url_joiner(self.get_link("hooks"), id),
                absolute=True,
            )
        )

create(url, description, events, active=True)

Creates a new webhook for the current repository

param: url: string: Url that will receive event requests param: description: string: Details about the webhook param: events: [string] List of event types that requests will generate for param: active: boolean: Enables/Disables the webhook

:return: Hook Object

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def create(
    self,
    url,
    description,
    events,
    active=True,
):
    """
    Creates a new webhook for the current repository

    param: url: string: Url that will receive event requests
    param: description: string: Details about the webhook
    param: events: [string] List of event types that requests will generate for
    param: active: boolean: Enables/Disables the webhook

    :return: Hook Object
    """

    data = {"url": url, "description": description, "active": active, "events": events}

    return self.__get_object(self.post(None, data))

each()

Return the list of webhooks in this repository.

:return: A generator for the Webhook objects

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
37
38
39
40
41
42
43
44
def each(self):
    """
    Return the list of webhooks in this repository.

    :return: A generator for the Webhook objects
    """
    for hook in self._get_paged(None):
        yield self.__get_object(hook)

get(id)

Return the hook with the requested hook uuid in this repository.

:param id: string: The id of the webhook

:return: The requested hook object

Source code in server/vendor/atlassian/bitbucket/cloud/repositories/hooks.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def get(self, id):
    """
    Return the hook with the requested hook uuid in this repository.

    :param id: string: The id of the webhook

    :return: The requested hook object
    """
    return self.__get_object(
        super(Hooks, self).get(
            self.url_joiner(self.get_link("hooks"), id),
            absolute=True,
        )
    )