debian-mirror-gitlab/doc/api/managed_licenses.md

147 lines
4.6 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
2022-07-23 23:45:48 +05:30
stage: Fulfillment
group: Utilization
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2019-09-30 21:07:59 +05:30
# Managed Licenses API **(ULTIMATE)**
2019-09-04 21:01:54 +05:30
2022-01-26 12:08:38 +05:30
WARNING:
2022-07-16 23:28:13 +05:30
"approval" and "blacklisted" approval statuses are changed to "allowed" and "denied" in GitLab 15.0.
2022-01-26 12:08:38 +05:30
2019-09-04 21:01:54 +05:30
## List managed licenses
Get all managed licenses for a given project.
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
GET /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
2019-09-04 21:01:54 +05:30
```
Example response:
```json
[
{
"id": 1,
"name": "MIT",
2022-07-16 23:28:13 +05:30
"approval_status": "allowed"
2019-09-04 21:01:54 +05:30
},
{
"id": 3,
"name": "ISC",
2022-07-16 23:28:13 +05:30
"approval_status": "denied"
2019-09-04 21:01:54 +05:30
}
]
```
## Show an existing managed license
Shows an existing managed license.
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
GET /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-09-04 21:01:54 +05:30
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2020-03-13 15:44:24 +05:30
```shell
2019-09-04 21:01:54 +05:30
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
```
Example response:
```json
{
"id": 1,
"name": "MIT",
2022-07-16 23:28:13 +05:30
"approval_status": "denied"
2019-09-04 21:01:54 +05:30
}
```
## Create a new managed license
Creates a new managed license for the given project with the given name and approval status.
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
POST /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-09-04 21:01:54 +05:30
| `name` | string | yes | The name of the managed license |
2022-07-16 23:28:13 +05:30
| `approval_status` | string | yes | The approval status of the license. "allowed" or "denied". |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2022-01-26 12:08:38 +05:30
curl --data "name=MIT&approval_status=denied" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
2019-09-04 21:01:54 +05:30
```
Example response:
```json
{
"id": 1,
"name": "MIT",
2022-07-16 23:28:13 +05:30
"approval_status": "allowed"
2019-09-04 21:01:54 +05:30
}
```
## Delete a managed license
2020-05-24 23:13:21 +05:30
Deletes a managed license with a given ID.
2019-09-04 21:01:54 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
DELETE /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-09-04 21:01:54 +05:30
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2020-03-13 15:44:24 +05:30
```shell
2019-09-04 21:01:54 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/4"
```
2019-09-30 21:07:59 +05:30
When successful, it replies with an HTTP 204 response.
2019-09-04 21:01:54 +05:30
## Edit an existing managed license
Updates an existing managed license with a new approval status.
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-04 21:01:54 +05:30
PATCH /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-09-04 21:01:54 +05:30
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2022-07-16 23:28:13 +05:30
| `approval_status` | string | yes | The approval status of the license. "allowed" or "denied". |
2019-09-04 21:01:54 +05:30
2020-03-13 15:44:24 +05:30
```shell
2022-01-26 12:08:38 +05:30
curl --request PATCH --data "approval_status=denied" \
2021-09-04 01:27:46 +05:30
--header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
2019-09-04 21:01:54 +05:30
```
Example response:
```json
{
"id": 1,
"name": "MIT",
2022-07-16 23:28:13 +05:30
"approval_status": "denied"
2019-09-04 21:01:54 +05:30
}
```