TIPCommon.adapters

class TIPCommon.adapters.pubsub.pubsub.PubSubAdapter

クラス TIPCommon.adapters.pubsub.pubsub.PubSubAdapter(session, project_id=None, logger=None, region=None)

ベース: object

Google Cloud プロジェクトの Pub/Sub トピックとサブスクリプションを管理するためのアダプタ クラス。

ack

ack(sub_name, ack_ids)

PubSubAdapter.pull() から返された AcknowledgeRequest レスポンスの ackIDs に関連付けられたメッセージを確認応答します。

パラメータ
sub_name str

サブスクリプション名。

ack_ids list[str])

確認応答されるメッセージの確認応答 ID のリスト。このリストは、Pub/Sub システムによって PubSubAdapter.pull() レスポンスで返されます。

static build_pubsub_message

static build_pubsub_message(message_content, encoding='utf-8', ordering_key=None, **attr)

PubSubMessage オブジェクトを作成します。

パラメータ
message_content str

メッセージのコンテンツ。

encoding str

メッセージ テキストをエンコードまたはデコードするエンコード タイプ。

デフォルト値は UTF-8 です。

ordering_key 省略可str

使用する場合、このパラメータはパブリッシュ順序に従う必要がある関連メッセージをすべて識別します。

**attr Optional

str

メッセージ オブジェクトの属性として渡す属性。

戻り値

TIPCommon.adapters.pubsub.PubSubMessage オブジェクト。

戻り値の型

PubSubMessage

create_subscription

create_subscription(sub_name, topic, **attr)

指定されたトピックの Pub/Sub サブスクリプションを作成します。

パラメータ
sub_name str

サブスクリプション名。

topic str

サブスクリプションを作成する Pub/Sub トピック名。

**attr サブスクリプション リクエストに渡す追加のパラメータ。

戻り値

作成されたサブスクリプションの TIPCommon.adapters.pubsub.Subscription オブジェクト。

戻り値の型

Subscription

create_topic

create_topic(topic_name)

Google Cloud プロジェクトに Pub/Sub トピックを作成します。

パラメータ
topic_name str

トピックの名前。名前は、 Google Cloud リソース名のルールに対応している必要があります。

戻り値

作成されたトピックの TIPCommon.adapters.pubsub.Topic オブジェクト。

戻り値の型

Topic

delete_subscription

delete_subscription(sub_name)

Google Cloud プロジェクトから Pub/Sub サブスクリプションを削除します。

パラメータ
sub_name str

削除するサブスクリプション名。

delete_topic

delete_topic(topic_name)

Google Cloud プロジェクトから Pub/Sub トピックを削除します。

パラメータ
topic_name str

削除するトピック。

static from_credentials

static from_credentials(credentials, project_id=None, verify_ssl=True, quota_project=None, logger=None, region=None)

google.oauth2.credentials.Credentials オブジェクトから PubSubAdapter オブジェクトを作成します。

パラメータ
credentials google.oauth2.credentials.Credentials

google.oauth2.credentials.Credentials オブジェクト。

project_id 省略可str

Google Cloud プロジェクト ID

指定しない場合、関数はデフォルトで認証情報オブジェクトで構成されたプロジェクトを使用しようとします。

verify_ssl 省略可bool

HTTP セッションで SSL 証明書の検証を有効にするかどうかを指定します。

quota_project 省略可str

割り当てと課金に使用するプロジェクト。

logger 省略可SiemplifyLogger

SiemplifyLogger オブジェクト。

region str

Pub/Sub が動作するリージョン。

戻り値

PubSubAdapter オブジェクト。

戻り値の型

PubSubAdapter

static from_service_account_info

static subscription_name(project_id, sub_name)

service_account JSON から PubSubAdapter オブジェクトを作成します。

パラメータ
user_service_account str

テキスト形式の Google Cloud サービス アカウントの JSON。

project_id 省略可str

Google Cloud プロジェクト ID

指定しない場合、関数はデフォルトで認証情報オブジェクトで構成されたプロジェクトを使用しようとします。

verify_ssl 省略可bool

HTTP セッションで SSL 証明書の検証を有効にするかどうかを指定します。

quota_project 省略可str

割り当てと課金に使用するプロジェクト。

logger 省略可SiemplifyLogger

SiemplifyLogger オブジェクト。

戻り値

PubSubAdapter オブジェクト。

戻り値の型

PubSubAdapter

get_subscription

get_subscription(sub_name, topic=None, create_if_not_exist=False, **attr)

Pub/Sub サブスクリプションを取得します。

パラメータ
sub_name str

サブスクリプション名。

topic str

サブスクリプションを作成する Pub/Sub トピック名。

create_if_not_existTrue の場合は必須。

create_if_not_exist Google Cloud に Pub/Sub サブスクリプションが存在しない場合は作成します。
**attr サブスクリプション作成リクエストに渡す追加パラメータ。

戻り値

取得したサブスクリプションの TIPCommon.adapters.pubsub.Subscription オブジェクト。

戻り値の型

Subscription

get_topic

get_topic(topic_name, create_if_not_exist=False)

構成された Google Cloudプロジェクトから Pub/Sub トピック オブジェクトを取得します。

パラメータ
topic_name str

トピックの名前(簡略化、projects/PROJECT_ID/topics/ 接頭辞なし)。

create_if_not_exist bool

Google Cloudに Pub/Sub トピックが存在しない場合は、作成します。

戻り値

受信したトピックの TIPCommon.adapters.pubsub.Topic オブジェクト。

戻り値の型

