Module: Gitlab::Client::Wikis

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

Overview

Defines methods related to wikis.

Instance Method Summary collapse

Instance Method Details

#create_wiki(project, title, content, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new wiki page for the given repository with the given title, slug, and content.

Examples:

Gitlab.create_wiki(3, 'Some Title', 'Some Content')
Gitlab.create_wiki(3, 'Some Title', 'Some Content', { format: 'rdoc' })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • content (String)

    The content of the wiki page.

  • title (String)

    The title of the wiki page.

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

    A customizable set of options.

Options Hash (options):

  • format (String) — default: optional

    The format of the wiki page. Available formats are: markdown (default), rdoc, and asciidoc.

Returns:



45
46
47
48
# File 'lib/gitlab/client/wikis.rb', line 45

def create_wiki(project, title, content, options = {})
  body = { content: content, title: title }.merge(options)
  post("/projects/#{url_encode project}/wikis", body: body)
end

#delete_wiki(project, slug) ⇒ Gitlab::ObjectifiedHash

Deletes a wiki page with a given slug.

Examples:

Gitlab.delete_wiki(42, 'foo')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • slug (String)

    The slug (a unique string) of the wiki page.

Returns:



75
76
77
# File 'lib/gitlab/client/wikis.rb', line 75

def delete_wiki(project, slug)
  delete("/projects/#{url_encode project}/wikis/#{slug}")
end

#update_wiki(project, slug, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates an existing wiki page. At least one parameter is required to update the wiki page.

Examples:

Gitlab.update_wiki(6, 'home', { title: 'New title' })
Gitlab.update_wiki(6, 'home', { title: 'New title', content: 'New Message', format: 'rdoc' })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • slug (String)

    The slug (a unique string) of the wiki page.

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

    A customizable set of options.

Options Hash (options):

  • content (String)

    The content of the wiki page.

  • title (String)

    The title of the wiki page.

  • format (String) — default: optional

    The format of the wiki page. Available formats are: markdown (default), rdoc, and asciidoc.

Returns:



63
64
65
# File 'lib/gitlab/client/wikis.rb', line 63

def update_wiki(project, slug, options = {})
  put("/projects/#{url_encode project}/wikis/#{slug}", body: options)
end

#wiki(project, slug) ⇒ Gitlab::ObjectifiedHash

Get a wiki page for a given project.

Examples:

Gitlab.wiki(3, 'home')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • slug (String)

    The slug (a unique string) of the wiki page

Returns:



29
30
31
# File 'lib/gitlab/client/wikis.rb', line 29

def wiki(project, slug)
  get("/projects/#{url_encode project}/wikis/#{slug}")
end

#wikis(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get all wiki pages for a given project.

Examples:

Gitlab.wikis(3)
Gitlab.wikis(3, {with_content: 'Some wiki content'})

Parameters:

  • project (Integer, String)

    The ID or name of a project.

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

    A customizable set of options.

Options Hash (options):

  • with_content(optional) (String)

    Include pages content

Returns:



17
18
19
# File 'lib/gitlab/client/wikis.rb', line 17

def wikis(project, options = {})
  get("/projects/#{url_encode project}/wikis", query: options)
end