> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Slack統合フォルダマッピングの管理

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

このスクリプトは、BoxをSlackのコンテンツストアとして使用している場合に、SlackとBox間のフォルダマッピングの管理に役立ちます。現在のSlackチャンネルとBoxフォルダのマッピングのリストが作成されるため、入力用のcsvに基づいてマッピングを作成または更新できます。このスクリプトではすべての権限が維持されます。

詳細については、[GitHubリポジトリ][1]を参照してください。

## 前提条件

### スクリプトの複製

このGitHubリポジトリを複製するか、`/examples`ディレクトリからファイルをダウンロードします。

```bash theme={null}
git clone https://github.com/box/boxcli.git
```

### Windows

[.NET Core](https://dotnet.microsoft.com/download)の最新バージョンのインストール

### macOSおよびLinux

[PowerShell][pwsh]をインストールします。`pwsh`コマンドを実行して、インストール結果をテストします。

```bash theme={null}
pwsh
```

どのディレクトリでこのコマンドを実行するかに応じて、出力が異なる場合があります。以下に例を示します。

```bash theme={null}
PowerShell 7.2.5
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /Users/user/repos/boxcli/examples>
```

<message>
  問題が発生する場合は、[.NET Core](https://dotnet.microsoft.com/download)と[PowerShell][pwsh]の両方をインストールしたかどうか確認してください。
</message>

### Box CLIのインストール

<Link href="/guides/cli">CLIクイックスタートガイド</Link>を使用して、Box CLIを構成してインストールします。使用しているユーザーが管理者または共同管理者であることを確認してください。

### Enterprise構成

* 適切なSlackワークスペースやオーガナイゼーションで[Box for Slackを構成してインストール][install-slack]します。
* [Slackのコンテンツレイヤー][content-layer]としてBoxを使用できるようにします。

## スクリプトの実行

ディレクトリを、スクリプトが格納されているフォルダに変更します。この例では、`Integration Mappings`フォルダになります。

```pwsh theme={null}
rvb@lab:~/box-cli/examples/Integration Mappings$ pwsh
PowerShell 7.2.4
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/rvb/box-cli/examples/Integration Mappings>
```

EXTRACTを指定してスクリプトを実行すると、現在のマッピングが抽出されます:

```pwsh theme={null}
./integration-mappings.ps1 -Action EXTRACT
```

または

UPDATEを指定してスクリプトを実行すると、現在のマッピングが更新されます:

```pwsh theme={null}
./integration-mappings.ps1 -Action UPDATE
```

または

CREATEを指定してスクリプトを実行すると、新しいマッピングが作成されます:

```pwsh theme={null}
./integration-mappings.ps1 -Action CREATE -MappingPath ./mapping_create_example.csv
```

デフォルトでは、csvファイルが./mappings.csvに保存され、./mappings.csvから読み込まれます。この場所を変更する場合は、次のように新しいパスを渡します:

```pwsh theme={null}
./integration-mappings.ps1 -Action EXTRACT -MappingPath ./mappings_new_location.csv
```

パラメータを指定しなかった場合は、スクリプトによって、パラメータを入力するよう求められます。

新しいチャンネルにマッピングを作成する際は、BoxフォルダID、SlackチャンネルID、およびSlackオーガナイゼーションIDを入力する必要があります。オーガナイゼーションIDの代わりにSlackワークスペースIDを使用できます。その場合は、csvの列見出し`SlackOrgId`を`SlackWorkspaceId`に置き換える必要があります。

```pwsh theme={null}
Starting Process
Applying new mappings
Output [...]
All bulk input entries processed successfully.
```

## ログ

ログは、メインフォルダ内の`logs`フォルダに格納されます。以下のログファイルにアクセスできます。

* `Integration-mappings_all.txt`: すべてのログエントリが含まれています。
* `Integration-mappings_errors.txt`: エラーのみが含まれています。

## 免責

このプロジェクトは、オープンソースの例を集めたものであるため、公式にサポートされている製品として扱わないでください。自己責任の下、Box CLIの使用方法に関する例の情報源として利用してください。

[pwsh]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.2

[install-slack]: https://support.box.com/hc/en-us/articles/360044195313-Installing-and-Using-the-Box-for-Slack-Integration

[content-layer]: https://support.box.com/hc/en-us/articles/4415585987859-Box-as-the-Content-Layer-for-Slack

[1]: https://github.com/box/boxcli/tree/main/examples/Integration%20Mappings

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("OAuth 2.0 Auth"), href: "/guides/authentication/oauth2/index", badge: "GUIDE" },
{ label: translate("Using PowerShell Scripts with the Box CLI"), href: "/guides/cli/scripts/powershell-script-templates", badge: "GUIDE" }
]}
/>
