Module: Gitlab::Client::SystemHooks

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/system_hooks.rb

Overview

Defines methods related to system hooks.

Instance Method Summary collapse

Instance Method Details

#add_hook(url, options = {}) ⇒ Gitlab::ObjectifiedHash Also known as: add_system_hook

Adds a new system hook.

Examples:

Gitlab.add_hook('http://example.com/hook')
Gitlab.add_system_hook('https://api.example.net/v1/hook')

Parameters:

  • url (String)

    The hook URL.

  • options (Hash) (defaults to: {})

    Additional options, as allowed by Gitlab API, including but not limited to:

Options Hash (options):

  • :token (String)

    A secret token for Gitlab to send in the ‘X-Gitlab-Token` header for authentication.

  • :enable_ssl_verification (boolean)

    ‘false` will cause Gitlab to ignore invalid/unsigned certificate errors (default is `true`)

Returns:



31
32
33
# File 'lib/gitlab/client/system_hooks.rb', line 31

def add_hook(url, options = {})
  post("/hooks", body: options.merge(url: url))
end

#delete_hook(id) ⇒ Gitlab::ObjectifiedHash Also known as: delete_system_hook

Deletes a new system hook.

Examples:

Gitlab.delete_hook(3)
Gitlab.delete_system_hook(12)

Parameters:

  • id (Integer)

    The ID of a system hook.

Returns:



57
58
59
# File 'lib/gitlab/client/system_hooks.rb', line 57

def delete_hook(id)
  delete("/hooks/#{id}")
end

#hook(id) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: system_hook

Tests a system hook.

Examples:

Gitlab.hook(3)
Gitlab.system_hook(12)

Parameters:

  • id (Integer)

    The ID of a system hook.

Returns:



44
45
46
# File 'lib/gitlab/client/system_hooks.rb', line 44

def hook(id)
  get("/hooks/#{id}")
end

#hooks(options = {}) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: system_hooks

Gets a list of system hooks.

Examples:

Gitlab.hooks
Gitlab.system_hooks

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



15
16
17
# File 'lib/gitlab/client/system_hooks.rb', line 15

def hooks(options={})
  get("/hooks", query: options)
end