Users.dataSources: update

更新指定的資料來源。dataStreamIddataTypetypedataStreamNamedevice 屬性除外,但 version 除外。

資料來源會以其 dataStreamId 來識別。立即試用

要求

HTTP 要求

PUT https://www.googleapis.com/fitness/v1/users/userId/dataSources/dataSourceId

參數

參數名稱 說明
路徑參數
dataSourceId string 要更新的資料來源的資料串流 ID。
userId string 為已識別的使用者更新資料來源。使用 me 表示已驗證的使用者。目前僅支援 me

授權

此要求需要至少具備下列其中一個範圍的授權:

範圍
https://www.googleapis.com/auth/fitness.activity.write
https://www.googleapis.com/auth/fitness.location.write
https://www.googleapis.com/auth/fitness.body.write
https://www.googleapis.com/auth/fitness.nutrition.write
https://www.googleapis.com/auth/fitness.blood_pressure.write
https://www.googleapis.com/auth/fitness.blood_glucose.write
https://www.googleapis.com/auth/fitness.oxygen_saturation.write
https://www.googleapis.com/auth/fitness.body_temperature.write
https://www.googleapis.com/auth/fitness.reproductive_health.write

詳情請參閱驗證與授權頁面。

要求主體

在要求內容中,請提供下列屬性的 Users.dataSources 資源

資源名稱 說明 附註
必要屬性
application nested object 提供感應器資料至平台的應用程式相關資訊。
application.name string 這個應用程式的名稱。對 REST 用戶端來說,這是必要步驟,但我們不會強制使用這個名稱。它可供其他開發人員辨識,以便找出哪個 REST 建立應用程式或資料來源。
dataStreamId string 這個資料來源產生的資料串流專屬 ID。ID:

  • 實體裝置的製造商、型號和序號 (UID)。
  • 應用程式的套件名稱或名稱。當 Android 應用程式建立資料來源時,系統會使用套件名稱。資料來源是由 REST 用戶端建立時,系統會使用開發人員專案編號。
  • 資料來源類型。
  • 資料來源的串流名稱。
請注意,系統不會將資料來源的所有屬性做為串流 ID 的一部分。具體來說,未使用硬體/應用程式的版本。我們可以透過版本更新來保留相同的串流。這也意味著,即使兩個 DataSource 物件不相同,也可能代表相同的資料串流。

Android 應用程式建立的資料串流 ID 格式如下:type:dataType.name:application.packageName:device.manufacturer:device.model:device.uid:dataStreamName

REST 用戶端建立的資料串流 ID 格式如下:type:dataType.name:developer project number:device.manufacturer:device.model:device.uid:dataStreamName

如果沒有可構成資料串流 ID 的任一選用欄位,資料串流 ID 將會省略。最低的可行資料串流 ID 為:type:dataType.name:developer 專案編號

最後,只要任何未建立資料來源的 REST 或 Android 用戶端讀取,開發人員專案編號和裝置 UID 都會經過模糊處理。只有資料來源建立者才能看到開發人員專案編號,且清楚明瞭。也就是說,用戶端的 data_stream_ids 會與其他用戶端不同。

dataType nested object 資料類型定義了從 Fitness API 收集、插入或查詢的資料串流的結構定義。
dataType.field[] list 欄位代表資料類型的一個維度。
dataType.field[].format string 資料類型中每個欄位支援的不同格式。

可接受的值如下:
  • blob
  • floatList
  • floatPoint
  • integer
  • integerList
  • map
  • string
dataType.field[].name string 用於定義資料的名稱和格式。與資料類型名稱不同,欄位名稱並非命名空間,而且只需要在資料類型中重複。
dataType.name string 每種資料類型都有不重複的命名空間名稱。系統會將 com.google 命名空間中的所有資料類型做為平台的一部分共用。
device nested object 代表可擁有感應器的整合式裝置 (例如手機或穿戴式裝置)。
device.manufacturer string 產品/硬體的製造商。
device.model string 使用者看到的裝置型號名稱。
device.type string 代表裝置類型的常數。

可接受的值如下:
  • chestStrap
  • headMounted
  • phone
  • scale
  • smartDisplay
  • tablet
  • unknown
  • watch
device.uid string 硬體的序號或其他專屬 ID。任何未建立資料來源的 REST 或 Android 用戶端讀取時,系統會對這個欄位進行模糊處理。只有資料來源建立者才能看到 uid 欄位,而且清楚明瞭。

模糊處理作業會維持相等性;也就是說,如果 id1 == id2,則模糊處理(id1) == obfuscated(id2)。

device.version string 裝置硬體/軟體的版本字串。
type string 說明這個資料來源類型的常數。指出這個資料來源是否產生原始或衍生資料。

可接受的值如下:
  • derived
  • raw

回應

如果成功,此方法會在回應主體中傳回 Users.dataSources 資源

試試看!

使用 APIs Explorer 針對即時資料呼叫這個方法,並查看回應。