# ディスカッションとプルリクエストとのやり取り

Hub での Pull Request および Discussion とのやり取りを可能にするメソッドの参考情報については、[HfApi](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi) のドキュメントページを確認してください。

- [get_repo_discussions()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.get_repo_discussions)
- [get_discussion_details()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.get_discussion_details)
- [create_discussion()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.create_discussion)
- [create_pull_request()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.create_pull_request)
- [rename_discussion()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.rename_discussion)
- [comment_discussion()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.comment_discussion)
- [edit_discussion_comment()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.edit_discussion_comment)
- [change_discussion_status()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.change_discussion_status)
- [merge_pull_request()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.merge_pull_request)

## データ構造[[huggingface_hub.Discussion]]

#### huggingface_hub.Discussion[[huggingface_hub.Discussion]]

```python
huggingface_hub.Discussion(title: str, status: typing.Literal['open', 'closed', 'merged', 'draft'], num: int, repo_id: str, repo_type: str, author: str, is_pull_request: bool, created_at: datetime, endpoint: str)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L20)

**パラメータ:**

title (`str`) : Discussion / Pull Request のタイトル

status (`str`) : Discussion / Pull Request のステータス。以下のいずれかである必要があります: * `"open"` * `"closed"` * `"merged"` (Pull Requests のみ) * `"draft"` (Pull Requests のみ)

num (`int`) : Discussion / Pull Request の番号。

repo_id (`str`) : Discussion / Pull Request がオープンされていたリポジトリのID (`"{namespace}/{repo_name}"`)。

repo_type (`str`) : Discussion / Pull Request がオープンされていたリポジトリのタイプ。可能な値は: `"model"`、`"dataset"`、`"space"`。

author (`str`) : Discussion / Pull Request の作成者のユーザー名です。ユーザーがその後削除されている場合は、`"deleted"` になる可能性があります。

is_pull_request (`bool`) : これが Pull Request かどうかを示します。

created_at (`datetime`) : Discussion / Pull Request が作成された `datetime`。

endpoint (`str`) : Hub のエンドポイント。デフォルトは https://huggingface.co です。

git_reference (`str`, *任意*) : (property) これが Pull Request の場合、変更をプッシュできる Git リファレンス。それ以外の場合は `None`。

url (`str`) : (property) Hub 上のディスカッションの URL。

Hub でのディスカッションまたは Pull Request。

このデータクラスは、直接インスタンス化することを意図していません。

#### huggingface_hub.DiscussionWithDetails[[huggingface_hub.DiscussionWithDetails]]

```python
huggingface_hub.DiscussionWithDetails(title: str, status: typing.Literal['open', 'closed', 'merged', 'draft'], num: int, repo_id: str, repo_type: str, author: str, is_pull_request: bool, created_at: datetime, endpoint: str, events: list, conflicting_files: list[str] | bool | None, target_branch: str | None, merge_commit_oid: str | None, diff: str | None)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L88)

**パラメータ:**

title (`str`) : Discussion / Pull Request のタイトル

status (`str`) : Discussion / Pull Request のステータス。以下のいずれかになります: * `"open"` * `"closed"` * `"merged"` (Pull Requests のみ) * `"draft"` (Pull Requests のみ)

num (`int`) : Discussion / Pull Request の番号。

repo_id (`str`) : Discussion / Pull Request がオープンされていたリポジトリのID (`"{namespace}/{repo_name}"`)。

repo_type (`str`) : Discussion / Pull Request がオープンされていたリポジトリのタイプ。可能な値は: `"model"`、`"dataset"`、`"space"`。

author (`str`) : Discussion / Pull Request の作成者のユーザー名です。ユーザーがその後削除されている場合は、`"deleted"` になる可能性があります。

is_pull_request (`bool`) : これが Pull Request かどうかを示します。

created_at (`datetime`) : Discussion / Pull Request が作成された `datetime`。

events (`list` of [DiscussionEvent](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionEvent)) : この Discussion または Pull Request 内の `DiscussionEvents` のリスト。

conflicting_files (`Union[list[str], bool, None]`, *任意*) : Pull Request の場合、競合するファイルのリスト。`self.is_pull_request` が `False` の場合は `None`。競合するファイルがあるがリストを取得できない場合は `True`。

target_branch (`str`, *任意*) : Pull Request の場合、変更がマージされるブランチ。`self.is_pull_request` が `False` の場合は `None`。

merge_commit_oid (`str`, *任意*) : 統合された Pull Request の場合、マージコミットの OID / SHA が設定され、それ以外の場合は `None` になります。

diff (`str`, *任意*) : Pull Request の場合は git diff、それ以外は `None`。

endpoint (`str`) : Hub のエンドポイント。デフォルトは https://huggingface.co です。

git_reference (`str`, *任意*) : (property) これが Pull Request の場合、変更をプッシュできる Git リファレンス。それ以外の場合は `None`。