Topic

patch_subscription

patch_subscription(sub_name, topic_name, push_config=None, bigquery_config=None, cloud_storage_config=None, ack_deadline_seconds=None, retain_acked_messages=None, retention_duration=None, labels=None, enable_message_ordering=None, expiration_policy=None, query_filter=None, dead_letter_policy=None, return_policy=None, detached=None, enable_once_delivery=None)

既存の定期購入を更新します。

パラメータ
sub_name str

サブスクリプション名。

topic_name str

このサブスクリプションがメッセージを受信するトピックの名前。

戻り値

受信したサブスクリプションの TIPCommon.adapters.pubsub.Subscription オブジェクト。

戻り値の型

Subscription

patch_topic

patch_topic(topic_name, labels=None, message_storage_policy=None, kms_key_name=None, schema_settings=None, satisfies_pzs=None, retention_duration=None)

既存のトピックを更新します。

パラメータ
topic_name str

トピック名。

戻り値

受信したトピックの TIPCommon.adapters.pubsub.Topic オブジェクト。

戻り値の型

Topic

publish

publish(topic_name, messages)

PubSubMessage オブジェクトのリストをトピックにパブリッシュします。

パラメータ
topic_name str

メッセージをパブリッシュするトピックの名前。

messages list

PubSubMessage オブジェクトのリスト。

リストは PubSubAdapter.build_message() 静的メソッドで作成できます。

戻り値

メッセージ ID のリスト。

戻り値の型

list[str]

pull

pull(sub_name, limit, timeout=60, encoding='utf-8')

Pub/Sub サブスクリプションからメッセージを pull します。

パラメータ
sub_name str

サブスクリプション名。

limit int

このリクエストで返されるメッセージの最大数。

timeout int

HTTP リクエストのタイムアウト(秒単位)。

デフォルトは 60 秒です。

encoding str

Pub/Sub メッセージのエンコード。デフォルトは utf-8 です。

戻り値

TIPCommon.adapters.pubsub.ReceivedMessage オブジェクトのリスト。

戻り値の型

list[ReceivedMessage]

static subscription_name

static subscription_name(project_id, sub_name)

次の形式で完全なサブスクリプション名を取得します: projects/project_id/subscriptions/subscription_name

パラメータ
project_id str

リソースを含むプロジェクトの名前。

sub_name str

Pub/Sub サブスクリプション名。

戻り値

次の形式の完全なサブスクリプション名: projects/project_id/subscriptions/subscription_name

戻り値の型

str

static topic_name

static topic_name(project_id, topic)

projects/project_id/topics/topic_name を取得します。

パラメータ
project_id str

リソースを含むプロジェクトの名前。

topic str

Pub/Sub トピック名。

戻り値

トピックの完全な名前: projects/project_id/topics/topic_name

戻り値の型

str

class TIPCommon.adapters.pubsub.data_models.PubSubMessage

クラス TIPCommon.adapters.pubsub.data_models.PubSubMessage(raw_data: 'dict', data: 'str' = None, attributes: 'dict' = None, message_id: 'str' = None, publish_time: 'int' = None, ordering_key: 'str' = None)

ベース: オブジェクト

attributes: dict= None

data: str= None

json()

message_id: str= None

ordering_key: str= None

publish_time: int= None

raw_data: dict

class TIPCommon.adapters.pubsub.data_models.ReceivedMessage

クラス TIPCommon.adapters.pubsub.data_models.ReceivedMessage(raw_data: 'dict', ack_id: 'str', message: 'PubSubMessage', delivery_attempt: 'int')

ベース: オブジェクト

ack_id: str

delivery_attempt: int

json()

message: PubSubMessage

raw_data: dict

class TIPCommon.adapters.pubsub.data_models.SchemaSettings

クラス TIPCommon.adapters.pubsub.data_models.SchemaSettings(raw_data: 'dict', schema: 'str', encoding: 'str' = None, first_revision_id: 'str' = None, last_revision_id: 'str' = None)

ベース: オブジェクト

encoding: str= None

first_revision_id: str= None

json()

last_revision_id: str= None

raw_data: dict

schema: str

class TIPCommon.adapters.pubsub.data_models.Subscription

クラス TIPCommon.adapters.pubsub.data_models.Subscription(raw_data: 'dict', name: 'str', identifier: 'str', topic_identifier: 'str', state: 'str', ack_deadline_secs: 'int' = None, retain_ack_messages: 'bool' = None, message_retention_duration: 'int' = None, labels: 'dict' = None, message_ordering: 'bool' = None, query_filter: 'str' = None, topic_message_retention_duration: 'int' = None)

ベース: オブジェクト

ack_deadline_secs: int= None

identifier: str

json()

labels: dict= None

message_ordering: bool= None

message_retention_duration: int= None

name: str

query_filter: str= None

raw_data: dict

retain_ack_messages: bool= None

state: str

topic_identifier: str

topic_message_retention_duration: int= None

class TIPCommon.adapters.pubsub.data_models.Topic

クラス TIPCommon.adapters.pubsub.data_models.Topic(raw_data: 'dict', name: 'str', identifier: 'str', labels: 'dict' = None, schema_settings: 'SchemaSettings' = None, message_retention_duration: 'int' = None)

ベース: オブジェクト

identifier: str

json()

labels: dict= None

message_retention_duration: int= None

name: str

raw_data: dict

schema_settings: SchemaSettings= None

さらにサポートが必要な場合 コミュニティ メンバーや Google SecOps のプロフェッショナルから回答を得ることができます。