次の方法で共有


SensorEvents.GetSensorEvents メソッド

定義

センサー イベント データの一覧を返します。 クエリの期間は、一度に 90 日に制限されます。 startDateTime と endDateTime が指定されていない場合、過去 90 日間のイベントを返します。

public virtual Azure.Response GetSensorEvents (string sensorId, string sensorPartnerId, DateTimeOffset? startDateTime = default, DateTimeOffset? endDateTime = default, bool? excludeDuplicateEvents = default, Azure.RequestContext context = default);
abstract member GetSensorEvents : string * string * Nullable<DateTimeOffset> * Nullable<DateTimeOffset> * Nullable<bool> * Azure.RequestContext -> Azure.Response
override this.GetSensorEvents : string * string * Nullable<DateTimeOffset> * Nullable<DateTimeOffset> * Nullable<bool> * Azure.RequestContext -> Azure.Response
Public Overridable Function GetSensorEvents (sensorId As String, sensorPartnerId As String, Optional startDateTime As Nullable(Of DateTimeOffset) = Nothing, Optional endDateTime As Nullable(Of DateTimeOffset) = Nothing, Optional excludeDuplicateEvents As Nullable(Of Boolean) = Nothing, Optional context As RequestContext = Nothing) As Response

パラメーター

sensorId
String

関連付けられているセンサーの ID。

sensorPartnerId
String

関連付けられているセンサー パートナーの ID。

startDateTime
Nullable<DateTimeOffset>

センサー イベントの検索スパン開始時刻 (包括的)、サンプル形式: yyyy-MM-ddTHH:mm:ssZ。 分数が指定されている場合は、最大秒単位で切り捨てられます。

endDateTime
Nullable<DateTimeOffset>

センサー イベントの検索スパン終了時刻 (包括的)、サンプル形式: yyyy-MM-ddTHH:mm:ssZ。 分数が指定されている場合は、最大秒単位で切り捨てられます。

excludeDuplicateEvents
Nullable<Boolean>

重複するイベントを除外し、最新のイベントのみを取得するフラグ (既定値: true)。

context
RequestContext

要求コンテキスト。これは、クライアント パイプラインの既定の動作を呼び出しごとにオーバーライドできます。

戻り値

サービスから返された応答。 応答本文スキーマの詳細については、以下の「解説」セクションを参照してください。

例外

sensorId または sensorPartnerId が null です。

サービスから成功以外の状態コードが返されました。

このサンプルでは、必要なパラメーターを使用して GetSensorEvents を呼び出し、結果を解析する方法を示します。

var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetSensorEventsClient(<2022-11-01-preview>);

Response response = client.GetSensorEvents("<sensorId>", "<sensorPartnerId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("value")[0].ToString());

このサンプルでは、すべてのパラメーターを使用して GetSensorEvents を呼び出す方法と、結果を解析する方法を示します。

var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetSensorEventsClient(<2022-11-01-preview>);

Response response = client.GetSensorEvents("<sensorId>", "<sensorPartnerId>", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, true);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("value")[0].GetProperty("sensorId").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("sensorPartnerId").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("partyId").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("boundaryId").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("eventDateTime").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("ingestionDateTime").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("measures").GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("skipToken").ToString());
Console.WriteLine(result.GetProperty("nextLink").ToString());

注釈

応答ペイロードの JSON スキーマを次に示します。

応答本文:

SensorEventListResponseスキーマ:

{
  value: [
    {
      sensorId: string, # Optional. Id of the sensor.
      sensorPartnerId: string, # Optional. Id of the sensor partner.
      partyId: string, # Optional. Id of the associated party.
      boundaryId: string, # Optional. Id of the associated boundary.
      eventDateTime: string (ISO 8601 Format), # Optional. DateTime of sensor event observation.
      ingestionDateTime: string (ISO 8601 Format), # Optional. DateTime of sensor event ingestion to data store.
      measures: Dictionary<string, any>, # Optional. Sensor measures.
    }
  ], # Required. List of requested objects.
  skipToken: string, # Optional. Token used in retrieving the next page. If null, there are no additional pages.
  nextLink: string, # Optional. Continuation link (absolute URI) to the next page of results in the list.
}

適用対象