第61章 GoogleMail


GoogleMail コンポーネント

Camel 2.15 以降で利用可能

コンポーネントの説明

Google Mail は OAuth 2.0 プロトコル を使用して Google アカウントを認証し、ユーザーデータへのアクセスを承認します。このコンポーネントを使用する前に、アカウントを作成し、OAuth クレデンシャル を生成 する必要があります。認証情報は、clientId、clientSecret、および refreshToken で設定されます。有効期間の長い refreshToken を生成するための便利なリソースは OAuth プレイグラウンドです
Maven ユーザーは、このコンポーネントの pom.xml に以下の依存関係を追加する必要があります。
<dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-google-mail</artifactId>
        <version>2.17.0.redhat-630xxx</version>
</dependency>
Copy to Clipboard Toggle word wrap

URI 形式

GoogleMail コンポーネントは以下の URI 形式を使用します。
google-mail://endpoint-prefix/endpoint?[options]
Copy to Clipboard Toggle word wrap
エンドポイント接頭辞は以下のいずれかになります。
  • attachments
  • ドラフト
  • history
  • labels
  • messages
  • threads
  • users

GoogleMailComponent

GoogleMail コンポーネントは、以下のオプションで設定できます。これらのオプションは、タイプ org.apache.camel.component.google.mail.GoogleMailConfiguration のコンポーネントの Bean プロパティー configuration を使用して提供できます。
Expand
オプション タイプ
accessToken String OAuth2 アクセストークン。通常、これは 1 時間後に期限切れになるため、長期間の使用には refreshToken が推奨されます。
applicationName String Google ドライブアプリケーション名。たとえば、camel-google-mail/1.0 です。
clientId String ドライブアプリケーションのクライアント ID。
clientSecret String ドライブアプリケーションのクライアントシークレット。
refreshToken
String
OAuth2 更新トークン。このトークンを使用すると、現在の有効期限が長い場合に Google Mail コンポーネントは新しい accessToken を取得できます。
scopes List<String> ドライブアプリケーションでユーザーアカウントに必要なパーミッションのレベルを指定します。詳細は、https://developers.google.com/gmail/api/auth/scopes を参照してください。
user String
Camel 2.16.0: サービスアカウントフローでアプリケーションの権限を借用しようとするユーザーのメールアドレス。
p12FileName String
Camel 2.16.0: Google サービスアカウントで使用する秘密鍵を持つ .p12 ファイルの名前。

プロデューサーエンドポイント

