名前空間API
ユーザー名とグループ名は名前空間と呼ばれる特別なカテゴリに属します。
以下のドキュメントも参照してください:
ページネーションが使用されています。
ネームスペースの一覧
認証済みユーザーの名前空間の一覧を取得します。ユーザーが管理者の場合、GitLabインスタンス内のすべてのネームスペースのリストが表示されます。
GET /namespaces
GET /namespaces?search=foobar
GET /namespaces?owned_only=true
| 属性 | 種類 | 必須 | 説明 | 
|---|---|---|---|
| search | 文字列です。 | いいえ | 検索条件に基づいて、ユーザーが閲覧する権限を持つネームスペースのリストを返します。 | 
| owned_only | boolean | いいえ | GitLab 14.2以降では、所有する名前空間のリストのみを返します。 | 
リクエストの例
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/namespaces"
応答例
[
  {
    "id": 1,
    "name": "user1",
    "path": "user1",
    "kind": "user",
    "full_path": "user1",
    "parent_id": null,
    "avatar_url": "https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
    "web_url": "https://gitlab.example.com/user1",
    "billable_members_count": 1,
    "plan": "default",
    "trial_ends_on": null,
    "trial": false,
    "root_repository_size": 100
  },
  {
    "id": 2,
    "name": "group1",
    "path": "group1",
    "kind": "group",
    "full_path": "group1",
    "parent_id": null,
    "avatar_url": null,
    "web_url": "https://gitlab.example.com/groups/group1",
    "members_count_with_descendants": 2,
    "billable_members_count": 2,
    "plan": "default",
    "trial_ends_on": null,
    "trial": false,
    "root_repository_size": 100
  },
  {
    "id": 3,
    "name": "bar",
    "path": "bar",
    "kind": "group",
    "full_path": "foo/bar",
    "parent_id": 9,
    "avatar_url": null,
    "web_url": "https://gitlab.example.com/groups/foo/bar",
    "members_count_with_descendants": 5,
    "billable_members_count": 5,
    "plan": "default",
    "trial_ends_on": null,
    "trial": false,
    "root_repository_size": 100
  }
]
オーナーは、ネームスペースに関連付けられたplan プロパティも参照します:
[
  {
    "id": 1,
    "name": "user1",
    "plan": "silver",
    ...
  }
]
GitLab.comのユーザーも、max_seats_used 、seats_in_use 、max_seats_used_changed_at パラメータを参照してください。max_seats_used は、グループのユーザー数の最高値です。seats_in_use は、現在使用中のライセンスシート数です。max_seats_used_changed_at は、max_seats_used の値が変更された日付を示します。すべての値は 1 日 1 回更新されます。
max_seats_used およびseats_in_use がゼロでないのは、有料プランのネームスペースのみです。
[
  {
    "id": 1,
    "name": "user1",
    "billable_members_count": 2,
    "max_seats_used": 3,
    "max_seats_used_changed_at":"2023-02-13T12:00:02.000Z",
    "seats_in_use": 2,
    ...
  }
]
members_count_with_descendants 、root_repository_size 、plan が表示されるのは、グループのオーナーだけです。ID によるネームスペースの取得
ID によってネームスペースを取得します。
GET /namespaces/:id
| 属性 | 種類 | 必須 | 説明 | 
|---|---|---|---|
| id | 整数/文字列 | yes | 名前空間のIDまたはURLエンコードされたパス | 
リクエストの例
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/namespaces/2"
応答例
{
  "id": 2,
  "name": "group1",
  "path": "group1",
  "kind": "group",
  "full_path": "group1",
  "parent_id": null,
  "avatar_url": null,
  "web_url": "https://gitlab.example.com/groups/group1",
  "members_count_with_descendants": 2,
  "billable_members_count": 2,
  "max_seats_used": 0,
  "seats_in_use": 0,
  "plan": "default",
  "trial_ends_on": null,
  "trial": false,
  "root_repository_size": 100
}
リクエストの例
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/namespaces/group1"
応答例
{
  "id": 2,
  "name": "group1",
  "path": "group1",
  "kind": "group",
  "full_path": "group1",
  "parent_id": null,
  "avatar_url": null,
  "web_url": "https://gitlab.example.com/groups/group1",
  "members_count_with_descendants": 2,
  "billable_members_count": 2,
  "max_seats_used": 0,
  "seats_in_use": 0,
  "plan": "default",
  "trial_ends_on": null,
  "trial": false,
  "root_repository_size": 100
}
名前空間の存在の取得
パスによってネームスペースの存在を取得します。まだ存在しない新しい名前空間のパスを提案します。
GET /namespaces/:namespace/exists
| 属性 | 種類 | 必須 | 説明 | 
|---|---|---|---|
| namespace | 文字列です。 | yes | 名前空間のパス。 | 
| parent_id | 整数。 | いいえ | 親ネームスペースの ID。ID が指定されていない場合は、トップ・レベルのネームスペースのみが考慮されます。 | 
リクエストの例
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/namespaces/my-group/exists?parent_id=1"
応答例
{
    "exists": true,
    "suggests": [
        "my-group1"
    ]
}
