# ゴミ箱コマンド

### 概要

ゴミ箱内の削除済みレコードを一覧表示したり管理します。削除されたレコードはパージされるまでゴミ箱に残ります。

### コマンド

CLIおよびSDKでゴミ箱を管理するときに、次の機能が利用できます。

* [ゴミ箱の一覧コマンド](#trash-list-command)
* [ゴミ箱からの復元コマンド](#trash-restore-command)
* [ゴミ箱アイテムの参照コマンド](#trash-get-command)
* [ゴミ箱の共有解除コマンド](#trash-unshare-command)
* [ゴミ箱の完全削除コマンド](#trash-purge-command)

### ゴミ箱の一覧コマンド <a href="#trash-list-command" id="trash-list-command"></a>

このコマンドはボルトのゴミ箱にあるレコードとフォルダーを一覧表示します。ゴミ箱のレコードはメモリに読み込まれ、削除済み・孤立・共有フォルダーとして取得できます。

<details>

<summary>DotNet CLI</summary>

**コマンド**: `trash`

**例:**

```bash
My Vault> trash list
  #  Folder UID              Record UID              Name                             Record Type  Deleted At             Status
---  ----------------------  ----------------------  -------------------------------  -----------  ---------------------  ------
  1                          0thOtx4abVGBaNKcycX04Q  defws                            address                             Share 
  2  JSz1s5lZ_KUNwbCnvQZRPw                          testrtg                                       08/10/2025 5:07:04 AM  Folder
```

</details>

<details>

<summary>DotNet SDK</summary>

**メソッド:**

```csharp
var deletedRecords = TrashManagement.GetDeletedRecords();
var orphanedRecords = TrashManagement.GetOrphanedRecords();
var sharedFolders = TrashManagement.GetSharedFolders();
```

これらの関数を組み合わせると、ゴミ箱データをすべて取得できます。

</details>

<details>

<summary>Power Commander</summary>

**コマンド**: `Get-KeeperTrashList -Verbose`

**例**

```powershell
PS> Get-KeeperTrashList -Verbose                                      
VERBOSE: Starting trash list operation with pattern: ''

Folder UID             Record UID             Name                                                     Record Type   Deleted At            Status
----------             ----------             ----                                                     -----------   ----------            ------
                       0thOtx4abVGBaNKcycX04Q defws                                                    address                             Share
mdigPPSMrgKA_HIoz4q0ww B9hlKf_0Qitj_MX75JlZ-g test_share_folder_folder_record1234567898765432123456789 login         23/09/2025 7:13:21 AM Share
jWfCYHdhU0sx4-MKi6i6cQ                        tes_share_folder_folder_folder                           Shared Folder                       Folder
PDNS1vASSHMWOhdkBv9Vzg                        test_share_folder_folder@delete                          Shared Folder                       Folder
mdigPPSMrgKA_HIoz4q0ww                        test_share_folder_folder@delete                          Shared Folder                       Folder
JSz1s5lZ_KUNwbCnvQZRPw                        testrtg                                                  Shared Folder                       Folder
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `trash list`

**フラグ:**

`-v` `--verbose` 詳細なverbose出力を表示する

`--format` 出力形式 - Table、JSON または CSV

`--output` 出力先ファイルのパス ("table" 形式では無視)

`pattern` ゴミ箱一覧時の検索条件

**例:**

```sh
My Vault> trash list
  #  Folder UID              Record UID              Name                           Record Type          Deleted At           Status
---  ----------------------  ----------------------  -----------------------------  -------------------  -------------------  --------
  1                          record_uid                                                                  2025-05-23 17:46:00  Record
```

</details>

<details>

<summary>Python SDK</summary>

**関数:** `_ensure_deleted_records_loaded`

```python
trash_management.TrashManagement._ensure_deleted_records_loaded(vault)
deleted_records = TrashManagement.get_deleted_records()
orphaned_records = TrashManagement.get_orphaned_records()
deleted_shared_folders = TrashManagement.get_shared_folders()
```

</details>

### ゴミ箱からの復元コマンド <a href="#trash-restore-command" id="trash-restore-command"></a>

ボルトのゴミ箱にあるレコードを復元するために使います。

<details>

<summary>DotNet CLI</summary>

**コマンド**: `trash restore <recorduid>`

**例:**

```
My Vault> trash restore 0thOtx4abVGBaNKcycX04Q
Successfully initiated restoration of 1 record(s)
```

</details>

<details>

<summary>DotNet SDK</summary>

**コマンド**: `RestoreTrashRecords`

```csharp
public static async Task RestoreTrashRecords(VaultOnline vault, List<string> records)
```

```
await TrashManagement.RestoreTrashRecords(context.Vault, records);
```

</details>

<details>

<summary>Power Commander</summary>

**コマンド**: `Restore-KeeperTrashRecords`

**例:**

```powershell
PS> Restore-KeeperTrashRecords -Records 0thOtx4abVGBaNKcycX04Q      
Successfully initiated restoration of 1 record(s)
Use 'Get-KeeperTrashList' to verify the restoration
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `trash restore`

**パラメータ:**

`records` 復元するレコードUIDの一覧

**フラグ**:

`--force` 確認メッセージをスキップする

`-h, --help` ヘルプを表示して終了する

**例:**

```sh
My Vault> trash restore <record_uid>
Do you want to restore 1 record(s)? [y/n]: y
```

</details>

<details>

<summary>Python SDK</summary>

**関数:** `restore_trash_records`

```python
trash_management.restore_trash_records(vault, record_uids)
record_uids - list of uids
vault - vault instance
```

</details>

### ゴミ箱アイテムの参照コマンド <a href="#trash-get-command" id="trash-get-command"></a>

このコマンドはゴミ箱のレコードを取得し、その情報を表示するために使います。

<details>

<summary>DotNet CLI</summary>

**コマンド**: `trash get <recorduid>`

**例:**

```
My Vault> trash get 0thOtx4abVGBaNKcycX04Q
                Title: defws
                 Type: address
              address: fdvefcq ₹ewrwfwv₹, esvbwqe, ₹webvwe bevwewds, DZ
   Direct User Shares: user2@email.com (Read Only) 
```

</details>

<details>

<summary>DotNet SDK</summary>

**コマンド**: 対象外

</details>

<details>

<summary>Power Commander</summary>

**コマンド**: `Get-KeeperTrashedRecordDetails`

```powershell
PS> Get-KeeperTrashedRecordDetails

cmdlet Get-KeeperTrashedRecordDetails at command pipeline position 1
Supply values for the following parameters:
RecordUid: 0thOtx4abVGBaNKcycX04Q
                Title: defws
                 Type: address
              address: fdvefcq, ₹ewrwfwv₹, esvbwqe, ₹webvwe, bevwewds, DZ
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド**: `trash get`

**パラメータ**:

`record` レコードUID

**例:**

```sh
My Vault> trash get <record_uid>
                Title: test_record
                 Type: login
                login: username@keepersecurity.com
             password: password
                  url: keepersecurity.com
```

</details>

<details>

<summary>Python SDK</summary>

**関数:** `get_trash_record`

```python
trash_management.get_trash_record(vault, record_uid)
```

</details>

### ゴミ箱の共有解除コマンド <a href="#trash-unshare-command" id="trash-unshare-command"></a>

このコマンドは、ゴミ箱のレコードの共有を他のユーザーのボルトから外し、孤立状態を避けるために使います。ゴミ箱のレコードは共有先ユーザーのボルトにも存在し得ます。

<details>

<summary>DotNet CLI</summary>

**コマンド**: `trash unshare <recorduid>`

**例:**

```bash
My Vault> trash unshare B9hlKf_0Qitj_MX75JlZ-g
There are no records to unshare
```

</details>

<details>

<summary>DotNet SDK</summary>

**コマンド**: 対象外

</details>

<details>

<summary>Power Commander</summary>

**コマンド**: `Remove-TrashedKeeperRecordShares`

**例:**

```powershell
Remove-TrashedKeeperRecordShares -Records "NyTgDxKnMRhcgpR_BGkFkw"
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `trash unshare`

**パラメータ**:

`records` レコードUID

**フラグ:**

`--force` 確認プロンプトをスキップする

`-h, --help` ヘルプを表示して終了する

**例:**

```sh
My Vault> trash unshare <record_uid>
Do you want to remove shares from 1 record(s)? [y/n]: y
My Vault>
```

</details>

<details>

<summary>Python SDK</summary>

対象外

</details>

### ゴミ箱の完全削除コマンド <a href="#trash-purge-command" id="trash-purge-command"></a>

このコマンドはゴミ箱のすべてのレコードと共有フォルダーを消去する (完全に削除する) ために使います。

<details>

<summary>DotNet CLI</summary>

**コマンド**: `trash purge`

**例:**

```
My Vault> trash purge
Are you sure you want to permanently delete all records in trash? This action cannot be undone. (yes/No): s
Purge operation cancelled
```

</details>

<details>

<summary>DotNet SDK</summary>

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

</details>

<details>

<summary>Power Commander</summary>

**コマンド**: `Clear-KeeperTrash`

**例:**

```powershell
PS> clear-KeeperTrash   
Are you sure you want to permanently delete all records in trash? This action cannot be undone. (yes/No): yes
Successfully purged all records from trash
```

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `trash purge`

**フラグ:**

`--force` 確認プロンプトをスキップする

`-h, --help` ヘルプを表示して終了する

**例:**

```
My Vault> trash purge
Do you want to empty your Trash Bin? [y/n]: y
My Vault>
```

</details>

<details>

<summary>Python SDK</summary>

**関数:** `purge_trash`

```python
trash_management(vault)
```

</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/trash-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.