プロデューサーエンドポイントはエンドポイント接頭辞を使用し、続いてエンドポイント名と以下で説明する関連オプションを使用できます。一部のエンドポイントには、短縮エイリアスを使用できます。エンドポイント URI には 接頭辞が含まれている必要があります。
必須ではないエンドポイントオプションは [] で示されます。エンドポイントに必須のオプションがない場合は、[] オプションのセットの 1 つを指定する必要があります。プロデューサーエンドポイントは、Camel Exchange In メッセージに含まれる値を持つ endpoint オプションの名前が含まれる必要がある特別なオプション inBody を使用することもできます。
エンドポイントオプションは、エンドポイント URI またはメッセージヘッダーで動的に指定できます。メッセージヘッダー名は CamelGoogleMail.<option> の形式である必要があります。inBody オプションはメッセージヘッダーを上書きすることに注意してください。つまり、エンドポイントオプション inBody=optionCamelGoogleMail.option ヘッダーを上書きすることに注意してください。
エンドポイントおよびオプションの詳細は、API ドキュメント( https://developers.google.com/gmail/api/v1/reference/)を参照してください。

1.エンドポイント接頭辞 アタッチメント

以下のエンドポイントは、以下のように接頭辞 attachments で呼び出すことができます。
google-mail://attachments/endpoint?[options]
Copy to Clipboard Toggle word wrap
Expand
エンドポイント 短縮形エイリアス オプション 結果ボディーのタイプ
get id、messageId、userId com.google.api.services.gmail.model.MessagePartBody

添付の URI オプション

Expand
名前 タイプ
id 文字列
messageId 文字列
userId 文字列

2.エンドポイント接頭 辞ドラフト

以下のエンドポイントは、以下のように接頭辞 drafts で呼び出すことができます。
google-mail://drafts/endpoint?[options]
Copy to Clipboard Toggle word wrap
Expand
エンドポイント 短縮形エイリアス オプション 結果ボディーのタイプ
create [mediaContent], content, userId com.google.api.services.gmail.model.Draft
delete id、userId
get id、userId com.google.api.services.gmail.model.Draft
list userId com.google.api.services.gmail.model.ListDraftsResponse
send [mediaContent], content, userId com.google.api.services.gmail.model.Message
update [mediaContent]、content、id、userId com.google.api.services.gmail.model.Draft

ドラフトの URI オプション

Expand
名前 タイプ
content com.google.api.services.gmail.model.Draft
id 文字列
mediaContent com.google.api.client.http.AbstractInputStreamContent
userId 文字列

3.エンドポイント接頭辞の 履歴

以下のエンドポイントは、以下のように接頭辞 history で呼び出すことができます。
google-mail://history/endpoint?[options]
Copy to Clipboard Toggle word wrap
Expand
エンドポイント 短縮形エイリアス オプション 結果ボディーのタイプ
list userId com.google.api.services.gmail.model.ListHistoryResponse

履歴の URI オプション

Expand
名前 タイプ
userId 文字列

4.エンドポイント接頭辞の ラベル

以下のエンドポイントは、以下のように接頭辞 labels で呼び出すことができます。
google-mail://labels/endpoint?[options]
Copy to Clipboard Toggle word wrap
Expand
エンドポイント 短縮形エイリアス オプション 結果ボディーのタイプ
create content, userId com.google.api.services.gmail.model.Label
delete id、userId
get id、userId com.google.api.services.gmail.model.Label
list userId com.google.api.services.gmail.model.ListLabelsResponse
patch content、id、userId com.google.api.services.gmail.model.Label
update content、id、userId com.google.api.services.gmail.model.Label

ラベルの URI オプション

Expand
名前 タイプ
content com.google.api.services.gmail.model.Label
id 文字列
userId 文字列

5.エンドポイント接頭辞 メッセージ

以下のエンドポイントは、以下のように接頭辞 messages で呼び出すことができます。
google-mail://messages/endpoint?[options]
Copy to Clipboard Toggle word wrap
Expand
エンドポイント 短縮形エイリアス オプション 結果ボディーのタイプ
delete id、userId
get id、userId com.google.api.services.gmail.model.Message
gmailImport [mediaContent], content, userId com.google.api.services.gmail.model.Message
insert [mediaContent], content, userId com.google.api.services.gmail.model.Message
list userId com.google.api.services.gmail.model.ListMessagesResponse
modify id, modifyMessageRequest, userId com.google.api.services.gmail.model.Message
send [mediaContent], content, userId com.google.api.services.gmail.model.Message
trash id、userId
untrash id、userId

メッセージの URI オプション

Expand
名前 タイプ
content com.google.api.services.gmail.model.Message
id 文字列
mediaContent com.google.api.client.http.AbstractInputStreamContent
modifyMessageRequest com.google.api.services.gmail.model.ModifyMessageRequest
userId 文字列

6.エンドポイント接頭辞 スレッド

以下のエンドポイントは、以下のように接頭辞 threads で呼び出すことができます。
google-mail://threads/endpoint?[options]
Copy to Clipboard Toggle word wrap
Expand
エンドポイント 短縮形エイリアス オプション 結果ボディーのタイプ
delete id、userId
get id、userId com.google.api.services.gmail.model.Thread
list userId com.google.api.services.gmail.model.ListThreadsResponse
modify content、id、userId com.google.api.services.gmail.model.Thread
trash id、userId
untrash id、userId

スレッドの URI オプション

Expand
名前 タイプ
content com.google.api.services.gmail.model.ModifyThreadRequest
id 文字列
userId 文字列

7.エンドポイント接頭辞 ユーザー

以下のエンドポイントは、以下のように接頭辞 users で呼び出すことができます。
google-mail://users/endpoint?[options]
Copy to Clipboard Toggle word wrap
Expand
エンドポイント 短縮形エイリアス オプション 結果ボディーのタイプ
getProfile userId com.google.api.services.gmail.model.Profile

ユーザーの URI オプション

Expand
名前 タイプ
userId 文字列

コンシューマーエンドポイント

プロデューサーエンドポイントはいずれもコンシューマーエンドポイントとして使用できます。コンシューマーエンドポイントは、consumer. 接頭辞が付い た Scheduled Poll Consumer オプション を使用して、エンドポイントの呼び出しをスケジュールできます。配列またはコレクションを返すコンシューマーエンドポイントは、要素ごとにエクスチェンジを 1 つ生成し、それらのルートはエクスチェンジごとに 1 回実行されます。

メッセージヘッダー

URI オプションは、CamelGoogleMail. 接頭辞が付いたプロデューサーエンドポイントのメッセージヘッダーで指定できます。

メッセージボディー

すべての結果メッセージ本文は、GoogleMailComponent が使用する基礎となる API によって提供されるオブジェクトを使用します。プロデューサーエンドポイントは、inBody エンドポイント URI パラメーターに受信メッセージボディーのオプション名を指定できます。配列またはコレクションを返すエンドポイントの場合、コンシューマーエンドポイントはすべての要素を個別のメッセージにマップします。
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat