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



type:dataType.name:developer project number:device.manufacturer:device.model:device.uid:dataStreamName可行的資料串流 ID 下限為:type:dataType.name:開發人員專案編號

最後,如果由未建立資料來源的任何 REST 或 Android 用戶端讀取,開發人員專案編號和裝置 UID 就會經過模糊處理。只有資料來源建立者可以查看開發人員專案編號,而且格式是一般的。也就是說,用戶端會看到不同的 data_stream_ids 組合,與具有不同憑證的其他用戶端不同。

dataType nested object 資料類型會定義健身 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 == id2,則 obfuscated(id1) == obfuscated(id2)。

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

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

回覆

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

試試看!

使用下方的 APIs Explorer,針對有效資料呼叫這個方法,然後查看回應。