共用方式為


DigitalTwinClient 類別

類別,根據自動產生的 IotHub REST API,為 DigitalTwin 作業提供方便的 API

DigitalTwinClient 的初始化運算式。

成功建立類別之後,已向 IoTHub 進行驗證,並已準備好呼叫成員 API 以與 IoTHub 通訊。

繼承
builtins.object
DigitalTwinClient

建構函式

DigitalTwinClient(connection_string=None, host=None, auth=None)

參數

名稱 Description
connection_string
str

如果使用connection_str驗證,則用來驗證與 IoTHub 連線的 IoTHub 連接字串。 預設值:無

預設值: None
host
str

如果我們使用權杖認證驗證,則為 Azure 服務 URL。 預設值:無

預設值: None
auth
str

如果使用權杖認證驗證,則為 Azure 驗證物件。 預設值:無

預設值: None

方法

from_connection_string

DigitalTwinClient 服務用戶端的 Classmethod 初始化運算式。 從連接字串建立 DigitalTwinClient 類別。

成功建立類別之後,已向 IoTHub 進行驗證,並已準備好呼叫成員 API 以與 IoTHub 通訊。

from_token_credential

DigitalTwinClient 服務用戶端的 Classmethod 初始化運算式。 從主機名稱 URL 和 Azure 權杖認證建立 DigitalTwinClient 類別。

成功建立類別之後,已向 IoTHub 進行驗證,並已準備好呼叫成員 API 以與 IoTHub 通訊。

get_digital_twin

擷取指定裝置的數位對應項。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。

invoke_command

在特定裝置上叫用命令,並取得其結果。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。 :p aram str command_name:命令的名稱。 :p aram str 承載:命令的引數。 :p aram int connect_timeout_in_seconds:數位對應項命令將等候答案的時間間隔上限,以秒為單位。 :p aram int response_timeout_in_seconds:數位對應項命令將等候回應的時間間隔上限,以秒為單位。 此值必須介於 5-300 內。

invoke_component_command

在特定裝置的元件上叫用命令,並取得其結果。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。 :p aram str component_path:元件的名稱。 :p aram str command_name:命令的名稱。 :p aram str 承載:命令的引數。 :p aram int connect_timeout_in_seconds:數位對應項命令將等候答案的時間間隔上限,以秒為單位。 :p aram int response_timeout_in_seconds:數位對應項命令將等候回應的時間間隔上限,以秒為單位。 此值必須介於 5-300 內。 :type response_timeout_in_seconds: int

update_digital_twin

使用修補程式物件更新指定裝置的數位對應項元件。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。 :p aram list[object]:要更新 Digital Twin 的 json-patch 物件。 :p aram str etag:用於更新作業的 etag (if_match) 值。

from_connection_string

DigitalTwinClient 服務用戶端的 Classmethod 初始化運算式。 從連接字串建立 DigitalTwinClient 類別。

成功建立類別之後,已向 IoTHub 進行驗證,並已準備好呼叫成員 API 以與 IoTHub 通訊。

from_connection_string(connection_string)

參數

名稱 Description
connection_string
必要
str

用來向 IoTHub 驗證連線的 IoTHub 連接字串。

傳回

類型 Description

from_token_credential

DigitalTwinClient 服務用戶端的 Classmethod 初始化運算式。 從主機名稱 URL 和 Azure 權杖認證建立 DigitalTwinClient 類別。

成功建立類別之後,已向 IoTHub 進行驗證,並已準備好呼叫成員 API 以與 IoTHub 通訊。

from_token_credential(url, token_credential)

參數

名稱 Description
url
必要
str

Azure 服務 URL (主機名稱) 。

token_credential
必要
<xref:azure.core.TokenCredential>

Azure 權杖認證物件

傳回

類型 Description

get_digital_twin

擷取指定裝置的數位對應項。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。

get_digital_twin(digital_twin_id)

參數

名稱 Description
digital_twin_id
必要

傳回

類型 Description

包含 Digital Twin 的傳回物件。

例外狀況

類型 Description
<xref:if the HTTP response status is not in >[<xref:200>]<xref:.>

invoke_command

在特定裝置上叫用命令,並取得其結果。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。 :p aram str command_name:命令的名稱。 :p aram str 承載:命令的引數。 :p aram int connect_timeout_in_seconds:數位對應項命令將等候答案的時間間隔上限,以秒為單位。 :p aram int response_timeout_in_seconds:數位對應項命令將等候回應的時間間隔上限,以秒為單位。 此值必須介於 5-300 內。

invoke_command(digital_twin_id, command_name, payload, connect_timeout_in_seconds=None, response_timeout_in_seconds=None)

參數

名稱 Description
digital_twin_id
必要
command_name
必要
payload
必要
connect_timeout_in_seconds
預設值: None
response_timeout_in_seconds
預設值: None

傳回

類型 Description

叫用命令的結果。

例外狀況

類型 Description
<xref:if the HTTP response status is not in >[<xref:200>]<xref:.>

invoke_component_command

在特定裝置的元件上叫用命令,並取得其結果。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。 :p aram str component_path:元件的名稱。 :p aram str command_name:命令的名稱。 :p aram str 承載:命令的引數。 :p aram int connect_timeout_in_seconds:數位對應項命令將等候答案的時間間隔上限,以秒為單位。 :p aram int response_timeout_in_seconds:數位對應項命令將等候回應的時間間隔上限,以秒為單位。 此值必須介於 5-300 內。 :type response_timeout_in_seconds: int

invoke_component_command(digital_twin_id, component_path, command_name, payload, connect_timeout_in_seconds=None, response_timeout_in_seconds=None)

參數

名稱 Description
digital_twin_id
必要
component_path
必要
command_name
必要
payload
必要
connect_timeout_in_seconds
預設值: None
response_timeout_in_seconds
預設值: None

傳回

類型 Description

叫用命令的結果。

例外狀況

類型 Description
<xref:if the HTTP response status is not in >[<xref:200>]<xref:.>

update_digital_twin

使用修補程式物件更新指定裝置的數位對應項元件。 :p aram str digital_twin__id:指定裝置的數位對應項識別碼。 :p aram list[object]:要更新 Digital Twin 的 json-patch 物件。 :p aram str etag:用於更新作業的 etag (if_match) 值。

update_digital_twin(digital_twin_id, digital_twin_patch, etag=None)

參數

名稱 Description
digital_twin_id
必要
digital_twin_patch
必要
etag
預設值: None

傳回

類型 Description

包含更新之 Digital Twin 的傳回物件。

例外狀況

類型 Description
<xref:if the HTTP response status is not in >[<xref:200>]<xref:.>