Provide ability to retrieve `visibility` level via Snippets API

Description

The Snippets API provides a convenient way to manage snippets and integrate into third-party applications.

As the Snippets API currently stands, a user can create or update a snippet with a given visibility level (private | internal | public). However, there is no way to ascertain the current visibility level of the snippet via the API.

GET /snippets/:id
{
  "id": 1,
  "title": "test",
  "file_name": "add.rb",
  "description": "Ruby test snippet",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "web_url": "http://example.com/snippets/1",
}

Proposal

Return visibility level when retrieving snippet data via the API.

Eg. (note 5th line in JSON)

{
  "id": 1,
  "title": "test",
  "file_name": "add.rb",
  "description": "Ruby test snippet",
  "visibility": "internal",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "web_url": "http://example.com/snippets/1",
}

Links / references

https://docs.gitlab.com/ce/api/snippets.html

Use cases

By knowing the current snippet visibility level, a third-party integration can display current visibility and manage visibility level.

Edited Jul 16, 2017 by Mark
Assignee Loading
Time tracking Loading