Skip to main content

A restful web service for querying the repository sizes of a GitLab registry.

Project description

GitLab-Registry-Usage-REST

Introduction

GitLab-Registry-Usage-REST is a package that periodically collects repository information (names, tags, sizes) of a GitLab registry server and offers the data via a secured RESTful HAL api. For the initial authentication a LDAP server is needed. Subsequent queries are secured by JSON Web Tokens (JWT).

Installation

The latest version can be obtained from PyPI:

pip install gitlab-registry-usage-rest
gitlab-registry-usage-rest --help

or from DockerHub:

docker run sciapp/gitlab-registry-usage-rest:latest --help

or from the AUR for Arch Linux based systems:

yay -S gitlab-registry-usage-rest

Usage

Gitlab-Registry-Usage-REST needs a configuration file in order to run. The default path is /etc/gitlab_registry_usage_rest.conf but can be altered with the -c command line switch. To get started, you can run

gitlab-registry-usage-rest --print-default-config

and edit this default configuration to fit your environment.

If you would like to use the docker repository, you can bind mount a local configuration file with the -v switch:

docker run -v "$(pwd)/gitlab_registry_usage_rest.conf:/etc/gitlab_registry_usage_rest.conf" sciapp/gitlab-registry-usage-rest:latest

Note: Docker expects an absolute path for the local configuration file.

The server offers these api endpoints:

  • /auth_token: Accepts a request with basic auth (and valid LDAP credentials) and returns an auth token for further api usage. All other endpoints only accept requests with a valid Bearer authorization header:

    Authorization: Bearer <token>
    
  • /repositories: Lists attributes of the repositories collection. Currently, only the timestamp of the last data refresh is contained:

    {
        "timestamp": 1521796487.7021387
    }
    
  • /repositories/<repository_name>: Queries attributes of a specific repository:

    {
        "name": "scientific-it-systems/administration/gitlab-registry-usage-rest",
        "size": 39899199,
        "disk_size": 39898911
    }
    
  • /repositories/<repository_name>/tags: Endpoint for the collection of repository tags, currently without any content.

  • /repositories/<repository_name>/tags/<tag_name>: Lists attributes of a tagged image stored in a repository:

    {
        "name": "latest",
        "size": 39899199,
        "disk_size": 39898911
    }
    

Additionally, all api endpoints (except /auth_token) offer an _embedded and a _links attribute if requested with the query string:

?embed=true&links=true

Instead of a boolean value, the embed key can also take an integer number to only request a specific level of embedded resources.

Links can be used to easily navigate between related resources. Embedded resources are convenient to query a complete hierarchy of resources with one GET request. Accordingly, the request

/repositories?embed=true

returns all resources at once.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlab-registry-usage-rest-0.2.6.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitlab_registry_usage_rest-0.2.6-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file gitlab-registry-usage-rest-0.2.6.tar.gz.

File metadata

  • Download URL: gitlab-registry-usage-rest-0.2.6.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for gitlab-registry-usage-rest-0.2.6.tar.gz
Algorithm Hash digest
SHA256 91d3b5375128a756d290a96699360c6ca3bdcc70cf88d8cf3caa3182ce7195e6
MD5 f074984e64b806e46513d800cc5fb3f9
BLAKE2b-256 66a8b3a2b86fb367a2a0ff82192aece12081561a175f2a016ae6e2c40413f979

See more details on using hashes here.

File details

Details for the file gitlab_registry_usage_rest-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: gitlab_registry_usage_rest-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for gitlab_registry_usage_rest-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8442444d10915722492738109dc7a21d29e1658e3611686e1b579cda019b265b
MD5 9a39d78aa7a2f2ed6aa20d249e235e1b
BLAKE2b-256 c4ccbd1f97c33740816103e0e3e0a06113987c610823c7b384df16524d06c745

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page