InfoGrab Docs

프로젝트 스니펫

요약

이 API를 사용하여 프로젝트 스니펫을 관리합니다. 지정된 프로젝트의 모든 스니펫을 나열합니다. 성공하면 200 OK와 다음 응답 속성을 반환합니다: 지정된 프로젝트 스니펫을 조회합니다. 프로젝트 스니펫을 생성합니다. 성공하면 201 Created와 다음 응답 속성을 반환합니다:

이 API를 사용하여 프로젝트 스니펫을 관리합니다. 관련 API로는 개인 스니펫스토리지 간 스니펫 이동이 있습니다.

프로젝트의 모든 스니펫 목록#

지정된 프로젝트의 모든 스니펫을 나열합니다.

GET /projects/:id/snippets

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets"

응답 예시:

[
  {
    "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"
    },
    "updated_at": "2012-06-28T10:52:04Z",
    "created_at": "2012-06-28T10:52:04Z",
    "imported": false,
    "imported_from": "none",
    "project_id": 1,
    "web_url": "http://example.com/example/example/snippets/1",
    "raw_url": "http://example.com/example/example/snippets/1/raw"
  },
  {
    "id": 3,
    "title": "Configuration helper",
    "file_name": "config.yml",
    "description": "YAML configuration snippet",
    "author": {
      "id": 2,
      "username": "jane_doe",
      "email": "jane@example.com",
      "name": "Jane Doe",
      "state": "active",
      "created_at": "2013-02-15T10:30:20Z"
    },
    "updated_at": "2013-03-10T14:15:30Z",
    "created_at": "2013-03-01T09:45:12Z",
    "imported": false,
    "imported_from": "none",
    "project_id": 1,
    "web_url": "http://example.com/example/example/snippets/3",
    "raw_url": "http://example.com/example/example/snippets/3/raw"
  }
]

스니펫 조회#

지정된 프로젝트 스니펫을 조회합니다.

GET /projects/:id/snippets/:snippet_id

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2"

응답 예시:

{
  "id": 2,
  "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"
  },
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "imported": false,
  "imported_from": "none",
  "project_id": 1,
  "web_url": "http://example.com/example/example/snippets/2",
  "raw_url": "http://example.com/example/example/snippets/2/raw"
}

스니펫 생성#

프로젝트 스니펫을 생성합니다. 사용자는 스니펫을 생성할 권한이 있어야 합니다.

POST /projects/:id/snippets

지원되는 속성:

속성 유형 필수 설명
files array of hashes 스니펫 파일의 배열.
files:content string 스니펫 파일의 내용.
files:file_path string 스니펫 파일의 파일 경로.
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
title string 스니펫 제목.
content string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 내용.
description string 아니요 스니펫 설명.
file_name string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 파일 이름.
visibility string 아니요 스니펫의 가시성 수준. 가능한 값: public, private, internal. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 201 Created와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: application/json" \
  --data '{"title": "Example Snippet Title", "description": "More verbose snippet description", "visibility": "private", "files": [{"file_path": "example.txt", "content": "source code \n with multiple lines\n"}]}' \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets"

응답 예시:

{
  "id": 1,
  "title": "Example Snippet Title",
  "file_name": "example.txt",
  "description": "More verbose snippet description",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "imported": false,
  "imported_from": "none",
  "project_id": 1,
  "web_url": "http://example.com/example/example/snippets/1",
  "raw_url": "http://example.com/example/example/snippets/1/raw"
}

스니펫 업데이트#

지정된 프로젝트 스니펫을 업데이트합니다. 사용자는 기존 스니펫을 변경할 권한이 있어야 합니다.

여러 파일이 있는 스니펫에 대한 업데이트는 files 속성을 사용해야 합니다.

PUT /projects/:id/snippets/:snippet_id

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.
files:action string 조건부 파일에 수행할 작업의 유형. 가능한 값: create, update, delete, move. files 속성을 사용할 때 필요.
content string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 내용.
description string 아니요 스니펫 설명.
file_name string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 파일 이름.
files array of hashes 아니요 스니펫 파일의 배열.
files:content string 아니요 스니펫 파일의 내용.
files:file_path string 아니요 스니펫 파일의 파일 경로.
files:previous_path string 아니요 스니펫 파일의 이전 경로.
title string 아니요 스니펫 제목.
visibility string 아니요 스니펫의 가시성 수준. 가능한 값: public, private, internal. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: application/json" \
  --data '{"title": "Updated Snippet Title", "description": "More verbose snippet description", "visibility": "private", "files": [{"action": "update", "file_path": "example.txt", "content": "updated source code \n with multiple lines\n"}]}' \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2"

응답 예시:

{
  "id": 2,
  "title": "Updated Snippet Title",
  "file_name": "example.txt",
  "description": "More verbose snippet description",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "imported": false,
  "imported_from": "none",
  "project_id": 1,
  "web_url": "http://example.com/example/example/snippets/2",
  "raw_url": "http://example.com/example/example/snippets/2/raw"
}

