> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/ja/sdks/ontology-resources.md).

# オントロジーリソース

Unitlab Python SDK でワークスペースのオントロジーを一覧表示・取得・作成・更新する方法。タイトルや日付による絞り込み、主なフィールド、必要な API キーの権限を解説します。

ワークスペースのオントロジーは再利用できます。オントロジーを指定してプロジェクトを作成すると、プロジェクトは独自のコピーを持つため、後でワークスペースのオントロジーを編集しても既存のプロジェクトは変わりません。

```python
ontology = client.ontologies.create(
    "Robot cell QA",
    description="Grippers and parts on the inspection line",
    structure=structure,
)

for item in client.ontologies.list(title_like="Robot"):
    print(item.id, item.title, item.last_edited_at)

ontology = client.ontologies.get("ONTOLOGY_ID")
ontology.description = "Adds the Fixture class"
ontology.structure.add_object("Fixture", Shape.BOUNDING_BOX)
ontology.save()
```

`create()` はオントロジーをすぐに利用可能にします。公開手順はありません。`save()` は `title`、`description`、`structure` を書き込み、新しいリビジョンを記録します。

## 一覧のフィルター <a href="#list-filters" id="list-filters"></a>

| フィルター                             | 一致条件                     |
| --------------------------------- | ------------------------ |
| `title_eq`, `title_like`          | タイトルの完全一致または部分一致         |
| `desc_eq`, `desc_like`            | 説明の完全一致または部分一致           |
| `created_before`, `created_after` | ISO 8601 形式の日付またはタイムスタンプ |
| `edited_before`, `edited_after`   | ISO 8601 形式の日付またはタイムスタンプ |

アーカイブされたオントロジーは一覧に表示されません。

## フィールド <a href="#fields" id="fields"></a>

| フィールド                               | 意味                                                      |
| ----------------------------------- | ------------------------------------------------------- |
| `id`                                | オントロジー ID。`projects.create()` に `ontology_hash` として渡します |
| `title`, `description`, `structure` | 内容                                                      |
| `data_type`                         | 互換性ファミリー。デフォルトは `image`                                 |
| `created_at`, `last_edited_at`      | 日時                                                      |
| `project_id`                        | オントロジーがプロジェクトに属する場合に設定されます                              |

読み取りには **View ontology**、作成と保存には **Manage ontologies** の権限がキーに必要です。

## 関連情報 <a href="#related" id="related"></a>

[Python でオントロジーを構築する](https://docs.unitlab.ai/api-sdk-cli/ja/sdks/build-ontologies-in-python.md) · [CLI：オントロジーとクラウドストレージ](https://docs.unitlab.ai/api-sdk-cli/ja/clis/cli-ontologies-and-cloud-storage.md)