url (`str`) : (property) Hub 上のディスカッションの URL。

[Discussion](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.Discussion)のサブクラスです。

#### huggingface_hub.DiscussionEvent[[huggingface_hub.DiscussionEvent]]

```python
huggingface_hub.DiscussionEvent(id: str, type: str, created_at: datetime, author: str, _event: dict)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L155)

**パラメータ:**

id (`str`) : イベントのIDです。16進数文字列です。

type (`str`) : イベントの型。

created_at (`datetime`) : イベントの作成タイムスタンプを保持する[`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)オブジェクト。

author (`str`) : Discussion / Pull Request の作成者のユーザー名です。ユーザーがその後削除されている場合は、`"deleted"` になる可能性があります。

DiscussionまたはPull Request内のイベント。

具体的なクラスを使用します:
* [DiscussionComment](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionComment)
* [DiscussionStatusChange](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionStatusChange)
* [ディスカッションコミット](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionCommit)
* [DiscussionTitleChange](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionTitleChange)

#### huggingface_hub.DiscussionComment[[huggingface_hub.DiscussionComment]]

```python
huggingface_hub.DiscussionComment(id: str, type: str, created_at: datetime, author: str, _event: dict, content: str, edited: bool, hidden: bool)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L188)

**パラメータ:**

id (`str`) : イベントのIDです。16進数文字列です。

type (`str`) : イベントの型。

created_at (`datetime`) : イベントの作成タイムスタンプを保持する[`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)オブジェクト。

author (`str`) : Discussion / Pull Request の作成者のユーザー名です。ユーザーがその後削除されている場合は、`"deleted"` になる可能性があります。

content (`str`) : コメントの生のMarkdownコンテンツです。メンション、リンク、画像はレンダリングされません。

edited (`bool`) : このコメントが編集されたかどうかを示します。

hidden (`bool`) : このコメントが非表示にされているかどうか。

Discussion / Pull Request 内のコメント。

[DiscussionEvent](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionEvent)のサブクラスです。

#### huggingface_hub.DiscussionStatusChange[[huggingface_hub.DiscussionStatusChange]]

```python
huggingface_hub.DiscussionStatusChange(id: str, type: str, created_at: datetime, author: str, _event: dict, new_status: str)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L243)

**パラメータ:**

id (`str`) : イベントのIDです。16進数文字列です。

type (`str`) : イベントの型。

created_at (`datetime`) : イベントの作成タイムスタンプを保持する[`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)オブジェクト。

author (`str`) : Discussion / Pull Request の作成者のユーザー名です。ユーザーがその後削除されている場合は、`"deleted"` になる可能性があります。

new_status (`str`) : 変更後のDiscussion / Pull Requestのステータス。以下のいずれかになります。* `"open"` * `"closed"` * `"merged"` (Pull Requests のみ)

Discussion / Pull Request におけるステータスの変更。

[DiscussionEvent](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionEvent)のサブクラスです。

#### huggingface_hub.DiscussionCommit[[huggingface_hub.DiscussionCommit]]

```python
huggingface_hub.DiscussionCommit(id: str, type: str, created_at: datetime, author: str, _event: dict, summary: str, oid: str)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L271)

**パラメータ:**

id (`str`) : イベントのIDです。16進数文字列です。

type (`str`) : イベントの型。

created_at (`datetime`) : イベントの作成タイムスタンプを保持する[`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)オブジェクト。

author (`str`) : Discussion / Pull Request の作成者のユーザー名です。ユーザーがその後削除されている場合は、`"deleted"` になる可能性があります。

summary (`str`) : コミットの概要。

oid (`str`) : コミットの OID / SHA を16進数文字列として表したものです。

Pull Request 内のコミット。

[DiscussionEvent](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionEvent)のサブクラスです。

#### huggingface_hub.DiscussionTitleChange[[huggingface_hub.DiscussionTitleChange]]

```python
huggingface_hub.DiscussionTitleChange(id: str, type: str, created_at: datetime, author: str, _event: dict, old_title: str, new_title: str)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L298)

**パラメータ:**

id (`str`) : イベントのIDです。16進数文字列です。

type (`str`) : イベントの型。

created_at (`datetime`) : イベントの作成タイムスタンプを保持する[`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)オブジェクト。

author (`str`) : Discussion / Pull Request の作成者のユーザー名です。ユーザーがその後削除されている場合は、`"deleted"` になる可能性があります。

old_title (`str`) : Discussion / Pull Request の以前のタイトル。

new_title (`str`) : 新しいタイトル。

Discussion / Pull Request における名前変更イベント。

[DiscussionEvent](/docs/huggingface_hub/v2.4.0/ja/package_reference/community#huggingface_hub.DiscussionEvent)のサブクラスです。