스니펫 삭제#

지정된 프로젝트 스니펫을 삭제합니다. 작업이 성공하면 204 No Content 상태 코드를 반환하고 리소스를 찾을 수 없으면 404를 반환합니다.

DELETE /projects/:id/snippets/:snippet_id

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.

요청 예시:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2"

스니펫 내용 조회#

프로젝트 스니펫을 일반 텍스트로 조회합니다.

GET /projects/:id/snippets/:snippet_id/raw

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2/raw"

스니펫 리포지터리 파일 내용 조회#

일반 텍스트로 원시 파일 내용을 조회합니다.

GET /projects/:id/snippets/:snippet_id/files/:ref/:file_path/raw

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
file_path string 파일의 URL 인코딩된 경로, 예를 들어 snippet%2Erb.
ref string 브랜치, 태그 또는 커밋의 이름, 예를 들어 main.
snippet_id integer 프로젝트 스니펫의 ID.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2/files/master/snippet%2Erb/raw"

사용자 에이전트 세부 정보 조회#

지정된 스니펫에 대한 사용자 에이전트 세부 정보를 조회합니다. 관리자 접근 권한이 있는 사용자만 사용할 수 있습니다.

GET /projects/:id/snippets/:snippet_id/user_agent_detail

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 스니펫 ID.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
akismet_submitted boolean true인 경우 스팸 감지를 위해 Akismet에 스니펫이 제출됨.
ip_address string 스니펫을 생성한 사용자의 IP 주소.
user_agent string 스니펫을 생성하는 데 사용된 브라우저의 사용자 에이전트 문자열.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2/user_agent_detail"

응답 예시:

{
  "user_agent": "AppleWebKit/537.36",
  "ip_address": "127.0.0.1",
  "akismet_submitted": false
}

프로젝트 스니펫

Tier: Free, Premium, Ultimate
Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
원문 보기
요약

이 API를 사용하여 프로젝트 스니펫을 관리합니다. 지정된 프로젝트의 모든 스니펫을 나열합니다. 성공하면 200 OK와 다음 응답 속성을 반환합니다: 지정된 프로젝트 스니펫을 조회합니다. 프로젝트 스니펫을 생성합니다. 성공하면 201 Created와 다음 응답 속성을 반환합니다:

이 API를 사용하여 프로젝트 스니펫을 관리합니다. 관련 API로는 개인 스니펫스토리지 간 스니펫 이동이 있습니다.

프로젝트의 모든 스니펫 목록#

지정된 프로젝트의 모든 스니펫을 나열합니다.

GET /projects/:id/snippets

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets"

응답 예시:

[
  {
    "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"
    },
    "updated_at": "2012-06-28T10:52:04Z",
    "created_at": "2012-06-28T10:52:04Z",
    "imported": false,
    "imported_from": "none",
    "project_id": 1,
    "web_url": "http://example.com/example/example/snippets/1",
    "raw_url": "http://example.com/example/example/snippets/1/raw"
  },
  {
    "id": 3,
    "title": "Configuration helper",
    "file_name": "config.yml",
    "description": "YAML configuration snippet",
    "author": {
      "id": 2,
      "username": "jane_doe",
      "email": "jane@example.com",
      "name": "Jane Doe",
      "state": "active",
      "created_at": "2013-02-15T10:30:20Z"
    },
    "updated_at": "2013-03-10T14:15:30Z",
    "created_at": "2013-03-01T09:45:12Z",
    "imported": false,
    "imported_from": "none",
    "project_id": 1,
    "web_url": "http://example.com/example/example/snippets/3",
    "raw_url": "http://example.com/example/example/snippets/3/raw"
  }
]

스니펫 조회#

지정된 프로젝트 스니펫을 조회합니다.

GET /projects/:id/snippets/:snippet_id

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2"

응답 예시:

{
  "id": 2,
  "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"
  },
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "imported": false,
  "imported_from": "none",
  "project_id": 1,
  "web_url": "http://example.com/example/example/snippets/2",
  "raw_url": "http://example.com/example/example/snippets/2/raw"
}

스니펫 생성#

프로젝트 스니펫을 생성합니다. 사용자는 스니펫을 생성할 권한이 있어야 합니다.

POST /projects/:id/snippets

지원되는 속성:

속성 유형 필수 설명
files array of hashes 스니펫 파일의 배열.
files:content string 스니펫 파일의 내용.
files:file_path string 스니펫 파일의 파일 경로.
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
title string 스니펫 제목.
content string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 내용.
description string 아니요 스니펫 설명.
file_name string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 파일 이름.
visibility string 아니요 스니펫의 가시성 수준. 가능한 값: public, private, internal. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 201 Created와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: application/json" \
  --data '{"title": "Example Snippet Title", "description": "More verbose snippet description", "visibility": "private", "files": [{"file_path": "example.txt", "content": "source code \n with multiple lines\n"}]}' \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets"

응답 예시:

