diff options
Diffstat (limited to 'doc/api/packages')
-rw-r--r-- | doc/api/packages/composer.md | 287 | ||||
-rw-r--r-- | doc/api/packages/conan.md | 614 | ||||
-rw-r--r-- | doc/api/packages/go_proxy.md | 133 | ||||
-rw-r--r-- | doc/api/packages/maven.md | 124 | ||||
-rw-r--r-- | doc/api/packages/nuget.md | 338 | ||||
-rw-r--r-- | doc/api/packages/pypi.md | 113 | ||||
-rw-r--r-- | doc/api/packages/rubygems.md | 149 |
7 files changed, 1758 insertions, 0 deletions
diff --git a/doc/api/packages/composer.md b/doc/api/packages/composer.md new file mode 100644 index 00000000000..ebf3ffba92f --- /dev/null +++ b/doc/api/packages/composer.md @@ -0,0 +1,287 @@ +--- +stage: Package +group: Package +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 +--- + +# Composer API + +This is the API documentation for [Composer Packages](../../user/packages/composer_repository/index.md). + +WARNING: +This API is used by the [Composer package manager client](https://getcomposer.org/) +and is generally not meant for manual consumption. + +For instructions on how to upload and install Composer packages from the GitLab +package registry, see the [Composer package registry documentation](../../user/packages/composer_repository/index.md). + +NOTE: +These endpoints do not adhere to the standard API authentication methods. +See the [Composer package registry documentation](../../user/packages/composer_repository/index.md) +for details on which headers and token types are supported. + +## Base repository request + +Returns the repository URL templates for requesting individual packages: + +```plaintext +GET group/:id/-/packages/composer/packages +``` + +| Attribute | Type | Required | Description | +| --------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the group. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/group/1/-/packages/composer/packages" +``` + +Example response: + +```json +{ + "packages": [], + "metadata-url": "/api/v4/group/1/-/packages/composer/p2/%package%.json", + "provider-includes": { + "p/%hash%.json": { + "sha256": "082df4a5035f8725a12i4a3d2da5e6aaa966d06843d0a5c6d499313810427bd6" + } + }, + "providers-url": "/api/v4/group/1/-/packages/composer/%package%$%hash%.json" +} +``` + +This endpoint is used by Composer V1 and V2. To see the V2-specific response, include the Composer +`User-Agent` header. Using Composer V2 is recommended over V1. + +```shell +curl --user <username>:<personal_access_token> \ + --header "User-Agent: Composer/2" \ + "https://gitlab.example.com/api/v4/group/1/-/packages/composer/packages" +``` + +Example response: + +```json +{ + "packages": [], + "metadata-url": "/api/v4/group/1/-/packages/composer/p2/%package%.json" +} +``` + +## V1 packages list + +Given the V1 provider sha, returns a list of packages within the repository. Using Composer V2 is +recommended over V1. + +```plaintext +GET group/:id/-/packages/composer/p/:sha +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | string | yes | The ID or full path of the group. | +| `sha` | string | yes | The provider sha, provided by the Composer [base request](#base-repository-request). | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/group/1/-/packages/composer/p/082df4a5035f8725a12i4a3d2da5e6aaa966d06843d0a5c6d499313810427bd6" +``` + +Example response: + +```json +{ + "providers": { + "my-org/my-composer-package": { + "sha256": "5c873497cdaa82eda35af5de24b789be92dfb6510baf117c42f03899c166b6e7" + } + } +} +``` + +## V1 Package Metadata + +Returns the list of versions and metadata for a given package. Using Composer V2 is recommended over +V1. + +```plaintext +GET group/:id/-/packages/composer/:package_name$:sha +``` + +Note the `$` symbol in the URL. When making requests, you may need to use the URL-encoded version of +the symbol `%24` (see example below). + +| Attribute | Type | Required | Description | +| -------------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the group. | +| `package_name` | string | yes | The name of the package. | +| `sha` | string | yes | The sha digest of the package, provided by the [V1 packages list](#v1-packages-list). | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/group/1/-/packages/composer/my-org/my-composer-package%245c873497cdaa82eda35af5de24b789be92dfb6510baf117c42f03899c166b6e7" +``` + +Example response: + +```json +{ + "packages": { + "my-org/my-composer-package": { + "1.0.0": { + "name": "my-org/my-composer-package", + "type": "library", + "license": "GPL-3.0-only", + "version": "1.0.0", + "dist": { + "type": "zip", + "url": "https://gitlab.example.com/api/v4/projects/1/packages/composer/archives/my-org/my-composer-package.zip?sha=673594f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "reference": "673594f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "shasum": "" + }, + "source": { + "type": "git", + "url": "https://gitlab.example.com/my-org/my-composer-package.git", + "reference": "673594f85a55fe3c0eb45df7bd2fa9d95a1601ab" + }, + "uid": 1234567 + }, + "2.0.0": { + "name": "my-org/my-composer-package", + "type": "library", + "license": "GPL-3.0-only", + "version": "2.0.0", + "dist": { + "type": "zip", + "url": "https://gitlab.example.com/api/v4/projects/1/packages/composer/archives/my-org/my-composer-package.zip?sha=445394f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "reference": "445394f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "shasum": "" + }, + "source": { + "type": "git", + "url": "https://gitlab.example.com/my-org/my-composer-package.git", + "reference": "445394f85a55fe3c0eb45df7bd2fa9d95a1601ab" + }, + "uid": 1234567 + } + } + } +} +``` + +## V2 Package Metadata + +Returns the list of versions and metadata for a given package: + +```plaintext +GET group/:id/-/packages/composer/p2/:package_name +``` + +| Attribute | Type | Required | Description | +| -------------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the group. | +| `package_name` | string | yes | The name of the package. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/group/1/-/packages/composer/p2/my-org/my-composer-package" +``` + +Example response: + +```json +{ + "packages": { + "my-org/my-composer-package": { + "1.0.0": { + "name": "my-org/my-composer-package", + "type": "library", + "license": "GPL-3.0-only", + "version": "1.0.0", + "dist": { + "type": "zip", + "url": "https://gitlab.example.com/api/v4/projects/1/packages/composer/archives/my-org/my-composer-package.zip?sha=673594f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "reference": "673594f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "shasum": "" + }, + "source": { + "type": "git", + "url": "https://gitlab.example.com/my-org/my-composer-package.git", + "reference": "673594f85a55fe3c0eb45df7bd2fa9d95a1601ab" + }, + "uid": 1234567 + }, + "2.0.0": { + "name": "my-org/my-composer-package", + "type": "library", + "license": "GPL-3.0-only", + "version": "2.0.0", + "dist": { + "type": "zip", + "url": "https://gitlab.example.com/api/v4/projects/1/packages/composer/archives/my-org/my-composer-package.zip?sha=445394f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "reference": "445394f85a55fe3c0eb45df7bd2fa9d95a1601ab", + "shasum": "" + }, + "source": { + "type": "git", + "url": "https://gitlab.example.com/my-org/my-composer-package.git", + "reference": "445394f85a55fe3c0eb45df7bd2fa9d95a1601ab" + }, + "uid": 1234567 + } + } + } +} +``` + +## Create a package + +Create a Composer package from a Git tag or branch: + +```plaintext +POST projects/:id/packages/composer +``` + +| Attribute | Type | Required | Description | +| --------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the group. | +| `tag` | string | no | The name of the tag to target for the package. | +| `branch` | string | no | The name of the branch to target for the package. | + +```shell +curl --request POST --user <username>:<personal_access_token> --data tag=v1.0.0 "https://gitlab.example.com/api/v4/projects/1/packages/composer" +``` + +Example response: + +```json +{ + "message": "201 Created" +} +``` + +## Download a package archive + +Download a Composer package. This URL is provided in the [v1](#v1-package-metadata) +or [v2 package metadata](#v2-package-metadata) +response. A `.zip` file extension must be in the request. + +```plaintext +GET projects/:id/packages/composer/archives/:package_name +``` + +| Attribute | Type | Required | Description | +| -------------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the group. | +| `package_name` | string | yes | The name of the package. | +| `sha` | string | yes | The target sha of the requested package version. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/composer/archives/my-org/my-composer-package.zip?sha=673594f85a55fe3c0eb45df7bd2fa9d95a1601ab" +``` + +Write the output to file: + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/composer/archives/my-org/my-composer-package.zip?sha=673594f85a55fe3c0eb45df7bd2fa9d95a1601ab" >> package.tar.gz +``` + +This writes the downloaded file to `package.tar.gz` in the current directory. diff --git a/doc/api/packages/conan.md b/doc/api/packages/conan.md new file mode 100644 index 00000000000..88ed2524173 --- /dev/null +++ b/doc/api/packages/conan.md @@ -0,0 +1,614 @@ +--- +stage: Package +group: Package +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 +--- + +# Conan API + +This is the API documentation for [Conan Packages](../../user/packages/conan_repository/index.md). + +WARNING: +This API is used by the [Conan package manager client](https://docs.conan.io/en/latest/) +and is generally not meant for manual consumption. + +For instructions on how to upload and install Conan packages from the GitLab +package registry, see the [Conan package registry documentation](../../user/packages/conan_repository/index.md). + +NOTE: +These endpoints do not adhere to the standard API authentication methods. +See each route for details on how credentials are expected to be passed. + +## Route prefix + +There are two sets of identical routes that each make requests in different scopes: + +- Use the instance-level prefix to make requests in the entire GitLab instance's scope. +- Use the project-level prefix to make requests in a single project's scope. + +The examples in this document all use the instance-level prefix. + +### Instance-level + +```plaintext +/packages/conan/v1 +``` + +When using the instance-level routes, be aware that there is a [naming +restriction](../../user/packages/conan_repository/index.md#package-recipe-naming-convention-for-instance-remotes) +for Conan recipes. + +### Project-level + +```plaintext + /projects/:id/packages/conan/v1` +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | string | yes | The project ID or full project path. | + +## Ping + +> Introduced in GitLab 12.2. + +Ping the GitLab Conan repository to verify availability: + +```plaintext +GET <route-prefix>/ping +``` + +```shell +curl "https://gitlab.example.com/api/v4/packages/conan/v1/ping" +``` + +Example response: + +```json +"" +``` + +## Search + +> Introduced in GitLab 12.4. + +Search the instance for Conan packages by name: + +```plaintext +GET <route-prefix>/conans/search +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `q` | string | yes | Search query. You can use `*` as a wildcard. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/packages/conan/v1/conans/search?q=Hello*" +``` + +Example response: + +```json +{ + "results": [ + "Hello/0.1@foo+conan_test_prod/beta", + "Hello/0.1@foo+conan_test_prod/stable", + "Hello/0.2@foo+conan_test_prod/beta", + "Hello/0.3@foo+conan_test_prod/beta", + "Hello/0.1@foo+conan-reference-test/stable", + "HelloWorld/0.1@baz+conan-reference-test/beta" + "hello-world/0.4@buz+conan-test/alpha" + ] +} +``` + +## Authenticate + +> Introduced in GitLab 12.2. + +Returns a JWT to be used for Conan requests in a Bearer header: + +```shell +"Authorization: Bearer <token> +``` + +The Conan package manager client automatically uses this token. + +```plaintext +GET <route-prefix>/users/authenticate +``` + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/packages/conan/v1/users/authenticate +``` + +Example response: + +```shell +eyJhbGciOiJIUzI1NiIiheR5cCI6IkpXVCJ9.eyJhY2Nlc3NfdG9rZW4iOjMyMTQyMzAsqaVzZXJfaWQiOjQwNTkyNTQsImp0aSI6IjdlNzBiZTNjLWFlNWQtNDEyOC1hMmIyLWZiOThhZWM0MWM2OSIsImlhd3r1MTYxNjYyMzQzNSwibmJmIjoxNjE2NjIzNDMwLCJleHAiOjE2MTY2MjcwMzV9.QF0Q3ZIB2GW5zNKyMSIe0HIFOITjEsZEioR-27Rtu7E +``` + +## Check Credentials + +> Introduced in GitLab 12.4. + +Checks the validity of Basic Auth credentials or a Conan JWT generated from [`/authenticate`](#authenticate). + +```plaintext +GET <route-prefix>/users/check_credentials +``` + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/users/check_credentials +``` + +Example response: + +```shell +ok +``` + +## Recipe Snapshot + +> Introduced in GitLab 12.5. + +This returns the snapshot of the recipe files for the specified Conan recipe. The snapshot is a list +of filenames with their associated md5 hash. + +```plaintext +GET <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable" +``` + +Example response: + +```json +{ + "conan_sources.tgz": "eadf19b33f4c3c7e113faabf26e76277", + "conanfile.py": "25e55b96a28f81a14ba8e8a8c99eeace", + "conanmanifest.txt": "5b6fd77a2ba14303ce4cdb08c87e82ab" +} +``` + +## Package Snapshot + +> Introduced in GitLab 12.5. + +This returns the snapshot of the package files for the specified Conan recipe with the specified +Conan reference. The snapshot is a list of filenames with their associated md5 hash. + +```plaintext +GET <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel/packages/:conan_package_reference +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `conan_package_reference` | string | yes | Reference hash of a Conan package. Conan generates this value. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f" +``` + +Example response: + +```json +{ + "conan_package.tgz": "749b29bdf72587081ca03ec033ee59dc", + "conaninfo.txt": "32859d737fe84e6a7ccfa4d64dc0d1f2", + "conanmanifest.txt": "a86b398e813bd9aa111485a9054a2301" +} +``` + +## Recipe Manifest + +> Introduced in GitLab 12.5. + +The manifest is a list of recipe filenames with their associated download URLs. + +```plaintext +GET <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel/digest +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable/digest" +``` + +Example response: + +```json +{ + "conan_sources.tgz": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conan_sources.tgz", + "conanfile.py": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanfile.py", + "conanmanifest.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanmanifest.txt" +} +``` + +The URLs in the response have the same route prefix used to request them. If you request them with +the project-level route, the returned URLs contain `/projects/:id`. + +## Package Manifest + +> Introduced in GitLab 12.5. + +The manifest is a list of package filenames with their associated download URLs. + +```plaintext +GET <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel/packages/:conan_package_reference/digest +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `conan_package_reference` | string | yes | Reference hash of a Conan package. Conan generates this value. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/digest" +``` + +Example response: + +```json +{ + "conan_package.tgz": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conan_package.tgz", + "conaninfo.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conaninfo.txt", + "conanmanifest.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conanmanifest.txt" +} +``` + +The URLs in the response have the same route prefix used to request them. If you request them with +the project-level route, the returned URLs contain `/projects/:id`. + +## Recipe Download URLs + +> Introduced in GitLab 12.5. + +Returns a list of recipe filenames with their associated download URLs. +This is the same payload as the [recipe manifest](#recipe-manifest) endpoint. + +```plaintext +GET <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel/download_urls +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable/digest" +``` + +Example response: + +```json +{ + "conan_sources.tgz": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conan_sources.tgz", + "conanfile.py": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanfile.py", + "conanmanifest.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanmanifest.txt" +} +``` + +The URLs in the response have the same route prefix used to request them. If you request them with +the project-level route, the returned URLs contain `/projects/:id`. + +## Package Download URLs + +> Introduced in GitLab 12.5. + +Returns a list of package filenames with their associated download URLs. +This is the same payload as the [package manifest](#package-manifest) endpoint. + +```plaintext +GET <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel/packages/:conan_package_reference/download_urls +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `conan_package_reference` | string | yes | Reference hash of a Conan package. Conan generates this value. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/download_urls" +``` + +Example response: + +```json +{ + "conan_package.tgz": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conan_package.tgz", + "conaninfo.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conaninfo.txt", + "conanmanifest.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conanmanifest.txt" +} +``` + +The URLs in the response have the same route prefix used to request them. If you request them with +the project-level route, the returned URLs contain `/projects/:id`. + +## Recipe Upload URLs + +> Introduced in GitLab 12.5. + +Given a list of recipe filenames and file sizes, a list of URLs to upload each file is returned. + +```plaintext +POST <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel/upload_urls +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | + +Example request JSON payload: + +```json +{ + "conanfile.py": 410, + "conanmanifest.txt": 130 +} +``` + +```shell +curl --request POST \ + --header "Authorization: Bearer <authenticate_token>" \ + --header "Content-Type: application/json" \ + --data '{"conanfile.py":410,"conanmanifest.txt":130}' \ + "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable/upload_urls" +``` + +Example response: + +```json +{ + "conanfile.py": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanfile.py", + "conanmanifest.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanmanifest.txt" +} +``` + +The URLs in the response have the same route prefix used to request them. If you request them with +the project-level route, the returned URLs contain `/projects/:id`. + +## Package Upload URLs + +> Introduced in GitLab 12.5. + +Given a list of package filenames and file sizes, a list of URLs to upload each file is returned. + +```plaintext +POST <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel/packages/:conan_package_reference/upload_urls +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `conan_package_reference` | string | yes | Reference hash of a Conan package. Conan generates this value. | + +Example request JSON payload: + +```json +{ + "conan_package.tgz": 5412, + "conanmanifest.txt": 130, + "conaninfo.txt": 210 + } +``` + +```shell +curl --request POST \ + --header "Authorization: Bearer <authenticate_token>" \ + --header "Content-Type: application/json" \ + --data '{"conan_package.tgz":5412,"conanmanifest.txt":130,"conaninfo.txt":210}' + "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/upload_urls" +``` + +Example response: + +```json +{ + "conan_package.tgz": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/package/103f6067a947f366ef91fc1b7da351c588d1827f/0/conan_package.tgz", + "conanmanifest.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/package/103f6067a947f366ef91fc1b7da351c588d1827f/0/conanmanifest.txt", + "conaninfo.txt": "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/package/103f6067a947f366ef91fc1b7da351c588d1827f/0/conaninfo.txt" +} +``` + +The URLs in the response have the same route prefix used to request them. If you request them with +the project-level route, the returned URLs contain `/projects/:id`. + +## Download a Recipe file + +> Introduced in GitLab 12.6. + +Download a recipe file to the package registry. You must use a download URL that the +[recipe download URLs endpoint](#recipe-download-urls) +returned. + +```shell +GET packages/conan/v1/files/:package_name/:package_version/:package_username/:package_channel/:recipe_revision/export/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `recipe_revision` | string | yes | Revision of the recipe. GitLab does not yet support Conan revisions, so the default value of `0` is always used. | +| `file_name` | string | yes | The name and file extension of the requested file. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanfile.py" +``` + +You can also write the output to a file by using: + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanfile.py" >> conanfile.py +``` + +This example writes to `conanfile.py` in the current directory. + +## Upload a Recipe file + +> Introduced in GitLab 12.6. + +Upload a recipe file to the package registry. You must use an upload URL that the +[recipe upload URLs endpoint](#recipe-upload-urls) +returned. + +```shell +GET packages/conan/v1/files/:package_name/:package_version/:package_username/:package_channel/:recipe_revision/export/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `recipe_revision` | string | yes | Revision of the recipe. GitLab does not yet support Conan revisions, so the default value of `0` is always used. | +| `file_name` | string | yes | The name and file extension of the requested file. | + +Provide the file context in the request body: + +```shell +curl --header "Authorization: Bearer <authenticate_token>" \ + --upload-file path/to/conanfile.py \ + "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/0/export/conanfile.py" +``` + +## Download a Package file + +> Introduced in GitLab 12.6. + +Download a package file to the package registry. You must use a download URL that the +[package download URLs endpoint](#package-download-urls) +returned. + +```shell +GET packages/conan/v1/files/:package_name/:package_version/:package_username/:package_channel/:recipe_revision/package/:conan_package_reference/:package_revision/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `recipe_revision` | string | yes | Revision of the recipe. GitLab does not yet support Conan revisions, so the default value of `0` is always used. | +| `conan_package_reference` | string | yes | Reference hash of a Conan package. Conan generates this value. | +| `package_revision` | string | yes | Revision of the package. GitLab does not yet support Conan revisions, so the default value of `0` is always used. | +| `file_name` | string | yes | The name and file extension of the requested file. | + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conaninfo.txt" +``` + +You can also write the output to a file by using: + +```shell +curl --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conaninfo.txt" >> conaninfo.txt +``` + +This example writes to `conaninfo.txt` in the current directory. + +## Upload a Package file + +> Introduced in GitLab 12.6. + +Upload a package file to the package registry. You must use an upload URL that the +[package upload URLs endpoint](#package-upload-urls) +returned. + +```shell +GET packages/conan/v1/files/:package_name/:package_version/:package_username/:package_channel/:recipe_revision/package/:conan_package_reference/:package_revision/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | +| `recipe_revision` | string | yes | Revision of the recipe. GitLab does not yet support Conan revisions, so the default value of `0` is always used. | +| `conan_package_reference` | string | yes | Reference hash of a Conan package. Conan generates this value. | +| `package_revision` | string | yes | Revision of the package. GitLab does not yet support Conan revisions, so the default value of `0` is always used. | +| `file_name` | string | yes | The name and file extension of the requested file. | + +Provide the file context in the request body: + +```shell +curl --header "Authorization: Bearer <authenticate_token>" \ + --upload-file path/to/conaninfo.txt \ + "https://gitlab.example.com/api/v4/packages/conan/v1/files/my-package/1.0/my-group+my-project/stable/packages/103f6067a947f366ef91fc1b7da351c588d1827f/0/conaninfo.txt" +``` + +## Delete a Package (delete a Conan recipe) + +> Introduced in GitLab 12.5. + +Delete the Conan recipe and package files from the registry: + +```plaintext +DELETE <route-prefix>/conans/:package_name/:package_version/:package_username/:package_channel +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `package_name` | string | yes | Name of a package. | +| `package_version` | string | yes | Version of a package. | +| `package_username` | string | yes | Conan username of a package. This is the `+`-separated full path of your project. | +| `package_channel` | string | yes | Channel of a package. | + +```shell +curl --request DELETE --header "Authorization: Bearer <authenticate_token>" "https://gitlab.example.com/api/v4/packages/conan/v1/conans/my-package/1.0/my-group+my-project/stable" +``` + +Example response: + +```json +{ + "id": 1, + "project_id": 123, + "created_at": "2020-08-19T13:17:28.655Z", + "updated_at": "2020-08-19T13:17:28.655Z", + "name": "my-package", + "version": "1.0", + "package_type": "conan", + "creator_id": null, + "status": "default" +} +``` diff --git a/doc/api/packages/go_proxy.md b/doc/api/packages/go_proxy.md new file mode 100644 index 00000000000..2f81435db42 --- /dev/null +++ b/doc/api/packages/go_proxy.md @@ -0,0 +1,133 @@ +--- +stage: Package +group: Package +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 +--- + +# Go Proxy API + +This is the API documentation for [Go Packages](../../user/packages/go_proxy/index.md). +This API is behind a feature flag that is disabled by default. GitLab administrators with access to +the GitLab Rails console can [enable](../../administration/feature_flags.md) +this API for your GitLab instance. + +WARNING: +This API is used by the [Go client](https://maven.apache.org/) +and is generally not meant for manual consumption. + +For instructions on how to work with the Go Proxy, see the [Go Proxy package documentation](../../user/packages/go_proxy/index.md). + +NOTE: +These endpoints do not adhere to the standard API authentication methods. +See the [Go Proxy package documentation](../../user/packages/go_proxy/index.md) +for details on which headers and token types are supported. + +## List + +> Introduced in GitLab 13.1. + +Get all tagged versions for a given Go module: + +```plaintext +GET projects/:id/packages/go/:module_name/@v/list +``` + +| Attribute | Type | Required | Description | +| -------------- | ------ | -------- | ----------- | +| `id` | string | yes | The project ID or full path of a project. | +| `module_name` | string | yes | The name of the Go module. | + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/go/my-go-module/@v/list" +``` + +Example output: + +```shell +"v1.0.0\nv1.0.1\nv1.3.8\n2.0.0\n2.1.0\n3.0.0" +``` + +## Version metadata + +> Introduced in GitLab 13.1. + +Get all tagged versions for a given Go module: + +```plaintext +GET projects/:id/packages/go/:module_name/@v/:module_version.info +``` + +| Attribute | Type | Required | Description | +| ----------------- | ------ | -------- | ----------- | +| `id` | string | yes | The project ID or full path of a project. | +| `module_name` | string | yes | The name of the Go module. | +| `module_version` | string | yes | The version of the Go module. | + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/go/my-go-module/@v/1.0.0.info" +``` + +Example output: + +```json +{ + "Version": "v1.0.0", + "Time": "1617822312 -0600" +} +``` + +## Download module file + +> Introduced in GitLab 13.1. + +Fetch the `.mod` module file: + +```plaintext +GET projects/:id/packages/go/:module_name/@v/:module_version.mod +``` + +| Attribute | Type | Required | Description | +| ----------------- | ------ | -------- | ----------- | +| `id` | string | yes | The project ID or full path of a project. | +| `module_name` | string | yes | The name of the Go module. | +| `module_version` | string | yes | The version of the Go module. | + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/go/my-go-module/@v/1.0.0.mod" +``` + +Write to a file: + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/go/my-go-module/@v/1.0.0.mod" >> foo.mod +``` + +This writes to `foo.mod` in the current directory. + +## Download module source + +> Introduced in GitLab 13.1. + +Fetch the `.zip` of the module source: + +```plaintext +GET projects/:id/packages/go/:module_name/@v/:module_version.zip +``` + +| Attribute | Type | Required | Description | +| ----------------- | ------ | -------- | ----------- | +| `id` | string | yes | The project ID or full path of a project. | +| `module_name` | string | yes | The name of the Go module. | +| `module_version` | string | yes | The version of the Go module. | + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/go/my-go-module/@v/1.0.0.zip" +``` + +Write to a file: + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/go/my-go-module/@v/1.0.0.zip" >> foo.zip +``` + +This writes to `foo.zip` in the current directory. diff --git a/doc/api/packages/maven.md b/doc/api/packages/maven.md new file mode 100644 index 00000000000..d03c9be3060 --- /dev/null +++ b/doc/api/packages/maven.md @@ -0,0 +1,124 @@ +--- +stage: Package +group: Package +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 +--- + +# Maven API + +This is the API documentation for [Maven Packages](../../user/packages/maven_repository/index.md). + +WARNING: +This API is used by the [Maven package manager client](https://maven.apache.org/) +and is generally not meant for manual consumption. + +For instructions on how to upload and install Maven packages from the GitLab +package registry, see the [Maven package registry documentation](../../user/packages/maven_repository/index.md). + +NOTE: +These endpoints do not adhere to the standard API authentication methods. +See [Maven package registry documentation](../../user/packages/maven_repository/index.md) +for details on which headers and token types are supported. + +## Download a package file at the instance-level + +> Introduced in GitLab 11.6. + +Download a Maven package file: + +```plaintext +GET packages/maven/*path/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `path` | string | yes | The Maven package path, in the format `<groupId>/<artifactId>/<version>`. Replace any `.` in the `groupId` with `/`. | +| `file_name` | string | yes | The name of the Maven package file. | + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/packages/maven/foo/bar/baz/mypkg-1.0-SNAPSHOT.jar" +``` + +To write the output to file: + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/packages/maven/foo/bar/baz/mypkg-1.0-SNAPSHOT.jar" >> mypkg-1.0-SNAPSHOT.jar +``` + +This writes the downloaded file to `mypkg-1.0-SNAPSHOT.jar` in the current directory. + +## Download a package file at the group-level + +> Introduced in GitLab 11.7. + +Download a Maven package file: + +```plaintext +GET groups/:id/-/packages/maven/*path/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `path` | string | yes | The Maven package path, in the format `<groupId>/<artifactId>/<version>`. Replace any `.` in the `groupId` with `/`. | +| `file_name` | string | yes | The name of the Maven package file. | + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/groups/1/-/packages/maven/foo/bar/baz/mypkg-1.0-SNAPSHOT.jar" +``` + +To write the output to file: + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/groups/1/-/packages/maven/foo/bar/baz/mypkg-1.0-SNAPSHOT.jar" >> mypkg-1.0-SNAPSHOT.jar +``` + +This writes the downloaded file to `mypkg-1.0-SNAPSHOT.jar` in the current directory. + +## Download a package file at the project-level + +> Introduced in GitLab 11.3. + +Download a Maven package file: + +```plaintext +GET projects/:id/packages/maven/*path/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `path` | string | yes | The Maven package path, in the format `<groupId>/<artifactId>/<version>`. Replace any `.` in the `groupId` with `/`. | +| `file_name` | string | yes | The name of the Maven package file. | + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/baz/mypkg-1.0-SNAPSHOT.jar" +``` + +To write the output to file: + +```shell +curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/baz/mypkg-1.0-SNAPSHOT.jar" >> mypkg-1.0-SNAPSHOT.jar +``` + +This writes the downloaded file to `mypkg-1.0-SNAPSHOT.jar` in the current directory. + +## Upload a package file + +> Introduced in GitLab 11.3. + +Upload a Maven package file: + +```plaintext +PUT projects/:id/packages/maven/*path/:file_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `path` | string | yes | The Maven package path, in the format `<groupId>/<artifactId>/<version>`. Replace any `.` in the `groupId` with `/`. | +| `file_name` | string | yes | The name of the Maven package file. | + +```shell +curl --request PUT \ + --upload-file path/to/mypkg-1.0-SNAPSHOT.pom \ + --header "Private-Token: <personal_access_token>" \ + "https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/baz/mypkg-1.0-SNAPSHOT.pom" +``` diff --git a/doc/api/packages/nuget.md b/doc/api/packages/nuget.md new file mode 100644 index 00000000000..ed61704770b --- /dev/null +++ b/doc/api/packages/nuget.md @@ -0,0 +1,338 @@ +--- +stage: Package +group: Package +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about..example/handbook/engineering/ux/technical-writing/#assignments +--- + +# NuGet API + +This is the API documentation for [NuGet Packages](../../user/packages/nuget_repository/index.md). + +WARNING: +This API is used by the [NuGet package manager client](https://www.nuget.org/) +and is generally not meant for manual consumption. + +For instructions on how to upload and install NuGet packages from the GitLab +package registry, see the [NuGet package registry documentation](../../user/packages/nuget_repository/index.md). + +NOTE: +These endpoints do not adhere to the standard API authentication methods. +See the [NuGet package registry documentation](../../user/packages/nuget_repository/index.md) +for details on which headers and token types are supported. + +## Package index + +> Introduced in GitLab 12.8. + +Returns the index for a given package, which includes a list of available versions: + +```plaintext +GET projects/:id/packages/nuget/download/:package_name/index +``` + +| Attribute | Type | Required | Description | +| -------------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | +| `package_name` | string | yes | The name of the package. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download/MyNuGetPkg/index" +``` + +Example response: + +```json +{ + "versions": [ + "1.3.0.17" + ] +} +``` + +## Download a package file + +> Introduced in GitLab 12.8. + +Download a NuGet package file. The [metadata service](#metadata-service) provides this URL. + +```plaintext +GET projects/:id/packages/nuget/download/:package_name/:package_version/:package_filename +``` + +| Attribute | Type | Required | Description | +| ----------------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | +| `package_name` | string | yes | The name of the package. | +| `package_version` | string | yes | The version of the package. | +| `package_filename`| string | yes | The name of the file. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download/MyNuGetPkg/1.3.0.17/mynugetpkg.1.3.0.17.nupkg" +``` + +Write the output to a file: + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download/MyNuGetPkg/1.3.0.17/mynugetpkg.1.3.0.17.nupkg" >> MyNuGetPkg.1.3.0.17.nupkg +``` + +This writes the downloaded file to `MyNuGetPkg.1.3.0.17.nupkg` in the current directory. + +## Upload a package file + +> Introduced in GitLab 12.8. + +Download a NuGet package file: + +```plaintext +PUT projects/:id/packages/nuget +``` + +| Attribute | Type | Required | Description | +| ----------------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | +| `package_name` | string | yes | The name of the package. | +| `package_version` | string | yes | The version of the package. | +| `package_filename`| string | yes | The name of the file. | + +```shell +curl --request PUT \ + --upload-file path/to/mynugetpkg.1.3.0.17.nupkg \ + --user <username>:<personal_access_token> \ + "https://gitlab.example.com/api/v4/projects/1/packages/nuget" +``` + +## Route prefix + +For the remaining routes, there are two sets of identical routes that each make requests in +different scopes: + +- Use the group-level prefix to make requests in a group's scope. +- Use the project-level prefix to make requests in a single project's scope. + +The examples in this document all use the project-level prefix. + +### Group-level + +```plaintext + /groups/:id/-/packages/nuget` +``` + +| Attribute | Type | Required | Description | +| --------- | ------ | -------- | ----------- | +| `id` | string | yes | The group ID or full group path. | + +### Project-level + +```plaintext + /projects/:id/packages/nuget` +``` + +| Attribute | Type | Required | Description | +| --------- | ------ | -------- | ----------- | +| `id` | string | yes | The project ID or full project path. | + +## Service Index + +> Introduced in GitLab 12.6. + +Returns a list of available API resources: + +```plaintext +GET <route-prefix>/index +``` + +Example Request: + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/nuget/index" +``` + +Example response: + +```json +{ + "version": "3.0.0", + "resources": [ + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/query", + "@type": "SearchQueryService", + "comment": "Filter and search for packages by keyword." + }, + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/query", + "@type": "SearchQueryService/3.0.0-beta", + "comment": "Filter and search for packages by keyword." + }, + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/query", + "@type": "SearchQueryService/3.0.0-rc", + "comment": "Filter and search for packages by keyword." + }, + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata", + "@type": "RegistrationsBaseUrl", + "comment": "Get package metadata." + }, + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata", + "@type": "RegistrationsBaseUrl/3.0.0-beta", + "comment": "Get package metadata." + }, + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata", + "@type": "RegistrationsBaseUrl/3.0.0-rc", + "comment": "Get package metadata." + }, + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download", + "@type": "PackageBaseAddress/3.0.0", + "comment": "Get package content (.nupkg)." + }, + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget", + "@type": "PackagePublish/2.0.0", + "comment": "Push and delete (or unlist) packages." + } + ] +} +``` + +The URLs in the response have the same route prefix used to request them. If you request them with +the group-level route, the returned URLs contain `/groups/:id/-`. + +## Metadata Service + +> Introduced in GitLab 12.8. + +Returns metadata for a package: + +```plaintext +GET <route-prefix>/metadata/:package_name/index +``` + +| Attribute | Type | Required | Description | +| -------------- | ------ | -------- | ----------- | +| `package_name` | string | yes | The name of the package. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/index" +``` + +Example response: + +```json +{ + "count": 1, + "items": [ + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/1.3.0.17.json", + "lower": "1.3.0.17", + "upper": "1.3.0.17", + "count": 1, + "items": [ + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/1.3.0.17.json", + "packageContent": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download/MyNuGetPkg/1.3.0.17/helloworld.1.3.0.17.nupkg", + "catalogEntry": { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/1.3.0.17.json", + "authors": "", + "dependencyGroups": [], + "id": "MyNuGetPkg", + "version": "1.3.0.17", + "tags": "", + "packageContent": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download/MyNuGetPkg/1.3.0.17/helloworld.1.3.0.17.nupkg", + "summary": "" + } + } + ] + } + ] +} +``` + +## Version Metadata Service + +> Introduced in GitLab 12.8. + +Returns metadata for a specific package version: + +```plaintext +GET <route-prefix>/metadata/:package_name/index +``` + +| Attribute | Type | Required | Description | +| -------------- | ------ | -------- | ----------- | +| `package_name` | string | yes | The name of the package. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/1.3.0.17" +``` + +Example response: + +```json +{ + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/1.3.0.17.json", + "packageContent": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download/MyNuGetPkg/1.3.0.17/helloworld.1.3.0.17.nupkg", + "catalogEntry": { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/1.3.0.17.json", + "authors": "", + "dependencyGroups": [], + "id": "MyNuGetPkg", + "version": "1.3.0.17", + "tags": "", + "packageContent": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/download/MyNuGetPkg/1.3.0.17/helloworld.1.3.0.17.nupkg", + "summary": "" + } +} +``` + +## Search Service + +> Introduced in GitLab 12.8. + +Given a query, search for NuGet packages in the repository: + +```plaintext +GET <route-prefix>/query +``` + +| Attribute | Type | Required | Description | +| ------------ | ------- | -------- | ----------- | +| `q` | string | yes | The search query. | +| `skip` | integer | no | The number of results to skip. | +| `take` | integer | no | The number of results to return. | +| `prerelease` | boolean | no | Include prerelease versions. Defaults to `true` if no value is supplied. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/nuget/query?q=MyNuGet" +``` + +Example response: + +```json +{ + "totalHits": 1, + "data": [ + { + "@type": "Package", + "authors": "", + "id": "MyNuGetPkg", + "title": "MyNuGetPkg", + "summary": "", + "totalDownloads": 0, + "verified": true, + "version": "1.3.0.17", + "versions": [ + { + "@id": "https://gitlab.example.com/api/v4/projects/1/packages/nuget/metadata/MyNuGetPkg/1.3.0.17.json", + "version": "1.3.0.17", + "downloads": 0 + } + ], + "tags": "" + } + ] +} +``` diff --git a/doc/api/packages/pypi.md b/doc/api/packages/pypi.md new file mode 100644 index 00000000000..531193e59e2 --- /dev/null +++ b/doc/api/packages/pypi.md @@ -0,0 +1,113 @@ +--- +stage: Package +group: Package +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 +--- + +# PyPI API + +This is the API documentation for [PyPI Packages](../../user/packages/pypi_repository/index.md). + +WARNING: +This API is used by the [PyPI package manager client](https://pypi.apache.org/) +and is generally not meant for manual consumption. + +For instructions on how to upload and install PyPI packages from the GitLab +package registry, see the [PyPI package registry documentation](../../user/packages/pypi_repository/index.md). + +NOTE: +These endpoints do not adhere to the standard API authentication methods. +See the [PyPI package registry documentation](../../user/packages/pypi_repository/index.md) +for details on which headers and token types are supported. + +## Download a package file + +> Introduced in GitLab 12.10. + +Download a PyPI package file. The [simple API](#simple-api-entry-point) +normally supplies this URL. + +```plaintext +GET projects/:id/packages/pypi/files/:sha256/:file_identifier +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | +| `sha256` | string | yes | PyPI package file sha256 check sum. | +| `file_identifier` | string | yes | The PyPI package file name. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/pypi/files/5y57017232013c8ac80647f4ca153k3726f6cba62d055cd747844ed95b3c65ff/my.pypi.package-0.0.1.tar.gz" +``` + +To write the output to a file: + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/pypi/files/5y57017232013c8ac80647f4ca153k3726f6cba62d055cd747844ed95b3c65ff/my.pypi.package-0.0.1.tar.gz" >> my.pypi.package-0.0.1.tar.gz +``` + +This writes the downloaded file to `my.pypi.package-0.0.1.tar.gz` in the current directory. + +## Simple API entry point + +> Introduced in GitLab 12.10. + +Returns the package descriptor as an HTML file: + +```plaintext +GET projects/:id/packages/pypi/simple/:package_name +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | +| `package_name` | string | yes | The name of the package. | + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/pypi/simple/my.pypi.package" +``` + +Example response: + +```html +<!DOCTYPE html> +<html> + <head> + <title>Links for my.pypi.package</title> + </head> + <body> + <h1>Links for my.pypi.package</h1> + <a href="https://gitlab.example.com/api/v4/projects/1/packages/pypi/files/5y57017232013c8ac80647f4ca153k3726f6cba62d055cd747844ed95b3c65ff/my.pypi.package-0.0.1-py3-none-any.whl#sha256=5y57017232013c8ac80647f4ca153k3726f6cba62d055cd747844ed95b3c65ff" data-requires-python=">=3.6">my.pypi.package-0.0.1-py3-none-any.whl</a><br><a href="https://gitlab.example.com/api/v4/projects/1/packages/pypi/files/9s9w01b0bcd52b709ec052084e33a5517ffca96f7728ddd9f8866a30cdf76f2/my.pypi.package-0.0.1.tar.gz#sha256=9s9w011b0bcd52b709ec052084e33a5517ffca96f7728ddd9f8866a30cdf76f2" data-requires-python=">=3.6">my.pypi.package-0.0.1.tar.gz</a><br> + </body> +</html> +``` + +To write the output to a file: + +```shell +curl --user <username>:<personal_access_token> "https://gitlab.example.com/api/v4/projects/1/packages/pypi/simple/my.pypi.package" >> simple.html +``` + +This writes the downloaded file to `simple.html` in the current directory. + +## Upload a package + +> Introduced in GitLab 11.3. + +Upload a PyPI package: + +```plaintext +PUT projects/:id/packages/pypi +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | + +```shell +curl --request PUT \ + --upload-file path/to/my.pypi.package-0.0.1.tar.gz \ + --user <username>:<personal_access_token> \ + "https://gitlab.example.com/api/v4/projects/1/packages/pypi" +``` diff --git a/doc/api/packages/rubygems.md b/doc/api/packages/rubygems.md new file mode 100644 index 00000000000..426548d5ed2 --- /dev/null +++ b/doc/api/packages/rubygems.md @@ -0,0 +1,149 @@ +--- +stage: Package +group: Package +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 +--- + +# Ruby gems API + +This is the API documentation for [Ruby gems](../../user/packages/rubygems_registry/index.md). + +WARNING: +This API is used by the [Ruby gems and Bundler package manager clients](https://maven.apache.org/) +and is generally not meant for manual consumption. This API is under development and is not ready +for production use due to limited functionality. + +For instructions on how to upload and install gems from the GitLab +package registry, see the [Ruby gems registry documentation](../../user/packages/rubygems_registry/index.md). + +NOTE: +These endpoints do not adhere to the standard API authentication methods. +See the [Ruby gems registry documentation](../../user/packages/rubygems_registry/index.md) +for details on which headers and token types are supported. + +## Enable the Ruby gems API + +The Ruby gems API for GitLab is behind a feature flag that is disabled by default. GitLab +administrators with access to the GitLab Rails console can enable this API for your instance. + +To enable it: + +```ruby +Feature.enable(:rubygem_packages) +``` + +To disable it: + +```ruby +Feature.disable(:rubygem_packages) +``` + +To enable or disable it for specific projects: + +```ruby +Feature.enable(:rubygem_packages, Project.find(1)) +Feature.disable(:rubygem_packages, Project.find(2)) +``` + +## Download a gem file + +> Introduced in GitLab 13.10. + +Download a gem: + +```plaintext +GET projects/:id/packages/rubygems/gems/:file_name +``` + +| Attribute | Type | Required | Description | +| ------------ | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | +| `file_name` | string | yes | The name of the `.gem` file. | + +```shell +curl --header "Authorization:<personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/rubygems/gems/my_gem-1.0.0.gem" +``` + +Write the output to file: + +```shell +curl --header "Authorization:<personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/rubygems/gems/my_gem-1.0.0.gem" >> my_gem-1.0.0.gem +``` + +This writes the downloaded file to `my_gem-1.0.0.gem` in the current directory. + +## Fetch a list of dependencies + +> Introduced in GitLab 13.10. + +Fetch a list of dependencies for a list of gems: + +```plaintext +GET projects/:id/packages/rubygems/api/v1/dependencies +``` + +| Attribute | Type | Required | Description | +| --------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | +| `gems` | string | no | Comma-separated list of gems to fetch dependencies for. | + +```shell +curl --header "Authorization:<personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/rubygems/api/v1/dependencies?gems=my_gem,foo" +``` + +This endpoint returns a marshalled array of hashes for all versions of the requested gems. Since the +response is marshalled, you can store it in a file. If Ruby is installed, you can use the following +Ruby command to read the response. For this to work, you must +[set your credentials in `~/.gem/credentials`](../../user/packages/rubygems_registry/index.md#authenticate-with-a-personal-access-token-or-deploy-token): + +```shell +$ ruby -ropen-uri -rpp -e \ + 'pp Marshal.load(open("https://gitlab.example.com/api/v4/projects/1/packages/rubygems/api/v1/dependencies?gems=my_gem,rails,foo"))' + +[{:name=>"my_gem", :number=>"0.0.1", :platform=>"ruby", :dependencies=>[]}, + {:name=>"my_gem", + :number=>"0.0.3", + :platform=>"ruby", + :dependencies=> + [["dependency_1", "~> 1.2.3"], + ["dependency_2", "= 3.0.0"], + ["dependency_3", ">= 1.0.0"], + ["dependency_4", ">= 0"]]}, + {:name=>"my_gem", + :number=>"0.0.2", + :platform=>"ruby", + :dependencies=> + [["dependency_1", "~> 1.2.3"], + ["dependency_2", "= 3.0.0"], + ["dependency_3", ">= 1.0.0"], + ["dependency_4", ">= 0"]]}, + {:name=>"foo", + :number=>"0.0.2", + :platform=>"ruby", + :dependencies=> + ["dependency_2", "= 3.0.0"], + ["dependency_4", ">= 0"]]}] +``` + +This writes the downloaded file to `mypkg-1.0-SNAPSHOT.jar` in the current directory. + +## Upload a gem + +> Introduced in GitLab 13.11. + +Upload a gem: + +```plaintext +POST projects/:id/packages/rubygems/api/v1/gems +``` + +| Attribute | Type | Required | Description | +| --------- | ------ | -------- | ----------- | +| `id` | string | yes | The ID or full path of the project. | + +```shell +curl --request POST \ + --upload-file path/to/my_gem_file.gem \ + --header "Authorization:<personal_access_token>" \ + "https://gitlab.example.com/api/v4/projects/1/packages/rubygems/api/v1/gems" +``` |