gitlab-org--gitlab-foss/doc/api/managed_licenses.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

147 lines
4.6 KiB
Markdown
Raw Normal View History

---
stage: Fulfillment
group: Utilization
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
# Managed Licenses API **(ULTIMATE)**
2019-05-18 21:27:41 +00:00
WARNING:
"approval" and "blacklisted" approval statuses are changed to "allowed" and "denied" in GitLab 15.0.
2019-05-18 21:27:41 +00:00
## List managed licenses
Get all managed licenses for a given project.
```plaintext
2019-05-18 21:27:41 +00:00
GET /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) |
2019-05-18 21:27:41 +00:00
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
2019-05-18 21:27:41 +00:00
```
Example response:
```json
[
{
"id": 1,
"name": "MIT",
"approval_status": "allowed"
2019-05-18 21:27:41 +00:00
},
{
"id": 3,
"name": "ISC",
"approval_status": "denied"
2019-05-18 21:27:41 +00:00
}
]
```
## Show an existing managed license
Shows an existing managed license.
```plaintext
2019-05-18 21:27:41 +00:00
GET /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-05-18 21:27:41 +00:00
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
```shell
2019-05-18 21:27:41 +00:00
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",
"approval_status": "denied"
2019-05-18 21:27:41 +00:00
}
```
## Create a new managed license
Creates a new managed license for the given project with the given name and approval status.
```plaintext
2019-05-18 21:27:41 +00:00
POST /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-05-18 21:27:41 +00:00
| `name` | string | yes | The name of the managed license |
| `approval_status` | string | yes | The approval status of the license. "allowed" or "denied". |
2019-05-18 21:27:41 +00:00
```shell
curl --data "name=MIT&approval_status=denied" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
2019-05-18 21:27:41 +00:00
```
Example response:
```json
{
"id": 1,
"name": "MIT",
"approval_status": "allowed"
2019-05-18 21:27:41 +00:00
}
```
## Delete a managed license
Deletes a managed license with a given ID.
2019-05-18 21:27:41 +00:00
```plaintext
2019-05-18 21:27:41 +00:00
DELETE /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-05-18 21:27:41 +00:00
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
```shell
2019-05-18 21:27:41 +00:00
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/4"
```
When successful, it replies with an HTTP 204 response.
2019-05-18 21:27:41 +00:00
## Edit an existing managed license
Updates an existing managed license with a new approval status.
```plaintext
2019-05-18 21:27:41 +00:00
PATCH /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2019-05-18 21:27:41 +00:00
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
| `approval_status` | string | yes | The approval status of the license. "allowed" or "denied". |
2019-05-18 21:27:41 +00:00
```shell
curl --request PATCH --data "approval_status=denied" \
--header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
2019-05-18 21:27:41 +00:00
```
Example response:
```json
{
"id": 1,
"name": "MIT",
"approval_status": "denied"
2019-05-18 21:27:41 +00:00
}
```