{
  "id": 1,
  "title": "Example Snippet Title",
  "file_name": "example.txt",
  "description": "More verbose snippet description",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "imported": false,
  "imported_from": "none",
  "project_id": 1,
  "web_url": "http://example.com/example/example/snippets/1",
  "raw_url": "http://example.com/example/example/snippets/1/raw"
}

스니펫 업데이트#

지정된 프로젝트 스니펫을 업데이트합니다. 사용자는 기존 스니펫을 변경할 권한이 있어야 합니다.

여러 파일이 있는 스니펫에 대한 업데이트는 files 속성을 사용해야 합니다.

PUT /projects/:id/snippets/:snippet_id

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.
files:action string 조건부 파일에 수행할 작업의 유형. 가능한 값: create, update, delete, move. files 속성을 사용할 때 필요.
content string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 내용.
description string 아니요 스니펫 설명.
file_name string 아니요 폐기됨: 대신 files를 사용하세요. 스니펫 파일 이름.
files array of hashes 아니요 스니펫 파일의 배열.
files:content string 아니요 스니펫 파일의 내용.
files:file_path string 아니요 스니펫 파일의 파일 경로.
files:previous_path string 아니요 스니펫 파일의 이전 경로.
title string 아니요 스니펫 제목.
visibility string 아니요 스니펫의 가시성 수준. 가능한 값: public, private, internal. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
author.created_at string 작성자 계정이 생성된 날짜 및 시간.
author.email string 스니펫 작성자의 이메일 주소.
author.id integer 스니펫 작성자의 ID.
author.name string 스니펫 작성자의 표시 이름.
author.state string 작성자 계정의 상태.
author.username string 스니펫 작성자의 사용자 이름.
created_at string ISO 8601 형식으로 스니펫이 생성된 날짜 및 시간.
description string 스니펫 설명.
file_name string 스니펫 파일 이름.
id integer 스니펫 ID.
imported boolean true인 경우 스니펫이 가져온 것임.
imported_from string 스니펫을 가져온 경우 가져온 소스.
project_id integer 스니펫을 포함하는 프로젝트의 ID.
raw_url string 원시 스니펫 내용에 대한 직접 URL.
title string 스니펫 제목.
updated_at string ISO 8601 형식으로 스니펫이 마지막으로 업데이트된 날짜 및 시간.
web_url string GitLab 웹 인터페이스에서 스니펫을 볼 URL.

요청 예시:

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: application/json" \
  --data '{"title": "Updated Snippet Title", "description": "More verbose snippet description", "visibility": "private", "files": [{"action": "update", "file_path": "example.txt", "content": "updated source code \n with multiple lines\n"}]}' \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2"

응답 예시:

{
  "id": 2,
  "title": "Updated Snippet Title",
  "file_name": "example.txt",
  "description": "More verbose snippet description",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "imported": false,
  "imported_from": "none",
  "project_id": 1,
  "web_url": "http://example.com/example/example/snippets/2",
  "raw_url": "http://example.com/example/example/snippets/2/raw"
}

스니펫 삭제#

지정된 프로젝트 스니펫을 삭제합니다. 작업이 성공하면 204 No Content 상태 코드를 반환하고 리소스를 찾을 수 없으면 404를 반환합니다.

DELETE /projects/:id/snippets/:snippet_id

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.

요청 예시:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2"

스니펫 내용 조회#

프로젝트 스니펫을 일반 텍스트로 조회합니다.

GET /projects/:id/snippets/:snippet_id/raw

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 프로젝트 스니펫의 ID.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2/raw"

스니펫 리포지터리 파일 내용 조회#

일반 텍스트로 원시 파일 내용을 조회합니다.

GET /projects/:id/snippets/:snippet_id/files/:ref/:file_path/raw

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
file_path string 파일의 URL 인코딩된 경로, 예를 들어 snippet%2Erb.
ref string 브랜치, 태그 또는 커밋의 이름, 예를 들어 main.
snippet_id integer 프로젝트 스니펫의 ID.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2/files/master/snippet%2Erb/raw"

사용자 에이전트 세부 정보 조회#

지정된 스니펫에 대한 사용자 에이전트 세부 정보를 조회합니다. 관리자 접근 권한이 있는 사용자만 사용할 수 있습니다.

GET /projects/:id/snippets/:snippet_id/user_agent_detail

지원되는 속성:

속성 유형 필수 설명
id integer or string 프로젝트 ID 또는 URL 인코딩된 경로.
snippet_id integer 스니펫 ID.

성공하면 200 OK와 다음 응답 속성을 반환합니다:

속성 유형 설명
akismet_submitted boolean true인 경우 스팸 감지를 위해 Akismet에 스니펫이 제출됨.
ip_address string 스니펫을 생성한 사용자의 IP 주소.
user_agent string 스니펫을 생성하는 데 사용된 브라우저의 사용자 에이전트 문자열.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/snippets/2/user_agent_detail"

응답 예시:

{
  "user_agent": "AppleWebKit/537.36",
  "ip_address": "127.0.0.1",
  "akismet_submitted": false
}