# PEDMコレクションコマンド

### 概要

ここでは、PEDMコレクションを管理するKeeperコマンダーのコマンドを扱います。コレクションは、ポリシーフィルターで利用できるユーザー、マシン、アプリケーション、その他のエンティティなどのリソースをまとめます。これらのコマンドで、コレクションの作成・表示・更新・削除や、コレクションと他のPEDMエンティティとのリンク管理が行えます。

このセクションで扱うコマンドは以下のとおりです。

* [**コレクション一覧コマンド**](#collection-list-command)
* [**コレクション参照コマンド**](#collection-view-command)
* [**コレクション追加コマンド**](#collection-add-command)
* [**コレクション更新コマンド**](#collection-update-command)
* [**コレクション削除コマンド**](#collection-delete-command)
* [**コレクション接続コマンド**](#collection-connect-command)
* [**コレクション切断コマンド**](#collection-disconnect-command)
* [**コレクション一括削除コマンド**](#collection-wipe-out-command)

### 使い方

`pedm collection command [--options]` または `pedm c command [--options]`

**エイリアス:** `c`

***

### コレクション一覧コマンド <a href="#collection-list-command" id="collection-list-command"></a>

すべてのPEDMコレクションを、タイプまたは検索パターンによる任意の絞り込みとともに表示します。コレクションは、OSビルド、アプリケーション、ユーザーアカウント、グループアカウント、カスタムコレクションなど、さまざまなリソースタイプを表せます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection list`

**エイリアス:** `pedm c l`, `pedm c list`

**フラグ:**

| フラグ             | 説明                         |
| --------------- | -------------------------- |
| `-v, --verbose` | コレクションの詳細情報を表示する           |
| `--type`        | コレクションタイプで絞り込む (整数)        |
| `--pattern`     | コレクション名の検索パターン             |
| `--format`      | 出力形式 - json、csv、tableのいずれか |
| `--output`      | 指定ファイルに保存する                |

**例:**

```
My Vault> pedm collection list --type 101

Collection UID: coll_abc123
Value: Name=Windows Servers
Link Count: 5
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin

plugin = admin_plugin.PedmPlugin(enterprise_loader)
plugin.collections.get_all_entities()
```

</details>

### コレクション参照コマンド <a href="#collection-view-command" id="collection-view-command"></a>

特定のコレクションについて、タイプ、値、エージェント・ポリシー・他のコレクションへの関連リンクを含む詳細を表示します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection view <collection> [collection...]`

**エイリアス:** `pedm c v`, `pedm c view`

**フラグ:**

| フラグ             | 説明                         |
| --------------- | -------------------------- |
| `-v, --verbose` | 詳細情報を表示する                  |
| `--link`        | 特定のリンクUIDの詳細を表示する。繰り返し指定可  |
| `--format`      | 出力形式 - json、csv、tableのいずれか |
| `--output`      | 指定ファイルに保存する                |
| `collection`    | コレクションUID (必須、複数指定可)       |

**例:**

```
My Vault> pedm collection view coll_abc123

Collection UID: coll_abc123
Collection Type: MACHINE (101)
Collection Value: Name=Windows Servers
Link Count: 5
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin

plugin = admin_plugin.PedmPlugin(enterprise_loader)
plugin.collections.get_entity(uid)
```

</details>

### コレクション追加コマンド <a href="#collection-add-command" id="collection-add-command"></a>

リソースをまとめるカスタムコレクションを新規作成します。ポリシーフィルターで、特定のユーザー・マシン・アプリケーションの集合を対象にするために利用できます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection add <collection_name> [collection_name...]`

**エイリアス:** `pedm c a`, `pedm c add`

**フラグ:**

| フラグ          | 説明                 |
| ------------ | ------------------ |
| `--type`     | コレクションタイプ (必須、整数)  |
| `collection` | コレクション名 (必須、複数指定可) |

**例:**

```
My Vault> pedm collection add "Finance Users" "HR Users" --type 103

Collection created successfully
Collection UID: coll_new123
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin

plugin = admin_plugin.PedmPlugin(enterprise_loader)

collection: Any = ['Collection names']
collection_type = int #'Collection type'

if isinstance(collection, str):
    collection = [collection]

collections: Dict[str, admin_types.CollectionData] = {}
for c in collection:
    collection_uid = utils.generate_uid()
    collection_data = {
        'Name': c,
        'IsCustom': True
    }
    collections[collection_uid] = admin_types.CollectionData(
        collection_uid=collection_uid, collection_type=collection_type,
        collection_data=json.dumps(collection_data))

status = plugin.modify_collections(add_collections=collections.values())
```

</details>

### コレクション更新コマンド <a href="#collection-update-command" id="collection-update-command"></a>

既存コレクションの名前を変更します。コレクションを作り直したりリンクに影響を与えたりせずに、管理者がコレクション名を更新できます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection update <collection>`

**エイリアス:** `pedm c u`, `pedm c update`

**フラグ:**

| フラグ          | 説明                    |
| ------------ | --------------------- |
| `--name`     | 新しいコレクション名 (必須)       |
| `--type`     | コレクションタイプ (任意、曖昧さ解消用) |
| `collection` | コレクションUIDまたは名前 (必須)   |

**例:**

```
My Vault> pedm collection update coll_abc123 --name "Updated Server Group"

Collection updated successfully
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin

plugin = admin_plugin.PedmPlugin(enterprise_loader)

new_name = 'rename collection'
collection_id = 'collection name or uid'
collection = plugin.collections.get_entity(collection_id)
collection_info = collection.collection_data
collection_info['Name'] = new_name
collection_data = admin_types.CollectionData(
    collection_uid=collection.collection_uid, collection_type=collection.collection_type,
    collection_data=json.dumps(collection_info))

status = plugin.modify_collections(update_collections=[collection_data])
```

</details>

### コレクション削除コマンド <a href="#collection-delete-command" id="collection-delete-command"></a>

システムから1つ以上のコレクションを削除します。特定のコレクションの削除に加え、@orphan\_resourceのような特殊値で孤立リソースコレクションを整理することにも対応します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection delete <collection> [collection...]`

**エイリアス:** `pedm c delete`

**フラグ:**

| フラグ           | 説明                                              |
| ------------- | ----------------------------------------------- |
| `-f, --force` | 確認プロンプトを出さずに実行する                                |
| `collection`  | コレクションUIDまたは名前、または @orphan\_resource (必須、複数指定可) |

**例:**

```
My Vault> pedm collection delete coll_old123 --force

Collection deleted successfully
```

```
My Vault> pedm collection delete @orphan_resource

Do you want to remove 3 collection(s)? (y/N): y
Collections deleted successfully
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin

plugin = admin_plugin.PedmPlugin(enterprise_loader)

collection_id = 'collection name or uid'
collection = plugin.collections.get_entity(collection_id)

uids = [collection.uid]
status = plugin.modify_collections(remove_collections=uids)
```

</details>

### コレクション接続コマンド <a href="#collection-connect-command" id="collection-connect-command"></a>

エンティティ (エージェント、ポリシー、他のコレクション)をコレクションにリンクします。ポリシーフィルターと整理のため、コレクションとPEDMエンティティとの関連付けを行います。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection connect <links> [links...]`

**エイリアス:** `pedm c connect`

**フラグ:**

| フラグ                | 説明                                       |
| ------------------ | ---------------------------------------- |
| `-c, --collection` | 親コレクションのUIDまたは名前 (必須)                    |
| `--link-type`      | リンクの種類 - agent、policy、またはcollection (必須) |
| `links`            | リンクUIDまたは名前 (必須、複数指定可)                   |

**例:**

```
My Vault> pedm collection connect agent_abc123 agent_def456 --collection coll_servers --link-type agent

Links created successfully
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types
from keepersdk.proto import pedm_pb2

plugin = admin_plugin.PedmPlugin(enterprise_loader)

collection_id = 'collection name or uid'
collection = plugin.collections.get_entity(collection_id)


link_types = ['agent', 'policy', 'collection']
link_type = link_types[0]
link_name = 'link name or uid'

links: List[str] = []
collection_link_type: int
if link_type == 'collection':
    coll_links = plugin.collections.get_entity(link_name)
    links.extend((x.collection_uid for x in coll_links))
    collection_link_type = pedm_pb2.CLT_COLLECTION
elif link_type == 'agent':
    agent = plugin.agents.get_entity(link_name)
    links.append(agent.agent_uid)
    collection_link_type = pedm_pb2.CLT_AGENT
elif link_type == 'policy':
    pol_links = plugin.policies.get_entity(link_name)
    links.extend((x.policy_uid for x in pol_links))
    collection_link_type = pedm_pb2.CLT_POLICY

to_add = [admin_types.CollectionLink(
    collection_uid=collection.collection_uid, link_uid=x, link_type=collection_link_type) for x in links]

status = plugin.set_collection_links(set_links=to_add)
```

</details>

### コレクション切断コマンド <a href="#collection-disconnect-command" id="collection-disconnect-command"></a>

コレクションと関連エンティティの間のリンクを削除します。親コレクションからエージェント・ポリシー・コレクションの紐づけを外しますが、エンティティそのものは削除しません。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection disconnect <links> [links...]`

**エイリアス:** `pedm c disconnect`

**フラグ:**

| フラグ                | 説明                    |
| ------------------ | --------------------- |
| `-c, --collection` | 親コレクションのUIDまたは名前 (必須) |
| `-f, --force`      | 確認プロンプトを出さずに実行する      |
| `links`            | リンクを外すUID (必須、複数指定可)  |

**例:**

```
My Vault> pedm collection disconnect agent_abc123 --collection coll_servers --force

Links removed successfully
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types

plugin = admin_plugin.PedmPlugin(enterprise_loader)

collection_id = 'collection name or uid'
collection = plugin.collections.get_entity(collection_id)

existing_links= list(x for x in plugin.storage.collection_links.get_links_by_subject(collection.collection_uid))
links: Any = ['UIDs to unlink']
to_unlink: Set[str] = set(links)

to_remove: List[admin_types.CollectionLink] = []
for link in existing_links:
    link_uid = link.link_uid
    if link_uid in to_unlink:
        to_remove.append(admin_types.CollectionLink(
            collection_uid=collection.collection_uid,
            link_uid=link_uid,
            link_type=link.link_type)
        )

status = plugin.set_collection_links(unset_links=to_remove)
```

</details>

### コレクション一括削除コマンド <a href="#collection-wipe-out-command" id="collection-wipe-out-command"></a>

指定したタイプのコレクションをすべてシステムから削除します。一括整理に役立ちますが、複数のコレクションを恒久削除するため注意して使用してください。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm collection wipe-out`

**エイリアス:** `pedm c wipe-out`

**フラグ:**

| フラグ      | 説明                     |
| -------- | ---------------------- |
| `--type` | ワイプアウトするコレクションタイプ (整数) |

**例:**

```
My Vault> pedm collection wipe-out --type 102

All collections of type 102 deleted
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin, admin_types

plugin = admin_plugin.PedmPlugin(enterprise_loader)

collection_type = 10 #collection type upto 100
if isinstance(collection_type, int):
    collection_type = [collection_type]
collections: List[str] = []
for coll in plugin.storage.collections.get_all_entities():
    if collection_type and coll.collection_type not in collection_type:
        continue
    collections.append(coll.collection_uid)

plugin.modify_collections(remove_collections=collections)
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/commander-sdk/keeper-commander-sdks/sdk-command-reference/pedm-commands/pedm-collection-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
