module Gitlab::Client::Snippets

def create_snippet(project, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about created snippet.

Options Hash: (**options)
  • :visibility (String) -- The visibility of a snippet
  • :lifetime (String) -- The expiration date of a snippet.
  • :code (String) -- The content of a snippet.
  • :file_name (String) -- The name of a snippet file.
  • :title (String) -- The title of a snippet.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or name of a project.
def create_snippet(project, options = {})
  post("/projects/#{url_encode project}/snippets", body: options)
end

def delete_snippet(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about deleted snippet.

Parameters:
  • id (Integer) -- The ID of a snippet.
  • project (Integer, String) -- The ID or name of a project.
def delete_snippet(project, id)
  delete("/projects/#{url_encode project}/snippets/#{id}")
end

def edit_snippet(project, id, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about updated snippet.

Options Hash: (**options)
  • :visibility (String) -- The visibility of a snippet
  • :lifetime (String) -- The expiration date of a snippet.
  • :code (String) -- The content of a snippet.
  • :file_name (String) -- The name of a snippet file.
  • :title (String) -- The title of a snippet.

Parameters:
  • options (Hash) -- A customizable set of options.
  • id (Integer) -- The ID of a snippet.
  • project (Integer, String) -- The ID or name of a project.
def edit_snippet(project, id, options = {})
  put("/projects/#{url_encode project}/snippets/#{id}", body: options)
end

def snippet(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • id (Integer) -- The ID of a snippet.
  • project (Integer, String) -- The ID or name of a project.
def snippet(project, id)
  get("/projects/#{url_encode project}/snippets/#{id}")
end

def snippet_content(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about deleted snippet.

Parameters:
  • id (Integer) -- The ID of a snippet.
  • project (Integer, String) -- The ID or name of a project.
def snippet_content(project, id)
  get("/projects/#{url_encode project}/snippets/#{id}/raw",
      format: nil,
      headers: { Accept: 'text/plain' },
      parser: ::Gitlab::Request::Parser)
end

def snippets(project, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or name of a project.
def snippets(project, options = {})
  get("/projects/#{url_encode project}/snippets", query: options)
end