You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

3693 lines
139 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package fitness provides access to the Fitness.
  6. //
  7. // For product documentation, see: https://developers.google.com/fit/rest/
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/fitness/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // fitnessService, err := fitness.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes:
  25. //
  26. // fitnessService, err := fitness.NewService(ctx, option.WithScopes(fitness.FitnessReproductiveHealthWriteScope))
  27. //
  28. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  29. //
  30. // fitnessService, err := fitness.NewService(ctx, option.WithAPIKey("AIza..."))
  31. //
  32. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  33. //
  34. // config := &oauth2.Config{...}
  35. // // ...
  36. // token, err := config.Exchange(ctx, ...)
  37. // fitnessService, err := fitness.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  38. //
  39. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  40. package fitness // import "google.golang.org/api/fitness/v1"
  41. import (
  42. "bytes"
  43. "context"
  44. "encoding/json"
  45. "errors"
  46. "fmt"
  47. "io"
  48. "net/http"
  49. "net/url"
  50. "strconv"
  51. "strings"
  52. gensupport "google.golang.org/api/gensupport"
  53. googleapi "google.golang.org/api/googleapi"
  54. option "google.golang.org/api/option"
  55. htransport "google.golang.org/api/transport/http"
  56. )
  57. // Always reference these packages, just in case the auto-generated code
  58. // below doesn't.
  59. var _ = bytes.NewBuffer
  60. var _ = strconv.Itoa
  61. var _ = fmt.Sprintf
  62. var _ = json.NewDecoder
  63. var _ = io.Copy
  64. var _ = url.Parse
  65. var _ = gensupport.MarshalJSON
  66. var _ = googleapi.Version
  67. var _ = errors.New
  68. var _ = strings.Replace
  69. var _ = context.Canceled
  70. const apiId = "fitness:v1"
  71. const apiName = "fitness"
  72. const apiVersion = "v1"
  73. const basePath = "https://www.googleapis.com/fitness/v1/users/"
  74. // OAuth2 scopes used by this API.
  75. const (
  76. // View your activity information in Google Fit
  77. FitnessActivityReadScope = "https://www.googleapis.com/auth/fitness.activity.read"
  78. // View and store your activity information in Google Fit
  79. FitnessActivityWriteScope = "https://www.googleapis.com/auth/fitness.activity.write"
  80. // View blood glucose data in Google Fit
  81. FitnessBloodGlucoseReadScope = "https://www.googleapis.com/auth/fitness.blood_glucose.read"
  82. // View and store blood glucose data in Google Fit
  83. FitnessBloodGlucoseWriteScope = "https://www.googleapis.com/auth/fitness.blood_glucose.write"
  84. // View blood pressure data in Google Fit
  85. FitnessBloodPressureReadScope = "https://www.googleapis.com/auth/fitness.blood_pressure.read"
  86. // View and store blood pressure data in Google Fit
  87. FitnessBloodPressureWriteScope = "https://www.googleapis.com/auth/fitness.blood_pressure.write"
  88. // View body sensor information in Google Fit
  89. FitnessBodyReadScope = "https://www.googleapis.com/auth/fitness.body.read"
  90. // View and store body sensor data in Google Fit
  91. FitnessBodyWriteScope = "https://www.googleapis.com/auth/fitness.body.write"
  92. // View body temperature data in Google Fit
  93. FitnessBodyTemperatureReadScope = "https://www.googleapis.com/auth/fitness.body_temperature.read"
  94. // View and store body temperature data in Google Fit
  95. FitnessBodyTemperatureWriteScope = "https://www.googleapis.com/auth/fitness.body_temperature.write"
  96. // View your stored location data in Google Fit
  97. FitnessLocationReadScope = "https://www.googleapis.com/auth/fitness.location.read"
  98. // View and store your location data in Google Fit
  99. FitnessLocationWriteScope = "https://www.googleapis.com/auth/fitness.location.write"
  100. // View nutrition information in Google Fit
  101. FitnessNutritionReadScope = "https://www.googleapis.com/auth/fitness.nutrition.read"
  102. // View and store nutrition information in Google Fit
  103. FitnessNutritionWriteScope = "https://www.googleapis.com/auth/fitness.nutrition.write"
  104. // View oxygen saturation data in Google Fit
  105. FitnessOxygenSaturationReadScope = "https://www.googleapis.com/auth/fitness.oxygen_saturation.read"
  106. // View and store oxygen saturation data in Google Fit
  107. FitnessOxygenSaturationWriteScope = "https://www.googleapis.com/auth/fitness.oxygen_saturation.write"
  108. // View reproductive health data in Google Fit
  109. FitnessReproductiveHealthReadScope = "https://www.googleapis.com/auth/fitness.reproductive_health.read"
  110. // View and store reproductive health data in Google Fit
  111. FitnessReproductiveHealthWriteScope = "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  112. )
  113. // NewService creates a new Service.
  114. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  115. scopesOption := option.WithScopes(
  116. "https://www.googleapis.com/auth/fitness.activity.read",
  117. "https://www.googleapis.com/auth/fitness.activity.write",
  118. "https://www.googleapis.com/auth/fitness.blood_glucose.read",
  119. "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  120. "https://www.googleapis.com/auth/fitness.blood_pressure.read",
  121. "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  122. "https://www.googleapis.com/auth/fitness.body.read",
  123. "https://www.googleapis.com/auth/fitness.body.write",
  124. "https://www.googleapis.com/auth/fitness.body_temperature.read",
  125. "https://www.googleapis.com/auth/fitness.body_temperature.write",
  126. "https://www.googleapis.com/auth/fitness.location.read",
  127. "https://www.googleapis.com/auth/fitness.location.write",
  128. "https://www.googleapis.com/auth/fitness.nutrition.read",
  129. "https://www.googleapis.com/auth/fitness.nutrition.write",
  130. "https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
  131. "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  132. "https://www.googleapis.com/auth/fitness.reproductive_health.read",
  133. "https://www.googleapis.com/auth/fitness.reproductive_health.write",
  134. )
  135. // NOTE: prepend, so we don't override user-specified scopes.
  136. opts = append([]option.ClientOption{scopesOption}, opts...)
  137. client, endpoint, err := htransport.NewClient(ctx, opts...)
  138. if err != nil {
  139. return nil, err
  140. }
  141. s, err := New(client)
  142. if err != nil {
  143. return nil, err
  144. }
  145. if endpoint != "" {
  146. s.BasePath = endpoint
  147. }
  148. return s, nil
  149. }
  150. // New creates a new Service. It uses the provided http.Client for requests.
  151. //
  152. // Deprecated: please use NewService instead.
  153. // To provide a custom HTTP client, use option.WithHTTPClient.
  154. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  155. func New(client *http.Client) (*Service, error) {
  156. if client == nil {
  157. return nil, errors.New("client is nil")
  158. }
  159. s := &Service{client: client, BasePath: basePath}
  160. s.Users = NewUsersService(s)
  161. return s, nil
  162. }
  163. type Service struct {
  164. client *http.Client
  165. BasePath string // API endpoint base URL
  166. UserAgent string // optional additional User-Agent fragment
  167. Users *UsersService
  168. }
  169. func (s *Service) userAgent() string {
  170. if s.UserAgent == "" {
  171. return googleapi.UserAgent
  172. }
  173. return googleapi.UserAgent + " " + s.UserAgent
  174. }
  175. func NewUsersService(s *Service) *UsersService {
  176. rs := &UsersService{s: s}
  177. rs.DataSources = NewUsersDataSourcesService(s)
  178. rs.Dataset = NewUsersDatasetService(s)
  179. rs.Sessions = NewUsersSessionsService(s)
  180. return rs
  181. }
  182. type UsersService struct {
  183. s *Service
  184. DataSources *UsersDataSourcesService
  185. Dataset *UsersDatasetService
  186. Sessions *UsersSessionsService
  187. }
  188. func NewUsersDataSourcesService(s *Service) *UsersDataSourcesService {
  189. rs := &UsersDataSourcesService{s: s}
  190. rs.DataPointChanges = NewUsersDataSourcesDataPointChangesService(s)
  191. rs.Datasets = NewUsersDataSourcesDatasetsService(s)
  192. return rs
  193. }
  194. type UsersDataSourcesService struct {
  195. s *Service
  196. DataPointChanges *UsersDataSourcesDataPointChangesService
  197. Datasets *UsersDataSourcesDatasetsService
  198. }
  199. func NewUsersDataSourcesDataPointChangesService(s *Service) *UsersDataSourcesDataPointChangesService {
  200. rs := &UsersDataSourcesDataPointChangesService{s: s}
  201. return rs
  202. }
  203. type UsersDataSourcesDataPointChangesService struct {
  204. s *Service
  205. }
  206. func NewUsersDataSourcesDatasetsService(s *Service) *UsersDataSourcesDatasetsService {
  207. rs := &UsersDataSourcesDatasetsService{s: s}
  208. return rs
  209. }
  210. type UsersDataSourcesDatasetsService struct {
  211. s *Service
  212. }
  213. func NewUsersDatasetService(s *Service) *UsersDatasetService {
  214. rs := &UsersDatasetService{s: s}
  215. return rs
  216. }
  217. type UsersDatasetService struct {
  218. s *Service
  219. }
  220. func NewUsersSessionsService(s *Service) *UsersSessionsService {
  221. rs := &UsersSessionsService{s: s}
  222. return rs
  223. }
  224. type UsersSessionsService struct {
  225. s *Service
  226. }
  227. type AggregateBucket struct {
  228. // Activity: Available for Bucket.Type.ACTIVITY_TYPE,
  229. // Bucket.Type.ACTIVITY_SEGMENT
  230. Activity int64 `json:"activity,omitempty"`
  231. // Dataset: There will be one dataset per AggregateBy in the request.
  232. Dataset []*Dataset `json:"dataset,omitempty"`
  233. // EndTimeMillis: The end time for the aggregated data, in milliseconds
  234. // since epoch, inclusive.
  235. EndTimeMillis int64 `json:"endTimeMillis,omitempty,string"`
  236. // Session: Available for Bucket.Type.SESSION
  237. Session *Session `json:"session,omitempty"`
  238. // StartTimeMillis: The start time for the aggregated data, in
  239. // milliseconds since epoch, inclusive.
  240. StartTimeMillis int64 `json:"startTimeMillis,omitempty,string"`
  241. // Type: The type of a bucket signifies how the data aggregation is
  242. // performed in the bucket.
  243. //
  244. // Possible values:
  245. // "activitySegment"
  246. // "activityType"
  247. // "session"
  248. // "time"
  249. // "unknown"
  250. Type string `json:"type,omitempty"`
  251. // ForceSendFields is a list of field names (e.g. "Activity") to
  252. // unconditionally include in API requests. By default, fields with
  253. // empty values are omitted from API requests. However, any non-pointer,
  254. // non-interface field appearing in ForceSendFields will be sent to the
  255. // server regardless of whether the field is empty or not. This may be
  256. // used to include empty fields in Patch requests.
  257. ForceSendFields []string `json:"-"`
  258. // NullFields is a list of field names (e.g. "Activity") to include in
  259. // API requests with the JSON null value. By default, fields with empty
  260. // values are omitted from API requests. However, any field with an
  261. // empty value appearing in NullFields will be sent to the server as
  262. // null. It is an error if a field in this list has a non-empty value.
  263. // This may be used to include null fields in Patch requests.
  264. NullFields []string `json:"-"`
  265. }
  266. func (s *AggregateBucket) MarshalJSON() ([]byte, error) {
  267. type NoMethod AggregateBucket
  268. raw := NoMethod(*s)
  269. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  270. }
  271. // AggregateBy: The specification of which data to aggregate.
  272. type AggregateBy struct {
  273. // DataSourceId: A data source ID to aggregate. Mutually exclusive of
  274. // dataTypeName. Only data from the specified data source ID will be
  275. // included in the aggregation. The dataset in the response will have
  276. // the same data source ID.
  277. DataSourceId string `json:"dataSourceId,omitempty"`
  278. // DataTypeName: The data type to aggregate. All data sources providing
  279. // this data type will contribute data to the aggregation. The response
  280. // will contain a single dataset for this data type name. The dataset
  281. // will have a data source ID of
  282. // derived:com.google.:com.google.android.gms:aggregated
  283. DataTypeName string `json:"dataTypeName,omitempty"`
  284. // ForceSendFields is a list of field names (e.g. "DataSourceId") to
  285. // unconditionally include in API requests. By default, fields with
  286. // empty values are omitted from API requests. However, any non-pointer,
  287. // non-interface field appearing in ForceSendFields will be sent to the
  288. // server regardless of whether the field is empty or not. This may be
  289. // used to include empty fields in Patch requests.
  290. ForceSendFields []string `json:"-"`
  291. // NullFields is a list of field names (e.g. "DataSourceId") to include
  292. // in API requests with the JSON null value. By default, fields with
  293. // empty values are omitted from API requests. However, any field with
  294. // an empty value appearing in NullFields will be sent to the server as
  295. // null. It is an error if a field in this list has a non-empty value.
  296. // This may be used to include null fields in Patch requests.
  297. NullFields []string `json:"-"`
  298. }
  299. func (s *AggregateBy) MarshalJSON() ([]byte, error) {
  300. type NoMethod AggregateBy
  301. raw := NoMethod(*s)
  302. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  303. }
  304. // AggregateRequest: Next id: 10
  305. type AggregateRequest struct {
  306. // AggregateBy: The specification of data to be aggregated. At least one
  307. // aggregateBy spec must be provided. All data that is specified will be
  308. // aggregated using the same bucketing criteria. There will be one
  309. // dataset in the response for every aggregateBy spec.
  310. AggregateBy []*AggregateBy `json:"aggregateBy,omitempty"`
  311. // BucketByActivitySegment: Specifies that data be aggregated each
  312. // activity segment recored for a user. Similar to
  313. // bucketByActivitySegment, but bucketing is done for each activity
  314. // segment rather than all segments of the same type. Mutually exclusive
  315. // of other bucketing specifications.
  316. BucketByActivitySegment *BucketByActivity `json:"bucketByActivitySegment,omitempty"`
  317. // BucketByActivityType: Specifies that data be aggregated by the type
  318. // of activity being performed when the data was recorded. All data that
  319. // was recorded during a certain activity type (for the given time
  320. // range) will be aggregated into the same bucket. Data that was
  321. // recorded while the user was not active will not be included in the
  322. // response. Mutually exclusive of other bucketing specifications.
  323. BucketByActivityType *BucketByActivity `json:"bucketByActivityType,omitempty"`
  324. // BucketBySession: Specifies that data be aggregated by user sessions.
  325. // Data that does not fall within the time range of a session will not
  326. // be included in the response. Mutually exclusive of other bucketing
  327. // specifications.
  328. BucketBySession *BucketBySession `json:"bucketBySession,omitempty"`
  329. // BucketByTime: Specifies that data be aggregated by a single time
  330. // interval. Mutually exclusive of other bucketing specifications.
  331. BucketByTime *BucketByTime `json:"bucketByTime,omitempty"`
  332. // EndTimeMillis: The end of a window of time. Data that intersects with
  333. // this time window will be aggregated. The time is in milliseconds
  334. // since epoch, inclusive.
  335. EndTimeMillis int64 `json:"endTimeMillis,omitempty,string"`
  336. // FilteredDataQualityStandard: DO NOT POPULATE THIS FIELD. As data
  337. // quality standards are deprecated, filling it in will result in no
  338. // data sources being returned. It will be removed in a future version
  339. // entirely.
  340. //
  341. // Possible values:
  342. // "dataQualityBloodGlucoseIso151972003"
  343. // "dataQualityBloodGlucoseIso151972013"
  344. // "dataQualityBloodPressureAami"
  345. // "dataQualityBloodPressureBhsAA"
  346. // "dataQualityBloodPressureBhsAB"
  347. // "dataQualityBloodPressureBhsBA"
  348. // "dataQualityBloodPressureBhsBB"
  349. // "dataQualityBloodPressureEsh2002"
  350. // "dataQualityBloodPressureEsh2010"
  351. // "dataQualityUnknown"
  352. FilteredDataQualityStandard []string `json:"filteredDataQualityStandard,omitempty"`
  353. // StartTimeMillis: The start of a window of time. Data that intersects
  354. // with this time window will be aggregated. The time is in milliseconds
  355. // since epoch, inclusive.
  356. StartTimeMillis int64 `json:"startTimeMillis,omitempty,string"`
  357. // ForceSendFields is a list of field names (e.g. "AggregateBy") to
  358. // unconditionally include in API requests. By default, fields with
  359. // empty values are omitted from API requests. However, any non-pointer,
  360. // non-interface field appearing in ForceSendFields will be sent to the
  361. // server regardless of whether the field is empty or not. This may be
  362. // used to include empty fields in Patch requests.
  363. ForceSendFields []string `json:"-"`
  364. // NullFields is a list of field names (e.g. "AggregateBy") to include
  365. // in API requests with the JSON null value. By default, fields with
  366. // empty values are omitted from API requests. However, any field with
  367. // an empty value appearing in NullFields will be sent to the server as
  368. // null. It is an error if a field in this list has a non-empty value.
  369. // This may be used to include null fields in Patch requests.
  370. NullFields []string `json:"-"`
  371. }
  372. func (s *AggregateRequest) MarshalJSON() ([]byte, error) {
  373. type NoMethod AggregateRequest
  374. raw := NoMethod(*s)
  375. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  376. }
  377. type AggregateResponse struct {
  378. // Bucket: A list of buckets containing the aggregated data.
  379. Bucket []*AggregateBucket `json:"bucket,omitempty"`
  380. // ServerResponse contains the HTTP response code and headers from the
  381. // server.
  382. googleapi.ServerResponse `json:"-"`
  383. // ForceSendFields is a list of field names (e.g. "Bucket") to
  384. // unconditionally include in API requests. By default, fields with
  385. // empty values are omitted from API requests. However, any non-pointer,
  386. // non-interface field appearing in ForceSendFields will be sent to the
  387. // server regardless of whether the field is empty or not. This may be
  388. // used to include empty fields in Patch requests.
  389. ForceSendFields []string `json:"-"`
  390. // NullFields is a list of field names (e.g. "Bucket") to include in API
  391. // requests with the JSON null value. By default, fields with empty
  392. // values are omitted from API requests. However, any field with an
  393. // empty value appearing in NullFields will be sent to the server as
  394. // null. It is an error if a field in this list has a non-empty value.
  395. // This may be used to include null fields in Patch requests.
  396. NullFields []string `json:"-"`
  397. }
  398. func (s *AggregateResponse) MarshalJSON() ([]byte, error) {
  399. type NoMethod AggregateResponse
  400. raw := NoMethod(*s)
  401. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  402. }
  403. type Application struct {
  404. // DetailsUrl: An optional URI that can be used to link back to the
  405. // application.
  406. DetailsUrl string `json:"detailsUrl,omitempty"`
  407. // Name: The name of this application. This is required for REST
  408. // clients, but we do not enforce uniqueness of this name. It is
  409. // provided as a matter of convenience for other developers who would
  410. // like to identify which REST created an Application or Data Source.
  411. Name string `json:"name,omitempty"`
  412. // PackageName: Package name for this application. This is used as a
  413. // unique identifier when created by Android applications, but cannot be
  414. // specified by REST clients. REST clients will have their developer
  415. // project number reflected into the Data Source data stream IDs,
  416. // instead of the packageName.
  417. PackageName string `json:"packageName,omitempty"`
  418. // Version: Version of the application. You should update this field
  419. // whenever the application changes in a way that affects the
  420. // computation of the data.
  421. Version string `json:"version,omitempty"`
  422. // ForceSendFields is a list of field names (e.g. "DetailsUrl") to
  423. // unconditionally include in API requests. By default, fields with
  424. // empty values are omitted from API requests. However, any non-pointer,
  425. // non-interface field appearing in ForceSendFields will be sent to the
  426. // server regardless of whether the field is empty or not. This may be
  427. // used to include empty fields in Patch requests.
  428. ForceSendFields []string `json:"-"`
  429. // NullFields is a list of field names (e.g. "DetailsUrl") to include in
  430. // API requests with the JSON null value. By default, fields with empty
  431. // values are omitted from API requests. However, any field with an
  432. // empty value appearing in NullFields will be sent to the server as
  433. // null. It is an error if a field in this list has a non-empty value.
  434. // This may be used to include null fields in Patch requests.
  435. NullFields []string `json:"-"`
  436. }
  437. func (s *Application) MarshalJSON() ([]byte, error) {
  438. type NoMethod Application
  439. raw := NoMethod(*s)
  440. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  441. }
  442. type BucketByActivity struct {
  443. // ActivityDataSourceId: The default activity stream will be used if a
  444. // specific activityDataSourceId is not specified.
  445. ActivityDataSourceId string `json:"activityDataSourceId,omitempty"`
  446. // MinDurationMillis: Specifies that only activity segments of duration
  447. // longer than minDurationMillis are considered and used as a container
  448. // for aggregated data.
  449. MinDurationMillis int64 `json:"minDurationMillis,omitempty,string"`
  450. // ForceSendFields is a list of field names (e.g.
  451. // "ActivityDataSourceId") to unconditionally include in API requests.
  452. // By default, fields with empty values are omitted from API requests.
  453. // However, any non-pointer, non-interface field appearing in
  454. // ForceSendFields will be sent to the server regardless of whether the
  455. // field is empty or not. This may be used to include empty fields in
  456. // Patch requests.
  457. ForceSendFields []string `json:"-"`
  458. // NullFields is a list of field names (e.g. "ActivityDataSourceId") to
  459. // include in API requests with the JSON null value. By default, fields
  460. // with empty values are omitted from API requests. However, any field
  461. // with an empty value appearing in NullFields will be sent to the
  462. // server as null. It is an error if a field in this list has a
  463. // non-empty value. This may be used to include null fields in Patch
  464. // requests.
  465. NullFields []string `json:"-"`
  466. }
  467. func (s *BucketByActivity) MarshalJSON() ([]byte, error) {
  468. type NoMethod BucketByActivity
  469. raw := NoMethod(*s)
  470. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  471. }
  472. type BucketBySession struct {
  473. // MinDurationMillis: Specifies that only sessions of duration longer
  474. // than minDurationMillis are considered and used as a container for
  475. // aggregated data.
  476. MinDurationMillis int64 `json:"minDurationMillis,omitempty,string"`
  477. // ForceSendFields is a list of field names (e.g. "MinDurationMillis")
  478. // to unconditionally include in API requests. By default, fields with
  479. // empty values are omitted from API requests. However, any non-pointer,
  480. // non-interface field appearing in ForceSendFields will be sent to the
  481. // server regardless of whether the field is empty or not. This may be
  482. // used to include empty fields in Patch requests.
  483. ForceSendFields []string `json:"-"`
  484. // NullFields is a list of field names (e.g. "MinDurationMillis") to
  485. // include in API requests with the JSON null value. By default, fields
  486. // with empty values are omitted from API requests. However, any field
  487. // with an empty value appearing in NullFields will be sent to the
  488. // server as null. It is an error if a field in this list has a
  489. // non-empty value. This may be used to include null fields in Patch
  490. // requests.
  491. NullFields []string `json:"-"`
  492. }
  493. func (s *BucketBySession) MarshalJSON() ([]byte, error) {
  494. type NoMethod BucketBySession
  495. raw := NoMethod(*s)
  496. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  497. }
  498. type BucketByTime struct {
  499. // DurationMillis: Specifies that result buckets aggregate data by
  500. // exactly durationMillis time frames. Time frames that contain no data
  501. // will be included in the response with an empty dataset.
  502. DurationMillis int64 `json:"durationMillis,omitempty,string"`
  503. Period *BucketByTimePeriod `json:"period,omitempty"`
  504. // ForceSendFields is a list of field names (e.g. "DurationMillis") to
  505. // unconditionally include in API requests. By default, fields with
  506. // empty values are omitted from API requests. However, any non-pointer,
  507. // non-interface field appearing in ForceSendFields will be sent to the
  508. // server regardless of whether the field is empty or not. This may be
  509. // used to include empty fields in Patch requests.
  510. ForceSendFields []string `json:"-"`
  511. // NullFields is a list of field names (e.g. "DurationMillis") to
  512. // include in API requests with the JSON null value. By default, fields
  513. // with empty values are omitted from API requests. However, any field
  514. // with an empty value appearing in NullFields will be sent to the
  515. // server as null. It is an error if a field in this list has a
  516. // non-empty value. This may be used to include null fields in Patch
  517. // requests.
  518. NullFields []string `json:"-"`
  519. }
  520. func (s *BucketByTime) MarshalJSON() ([]byte, error) {
  521. type NoMethod BucketByTime
  522. raw := NoMethod(*s)
  523. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  524. }
  525. type BucketByTimePeriod struct {
  526. // TimeZoneId: org.joda.timezone.DateTimeZone
  527. TimeZoneId string `json:"timeZoneId,omitempty"`
  528. // Possible values:
  529. // "day"
  530. // "month"
  531. // "week"
  532. Type string `json:"type,omitempty"`
  533. Value int64 `json:"value,omitempty"`
  534. // ForceSendFields is a list of field names (e.g. "TimeZoneId") to
  535. // unconditionally include in API requests. By default, fields with
  536. // empty values are omitted from API requests. However, any non-pointer,
  537. // non-interface field appearing in ForceSendFields will be sent to the
  538. // server regardless of whether the field is empty or not. This may be
  539. // used to include empty fields in Patch requests.
  540. ForceSendFields []string `json:"-"`
  541. // NullFields is a list of field names (e.g. "TimeZoneId") to include in
  542. // API requests with the JSON null value. By default, fields with empty
  543. // values are omitted from API requests. However, any field with an
  544. // empty value appearing in NullFields will be sent to the server as
  545. // null. It is an error if a field in this list has a non-empty value.
  546. // This may be used to include null fields in Patch requests.
  547. NullFields []string `json:"-"`
  548. }
  549. func (s *BucketByTimePeriod) MarshalJSON() ([]byte, error) {
  550. type NoMethod BucketByTimePeriod
  551. raw := NoMethod(*s)
  552. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  553. }
  554. // DataPoint: Represents a single data point, generated by a particular
  555. // data source. A data point holds a value for each field, an end
  556. // timestamp and an optional start time. The exact semantics of each of
  557. // these attributes are specified in the documentation for the
  558. // particular data type.
  559. //
  560. // A data point can represent an instantaneous measurement, reading or
  561. // input observation, as well as averages or aggregates over a time
  562. // interval. Check the data type documentation to determine which is the
  563. // case for a particular data type.
  564. //
  565. // Data points always contain one value for each field of the data type.
  566. type DataPoint struct {
  567. // ComputationTimeMillis: DO NOT USE THIS FIELD. It is ignored, and not
  568. // stored.
  569. ComputationTimeMillis int64 `json:"computationTimeMillis,omitempty,string"`
  570. // DataTypeName: The data type defining the format of the values in this
  571. // data point.
  572. DataTypeName string `json:"dataTypeName,omitempty"`
  573. // EndTimeNanos: The end time of the interval represented by this data
  574. // point, in nanoseconds since epoch.
  575. EndTimeNanos int64 `json:"endTimeNanos,omitempty,string"`
  576. // ModifiedTimeMillis: Indicates the last time this data point was
  577. // modified. Useful only in contexts where we are listing the data
  578. // changes, rather than representing the current state of the data.
  579. ModifiedTimeMillis int64 `json:"modifiedTimeMillis,omitempty,string"`
  580. // OriginDataSourceId: If the data point is contained in a dataset for a
  581. // derived data source, this field will be populated with the data
  582. // source stream ID that created the data point originally.
  583. //
  584. // WARNING: do not rely on this field for anything other than debugging.
  585. // The value of this field, if it is set at all, is an implementation
  586. // detail and is not guaranteed to remain consistent.
  587. OriginDataSourceId string `json:"originDataSourceId,omitempty"`
  588. // RawTimestampNanos: The raw timestamp from the original SensorEvent.
  589. RawTimestampNanos int64 `json:"rawTimestampNanos,omitempty,string"`
  590. // StartTimeNanos: The start time of the interval represented by this
  591. // data point, in nanoseconds since epoch.
  592. StartTimeNanos int64 `json:"startTimeNanos,omitempty,string"`
  593. // Value: Values of each data type field for the data point. It is
  594. // expected that each value corresponding to a data type field will
  595. // occur in the same order that the field is listed with in the data
  596. // type specified in a data source.
  597. //
  598. // Only one of integer and floating point fields will be populated,
  599. // depending on the format enum value within data source's type field.
  600. Value []*Value `json:"value,omitempty"`
  601. // ForceSendFields is a list of field names (e.g.
  602. // "ComputationTimeMillis") to unconditionally include in API requests.
  603. // By default, fields with empty values are omitted from API requests.
  604. // However, any non-pointer, non-interface field appearing in
  605. // ForceSendFields will be sent to the server regardless of whether the
  606. // field is empty or not. This may be used to include empty fields in
  607. // Patch requests.
  608. ForceSendFields []string `json:"-"`
  609. // NullFields is a list of field names (e.g. "ComputationTimeMillis") to
  610. // include in API requests with the JSON null value. By default, fields
  611. // with empty values are omitted from API requests. However, any field
  612. // with an empty value appearing in NullFields will be sent to the
  613. // server as null. It is an error if a field in this list has a
  614. // non-empty value. This may be used to include null fields in Patch
  615. // requests.
  616. NullFields []string `json:"-"`
  617. }
  618. func (s *DataPoint) MarshalJSON() ([]byte, error) {
  619. type NoMethod DataPoint
  620. raw := NoMethod(*s)
  621. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  622. }
  623. // DataSource: Definition of a unique source of sensor data. Data
  624. // sources can expose raw data coming from hardware sensors on local or
  625. // companion devices. They can also expose derived data, created by
  626. // transforming or merging other data sources. Multiple data sources can
  627. // exist for the same data type. Every data point inserted into or read
  628. // from this service has an associated data source.
  629. //
  630. // The data source contains enough information to uniquely identify its
  631. // data, including the hardware device and the application that
  632. // collected and/or transformed the data. It also holds useful metadata,
  633. // such as the hardware and application versions, and the device
  634. // type.
  635. //
  636. // Each data source produces a unique stream of data, with a unique
  637. // identifier. Not all changes to data source affect the stream
  638. // identifier, so that data collected by updated versions of the same
  639. // application/device can still be considered to belong to the same data
  640. // stream.
  641. type DataSource struct {
  642. // Application: Information about an application which feeds sensor data
  643. // into the platform.
  644. Application *Application `json:"application,omitempty"`
  645. // DataQualityStandard: DO NOT POPULATE THIS FIELD. It is never
  646. // populated in responses from the platform, and is ignored in queries.
  647. // It will be removed in a future version entirely.
  648. //
  649. // Possible values:
  650. // "dataQualityBloodGlucoseIso151972003"
  651. // "dataQualityBloodGlucoseIso151972013"
  652. // "dataQualityBloodPressureAami"
  653. // "dataQualityBloodPressureBhsAA"
  654. // "dataQualityBloodPressureBhsAB"
  655. // "dataQualityBloodPressureBhsBA"
  656. // "dataQualityBloodPressureBhsBB"
  657. // "dataQualityBloodPressureEsh2002"
  658. // "dataQualityBloodPressureEsh2010"
  659. // "dataQualityUnknown"
  660. DataQualityStandard []string `json:"dataQualityStandard,omitempty"`
  661. // DataStreamId: A unique identifier for the data stream produced by
  662. // this data source. The identifier includes:
  663. //
  664. //
  665. // - The physical device's manufacturer, model, and serial number (UID).
  666. //
  667. // - The application's package name or name. Package name is used when
  668. // the data source was created by an Android application. The developer
  669. // project number is used when the data source was created by a REST
  670. // client.
  671. // - The data source's type.
  672. // - The data source's stream name. Note that not all attributes of the
  673. // data source are used as part of the stream identifier. In particular,
  674. // the version of the hardware/the application isn't used. This allows
  675. // us to preserve the same stream through version updates. This also
  676. // means that two DataSource objects may represent the same data stream
  677. // even if they're not equal.
  678. //
  679. // The exact format of the data stream ID created by an Android
  680. // application is:
  681. // type:dataType.name:application.packageName:device.manufacturer:device.
  682. // model:device.uid:dataStreamName
  683. //
  684. // The exact format of the data stream ID created by a REST client is:
  685. // type:dataType.name:developer project
  686. // number:device.manufacturer:device.model:device.uid:dataStreamName
  687. //
  688. //
  689. // When any of the optional fields that comprise of the data stream ID
  690. // are blank, they will be omitted from the data stream ID. The minimum
  691. // viable data stream ID would be: type:dataType.name:developer project
  692. // number
  693. //
  694. // Finally, the developer project number is obfuscated when read by any
  695. // REST or Android client that did not create the data source. Only the
  696. // data source creator will see the developer project number in clear
  697. // and normal form.
  698. DataStreamId string `json:"dataStreamId,omitempty"`
  699. // DataStreamName: The stream name uniquely identifies this particular
  700. // data source among other data sources of the same type from the same
  701. // underlying producer. Setting the stream name is optional, but should
  702. // be done whenever an application exposes two streams for the same data
  703. // type, or when a device has two equivalent sensors.
  704. DataStreamName string `json:"dataStreamName,omitempty"`
  705. // DataType: The data type defines the schema for a stream of data being
  706. // collected by, inserted into, or queried from the Fitness API.
  707. DataType *DataType `json:"dataType,omitempty"`
  708. // Device: Representation of an integrated device (such as a phone or a
  709. // wearable) that can hold sensors.
  710. Device *Device `json:"device,omitempty"`
  711. // Name: An end-user visible name for this data source.
  712. Name string `json:"name,omitempty"`
  713. // Type: A constant describing the type of this data source. Indicates
  714. // whether this data source produces raw or derived data.
  715. //
  716. // Possible values:
  717. // "derived"
  718. // "raw"
  719. Type string `json:"type,omitempty"`
  720. // ServerResponse contains the HTTP response code and headers from the
  721. // server.
  722. googleapi.ServerResponse `json:"-"`
  723. // ForceSendFields is a list of field names (e.g. "Application") to
  724. // unconditionally include in API requests. By default, fields with
  725. // empty values are omitted from API requests. However, any non-pointer,
  726. // non-interface field appearing in ForceSendFields will be sent to the
  727. // server regardless of whether the field is empty or not. This may be
  728. // used to include empty fields in Patch requests.
  729. ForceSendFields []string `json:"-"`
  730. // NullFields is a list of field names (e.g. "Application") to include
  731. // in API requests with the JSON null value. By default, fields with
  732. // empty values are omitted from API requests. However, any field with
  733. // an empty value appearing in NullFields will be sent to the server as
  734. // null. It is an error if a field in this list has a non-empty value.
  735. // This may be used to include null fields in Patch requests.
  736. NullFields []string `json:"-"`
  737. }
  738. func (s *DataSource) MarshalJSON() ([]byte, error) {
  739. type NoMethod DataSource
  740. raw := NoMethod(*s)
  741. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  742. }
  743. type DataType struct {
  744. // Field: A field represents one dimension of a data type.
  745. Field []*DataTypeField `json:"field,omitempty"`
  746. // Name: Each data type has a unique, namespaced, name. All data types
  747. // in the com.google namespace are shared as part of the platform.
  748. Name string `json:"name,omitempty"`
  749. // ForceSendFields is a list of field names (e.g. "Field") to
  750. // unconditionally include in API requests. By default, fields with
  751. // empty values are omitted from API requests. However, any non-pointer,
  752. // non-interface field appearing in ForceSendFields will be sent to the
  753. // server regardless of whether the field is empty or not. This may be
  754. // used to include empty fields in Patch requests.
  755. ForceSendFields []string `json:"-"`
  756. // NullFields is a list of field names (e.g. "Field") to include in API
  757. // requests with the JSON null value. By default, fields with empty
  758. // values are omitted from API requests. However, any field with an
  759. // empty value appearing in NullFields will be sent to the server as
  760. // null. It is an error if a field in this list has a non-empty value.
  761. // This may be used to include null fields in Patch requests.
  762. NullFields []string `json:"-"`
  763. }
  764. func (s *DataType) MarshalJSON() ([]byte, error) {
  765. type NoMethod DataType
  766. raw := NoMethod(*s)
  767. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  768. }
  769. // DataTypeField: In case of multi-dimensional data (such as an
  770. // accelerometer with x, y, and z axes) each field represents one
  771. // dimension. Each data type field has a unique name which identifies
  772. // it. The field also defines the format of the data (int, float,
  773. // etc.).
  774. //
  775. // This message is only instantiated in code and not used for wire comms
  776. // or stored in any way.
  777. type DataTypeField struct {
  778. // Format: The different supported formats for each field in a data
  779. // type.
  780. //
  781. // Possible values:
  782. // "blob"
  783. // "floatList"
  784. // "floatPoint"
  785. // "integer"
  786. // "integerList"
  787. // "map"
  788. // "string"
  789. Format string `json:"format,omitempty"`
  790. // Name: Defines the name and format of data. Unlike data type names,
  791. // field names are not namespaced, and only need to be unique within the
  792. // data type.
  793. Name string `json:"name,omitempty"`
  794. Optional bool `json:"optional,omitempty"`
  795. // ForceSendFields is a list of field names (e.g. "Format") to
  796. // unconditionally include in API requests. By default, fields with
  797. // empty values are omitted from API requests. However, any non-pointer,
  798. // non-interface field appearing in ForceSendFields will be sent to the
  799. // server regardless of whether the field is empty or not. This may be
  800. // used to include empty fields in Patch requests.
  801. ForceSendFields []string `json:"-"`
  802. // NullFields is a list of field names (e.g. "Format") to include in API
  803. // requests with the JSON null value. By default, fields with empty
  804. // values are omitted from API requests. However, any field with an
  805. // empty value appearing in NullFields will be sent to the server as
  806. // null. It is an error if a field in this list has a non-empty value.
  807. // This may be used to include null fields in Patch requests.
  808. NullFields []string `json:"-"`
  809. }
  810. func (s *DataTypeField) MarshalJSON() ([]byte, error) {
  811. type NoMethod DataTypeField
  812. raw := NoMethod(*s)
  813. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  814. }
  815. // Dataset: A dataset represents a projection container for data points.
  816. // They do not carry any info of their own. Datasets represent a set of
  817. // data points from a particular data source. A data point can be found
  818. // in more than one dataset.
  819. type Dataset struct {
  820. // DataSourceId: The data stream ID of the data source that created the
  821. // points in this dataset.
  822. DataSourceId string `json:"dataSourceId,omitempty"`
  823. // MaxEndTimeNs: The largest end time of all data points in this
  824. // possibly partial representation of the dataset. Time is in
  825. // nanoseconds from epoch. This should also match the second part of the
  826. // dataset identifier.
  827. MaxEndTimeNs int64 `json:"maxEndTimeNs,omitempty,string"`
  828. // MinStartTimeNs: The smallest start time of all data points in this
  829. // possibly partial representation of the dataset. Time is in
  830. // nanoseconds from epoch. This should also match the first part of the
  831. // dataset identifier.
  832. MinStartTimeNs int64 `json:"minStartTimeNs,omitempty,string"`
  833. // NextPageToken: This token will be set when a dataset is received in
  834. // response to a GET request and the dataset is too large to be included
  835. // in a single response. Provide this value in a subsequent GET request
  836. // to return the next page of data points within this dataset.
  837. NextPageToken string `json:"nextPageToken,omitempty"`
  838. // Point: A partial list of data points contained in the dataset,
  839. // ordered by largest endTimeNanos first. This list is considered
  840. // complete when retrieving a small dataset and partial when patching a
  841. // dataset or retrieving a dataset that is too large to include in a
  842. // single response.
  843. Point []*DataPoint `json:"point,omitempty"`
  844. // ServerResponse contains the HTTP response code and headers from the
  845. // server.
  846. googleapi.ServerResponse `json:"-"`
  847. // ForceSendFields is a list of field names (e.g. "DataSourceId") to
  848. // unconditionally include in API requests. By default, fields with
  849. // empty values are omitted from API requests. However, any non-pointer,
  850. // non-interface field appearing in ForceSendFields will be sent to the
  851. // server regardless of whether the field is empty or not. This may be
  852. // used to include empty fields in Patch requests.
  853. ForceSendFields []string `json:"-"`
  854. // NullFields is a list of field names (e.g. "DataSourceId") to include
  855. // in API requests with the JSON null value. By default, fields with
  856. // empty values are omitted from API requests. However, any field with
  857. // an empty value appearing in NullFields will be sent to the server as
  858. // null. It is an error if a field in this list has a non-empty value.
  859. // This may be used to include null fields in Patch requests.
  860. NullFields []string `json:"-"`
  861. }
  862. func (s *Dataset) MarshalJSON() ([]byte, error) {
  863. type NoMethod Dataset
  864. raw := NoMethod(*s)
  865. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  866. }
  867. // Device: Representation of an integrated device (such as a phone or a
  868. // wearable) that can hold sensors. Each sensor is exposed as a data
  869. // source.
  870. //
  871. // The main purpose of the device information contained in this class is
  872. // to identify the hardware of a particular data source. This can be
  873. // useful in different ways, including:
  874. // - Distinguishing two similar sensors on different devices (the step
  875. // counter on two nexus 5 phones, for instance)
  876. // - Display the source of data to the user (by using the device make /
  877. // model)
  878. // - Treat data differently depending on sensor type (accelerometers on
  879. // a watch may give different patterns than those on a phone)
  880. // - Build different analysis models for each device/version.
  881. type Device struct {
  882. // Manufacturer: Manufacturer of the product/hardware.
  883. Manufacturer string `json:"manufacturer,omitempty"`
  884. // Model: End-user visible model name for the device.
  885. Model string `json:"model,omitempty"`
  886. // Type: A constant representing the type of the device.
  887. //
  888. // Possible values:
  889. // "chestStrap"
  890. // "headMounted"
  891. // "phone"
  892. // "scale"
  893. // "tablet"
  894. // "unknown"
  895. // "watch"
  896. Type string `json:"type,omitempty"`
  897. // Uid: The serial number or other unique ID for the hardware. This
  898. // field is obfuscated when read by any REST or Android client that did
  899. // not create the data source. Only the data source creator will see the
  900. // uid field in clear and normal form.
  901. Uid string `json:"uid,omitempty"`
  902. // Version: Version string for the device hardware/software.
  903. Version string `json:"version,omitempty"`
  904. // ForceSendFields is a list of field names (e.g. "Manufacturer") to
  905. // unconditionally include in API requests. By default, fields with
  906. // empty values are omitted from API requests. However, any non-pointer,
  907. // non-interface field appearing in ForceSendFields will be sent to the
  908. // server regardless of whether the field is empty or not. This may be
  909. // used to include empty fields in Patch requests.
  910. ForceSendFields []string `json:"-"`
  911. // NullFields is a list of field names (e.g. "Manufacturer") to include
  912. // in API requests with the JSON null value. By default, fields with
  913. // empty values are omitted from API requests. However, any field with
  914. // an empty value appearing in NullFields will be sent to the server as
  915. // null. It is an error if a field in this list has a non-empty value.
  916. // This may be used to include null fields in Patch requests.
  917. NullFields []string `json:"-"`
  918. }
  919. func (s *Device) MarshalJSON() ([]byte, error) {
  920. type NoMethod Device
  921. raw := NoMethod(*s)
  922. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  923. }
  924. type ListDataPointChangesResponse struct {
  925. // DataSourceId: The data stream ID of the data source with data point
  926. // changes.
  927. DataSourceId string `json:"dataSourceId,omitempty"`
  928. // DeletedDataPoint: Deleted data points for the user. Note, for
  929. // modifications this should be parsed before handling insertions.
  930. DeletedDataPoint []*DataPoint `json:"deletedDataPoint,omitempty"`
  931. // InsertedDataPoint: Inserted data points for the user.
  932. InsertedDataPoint []*DataPoint `json:"insertedDataPoint,omitempty"`
  933. // NextPageToken: The continuation token, which is used to page through
  934. // large result sets. Provide this value in a subsequent request to
  935. // return the next page of results.
  936. NextPageToken string `json:"nextPageToken,omitempty"`
  937. // ServerResponse contains the HTTP response code and headers from the
  938. // server.
  939. googleapi.ServerResponse `json:"-"`
  940. // ForceSendFields is a list of field names (e.g. "DataSourceId") to
  941. // unconditionally include in API requests. By default, fields with
  942. // empty values are omitted from API requests. However, any non-pointer,
  943. // non-interface field appearing in ForceSendFields will be sent to the
  944. // server regardless of whether the field is empty or not. This may be
  945. // used to include empty fields in Patch requests.
  946. ForceSendFields []string `json:"-"`
  947. // NullFields is a list of field names (e.g. "DataSourceId") to include
  948. // in API requests with the JSON null value. By default, fields with
  949. // empty values are omitted from API requests. However, any field with
  950. // an empty value appearing in NullFields will be sent to the server as
  951. // null. It is an error if a field in this list has a non-empty value.
  952. // This may be used to include null fields in Patch requests.
  953. NullFields []string `json:"-"`
  954. }
  955. func (s *ListDataPointChangesResponse) MarshalJSON() ([]byte, error) {
  956. type NoMethod ListDataPointChangesResponse
  957. raw := NoMethod(*s)
  958. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  959. }
  960. type ListDataSourcesResponse struct {
  961. // DataSource: A previously created data source.
  962. DataSource []*DataSource `json:"dataSource,omitempty"`
  963. // ServerResponse contains the HTTP response code and headers from the
  964. // server.
  965. googleapi.ServerResponse `json:"-"`
  966. // ForceSendFields is a list of field names (e.g. "DataSource") to
  967. // unconditionally include in API requests. By default, fields with
  968. // empty values are omitted from API requests. However, any non-pointer,
  969. // non-interface field appearing in ForceSendFields will be sent to the
  970. // server regardless of whether the field is empty or not. This may be
  971. // used to include empty fields in Patch requests.
  972. ForceSendFields []string `json:"-"`
  973. // NullFields is a list of field names (e.g. "DataSource") to include in
  974. // API requests with the JSON null value. By default, fields with empty
  975. // values are omitted from API requests. However, any field with an
  976. // empty value appearing in NullFields will be sent to the server as
  977. // null. It is an error if a field in this list has a non-empty value.
  978. // This may be used to include null fields in Patch requests.
  979. NullFields []string `json:"-"`
  980. }
  981. func (s *ListDataSourcesResponse) MarshalJSON() ([]byte, error) {
  982. type NoMethod ListDataSourcesResponse
  983. raw := NoMethod(*s)
  984. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  985. }
  986. type ListSessionsResponse struct {
  987. // DeletedSession: If includeDeleted is set to true in the request, this
  988. // list will contain sessions deleted with original end times that are
  989. // within the startTime and endTime frame.
  990. DeletedSession []*Session `json:"deletedSession,omitempty"`
  991. // HasMoreData: Flag to indicate server has more data to transfer
  992. HasMoreData bool `json:"hasMoreData,omitempty"`
  993. // NextPageToken: The continuation token, which is used to page through
  994. // large result sets. Provide this value in a subsequent request to
  995. // return the next page of results.
  996. NextPageToken string `json:"nextPageToken,omitempty"`
  997. // Session: Sessions with an end time that is between startTime and
  998. // endTime of the request.
  999. Session []*Session `json:"session,omitempty"`
  1000. // ServerResponse contains the HTTP response code and headers from the
  1001. // server.
  1002. googleapi.ServerResponse `json:"-"`
  1003. // ForceSendFields is a list of field names (e.g. "DeletedSession") to
  1004. // unconditionally include in API requests. By default, fields with
  1005. // empty values are omitted from API requests. However, any non-pointer,
  1006. // non-interface field appearing in ForceSendFields will be sent to the
  1007. // server regardless of whether the field is empty or not. This may be
  1008. // used to include empty fields in Patch requests.
  1009. ForceSendFields []string `json:"-"`
  1010. // NullFields is a list of field names (e.g. "DeletedSession") to
  1011. // include in API requests with the JSON null value. By default, fields
  1012. // with empty values are omitted from API requests. However, any field
  1013. // with an empty value appearing in NullFields will be sent to the
  1014. // server as null. It is an error if a field in this list has a
  1015. // non-empty value. This may be used to include null fields in Patch
  1016. // requests.
  1017. NullFields []string `json:"-"`
  1018. }
  1019. func (s *ListSessionsResponse) MarshalJSON() ([]byte, error) {
  1020. type NoMethod ListSessionsResponse
  1021. raw := NoMethod(*s)
  1022. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1023. }
  1024. // MapValue: Holder object for the value of an entry in a map field of a
  1025. // data point.
  1026. //
  1027. // A map value supports a subset of the formats that the regular Value
  1028. // supports.
  1029. type MapValue struct {
  1030. // FpVal: Floating point value.
  1031. FpVal float64 `json:"fpVal,omitempty"`
  1032. // ForceSendFields is a list of field names (e.g. "FpVal") to
  1033. // unconditionally include in API requests. By default, fields with
  1034. // empty values are omitted from API requests. However, any non-pointer,
  1035. // non-interface field appearing in ForceSendFields will be sent to the
  1036. // server regardless of whether the field is empty or not. This may be
  1037. // used to include empty fields in Patch requests.
  1038. ForceSendFields []string `json:"-"`
  1039. // NullFields is a list of field names (e.g. "FpVal") to include in API
  1040. // requests with the JSON null value. By default, fields with empty
  1041. // values are omitted from API requests. However, any field with an
  1042. // empty value appearing in NullFields will be sent to the server as
  1043. // null. It is an error if a field in this list has a non-empty value.
  1044. // This may be used to include null fields in Patch requests.
  1045. NullFields []string `json:"-"`
  1046. }
  1047. func (s *MapValue) MarshalJSON() ([]byte, error) {
  1048. type NoMethod MapValue
  1049. raw := NoMethod(*s)
  1050. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1051. }
  1052. func (s *MapValue) UnmarshalJSON(data []byte) error {
  1053. type NoMethod MapValue
  1054. var s1 struct {
  1055. FpVal gensupport.JSONFloat64 `json:"fpVal"`
  1056. *NoMethod
  1057. }
  1058. s1.NoMethod = (*NoMethod)(s)
  1059. if err := json.Unmarshal(data, &s1); err != nil {
  1060. return err
  1061. }
  1062. s.FpVal = float64(s1.FpVal)
  1063. return nil
  1064. }
  1065. // Session: Sessions contain metadata, such as a user-friendly name and
  1066. // time interval information.
  1067. type Session struct {
  1068. // ActiveTimeMillis: Session active time. While start_time_millis and
  1069. // end_time_millis define the full session time, the active time can be
  1070. // shorter and specified by active_time_millis. If the inactive time
  1071. // during the session is known, it should also be inserted via a
  1072. // com.google.activity.segment data point with a STILL activity value
  1073. ActiveTimeMillis int64 `json:"activeTimeMillis,omitempty,string"`
  1074. // ActivityType: The type of activity this session represents.
  1075. ActivityType int64 `json:"activityType,omitempty"`
  1076. // Application: The application that created the session.
  1077. Application *Application `json:"application,omitempty"`
  1078. // Description: A description for this session.
  1079. Description string `json:"description,omitempty"`
  1080. // EndTimeMillis: An end time, in milliseconds since epoch, inclusive.
  1081. EndTimeMillis int64 `json:"endTimeMillis,omitempty,string"`
  1082. // Id: A client-generated identifier that is unique across all sessions
  1083. // owned by this particular user.
  1084. Id string `json:"id,omitempty"`
  1085. // ModifiedTimeMillis: A timestamp that indicates when the session was
  1086. // last modified.
  1087. ModifiedTimeMillis int64 `json:"modifiedTimeMillis,omitempty,string"`
  1088. // Name: A human readable name of the session.
  1089. Name string `json:"name,omitempty"`
  1090. // StartTimeMillis: A start time, in milliseconds since epoch,
  1091. // inclusive.
  1092. StartTimeMillis int64 `json:"startTimeMillis,omitempty,string"`
  1093. // ServerResponse contains the HTTP response code and headers from the
  1094. // server.
  1095. googleapi.ServerResponse `json:"-"`
  1096. // ForceSendFields is a list of field names (e.g. "ActiveTimeMillis") to
  1097. // unconditionally include in API requests. By default, fields with
  1098. // empty values are omitted from API requests. However, any non-pointer,
  1099. // non-interface field appearing in ForceSendFields will be sent to the
  1100. // server regardless of whether the field is empty or not. This may be
  1101. // used to include empty fields in Patch requests.
  1102. ForceSendFields []string `json:"-"`
  1103. // NullFields is a list of field names (e.g. "ActiveTimeMillis") to
  1104. // include in API requests with the JSON null value. By default, fields
  1105. // with empty values are omitted from API requests. However, any field
  1106. // with an empty value appearing in NullFields will be sent to the
  1107. // server as null. It is an error if a field in this list has a
  1108. // non-empty value. This may be used to include null fields in Patch
  1109. // requests.
  1110. NullFields []string `json:"-"`
  1111. }
  1112. func (s *Session) MarshalJSON() ([]byte, error) {
  1113. type NoMethod Session
  1114. raw := NoMethod(*s)
  1115. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1116. }
  1117. // Value: Holder object for the value of a single field in a data
  1118. // point.
  1119. //
  1120. // A field value has a particular format and is only ever set to one of
  1121. // an integer or a floating point value. LINT.IfChange
  1122. type Value struct {
  1123. // FpVal: Floating point value. When this is set, other values must not
  1124. // be set.
  1125. FpVal float64 `json:"fpVal,omitempty"`
  1126. // IntVal: Integer value. When this is set, other values must not be
  1127. // set.
  1128. IntVal int64 `json:"intVal,omitempty"`
  1129. // MapVal: Map value. The valid key space and units for the
  1130. // corresponding value of each entry should be documented as part of the
  1131. // data type definition. Keys should be kept small whenever possible.
  1132. // Data streams with large keys and high data frequency may be down
  1133. // sampled.
  1134. MapVal []*ValueMapValEntry `json:"mapVal,omitempty"`
  1135. // StringVal: String value. When this is set, other values must not be
  1136. // set. Strings should be kept small whenever possible. Data streams
  1137. // with large string values and high data frequency may be down sampled.
  1138. StringVal string `json:"stringVal,omitempty"`
  1139. // ForceSendFields is a list of field names (e.g. "FpVal") to
  1140. // unconditionally include in API requests. By default, fields with
  1141. // empty values are omitted from API requests. However, any non-pointer,
  1142. // non-interface field appearing in ForceSendFields will be sent to the
  1143. // server regardless of whether the field is empty or not. This may be
  1144. // used to include empty fields in Patch requests.
  1145. ForceSendFields []string `json:"-"`
  1146. // NullFields is a list of field names (e.g. "FpVal") to include in API
  1147. // requests with the JSON null value. By default, fields with empty
  1148. // values are omitted from API requests. However, any field with an
  1149. // empty value appearing in NullFields will be sent to the server as
  1150. // null. It is an error if a field in this list has a non-empty value.
  1151. // This may be used to include null fields in Patch requests.
  1152. NullFields []string `json:"-"`
  1153. }
  1154. func (s *Value) MarshalJSON() ([]byte, error) {
  1155. type NoMethod Value
  1156. raw := NoMethod(*s)
  1157. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1158. }
  1159. func (s *Value) UnmarshalJSON(data []byte) error {
  1160. type NoMethod Value
  1161. var s1 struct {
  1162. FpVal gensupport.JSONFloat64 `json:"fpVal"`
  1163. *NoMethod
  1164. }
  1165. s1.NoMethod = (*NoMethod)(s)
  1166. if err := json.Unmarshal(data, &s1); err != nil {
  1167. return err
  1168. }
  1169. s.FpVal = float64(s1.FpVal)
  1170. return nil
  1171. }
  1172. type ValueMapValEntry struct {
  1173. Key string `json:"key,omitempty"`
  1174. Value *MapValue `json:"value,omitempty"`
  1175. // ForceSendFields is a list of field names (e.g. "Key") to
  1176. // unconditionally include in API requests. By default, fields with
  1177. // empty values are omitted from API requests. However, any non-pointer,
  1178. // non-interface field appearing in ForceSendFields will be sent to the
  1179. // server regardless of whether the field is empty or not. This may be
  1180. // used to include empty fields in Patch requests.
  1181. ForceSendFields []string `json:"-"`
  1182. // NullFields is a list of field names (e.g. "Key") to include in API
  1183. // requests with the JSON null value. By default, fields with empty
  1184. // values are omitted from API requests. However, any field with an
  1185. // empty value appearing in NullFields will be sent to the server as
  1186. // null. It is an error if a field in this list has a non-empty value.
  1187. // This may be used to include null fields in Patch requests.
  1188. NullFields []string `json:"-"`
  1189. }
  1190. func (s *ValueMapValEntry) MarshalJSON() ([]byte, error) {
  1191. type NoMethod ValueMapValEntry
  1192. raw := NoMethod(*s)
  1193. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1194. }
  1195. // method id "fitness.users.dataSources.create":
  1196. type UsersDataSourcesCreateCall struct {
  1197. s *Service
  1198. userId string
  1199. datasource *DataSource
  1200. urlParams_ gensupport.URLParams
  1201. ctx_ context.Context
  1202. header_ http.Header
  1203. }
  1204. // Create: Creates a new data source that is unique across all data
  1205. // sources belonging to this user. The data stream ID field can be
  1206. // omitted and will be generated by the server with the correct format.
  1207. // The data stream ID is an ordered combination of some fields from the
  1208. // data source. In addition to the data source fields reflected into the
  1209. // data source ID, the developer project number that is authenticated
  1210. // when creating the data source is included. This developer project
  1211. // number is obfuscated when read by any other developer reading public
  1212. // data types.
  1213. func (r *UsersDataSourcesService) Create(userId string, datasource *DataSource) *UsersDataSourcesCreateCall {
  1214. c := &UsersDataSourcesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1215. c.userId = userId
  1216. c.datasource = datasource
  1217. return c
  1218. }
  1219. // Fields allows partial responses to be retrieved. See
  1220. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1221. // for more information.
  1222. func (c *UsersDataSourcesCreateCall) Fields(s ...googleapi.Field) *UsersDataSourcesCreateCall {
  1223. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1224. return c
  1225. }
  1226. // Context sets the context to be used in this call's Do method. Any
  1227. // pending HTTP request will be aborted if the provided context is
  1228. // canceled.
  1229. func (c *UsersDataSourcesCreateCall) Context(ctx context.Context) *UsersDataSourcesCreateCall {
  1230. c.ctx_ = ctx
  1231. return c
  1232. }
  1233. // Header returns an http.Header that can be modified by the caller to
  1234. // add HTTP headers to the request.
  1235. func (c *UsersDataSourcesCreateCall) Header() http.Header {
  1236. if c.header_ == nil {
  1237. c.header_ = make(http.Header)
  1238. }
  1239. return c.header_
  1240. }
  1241. func (c *UsersDataSourcesCreateCall) doRequest(alt string) (*http.Response, error) {
  1242. reqHeaders := make(http.Header)
  1243. for k, v := range c.header_ {
  1244. reqHeaders[k] = v
  1245. }
  1246. reqHeaders.Set("User-Agent", c.s.userAgent())
  1247. var body io.Reader = nil
  1248. body, err := googleapi.WithoutDataWrapper.JSONReader(c.datasource)
  1249. if err != nil {
  1250. return nil, err
  1251. }
  1252. reqHeaders.Set("Content-Type", "application/json")
  1253. c.urlParams_.Set("alt", alt)
  1254. c.urlParams_.Set("prettyPrint", "false")
  1255. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources")
  1256. urls += "?" + c.urlParams_.Encode()
  1257. req, err := http.NewRequest("POST", urls, body)
  1258. if err != nil {
  1259. return nil, err
  1260. }
  1261. req.Header = reqHeaders
  1262. googleapi.Expand(req.URL, map[string]string{
  1263. "userId": c.userId,
  1264. })
  1265. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1266. }
  1267. // Do executes the "fitness.users.dataSources.create" call.
  1268. // Exactly one of *DataSource or error will be non-nil. Any non-2xx
  1269. // status code is an error. Response headers are in either
  1270. // *DataSource.ServerResponse.Header or (if a response was returned at
  1271. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1272. // to check whether the returned error was because
  1273. // http.StatusNotModified was returned.
  1274. func (c *UsersDataSourcesCreateCall) Do(opts ...googleapi.CallOption) (*DataSource, error) {
  1275. gensupport.SetOptions(c.urlParams_, opts...)
  1276. res, err := c.doRequest("json")
  1277. if res != nil && res.StatusCode == http.StatusNotModified {
  1278. if res.Body != nil {
  1279. res.Body.Close()
  1280. }
  1281. return nil, &googleapi.Error{
  1282. Code: res.StatusCode,
  1283. Header: res.Header,
  1284. }
  1285. }
  1286. if err != nil {
  1287. return nil, err
  1288. }
  1289. defer googleapi.CloseBody(res)
  1290. if err := googleapi.CheckResponse(res); err != nil {
  1291. return nil, err
  1292. }
  1293. ret := &DataSource{
  1294. ServerResponse: googleapi.ServerResponse{
  1295. Header: res.Header,
  1296. HTTPStatusCode: res.StatusCode,
  1297. },
  1298. }
  1299. target := &ret
  1300. if err := gensupport.DecodeResponse(target, res); err != nil {
  1301. return nil, err
  1302. }
  1303. return ret, nil
  1304. // {
  1305. // "description": "Creates a new data source that is unique across all data sources belonging to this user. The data stream ID field can be omitted and will be generated by the server with the correct format. The data stream ID is an ordered combination of some fields from the data source. In addition to the data source fields reflected into the data source ID, the developer project number that is authenticated when creating the data source is included. This developer project number is obfuscated when read by any other developer reading public data types.",
  1306. // "httpMethod": "POST",
  1307. // "id": "fitness.users.dataSources.create",
  1308. // "parameterOrder": [
  1309. // "userId"
  1310. // ],
  1311. // "parameters": {
  1312. // "userId": {
  1313. // "description": "Create the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  1314. // "location": "path",
  1315. // "required": true,
  1316. // "type": "string"
  1317. // }
  1318. // },
  1319. // "path": "{userId}/dataSources",
  1320. // "request": {
  1321. // "$ref": "DataSource"
  1322. // },
  1323. // "response": {
  1324. // "$ref": "DataSource"
  1325. // },
  1326. // "scopes": [
  1327. // "https://www.googleapis.com/auth/fitness.activity.write",
  1328. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  1329. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  1330. // "https://www.googleapis.com/auth/fitness.body.write",
  1331. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  1332. // "https://www.googleapis.com/auth/fitness.location.write",
  1333. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  1334. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  1335. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  1336. // ]
  1337. // }
  1338. }
  1339. // method id "fitness.users.dataSources.delete":
  1340. type UsersDataSourcesDeleteCall struct {
  1341. s *Service
  1342. userId string
  1343. dataSourceId string
  1344. urlParams_ gensupport.URLParams
  1345. ctx_ context.Context
  1346. header_ http.Header
  1347. }
  1348. // Delete: Deletes the specified data source. The request will fail if
  1349. // the data source contains any data points.
  1350. func (r *UsersDataSourcesService) Delete(userId string, dataSourceId string) *UsersDataSourcesDeleteCall {
  1351. c := &UsersDataSourcesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1352. c.userId = userId
  1353. c.dataSourceId = dataSourceId
  1354. return c
  1355. }
  1356. // Fields allows partial responses to be retrieved. See
  1357. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1358. // for more information.
  1359. func (c *UsersDataSourcesDeleteCall) Fields(s ...googleapi.Field) *UsersDataSourcesDeleteCall {
  1360. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1361. return c
  1362. }
  1363. // Context sets the context to be used in this call's Do method. Any
  1364. // pending HTTP request will be aborted if the provided context is
  1365. // canceled.
  1366. func (c *UsersDataSourcesDeleteCall) Context(ctx context.Context) *UsersDataSourcesDeleteCall {
  1367. c.ctx_ = ctx
  1368. return c
  1369. }
  1370. // Header returns an http.Header that can be modified by the caller to
  1371. // add HTTP headers to the request.
  1372. func (c *UsersDataSourcesDeleteCall) Header() http.Header {
  1373. if c.header_ == nil {
  1374. c.header_ = make(http.Header)
  1375. }
  1376. return c.header_
  1377. }
  1378. func (c *UsersDataSourcesDeleteCall) doRequest(alt string) (*http.Response, error) {
  1379. reqHeaders := make(http.Header)
  1380. for k, v := range c.header_ {
  1381. reqHeaders[k] = v
  1382. }
  1383. reqHeaders.Set("User-Agent", c.s.userAgent())
  1384. var body io.Reader = nil
  1385. c.urlParams_.Set("alt", alt)
  1386. c.urlParams_.Set("prettyPrint", "false")
  1387. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources/{dataSourceId}")
  1388. urls += "?" + c.urlParams_.Encode()
  1389. req, err := http.NewRequest("DELETE", urls, body)
  1390. if err != nil {
  1391. return nil, err
  1392. }
  1393. req.Header = reqHeaders
  1394. googleapi.Expand(req.URL, map[string]string{
  1395. "userId": c.userId,
  1396. "dataSourceId": c.dataSourceId,
  1397. })
  1398. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1399. }
  1400. // Do executes the "fitness.users.dataSources.delete" call.
  1401. // Exactly one of *DataSource or error will be non-nil. Any non-2xx
  1402. // status code is an error. Response headers are in either
  1403. // *DataSource.ServerResponse.Header or (if a response was returned at
  1404. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1405. // to check whether the returned error was because
  1406. // http.StatusNotModified was returned.
  1407. func (c *UsersDataSourcesDeleteCall) Do(opts ...googleapi.CallOption) (*DataSource, error) {
  1408. gensupport.SetOptions(c.urlParams_, opts...)
  1409. res, err := c.doRequest("json")
  1410. if res != nil && res.StatusCode == http.StatusNotModified {
  1411. if res.Body != nil {
  1412. res.Body.Close()
  1413. }
  1414. return nil, &googleapi.Error{
  1415. Code: res.StatusCode,
  1416. Header: res.Header,
  1417. }
  1418. }
  1419. if err != nil {
  1420. return nil, err
  1421. }
  1422. defer googleapi.CloseBody(res)
  1423. if err := googleapi.CheckResponse(res); err != nil {
  1424. return nil, err
  1425. }
  1426. ret := &DataSource{
  1427. ServerResponse: googleapi.ServerResponse{
  1428. Header: res.Header,
  1429. HTTPStatusCode: res.StatusCode,
  1430. },
  1431. }
  1432. target := &ret
  1433. if err := gensupport.DecodeResponse(target, res); err != nil {
  1434. return nil, err
  1435. }
  1436. return ret, nil
  1437. // {
  1438. // "description": "Deletes the specified data source. The request will fail if the data source contains any data points.",
  1439. // "httpMethod": "DELETE",
  1440. // "id": "fitness.users.dataSources.delete",
  1441. // "parameterOrder": [
  1442. // "userId",
  1443. // "dataSourceId"
  1444. // ],
  1445. // "parameters": {
  1446. // "dataSourceId": {
  1447. // "description": "The data stream ID of the data source to delete.",
  1448. // "location": "path",
  1449. // "required": true,
  1450. // "type": "string"
  1451. // },
  1452. // "userId": {
  1453. // "description": "Retrieve a data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  1454. // "location": "path",
  1455. // "required": true,
  1456. // "type": "string"
  1457. // }
  1458. // },
  1459. // "path": "{userId}/dataSources/{dataSourceId}",
  1460. // "response": {
  1461. // "$ref": "DataSource"
  1462. // },
  1463. // "scopes": [
  1464. // "https://www.googleapis.com/auth/fitness.activity.write",
  1465. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  1466. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  1467. // "https://www.googleapis.com/auth/fitness.body.write",
  1468. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  1469. // "https://www.googleapis.com/auth/fitness.location.write",
  1470. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  1471. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  1472. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  1473. // ]
  1474. // }
  1475. }
  1476. // method id "fitness.users.dataSources.get":
  1477. type UsersDataSourcesGetCall struct {
  1478. s *Service
  1479. userId string
  1480. dataSourceId string
  1481. urlParams_ gensupport.URLParams
  1482. ifNoneMatch_ string
  1483. ctx_ context.Context
  1484. header_ http.Header
  1485. }
  1486. // Get: Returns the specified data source.
  1487. func (r *UsersDataSourcesService) Get(userId string, dataSourceId string) *UsersDataSourcesGetCall {
  1488. c := &UsersDataSourcesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1489. c.userId = userId
  1490. c.dataSourceId = dataSourceId
  1491. return c
  1492. }
  1493. // Fields allows partial responses to be retrieved. See
  1494. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1495. // for more information.
  1496. func (c *UsersDataSourcesGetCall) Fields(s ...googleapi.Field) *UsersDataSourcesGetCall {
  1497. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1498. return c
  1499. }
  1500. // IfNoneMatch sets the optional parameter which makes the operation
  1501. // fail if the object's ETag matches the given value. This is useful for
  1502. // getting updates only after the object has changed since the last
  1503. // request. Use googleapi.IsNotModified to check whether the response
  1504. // error from Do is the result of In-None-Match.
  1505. func (c *UsersDataSourcesGetCall) IfNoneMatch(entityTag string) *UsersDataSourcesGetCall {
  1506. c.ifNoneMatch_ = entityTag
  1507. return c
  1508. }
  1509. // Context sets the context to be used in this call's Do method. Any
  1510. // pending HTTP request will be aborted if the provided context is
  1511. // canceled.
  1512. func (c *UsersDataSourcesGetCall) Context(ctx context.Context) *UsersDataSourcesGetCall {
  1513. c.ctx_ = ctx
  1514. return c
  1515. }
  1516. // Header returns an http.Header that can be modified by the caller to
  1517. // add HTTP headers to the request.
  1518. func (c *UsersDataSourcesGetCall) Header() http.Header {
  1519. if c.header_ == nil {
  1520. c.header_ = make(http.Header)
  1521. }
  1522. return c.header_
  1523. }
  1524. func (c *UsersDataSourcesGetCall) doRequest(alt string) (*http.Response, error) {
  1525. reqHeaders := make(http.Header)
  1526. for k, v := range c.header_ {
  1527. reqHeaders[k] = v
  1528. }
  1529. reqHeaders.Set("User-Agent", c.s.userAgent())
  1530. if c.ifNoneMatch_ != "" {
  1531. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1532. }
  1533. var body io.Reader = nil
  1534. c.urlParams_.Set("alt", alt)
  1535. c.urlParams_.Set("prettyPrint", "false")
  1536. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources/{dataSourceId}")
  1537. urls += "?" + c.urlParams_.Encode()
  1538. req, err := http.NewRequest("GET", urls, body)
  1539. if err != nil {
  1540. return nil, err
  1541. }
  1542. req.Header = reqHeaders
  1543. googleapi.Expand(req.URL, map[string]string{
  1544. "userId": c.userId,
  1545. "dataSourceId": c.dataSourceId,
  1546. })
  1547. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1548. }
  1549. // Do executes the "fitness.users.dataSources.get" call.
  1550. // Exactly one of *DataSource or error will be non-nil. Any non-2xx
  1551. // status code is an error. Response headers are in either
  1552. // *DataSource.ServerResponse.Header or (if a response was returned at
  1553. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1554. // to check whether the returned error was because
  1555. // http.StatusNotModified was returned.
  1556. func (c *UsersDataSourcesGetCall) Do(opts ...googleapi.CallOption) (*DataSource, error) {
  1557. gensupport.SetOptions(c.urlParams_, opts...)
  1558. res, err := c.doRequest("json")
  1559. if res != nil && res.StatusCode == http.StatusNotModified {
  1560. if res.Body != nil {
  1561. res.Body.Close()
  1562. }
  1563. return nil, &googleapi.Error{
  1564. Code: res.StatusCode,
  1565. Header: res.Header,
  1566. }
  1567. }
  1568. if err != nil {
  1569. return nil, err
  1570. }
  1571. defer googleapi.CloseBody(res)
  1572. if err := googleapi.CheckResponse(res); err != nil {
  1573. return nil, err
  1574. }
  1575. ret := &DataSource{
  1576. ServerResponse: googleapi.ServerResponse{
  1577. Header: res.Header,
  1578. HTTPStatusCode: res.StatusCode,
  1579. },
  1580. }
  1581. target := &ret
  1582. if err := gensupport.DecodeResponse(target, res); err != nil {
  1583. return nil, err
  1584. }
  1585. return ret, nil
  1586. // {
  1587. // "description": "Returns the specified data source.",
  1588. // "httpMethod": "GET",
  1589. // "id": "fitness.users.dataSources.get",
  1590. // "parameterOrder": [
  1591. // "userId",
  1592. // "dataSourceId"
  1593. // ],
  1594. // "parameters": {
  1595. // "dataSourceId": {
  1596. // "description": "The data stream ID of the data source to retrieve.",
  1597. // "location": "path",
  1598. // "required": true,
  1599. // "type": "string"
  1600. // },
  1601. // "userId": {
  1602. // "description": "Retrieve a data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  1603. // "location": "path",
  1604. // "required": true,
  1605. // "type": "string"
  1606. // }
  1607. // },
  1608. // "path": "{userId}/dataSources/{dataSourceId}",
  1609. // "response": {
  1610. // "$ref": "DataSource"
  1611. // },
  1612. // "scopes": [
  1613. // "https://www.googleapis.com/auth/fitness.activity.read",
  1614. // "https://www.googleapis.com/auth/fitness.activity.write",
  1615. // "https://www.googleapis.com/auth/fitness.blood_glucose.read",
  1616. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  1617. // "https://www.googleapis.com/auth/fitness.blood_pressure.read",
  1618. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  1619. // "https://www.googleapis.com/auth/fitness.body.read",
  1620. // "https://www.googleapis.com/auth/fitness.body.write",
  1621. // "https://www.googleapis.com/auth/fitness.body_temperature.read",
  1622. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  1623. // "https://www.googleapis.com/auth/fitness.location.read",
  1624. // "https://www.googleapis.com/auth/fitness.location.write",
  1625. // "https://www.googleapis.com/auth/fitness.nutrition.read",
  1626. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  1627. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
  1628. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  1629. // "https://www.googleapis.com/auth/fitness.reproductive_health.read",
  1630. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  1631. // ]
  1632. // }
  1633. }
  1634. // method id "fitness.users.dataSources.list":
  1635. type UsersDataSourcesListCall struct {
  1636. s *Service
  1637. userId string
  1638. urlParams_ gensupport.URLParams
  1639. ifNoneMatch_ string
  1640. ctx_ context.Context
  1641. header_ http.Header
  1642. }
  1643. // List: Lists all data sources that are visible to the developer, using
  1644. // the OAuth scopes provided. The list is not exhaustive; the user may
  1645. // have private data sources that are only visible to other developers,
  1646. // or calls using other scopes.
  1647. func (r *UsersDataSourcesService) List(userId string) *UsersDataSourcesListCall {
  1648. c := &UsersDataSourcesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1649. c.userId = userId
  1650. return c
  1651. }
  1652. // DataTypeName sets the optional parameter "dataTypeName": The names of
  1653. // data types to include in the list. If not specified, all data sources
  1654. // will be returned.
  1655. func (c *UsersDataSourcesListCall) DataTypeName(dataTypeName ...string) *UsersDataSourcesListCall {
  1656. c.urlParams_.SetMulti("dataTypeName", append([]string{}, dataTypeName...))
  1657. return c
  1658. }
  1659. // Fields allows partial responses to be retrieved. See
  1660. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1661. // for more information.
  1662. func (c *UsersDataSourcesListCall) Fields(s ...googleapi.Field) *UsersDataSourcesListCall {
  1663. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1664. return c
  1665. }
  1666. // IfNoneMatch sets the optional parameter which makes the operation
  1667. // fail if the object's ETag matches the given value. This is useful for
  1668. // getting updates only after the object has changed since the last
  1669. // request. Use googleapi.IsNotModified to check whether the response
  1670. // error from Do is the result of In-None-Match.
  1671. func (c *UsersDataSourcesListCall) IfNoneMatch(entityTag string) *UsersDataSourcesListCall {
  1672. c.ifNoneMatch_ = entityTag
  1673. return c
  1674. }
  1675. // Context sets the context to be used in this call's Do method. Any
  1676. // pending HTTP request will be aborted if the provided context is
  1677. // canceled.
  1678. func (c *UsersDataSourcesListCall) Context(ctx context.Context) *UsersDataSourcesListCall {
  1679. c.ctx_ = ctx
  1680. return c
  1681. }
  1682. // Header returns an http.Header that can be modified by the caller to
  1683. // add HTTP headers to the request.
  1684. func (c *UsersDataSourcesListCall) Header() http.Header {
  1685. if c.header_ == nil {
  1686. c.header_ = make(http.Header)
  1687. }
  1688. return c.header_
  1689. }
  1690. func (c *UsersDataSourcesListCall) doRequest(alt string) (*http.Response, error) {
  1691. reqHeaders := make(http.Header)
  1692. for k, v := range c.header_ {
  1693. reqHeaders[k] = v
  1694. }
  1695. reqHeaders.Set("User-Agent", c.s.userAgent())
  1696. if c.ifNoneMatch_ != "" {
  1697. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1698. }
  1699. var body io.Reader = nil
  1700. c.urlParams_.Set("alt", alt)
  1701. c.urlParams_.Set("prettyPrint", "false")
  1702. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources")
  1703. urls += "?" + c.urlParams_.Encode()
  1704. req, err := http.NewRequest("GET", urls, body)
  1705. if err != nil {
  1706. return nil, err
  1707. }
  1708. req.Header = reqHeaders
  1709. googleapi.Expand(req.URL, map[string]string{
  1710. "userId": c.userId,
  1711. })
  1712. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1713. }
  1714. // Do executes the "fitness.users.dataSources.list" call.
  1715. // Exactly one of *ListDataSourcesResponse or error will be non-nil. Any
  1716. // non-2xx status code is an error. Response headers are in either
  1717. // *ListDataSourcesResponse.ServerResponse.Header or (if a response was
  1718. // returned at all) in error.(*googleapi.Error).Header. Use
  1719. // googleapi.IsNotModified to check whether the returned error was
  1720. // because http.StatusNotModified was returned.
  1721. func (c *UsersDataSourcesListCall) Do(opts ...googleapi.CallOption) (*ListDataSourcesResponse, error) {
  1722. gensupport.SetOptions(c.urlParams_, opts...)
  1723. res, err := c.doRequest("json")
  1724. if res != nil && res.StatusCode == http.StatusNotModified {
  1725. if res.Body != nil {
  1726. res.Body.Close()
  1727. }
  1728. return nil, &googleapi.Error{
  1729. Code: res.StatusCode,
  1730. Header: res.Header,
  1731. }
  1732. }
  1733. if err != nil {
  1734. return nil, err
  1735. }
  1736. defer googleapi.CloseBody(res)
  1737. if err := googleapi.CheckResponse(res); err != nil {
  1738. return nil, err
  1739. }
  1740. ret := &ListDataSourcesResponse{
  1741. ServerResponse: googleapi.ServerResponse{
  1742. Header: res.Header,
  1743. HTTPStatusCode: res.StatusCode,
  1744. },
  1745. }
  1746. target := &ret
  1747. if err := gensupport.DecodeResponse(target, res); err != nil {
  1748. return nil, err
  1749. }
  1750. return ret, nil
  1751. // {
  1752. // "description": "Lists all data sources that are visible to the developer, using the OAuth scopes provided. The list is not exhaustive; the user may have private data sources that are only visible to other developers, or calls using other scopes.",
  1753. // "httpMethod": "GET",
  1754. // "id": "fitness.users.dataSources.list",
  1755. // "parameterOrder": [
  1756. // "userId"
  1757. // ],
  1758. // "parameters": {
  1759. // "dataTypeName": {
  1760. // "description": "The names of data types to include in the list. If not specified, all data sources will be returned.",
  1761. // "location": "query",
  1762. // "repeated": true,
  1763. // "type": "string"
  1764. // },
  1765. // "userId": {
  1766. // "description": "List data sources for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  1767. // "location": "path",
  1768. // "required": true,
  1769. // "type": "string"
  1770. // }
  1771. // },
  1772. // "path": "{userId}/dataSources",
  1773. // "response": {
  1774. // "$ref": "ListDataSourcesResponse"
  1775. // },
  1776. // "scopes": [
  1777. // "https://www.googleapis.com/auth/fitness.activity.read",
  1778. // "https://www.googleapis.com/auth/fitness.activity.write",
  1779. // "https://www.googleapis.com/auth/fitness.blood_glucose.read",
  1780. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  1781. // "https://www.googleapis.com/auth/fitness.blood_pressure.read",
  1782. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  1783. // "https://www.googleapis.com/auth/fitness.body.read",
  1784. // "https://www.googleapis.com/auth/fitness.body.write",
  1785. // "https://www.googleapis.com/auth/fitness.body_temperature.read",
  1786. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  1787. // "https://www.googleapis.com/auth/fitness.location.read",
  1788. // "https://www.googleapis.com/auth/fitness.location.write",
  1789. // "https://www.googleapis.com/auth/fitness.nutrition.read",
  1790. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  1791. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
  1792. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  1793. // "https://www.googleapis.com/auth/fitness.reproductive_health.read",
  1794. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  1795. // ]
  1796. // }
  1797. }
  1798. // method id "fitness.users.dataSources.update":
  1799. type UsersDataSourcesUpdateCall struct {
  1800. s *Service
  1801. userId string
  1802. dataSourceId string
  1803. datasource *DataSource
  1804. urlParams_ gensupport.URLParams
  1805. ctx_ context.Context
  1806. header_ http.Header
  1807. }
  1808. // Update: Updates the specified data source. The dataStreamId,
  1809. // dataType, type, dataStreamName, and device properties with the
  1810. // exception of version, cannot be modified.
  1811. //
  1812. // Data sources are identified by their dataStreamId.
  1813. func (r *UsersDataSourcesService) Update(userId string, dataSourceId string, datasource *DataSource) *UsersDataSourcesUpdateCall {
  1814. c := &UsersDataSourcesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1815. c.userId = userId
  1816. c.dataSourceId = dataSourceId
  1817. c.datasource = datasource
  1818. return c
  1819. }
  1820. // Fields allows partial responses to be retrieved. See
  1821. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1822. // for more information.
  1823. func (c *UsersDataSourcesUpdateCall) Fields(s ...googleapi.Field) *UsersDataSourcesUpdateCall {
  1824. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1825. return c
  1826. }
  1827. // Context sets the context to be used in this call's Do method. Any
  1828. // pending HTTP request will be aborted if the provided context is
  1829. // canceled.
  1830. func (c *UsersDataSourcesUpdateCall) Context(ctx context.Context) *UsersDataSourcesUpdateCall {
  1831. c.ctx_ = ctx
  1832. return c
  1833. }
  1834. // Header returns an http.Header that can be modified by the caller to
  1835. // add HTTP headers to the request.
  1836. func (c *UsersDataSourcesUpdateCall) Header() http.Header {
  1837. if c.header_ == nil {
  1838. c.header_ = make(http.Header)
  1839. }
  1840. return c.header_
  1841. }
  1842. func (c *UsersDataSourcesUpdateCall) doRequest(alt string) (*http.Response, error) {
  1843. reqHeaders := make(http.Header)
  1844. for k, v := range c.header_ {
  1845. reqHeaders[k] = v
  1846. }
  1847. reqHeaders.Set("User-Agent", c.s.userAgent())
  1848. var body io.Reader = nil
  1849. body, err := googleapi.WithoutDataWrapper.JSONReader(c.datasource)
  1850. if err != nil {
  1851. return nil, err
  1852. }
  1853. reqHeaders.Set("Content-Type", "application/json")
  1854. c.urlParams_.Set("alt", alt)
  1855. c.urlParams_.Set("prettyPrint", "false")
  1856. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources/{dataSourceId}")
  1857. urls += "?" + c.urlParams_.Encode()
  1858. req, err := http.NewRequest("PUT", urls, body)
  1859. if err != nil {
  1860. return nil, err
  1861. }
  1862. req.Header = reqHeaders
  1863. googleapi.Expand(req.URL, map[string]string{
  1864. "userId": c.userId,
  1865. "dataSourceId": c.dataSourceId,
  1866. })
  1867. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1868. }
  1869. // Do executes the "fitness.users.dataSources.update" call.
  1870. // Exactly one of *DataSource or error will be non-nil. Any non-2xx
  1871. // status code is an error. Response headers are in either
  1872. // *DataSource.ServerResponse.Header or (if a response was returned at
  1873. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1874. // to check whether the returned error was because
  1875. // http.StatusNotModified was returned.
  1876. func (c *UsersDataSourcesUpdateCall) Do(opts ...googleapi.CallOption) (*DataSource, error) {
  1877. gensupport.SetOptions(c.urlParams_, opts...)
  1878. res, err := c.doRequest("json")
  1879. if res != nil && res.StatusCode == http.StatusNotModified {
  1880. if res.Body != nil {
  1881. res.Body.Close()
  1882. }
  1883. return nil, &googleapi.Error{
  1884. Code: res.StatusCode,
  1885. Header: res.Header,
  1886. }
  1887. }
  1888. if err != nil {
  1889. return nil, err
  1890. }
  1891. defer googleapi.CloseBody(res)
  1892. if err := googleapi.CheckResponse(res); err != nil {
  1893. return nil, err
  1894. }
  1895. ret := &DataSource{
  1896. ServerResponse: googleapi.ServerResponse{
  1897. Header: res.Header,
  1898. HTTPStatusCode: res.StatusCode,
  1899. },
  1900. }
  1901. target := &ret
  1902. if err := gensupport.DecodeResponse(target, res); err != nil {
  1903. return nil, err
  1904. }
  1905. return ret, nil
  1906. // {
  1907. // "description": "Updates the specified data source. The dataStreamId, dataType, type, dataStreamName, and device properties with the exception of version, cannot be modified.\n\nData sources are identified by their dataStreamId.",
  1908. // "httpMethod": "PUT",
  1909. // "id": "fitness.users.dataSources.update",
  1910. // "parameterOrder": [
  1911. // "userId",
  1912. // "dataSourceId"
  1913. // ],
  1914. // "parameters": {
  1915. // "dataSourceId": {
  1916. // "description": "The data stream ID of the data source to update.",
  1917. // "location": "path",
  1918. // "required": true,
  1919. // "type": "string"
  1920. // },
  1921. // "userId": {
  1922. // "description": "Update the data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  1923. // "location": "path",
  1924. // "required": true,
  1925. // "type": "string"
  1926. // }
  1927. // },
  1928. // "path": "{userId}/dataSources/{dataSourceId}",
  1929. // "request": {
  1930. // "$ref": "DataSource"
  1931. // },
  1932. // "response": {
  1933. // "$ref": "DataSource"
  1934. // },
  1935. // "scopes": [
  1936. // "https://www.googleapis.com/auth/fitness.activity.write",
  1937. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  1938. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  1939. // "https://www.googleapis.com/auth/fitness.body.write",
  1940. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  1941. // "https://www.googleapis.com/auth/fitness.location.write",
  1942. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  1943. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  1944. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  1945. // ]
  1946. // }
  1947. }
  1948. // method id "fitness.users.dataSources.dataPointChanges.list":
  1949. type UsersDataSourcesDataPointChangesListCall struct {
  1950. s *Service
  1951. userId string
  1952. dataSourceId string
  1953. urlParams_ gensupport.URLParams
  1954. ifNoneMatch_ string
  1955. ctx_ context.Context
  1956. header_ http.Header
  1957. }
  1958. // List: Queries for user's data point changes for a particular data
  1959. // source.
  1960. func (r *UsersDataSourcesDataPointChangesService) List(userId string, dataSourceId string) *UsersDataSourcesDataPointChangesListCall {
  1961. c := &UsersDataSourcesDataPointChangesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1962. c.userId = userId
  1963. c.dataSourceId = dataSourceId
  1964. return c
  1965. }
  1966. // Limit sets the optional parameter "limit": If specified, no more than
  1967. // this many data point changes will be included in the response.
  1968. func (c *UsersDataSourcesDataPointChangesListCall) Limit(limit int64) *UsersDataSourcesDataPointChangesListCall {
  1969. c.urlParams_.Set("limit", fmt.Sprint(limit))
  1970. return c
  1971. }
  1972. // PageToken sets the optional parameter "pageToken": The continuation
  1973. // token, which is used to page through large result sets. To get the
  1974. // next page of results, set this parameter to the value of
  1975. // nextPageToken from the previous response.
  1976. func (c *UsersDataSourcesDataPointChangesListCall) PageToken(pageToken string) *UsersDataSourcesDataPointChangesListCall {
  1977. c.urlParams_.Set("pageToken", pageToken)
  1978. return c
  1979. }
  1980. // Fields allows partial responses to be retrieved. See
  1981. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1982. // for more information.
  1983. func (c *UsersDataSourcesDataPointChangesListCall) Fields(s ...googleapi.Field) *UsersDataSourcesDataPointChangesListCall {
  1984. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1985. return c
  1986. }
  1987. // IfNoneMatch sets the optional parameter which makes the operation
  1988. // fail if the object's ETag matches the given value. This is useful for
  1989. // getting updates only after the object has changed since the last
  1990. // request. Use googleapi.IsNotModified to check whether the response
  1991. // error from Do is the result of In-None-Match.
  1992. func (c *UsersDataSourcesDataPointChangesListCall) IfNoneMatch(entityTag string) *UsersDataSourcesDataPointChangesListCall {
  1993. c.ifNoneMatch_ = entityTag
  1994. return c
  1995. }
  1996. // Context sets the context to be used in this call's Do method. Any
  1997. // pending HTTP request will be aborted if the provided context is
  1998. // canceled.
  1999. func (c *UsersDataSourcesDataPointChangesListCall) Context(ctx context.Context) *UsersDataSourcesDataPointChangesListCall {
  2000. c.ctx_ = ctx
  2001. return c
  2002. }
  2003. // Header returns an http.Header that can be modified by the caller to
  2004. // add HTTP headers to the request.
  2005. func (c *UsersDataSourcesDataPointChangesListCall) Header() http.Header {
  2006. if c.header_ == nil {
  2007. c.header_ = make(http.Header)
  2008. }
  2009. return c.header_
  2010. }
  2011. func (c *UsersDataSourcesDataPointChangesListCall) doRequest(alt string) (*http.Response, error) {
  2012. reqHeaders := make(http.Header)
  2013. for k, v := range c.header_ {
  2014. reqHeaders[k] = v
  2015. }
  2016. reqHeaders.Set("User-Agent", c.s.userAgent())
  2017. if c.ifNoneMatch_ != "" {
  2018. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2019. }
  2020. var body io.Reader = nil
  2021. c.urlParams_.Set("alt", alt)
  2022. c.urlParams_.Set("prettyPrint", "false")
  2023. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources/{dataSourceId}/dataPointChanges")
  2024. urls += "?" + c.urlParams_.Encode()
  2025. req, err := http.NewRequest("GET", urls, body)
  2026. if err != nil {
  2027. return nil, err
  2028. }
  2029. req.Header = reqHeaders
  2030. googleapi.Expand(req.URL, map[string]string{
  2031. "userId": c.userId,
  2032. "dataSourceId": c.dataSourceId,
  2033. })
  2034. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2035. }
  2036. // Do executes the "fitness.users.dataSources.dataPointChanges.list" call.
  2037. // Exactly one of *ListDataPointChangesResponse or error will be
  2038. // non-nil. Any non-2xx status code is an error. Response headers are in
  2039. // either *ListDataPointChangesResponse.ServerResponse.Header or (if a
  2040. // response was returned at all) in error.(*googleapi.Error).Header. Use
  2041. // googleapi.IsNotModified to check whether the returned error was
  2042. // because http.StatusNotModified was returned.
  2043. func (c *UsersDataSourcesDataPointChangesListCall) Do(opts ...googleapi.CallOption) (*ListDataPointChangesResponse, error) {
  2044. gensupport.SetOptions(c.urlParams_, opts...)
  2045. res, err := c.doRequest("json")
  2046. if res != nil && res.StatusCode == http.StatusNotModified {
  2047. if res.Body != nil {
  2048. res.Body.Close()
  2049. }
  2050. return nil, &googleapi.Error{
  2051. Code: res.StatusCode,
  2052. Header: res.Header,
  2053. }
  2054. }
  2055. if err != nil {
  2056. return nil, err
  2057. }
  2058. defer googleapi.CloseBody(res)
  2059. if err := googleapi.CheckResponse(res); err != nil {
  2060. return nil, err
  2061. }
  2062. ret := &ListDataPointChangesResponse{
  2063. ServerResponse: googleapi.ServerResponse{
  2064. Header: res.Header,
  2065. HTTPStatusCode: res.StatusCode,
  2066. },
  2067. }
  2068. target := &ret
  2069. if err := gensupport.DecodeResponse(target, res); err != nil {
  2070. return nil, err
  2071. }
  2072. return ret, nil
  2073. // {
  2074. // "description": "Queries for user's data point changes for a particular data source.",
  2075. // "httpMethod": "GET",
  2076. // "id": "fitness.users.dataSources.dataPointChanges.list",
  2077. // "parameterOrder": [
  2078. // "userId",
  2079. // "dataSourceId"
  2080. // ],
  2081. // "parameters": {
  2082. // "dataSourceId": {
  2083. // "description": "The data stream ID of the data source that created the dataset.",
  2084. // "location": "path",
  2085. // "required": true,
  2086. // "type": "string"
  2087. // },
  2088. // "limit": {
  2089. // "description": "If specified, no more than this many data point changes will be included in the response.",
  2090. // "format": "int32",
  2091. // "location": "query",
  2092. // "type": "integer"
  2093. // },
  2094. // "pageToken": {
  2095. // "description": "The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of nextPageToken from the previous response.",
  2096. // "location": "query",
  2097. // "type": "string"
  2098. // },
  2099. // "userId": {
  2100. // "description": "List data points for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  2101. // "location": "path",
  2102. // "required": true,
  2103. // "type": "string"
  2104. // }
  2105. // },
  2106. // "path": "{userId}/dataSources/{dataSourceId}/dataPointChanges",
  2107. // "response": {
  2108. // "$ref": "ListDataPointChangesResponse"
  2109. // },
  2110. // "scopes": [
  2111. // "https://www.googleapis.com/auth/fitness.activity.read",
  2112. // "https://www.googleapis.com/auth/fitness.activity.write",
  2113. // "https://www.googleapis.com/auth/fitness.blood_glucose.read",
  2114. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  2115. // "https://www.googleapis.com/auth/fitness.blood_pressure.read",
  2116. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  2117. // "https://www.googleapis.com/auth/fitness.body.read",
  2118. // "https://www.googleapis.com/auth/fitness.body.write",
  2119. // "https://www.googleapis.com/auth/fitness.body_temperature.read",
  2120. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  2121. // "https://www.googleapis.com/auth/fitness.location.read",
  2122. // "https://www.googleapis.com/auth/fitness.location.write",
  2123. // "https://www.googleapis.com/auth/fitness.nutrition.read",
  2124. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  2125. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
  2126. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  2127. // "https://www.googleapis.com/auth/fitness.reproductive_health.read",
  2128. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  2129. // ]
  2130. // }
  2131. }
  2132. // Pages invokes f for each page of results.
  2133. // A non-nil error returned from f will halt the iteration.
  2134. // The provided context supersedes any context provided to the Context method.
  2135. func (c *UsersDataSourcesDataPointChangesListCall) Pages(ctx context.Context, f func(*ListDataPointChangesResponse) error) error {
  2136. c.ctx_ = ctx
  2137. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2138. for {
  2139. x, err := c.Do()
  2140. if err != nil {
  2141. return err
  2142. }
  2143. if err := f(x); err != nil {
  2144. return err
  2145. }
  2146. if x.NextPageToken == "" {
  2147. return nil
  2148. }
  2149. c.PageToken(x.NextPageToken)
  2150. }
  2151. }
  2152. // method id "fitness.users.dataSources.datasets.delete":
  2153. type UsersDataSourcesDatasetsDeleteCall struct {
  2154. s *Service
  2155. userId string
  2156. dataSourceId string
  2157. datasetId string
  2158. urlParams_ gensupport.URLParams
  2159. ctx_ context.Context
  2160. header_ http.Header
  2161. }
  2162. // Delete: Performs an inclusive delete of all data points whose start
  2163. // and end times have any overlap with the time range specified by the
  2164. // dataset ID. For most data types, the entire data point will be
  2165. // deleted. For data types where the time span represents a consistent
  2166. // value (such as com.google.activity.segment), and a data point
  2167. // straddles either end point of the dataset, only the overlapping
  2168. // portion of the data point will be deleted.
  2169. func (r *UsersDataSourcesDatasetsService) Delete(userId string, dataSourceId string, datasetId string) *UsersDataSourcesDatasetsDeleteCall {
  2170. c := &UsersDataSourcesDatasetsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2171. c.userId = userId
  2172. c.dataSourceId = dataSourceId
  2173. c.datasetId = datasetId
  2174. return c
  2175. }
  2176. // CurrentTimeMillis sets the optional parameter "currentTimeMillis":
  2177. // The client's current time in milliseconds since epoch.
  2178. func (c *UsersDataSourcesDatasetsDeleteCall) CurrentTimeMillis(currentTimeMillis int64) *UsersDataSourcesDatasetsDeleteCall {
  2179. c.urlParams_.Set("currentTimeMillis", fmt.Sprint(currentTimeMillis))
  2180. return c
  2181. }
  2182. // ModifiedTimeMillis sets the optional parameter "modifiedTimeMillis":
  2183. // When the operation was performed on the client.
  2184. func (c *UsersDataSourcesDatasetsDeleteCall) ModifiedTimeMillis(modifiedTimeMillis int64) *UsersDataSourcesDatasetsDeleteCall {
  2185. c.urlParams_.Set("modifiedTimeMillis", fmt.Sprint(modifiedTimeMillis))
  2186. return c
  2187. }
  2188. // Fields allows partial responses to be retrieved. See
  2189. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2190. // for more information.
  2191. func (c *UsersDataSourcesDatasetsDeleteCall) Fields(s ...googleapi.Field) *UsersDataSourcesDatasetsDeleteCall {
  2192. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2193. return c
  2194. }
  2195. // Context sets the context to be used in this call's Do method. Any
  2196. // pending HTTP request will be aborted if the provided context is
  2197. // canceled.
  2198. func (c *UsersDataSourcesDatasetsDeleteCall) Context(ctx context.Context) *UsersDataSourcesDatasetsDeleteCall {
  2199. c.ctx_ = ctx
  2200. return c
  2201. }
  2202. // Header returns an http.Header that can be modified by the caller to
  2203. // add HTTP headers to the request.
  2204. func (c *UsersDataSourcesDatasetsDeleteCall) Header() http.Header {
  2205. if c.header_ == nil {
  2206. c.header_ = make(http.Header)
  2207. }
  2208. return c.header_
  2209. }
  2210. func (c *UsersDataSourcesDatasetsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2211. reqHeaders := make(http.Header)
  2212. for k, v := range c.header_ {
  2213. reqHeaders[k] = v
  2214. }
  2215. reqHeaders.Set("User-Agent", c.s.userAgent())
  2216. var body io.Reader = nil
  2217. c.urlParams_.Set("alt", alt)
  2218. c.urlParams_.Set("prettyPrint", "false")
  2219. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources/{dataSourceId}/datasets/{datasetId}")
  2220. urls += "?" + c.urlParams_.Encode()
  2221. req, err := http.NewRequest("DELETE", urls, body)
  2222. if err != nil {
  2223. return nil, err
  2224. }
  2225. req.Header = reqHeaders
  2226. googleapi.Expand(req.URL, map[string]string{
  2227. "userId": c.userId,
  2228. "dataSourceId": c.dataSourceId,
  2229. "datasetId": c.datasetId,
  2230. })
  2231. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2232. }
  2233. // Do executes the "fitness.users.dataSources.datasets.delete" call.
  2234. func (c *UsersDataSourcesDatasetsDeleteCall) Do(opts ...googleapi.CallOption) error {
  2235. gensupport.SetOptions(c.urlParams_, opts...)
  2236. res, err := c.doRequest("json")
  2237. if err != nil {
  2238. return err
  2239. }
  2240. defer googleapi.CloseBody(res)
  2241. if err := googleapi.CheckResponse(res); err != nil {
  2242. return err
  2243. }
  2244. return nil
  2245. // {
  2246. // "description": "Performs an inclusive delete of all data points whose start and end times have any overlap with the time range specified by the dataset ID. For most data types, the entire data point will be deleted. For data types where the time span represents a consistent value (such as com.google.activity.segment), and a data point straddles either end point of the dataset, only the overlapping portion of the data point will be deleted.",
  2247. // "httpMethod": "DELETE",
  2248. // "id": "fitness.users.dataSources.datasets.delete",
  2249. // "parameterOrder": [
  2250. // "userId",
  2251. // "dataSourceId",
  2252. // "datasetId"
  2253. // ],
  2254. // "parameters": {
  2255. // "currentTimeMillis": {
  2256. // "description": "The client's current time in milliseconds since epoch.",
  2257. // "format": "int64",
  2258. // "location": "query",
  2259. // "type": "string"
  2260. // },
  2261. // "dataSourceId": {
  2262. // "description": "The data stream ID of the data source that created the dataset.",
  2263. // "location": "path",
  2264. // "required": true,
  2265. // "type": "string"
  2266. // },
  2267. // "datasetId": {
  2268. // "description": "Dataset identifier that is a composite of the minimum data point start time and maximum data point end time represented as nanoseconds from the epoch. The ID is formatted like: \"startTime-endTime\" where startTime and endTime are 64 bit integers.",
  2269. // "location": "path",
  2270. // "required": true,
  2271. // "type": "string"
  2272. // },
  2273. // "modifiedTimeMillis": {
  2274. // "description": "When the operation was performed on the client.",
  2275. // "format": "int64",
  2276. // "location": "query",
  2277. // "type": "string"
  2278. // },
  2279. // "userId": {
  2280. // "description": "Delete a dataset for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  2281. // "location": "path",
  2282. // "required": true,
  2283. // "type": "string"
  2284. // }
  2285. // },
  2286. // "path": "{userId}/dataSources/{dataSourceId}/datasets/{datasetId}",
  2287. // "scopes": [
  2288. // "https://www.googleapis.com/auth/fitness.activity.write",
  2289. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  2290. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  2291. // "https://www.googleapis.com/auth/fitness.body.write",
  2292. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  2293. // "https://www.googleapis.com/auth/fitness.location.write",
  2294. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  2295. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  2296. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  2297. // ]
  2298. // }
  2299. }
  2300. // method id "fitness.users.dataSources.datasets.get":
  2301. type UsersDataSourcesDatasetsGetCall struct {
  2302. s *Service
  2303. userId string
  2304. dataSourceId string
  2305. datasetId string
  2306. urlParams_ gensupport.URLParams
  2307. ifNoneMatch_ string
  2308. ctx_ context.Context
  2309. header_ http.Header
  2310. }
  2311. // Get: Returns a dataset containing all data points whose start and end
  2312. // times overlap with the specified range of the dataset minimum start
  2313. // time and maximum end time. Specifically, any data point whose start
  2314. // time is less than or equal to the dataset end time and whose end time
  2315. // is greater than or equal to the dataset start time.
  2316. func (r *UsersDataSourcesDatasetsService) Get(userId string, dataSourceId string, datasetId string) *UsersDataSourcesDatasetsGetCall {
  2317. c := &UsersDataSourcesDatasetsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2318. c.userId = userId
  2319. c.dataSourceId = dataSourceId
  2320. c.datasetId = datasetId
  2321. return c
  2322. }
  2323. // Limit sets the optional parameter "limit": If specified, no more than
  2324. // this many data points will be included in the dataset. If there are
  2325. // more data points in the dataset, nextPageToken will be set in the
  2326. // dataset response.
  2327. func (c *UsersDataSourcesDatasetsGetCall) Limit(limit int64) *UsersDataSourcesDatasetsGetCall {
  2328. c.urlParams_.Set("limit", fmt.Sprint(limit))
  2329. return c
  2330. }
  2331. // PageToken sets the optional parameter "pageToken": The continuation
  2332. // token, which is used to page through large datasets. To get the next
  2333. // page of a dataset, set this parameter to the value of nextPageToken
  2334. // from the previous response. Each subsequent call will yield a partial
  2335. // dataset with data point end timestamps that are strictly smaller than
  2336. // those in the previous partial response.
  2337. func (c *UsersDataSourcesDatasetsGetCall) PageToken(pageToken string) *UsersDataSourcesDatasetsGetCall {
  2338. c.urlParams_.Set("pageToken", pageToken)
  2339. return c
  2340. }
  2341. // Fields allows partial responses to be retrieved. See
  2342. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2343. // for more information.
  2344. func (c *UsersDataSourcesDatasetsGetCall) Fields(s ...googleapi.Field) *UsersDataSourcesDatasetsGetCall {
  2345. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2346. return c
  2347. }
  2348. // IfNoneMatch sets the optional parameter which makes the operation
  2349. // fail if the object's ETag matches the given value. This is useful for
  2350. // getting updates only after the object has changed since the last
  2351. // request. Use googleapi.IsNotModified to check whether the response
  2352. // error from Do is the result of In-None-Match.
  2353. func (c *UsersDataSourcesDatasetsGetCall) IfNoneMatch(entityTag string) *UsersDataSourcesDatasetsGetCall {
  2354. c.ifNoneMatch_ = entityTag
  2355. return c
  2356. }
  2357. // Context sets the context to be used in this call's Do method. Any
  2358. // pending HTTP request will be aborted if the provided context is
  2359. // canceled.
  2360. func (c *UsersDataSourcesDatasetsGetCall) Context(ctx context.Context) *UsersDataSourcesDatasetsGetCall {
  2361. c.ctx_ = ctx
  2362. return c
  2363. }
  2364. // Header returns an http.Header that can be modified by the caller to
  2365. // add HTTP headers to the request.
  2366. func (c *UsersDataSourcesDatasetsGetCall) Header() http.Header {
  2367. if c.header_ == nil {
  2368. c.header_ = make(http.Header)
  2369. }
  2370. return c.header_
  2371. }
  2372. func (c *UsersDataSourcesDatasetsGetCall) doRequest(alt string) (*http.Response, error) {
  2373. reqHeaders := make(http.Header)
  2374. for k, v := range c.header_ {
  2375. reqHeaders[k] = v
  2376. }
  2377. reqHeaders.Set("User-Agent", c.s.userAgent())
  2378. if c.ifNoneMatch_ != "" {
  2379. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2380. }
  2381. var body io.Reader = nil
  2382. c.urlParams_.Set("alt", alt)
  2383. c.urlParams_.Set("prettyPrint", "false")
  2384. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources/{dataSourceId}/datasets/{datasetId}")
  2385. urls += "?" + c.urlParams_.Encode()
  2386. req, err := http.NewRequest("GET", urls, body)
  2387. if err != nil {
  2388. return nil, err
  2389. }
  2390. req.Header = reqHeaders
  2391. googleapi.Expand(req.URL, map[string]string{
  2392. "userId": c.userId,
  2393. "dataSourceId": c.dataSourceId,
  2394. "datasetId": c.datasetId,
  2395. })
  2396. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2397. }
  2398. // Do executes the "fitness.users.dataSources.datasets.get" call.
  2399. // Exactly one of *Dataset or error will be non-nil. Any non-2xx status
  2400. // code is an error. Response headers are in either
  2401. // *Dataset.ServerResponse.Header or (if a response was returned at all)
  2402. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2403. // check whether the returned error was because http.StatusNotModified
  2404. // was returned.
  2405. func (c *UsersDataSourcesDatasetsGetCall) Do(opts ...googleapi.CallOption) (*Dataset, error) {
  2406. gensupport.SetOptions(c.urlParams_, opts...)
  2407. res, err := c.doRequest("json")
  2408. if res != nil && res.StatusCode == http.StatusNotModified {
  2409. if res.Body != nil {
  2410. res.Body.Close()
  2411. }
  2412. return nil, &googleapi.Error{
  2413. Code: res.StatusCode,
  2414. Header: res.Header,
  2415. }
  2416. }
  2417. if err != nil {
  2418. return nil, err
  2419. }
  2420. defer googleapi.CloseBody(res)
  2421. if err := googleapi.CheckResponse(res); err != nil {
  2422. return nil, err
  2423. }
  2424. ret := &Dataset{
  2425. ServerResponse: googleapi.ServerResponse{
  2426. Header: res.Header,
  2427. HTTPStatusCode: res.StatusCode,
  2428. },
  2429. }
  2430. target := &ret
  2431. if err := gensupport.DecodeResponse(target, res); err != nil {
  2432. return nil, err
  2433. }
  2434. return ret, nil
  2435. // {
  2436. // "description": "Returns a dataset containing all data points whose start and end times overlap with the specified range of the dataset minimum start time and maximum end time. Specifically, any data point whose start time is less than or equal to the dataset end time and whose end time is greater than or equal to the dataset start time.",
  2437. // "httpMethod": "GET",
  2438. // "id": "fitness.users.dataSources.datasets.get",
  2439. // "parameterOrder": [
  2440. // "userId",
  2441. // "dataSourceId",
  2442. // "datasetId"
  2443. // ],
  2444. // "parameters": {
  2445. // "dataSourceId": {
  2446. // "description": "The data stream ID of the data source that created the dataset.",
  2447. // "location": "path",
  2448. // "required": true,
  2449. // "type": "string"
  2450. // },
  2451. // "datasetId": {
  2452. // "description": "Dataset identifier that is a composite of the minimum data point start time and maximum data point end time represented as nanoseconds from the epoch. The ID is formatted like: \"startTime-endTime\" where startTime and endTime are 64 bit integers.",
  2453. // "location": "path",
  2454. // "required": true,
  2455. // "type": "string"
  2456. // },
  2457. // "limit": {
  2458. // "description": "If specified, no more than this many data points will be included in the dataset. If there are more data points in the dataset, nextPageToken will be set in the dataset response.",
  2459. // "format": "int32",
  2460. // "location": "query",
  2461. // "type": "integer"
  2462. // },
  2463. // "pageToken": {
  2464. // "description": "The continuation token, which is used to page through large datasets. To get the next page of a dataset, set this parameter to the value of nextPageToken from the previous response. Each subsequent call will yield a partial dataset with data point end timestamps that are strictly smaller than those in the previous partial response.",
  2465. // "location": "query",
  2466. // "type": "string"
  2467. // },
  2468. // "userId": {
  2469. // "description": "Retrieve a dataset for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  2470. // "location": "path",
  2471. // "required": true,
  2472. // "type": "string"
  2473. // }
  2474. // },
  2475. // "path": "{userId}/dataSources/{dataSourceId}/datasets/{datasetId}",
  2476. // "response": {
  2477. // "$ref": "Dataset"
  2478. // },
  2479. // "scopes": [
  2480. // "https://www.googleapis.com/auth/fitness.activity.read",
  2481. // "https://www.googleapis.com/auth/fitness.activity.write",
  2482. // "https://www.googleapis.com/auth/fitness.blood_glucose.read",
  2483. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  2484. // "https://www.googleapis.com/auth/fitness.blood_pressure.read",
  2485. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  2486. // "https://www.googleapis.com/auth/fitness.body.read",
  2487. // "https://www.googleapis.com/auth/fitness.body.write",
  2488. // "https://www.googleapis.com/auth/fitness.body_temperature.read",
  2489. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  2490. // "https://www.googleapis.com/auth/fitness.location.read",
  2491. // "https://www.googleapis.com/auth/fitness.location.write",
  2492. // "https://www.googleapis.com/auth/fitness.nutrition.read",
  2493. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  2494. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
  2495. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  2496. // "https://www.googleapis.com/auth/fitness.reproductive_health.read",
  2497. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  2498. // ]
  2499. // }
  2500. }
  2501. // Pages invokes f for each page of results.
  2502. // A non-nil error returned from f will halt the iteration.
  2503. // The provided context supersedes any context provided to the Context method.
  2504. func (c *UsersDataSourcesDatasetsGetCall) Pages(ctx context.Context, f func(*Dataset) error) error {
  2505. c.ctx_ = ctx
  2506. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2507. for {
  2508. x, err := c.Do()
  2509. if err != nil {
  2510. return err
  2511. }
  2512. if err := f(x); err != nil {
  2513. return err
  2514. }
  2515. if x.NextPageToken == "" {
  2516. return nil
  2517. }
  2518. c.PageToken(x.NextPageToken)
  2519. }
  2520. }
  2521. // method id "fitness.users.dataSources.datasets.patch":
  2522. type UsersDataSourcesDatasetsPatchCall struct {
  2523. s *Service
  2524. userId string
  2525. dataSourceId string
  2526. datasetId string
  2527. dataset *Dataset
  2528. urlParams_ gensupport.URLParams
  2529. ctx_ context.Context
  2530. header_ http.Header
  2531. }
  2532. // Patch: Adds data points to a dataset. The dataset need not be
  2533. // previously created. All points within the given dataset will be
  2534. // returned with subsquent calls to retrieve this dataset. Data points
  2535. // can belong to more than one dataset. This method does not use patch
  2536. // semantics.
  2537. func (r *UsersDataSourcesDatasetsService) Patch(userId string, dataSourceId string, datasetId string, dataset *Dataset) *UsersDataSourcesDatasetsPatchCall {
  2538. c := &UsersDataSourcesDatasetsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2539. c.userId = userId
  2540. c.dataSourceId = dataSourceId
  2541. c.datasetId = datasetId
  2542. c.dataset = dataset
  2543. return c
  2544. }
  2545. // CurrentTimeMillis sets the optional parameter "currentTimeMillis":
  2546. // The client's current time in milliseconds since epoch. Note that the
  2547. // minStartTimeNs and maxEndTimeNs properties in the request body are in
  2548. // nanoseconds instead of milliseconds.
  2549. func (c *UsersDataSourcesDatasetsPatchCall) CurrentTimeMillis(currentTimeMillis int64) *UsersDataSourcesDatasetsPatchCall {
  2550. c.urlParams_.Set("currentTimeMillis", fmt.Sprint(currentTimeMillis))
  2551. return c
  2552. }
  2553. // Fields allows partial responses to be retrieved. See
  2554. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2555. // for more information.
  2556. func (c *UsersDataSourcesDatasetsPatchCall) Fields(s ...googleapi.Field) *UsersDataSourcesDatasetsPatchCall {
  2557. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2558. return c
  2559. }
  2560. // Context sets the context to be used in this call's Do method. Any
  2561. // pending HTTP request will be aborted if the provided context is
  2562. // canceled.
  2563. func (c *UsersDataSourcesDatasetsPatchCall) Context(ctx context.Context) *UsersDataSourcesDatasetsPatchCall {
  2564. c.ctx_ = ctx
  2565. return c
  2566. }
  2567. // Header returns an http.Header that can be modified by the caller to
  2568. // add HTTP headers to the request.
  2569. func (c *UsersDataSourcesDatasetsPatchCall) Header() http.Header {
  2570. if c.header_ == nil {
  2571. c.header_ = make(http.Header)
  2572. }
  2573. return c.header_
  2574. }
  2575. func (c *UsersDataSourcesDatasetsPatchCall) doRequest(alt string) (*http.Response, error) {
  2576. reqHeaders := make(http.Header)
  2577. for k, v := range c.header_ {
  2578. reqHeaders[k] = v
  2579. }
  2580. reqHeaders.Set("User-Agent", c.s.userAgent())
  2581. var body io.Reader = nil
  2582. body, err := googleapi.WithoutDataWrapper.JSONReader(c.dataset)
  2583. if err != nil {
  2584. return nil, err
  2585. }
  2586. reqHeaders.Set("Content-Type", "application/json")
  2587. c.urlParams_.Set("alt", alt)
  2588. c.urlParams_.Set("prettyPrint", "false")
  2589. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataSources/{dataSourceId}/datasets/{datasetId}")
  2590. urls += "?" + c.urlParams_.Encode()
  2591. req, err := http.NewRequest("PATCH", urls, body)
  2592. if err != nil {
  2593. return nil, err
  2594. }
  2595. req.Header = reqHeaders
  2596. googleapi.Expand(req.URL, map[string]string{
  2597. "userId": c.userId,
  2598. "dataSourceId": c.dataSourceId,
  2599. "datasetId": c.datasetId,
  2600. })
  2601. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2602. }
  2603. // Do executes the "fitness.users.dataSources.datasets.patch" call.
  2604. // Exactly one of *Dataset or error will be non-nil. Any non-2xx status
  2605. // code is an error. Response headers are in either
  2606. // *Dataset.ServerResponse.Header or (if a response was returned at all)
  2607. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2608. // check whether the returned error was because http.StatusNotModified
  2609. // was returned.
  2610. func (c *UsersDataSourcesDatasetsPatchCall) Do(opts ...googleapi.CallOption) (*Dataset, error) {
  2611. gensupport.SetOptions(c.urlParams_, opts...)
  2612. res, err := c.doRequest("json")
  2613. if res != nil && res.StatusCode == http.StatusNotModified {
  2614. if res.Body != nil {
  2615. res.Body.Close()
  2616. }
  2617. return nil, &googleapi.Error{
  2618. Code: res.StatusCode,
  2619. Header: res.Header,
  2620. }
  2621. }
  2622. if err != nil {
  2623. return nil, err
  2624. }
  2625. defer googleapi.CloseBody(res)
  2626. if err := googleapi.CheckResponse(res); err != nil {
  2627. return nil, err
  2628. }
  2629. ret := &Dataset{
  2630. ServerResponse: googleapi.ServerResponse{
  2631. Header: res.Header,
  2632. HTTPStatusCode: res.StatusCode,
  2633. },
  2634. }
  2635. target := &ret
  2636. if err := gensupport.DecodeResponse(target, res); err != nil {
  2637. return nil, err
  2638. }
  2639. return ret, nil
  2640. // {
  2641. // "description": "Adds data points to a dataset. The dataset need not be previously created. All points within the given dataset will be returned with subsquent calls to retrieve this dataset. Data points can belong to more than one dataset. This method does not use patch semantics.",
  2642. // "httpMethod": "PATCH",
  2643. // "id": "fitness.users.dataSources.datasets.patch",
  2644. // "parameterOrder": [
  2645. // "userId",
  2646. // "dataSourceId",
  2647. // "datasetId"
  2648. // ],
  2649. // "parameters": {
  2650. // "currentTimeMillis": {
  2651. // "description": "The client's current time in milliseconds since epoch. Note that the minStartTimeNs and maxEndTimeNs properties in the request body are in nanoseconds instead of milliseconds.",
  2652. // "format": "int64",
  2653. // "location": "query",
  2654. // "type": "string"
  2655. // },
  2656. // "dataSourceId": {
  2657. // "description": "The data stream ID of the data source that created the dataset.",
  2658. // "location": "path",
  2659. // "required": true,
  2660. // "type": "string"
  2661. // },
  2662. // "datasetId": {
  2663. // "description": "Dataset identifier that is a composite of the minimum data point start time and maximum data point end time represented as nanoseconds from the epoch. The ID is formatted like: \"startTime-endTime\" where startTime and endTime are 64 bit integers.",
  2664. // "location": "path",
  2665. // "required": true,
  2666. // "type": "string"
  2667. // },
  2668. // "userId": {
  2669. // "description": "Patch a dataset for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  2670. // "location": "path",
  2671. // "required": true,
  2672. // "type": "string"
  2673. // }
  2674. // },
  2675. // "path": "{userId}/dataSources/{dataSourceId}/datasets/{datasetId}",
  2676. // "request": {
  2677. // "$ref": "Dataset"
  2678. // },
  2679. // "response": {
  2680. // "$ref": "Dataset"
  2681. // },
  2682. // "scopes": [
  2683. // "https://www.googleapis.com/auth/fitness.activity.write",
  2684. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  2685. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  2686. // "https://www.googleapis.com/auth/fitness.body.write",
  2687. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  2688. // "https://www.googleapis.com/auth/fitness.location.write",
  2689. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  2690. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  2691. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  2692. // ]
  2693. // }
  2694. }
  2695. // Pages invokes f for each page of results.
  2696. // A non-nil error returned from f will halt the iteration.
  2697. // The provided context supersedes any context provided to the Context method.
  2698. func (c *UsersDataSourcesDatasetsPatchCall) Pages(ctx context.Context, f func(*Dataset) error) error {
  2699. c.ctx_ = ctx
  2700. defer func(pt string) { c.dataset.NextPageToken = pt }(c.dataset.NextPageToken) // reset paging to original point
  2701. for {
  2702. x, err := c.Do()
  2703. if err != nil {
  2704. return err
  2705. }
  2706. if err := f(x); err != nil {
  2707. return err
  2708. }
  2709. if x.NextPageToken == "" {
  2710. return nil
  2711. }
  2712. c.dataset.NextPageToken = x.NextPageToken
  2713. }
  2714. }
  2715. // method id "fitness.users.dataset.aggregate":
  2716. type UsersDatasetAggregateCall struct {
  2717. s *Service
  2718. userId string
  2719. aggregaterequest *AggregateRequest
  2720. urlParams_ gensupport.URLParams
  2721. ctx_ context.Context
  2722. header_ http.Header
  2723. }
  2724. // Aggregate: Aggregates data of a certain type or stream into buckets
  2725. // divided by a given type of boundary. Multiple data sets of multiple
  2726. // types and from multiple sources can be aggreated into exactly one
  2727. // bucket type per request.
  2728. func (r *UsersDatasetService) Aggregate(userId string, aggregaterequest *AggregateRequest) *UsersDatasetAggregateCall {
  2729. c := &UsersDatasetAggregateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2730. c.userId = userId
  2731. c.aggregaterequest = aggregaterequest
  2732. return c
  2733. }
  2734. // Fields allows partial responses to be retrieved. See
  2735. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2736. // for more information.
  2737. func (c *UsersDatasetAggregateCall) Fields(s ...googleapi.Field) *UsersDatasetAggregateCall {
  2738. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2739. return c
  2740. }
  2741. // Context sets the context to be used in this call's Do method. Any
  2742. // pending HTTP request will be aborted if the provided context is
  2743. // canceled.
  2744. func (c *UsersDatasetAggregateCall) Context(ctx context.Context) *UsersDatasetAggregateCall {
  2745. c.ctx_ = ctx
  2746. return c
  2747. }
  2748. // Header returns an http.Header that can be modified by the caller to
  2749. // add HTTP headers to the request.
  2750. func (c *UsersDatasetAggregateCall) Header() http.Header {
  2751. if c.header_ == nil {
  2752. c.header_ = make(http.Header)
  2753. }
  2754. return c.header_
  2755. }
  2756. func (c *UsersDatasetAggregateCall) doRequest(alt string) (*http.Response, error) {
  2757. reqHeaders := make(http.Header)
  2758. for k, v := range c.header_ {
  2759. reqHeaders[k] = v
  2760. }
  2761. reqHeaders.Set("User-Agent", c.s.userAgent())
  2762. var body io.Reader = nil
  2763. body, err := googleapi.WithoutDataWrapper.JSONReader(c.aggregaterequest)
  2764. if err != nil {
  2765. return nil, err
  2766. }
  2767. reqHeaders.Set("Content-Type", "application/json")
  2768. c.urlParams_.Set("alt", alt)
  2769. c.urlParams_.Set("prettyPrint", "false")
  2770. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/dataset:aggregate")
  2771. urls += "?" + c.urlParams_.Encode()
  2772. req, err := http.NewRequest("POST", urls, body)
  2773. if err != nil {
  2774. return nil, err
  2775. }
  2776. req.Header = reqHeaders
  2777. googleapi.Expand(req.URL, map[string]string{
  2778. "userId": c.userId,
  2779. })
  2780. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2781. }
  2782. // Do executes the "fitness.users.dataset.aggregate" call.
  2783. // Exactly one of *AggregateResponse or error will be non-nil. Any
  2784. // non-2xx status code is an error. Response headers are in either
  2785. // *AggregateResponse.ServerResponse.Header or (if a response was
  2786. // returned at all) in error.(*googleapi.Error).Header. Use
  2787. // googleapi.IsNotModified to check whether the returned error was
  2788. // because http.StatusNotModified was returned.
  2789. func (c *UsersDatasetAggregateCall) Do(opts ...googleapi.CallOption) (*AggregateResponse, error) {
  2790. gensupport.SetOptions(c.urlParams_, opts...)
  2791. res, err := c.doRequest("json")
  2792. if res != nil && res.StatusCode == http.StatusNotModified {
  2793. if res.Body != nil {
  2794. res.Body.Close()
  2795. }
  2796. return nil, &googleapi.Error{
  2797. Code: res.StatusCode,
  2798. Header: res.Header,
  2799. }
  2800. }
  2801. if err != nil {
  2802. return nil, err
  2803. }
  2804. defer googleapi.CloseBody(res)
  2805. if err := googleapi.CheckResponse(res); err != nil {
  2806. return nil, err
  2807. }
  2808. ret := &AggregateResponse{
  2809. ServerResponse: googleapi.ServerResponse{
  2810. Header: res.Header,
  2811. HTTPStatusCode: res.StatusCode,
  2812. },
  2813. }
  2814. target := &ret
  2815. if err := gensupport.DecodeResponse(target, res); err != nil {
  2816. return nil, err
  2817. }
  2818. return ret, nil
  2819. // {
  2820. // "description": "Aggregates data of a certain type or stream into buckets divided by a given type of boundary. Multiple data sets of multiple types and from multiple sources can be aggreated into exactly one bucket type per request.",
  2821. // "httpMethod": "POST",
  2822. // "id": "fitness.users.dataset.aggregate",
  2823. // "parameterOrder": [
  2824. // "userId"
  2825. // ],
  2826. // "parameters": {
  2827. // "userId": {
  2828. // "description": "Aggregate data for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  2829. // "location": "path",
  2830. // "required": true,
  2831. // "type": "string"
  2832. // }
  2833. // },
  2834. // "path": "{userId}/dataset:aggregate",
  2835. // "request": {
  2836. // "$ref": "AggregateRequest"
  2837. // },
  2838. // "response": {
  2839. // "$ref": "AggregateResponse"
  2840. // },
  2841. // "scopes": [
  2842. // "https://www.googleapis.com/auth/fitness.activity.read",
  2843. // "https://www.googleapis.com/auth/fitness.activity.write",
  2844. // "https://www.googleapis.com/auth/fitness.blood_glucose.read",
  2845. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  2846. // "https://www.googleapis.com/auth/fitness.blood_pressure.read",
  2847. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  2848. // "https://www.googleapis.com/auth/fitness.body.read",
  2849. // "https://www.googleapis.com/auth/fitness.body.write",
  2850. // "https://www.googleapis.com/auth/fitness.body_temperature.read",
  2851. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  2852. // "https://www.googleapis.com/auth/fitness.location.read",
  2853. // "https://www.googleapis.com/auth/fitness.location.write",
  2854. // "https://www.googleapis.com/auth/fitness.nutrition.read",
  2855. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  2856. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
  2857. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  2858. // "https://www.googleapis.com/auth/fitness.reproductive_health.read",
  2859. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  2860. // ]
  2861. // }
  2862. }
  2863. // method id "fitness.users.sessions.delete":
  2864. type UsersSessionsDeleteCall struct {
  2865. s *Service
  2866. userId string
  2867. sessionId string
  2868. urlParams_ gensupport.URLParams
  2869. ctx_ context.Context
  2870. header_ http.Header
  2871. }
  2872. // Delete: Deletes a session specified by the given session ID.
  2873. func (r *UsersSessionsService) Delete(userId string, sessionId string) *UsersSessionsDeleteCall {
  2874. c := &UsersSessionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2875. c.userId = userId
  2876. c.sessionId = sessionId
  2877. return c
  2878. }
  2879. // CurrentTimeMillis sets the optional parameter "currentTimeMillis":
  2880. // The client's current time in milliseconds since epoch.
  2881. func (c *UsersSessionsDeleteCall) CurrentTimeMillis(currentTimeMillis int64) *UsersSessionsDeleteCall {
  2882. c.urlParams_.Set("currentTimeMillis", fmt.Sprint(currentTimeMillis))
  2883. return c
  2884. }
  2885. // Fields allows partial responses to be retrieved. See
  2886. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2887. // for more information.
  2888. func (c *UsersSessionsDeleteCall) Fields(s ...googleapi.Field) *UsersSessionsDeleteCall {
  2889. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2890. return c
  2891. }
  2892. // Context sets the context to be used in this call's Do method. Any
  2893. // pending HTTP request will be aborted if the provided context is
  2894. // canceled.
  2895. func (c *UsersSessionsDeleteCall) Context(ctx context.Context) *UsersSessionsDeleteCall {
  2896. c.ctx_ = ctx
  2897. return c
  2898. }
  2899. // Header returns an http.Header that can be modified by the caller to
  2900. // add HTTP headers to the request.
  2901. func (c *UsersSessionsDeleteCall) Header() http.Header {
  2902. if c.header_ == nil {
  2903. c.header_ = make(http.Header)
  2904. }
  2905. return c.header_
  2906. }
  2907. func (c *UsersSessionsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2908. reqHeaders := make(http.Header)
  2909. for k, v := range c.header_ {
  2910. reqHeaders[k] = v
  2911. }
  2912. reqHeaders.Set("User-Agent", c.s.userAgent())
  2913. var body io.Reader = nil
  2914. c.urlParams_.Set("alt", alt)
  2915. c.urlParams_.Set("prettyPrint", "false")
  2916. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/sessions/{sessionId}")
  2917. urls += "?" + c.urlParams_.Encode()
  2918. req, err := http.NewRequest("DELETE", urls, body)
  2919. if err != nil {
  2920. return nil, err
  2921. }
  2922. req.Header = reqHeaders
  2923. googleapi.Expand(req.URL, map[string]string{
  2924. "userId": c.userId,
  2925. "sessionId": c.sessionId,
  2926. })
  2927. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2928. }
  2929. // Do executes the "fitness.users.sessions.delete" call.
  2930. func (c *UsersSessionsDeleteCall) Do(opts ...googleapi.CallOption) error {
  2931. gensupport.SetOptions(c.urlParams_, opts...)
  2932. res, err := c.doRequest("json")
  2933. if err != nil {
  2934. return err
  2935. }
  2936. defer googleapi.CloseBody(res)
  2937. if err := googleapi.CheckResponse(res); err != nil {
  2938. return err
  2939. }
  2940. return nil
  2941. // {
  2942. // "description": "Deletes a session specified by the given session ID.",
  2943. // "httpMethod": "DELETE",
  2944. // "id": "fitness.users.sessions.delete",
  2945. // "parameterOrder": [
  2946. // "userId",
  2947. // "sessionId"
  2948. // ],
  2949. // "parameters": {
  2950. // "currentTimeMillis": {
  2951. // "description": "The client's current time in milliseconds since epoch.",
  2952. // "format": "int64",
  2953. // "location": "query",
  2954. // "type": "string"
  2955. // },
  2956. // "sessionId": {
  2957. // "description": "The ID of the session to be deleted.",
  2958. // "location": "path",
  2959. // "required": true,
  2960. // "type": "string"
  2961. // },
  2962. // "userId": {
  2963. // "description": "Delete a session for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  2964. // "location": "path",
  2965. // "required": true,
  2966. // "type": "string"
  2967. // }
  2968. // },
  2969. // "path": "{userId}/sessions/{sessionId}",
  2970. // "scopes": [
  2971. // "https://www.googleapis.com/auth/fitness.activity.write"
  2972. // ]
  2973. // }
  2974. }
  2975. // method id "fitness.users.sessions.list":
  2976. type UsersSessionsListCall struct {
  2977. s *Service
  2978. userId string
  2979. urlParams_ gensupport.URLParams
  2980. ifNoneMatch_ string
  2981. ctx_ context.Context
  2982. header_ http.Header
  2983. }
  2984. // List: Lists sessions previously created.
  2985. func (r *UsersSessionsService) List(userId string) *UsersSessionsListCall {
  2986. c := &UsersSessionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2987. c.userId = userId
  2988. return c
  2989. }
  2990. // EndTime sets the optional parameter "endTime": An RFC3339 timestamp.
  2991. // Only sessions ending between the start and end times will be included
  2992. // in the response.
  2993. func (c *UsersSessionsListCall) EndTime(endTime string) *UsersSessionsListCall {
  2994. c.urlParams_.Set("endTime", endTime)
  2995. return c
  2996. }
  2997. // IncludeDeleted sets the optional parameter "includeDeleted": If true,
  2998. // deleted sessions will be returned. When set to true, sessions
  2999. // returned in this response will only have an ID and will not have any
  3000. // other fields.
  3001. func (c *UsersSessionsListCall) IncludeDeleted(includeDeleted bool) *UsersSessionsListCall {
  3002. c.urlParams_.Set("includeDeleted", fmt.Sprint(includeDeleted))
  3003. return c
  3004. }
  3005. // PageToken sets the optional parameter "pageToken": The continuation
  3006. // token, which is used for incremental syncing. To get the next batch
  3007. // of changes, set this parameter to the value of nextPageToken from the
  3008. // previous response. This token is treated as a timestamp (in millis
  3009. // since epoch). If specified, the API returns sessions modified since
  3010. // this time. The page token is ignored if either start or end time is
  3011. // specified. If none of start time, end time, and the page token is
  3012. // specified, sessions modified in the last 30 days are returned.
  3013. func (c *UsersSessionsListCall) PageToken(pageToken string) *UsersSessionsListCall {
  3014. c.urlParams_.Set("pageToken", pageToken)
  3015. return c
  3016. }
  3017. // StartTime sets the optional parameter "startTime": An RFC3339
  3018. // timestamp. Only sessions ending between the start and end times will
  3019. // be included in the response.
  3020. func (c *UsersSessionsListCall) StartTime(startTime string) *UsersSessionsListCall {
  3021. c.urlParams_.Set("startTime", startTime)
  3022. return c
  3023. }
  3024. // Fields allows partial responses to be retrieved. See
  3025. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3026. // for more information.
  3027. func (c *UsersSessionsListCall) Fields(s ...googleapi.Field) *UsersSessionsListCall {
  3028. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3029. return c
  3030. }
  3031. // IfNoneMatch sets the optional parameter which makes the operation
  3032. // fail if the object's ETag matches the given value. This is useful for
  3033. // getting updates only after the object has changed since the last
  3034. // request. Use googleapi.IsNotModified to check whether the response
  3035. // error from Do is the result of In-None-Match.
  3036. func (c *UsersSessionsListCall) IfNoneMatch(entityTag string) *UsersSessionsListCall {
  3037. c.ifNoneMatch_ = entityTag
  3038. return c
  3039. }
  3040. // Context sets the context to be used in this call's Do method. Any
  3041. // pending HTTP request will be aborted if the provided context is
  3042. // canceled.
  3043. func (c *UsersSessionsListCall) Context(ctx context.Context) *UsersSessionsListCall {
  3044. c.ctx_ = ctx
  3045. return c
  3046. }
  3047. // Header returns an http.Header that can be modified by the caller to
  3048. // add HTTP headers to the request.
  3049. func (c *UsersSessionsListCall) Header() http.Header {
  3050. if c.header_ == nil {
  3051. c.header_ = make(http.Header)
  3052. }
  3053. return c.header_
  3054. }
  3055. func (c *UsersSessionsListCall) doRequest(alt string) (*http.Response, error) {
  3056. reqHeaders := make(http.Header)
  3057. for k, v := range c.header_ {
  3058. reqHeaders[k] = v
  3059. }
  3060. reqHeaders.Set("User-Agent", c.s.userAgent())
  3061. if c.ifNoneMatch_ != "" {
  3062. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3063. }
  3064. var body io.Reader = nil
  3065. c.urlParams_.Set("alt", alt)
  3066. c.urlParams_.Set("prettyPrint", "false")
  3067. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/sessions")
  3068. urls += "?" + c.urlParams_.Encode()
  3069. req, err := http.NewRequest("GET", urls, body)
  3070. if err != nil {
  3071. return nil, err
  3072. }
  3073. req.Header = reqHeaders
  3074. googleapi.Expand(req.URL, map[string]string{
  3075. "userId": c.userId,
  3076. })
  3077. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3078. }
  3079. // Do executes the "fitness.users.sessions.list" call.
  3080. // Exactly one of *ListSessionsResponse or error will be non-nil. Any
  3081. // non-2xx status code is an error. Response headers are in either
  3082. // *ListSessionsResponse.ServerResponse.Header or (if a response was
  3083. // returned at all) in error.(*googleapi.Error).Header. Use
  3084. // googleapi.IsNotModified to check whether the returned error was
  3085. // because http.StatusNotModified was returned.
  3086. func (c *UsersSessionsListCall) Do(opts ...googleapi.CallOption) (*ListSessionsResponse, error) {
  3087. gensupport.SetOptions(c.urlParams_, opts...)
  3088. res, err := c.doRequest("json")
  3089. if res != nil && res.StatusCode == http.StatusNotModified {
  3090. if res.Body != nil {
  3091. res.Body.Close()
  3092. }
  3093. return nil, &googleapi.Error{
  3094. Code: res.StatusCode,
  3095. Header: res.Header,
  3096. }
  3097. }
  3098. if err != nil {
  3099. return nil, err
  3100. }
  3101. defer googleapi.CloseBody(res)
  3102. if err := googleapi.CheckResponse(res); err != nil {
  3103. return nil, err
  3104. }
  3105. ret := &ListSessionsResponse{
  3106. ServerResponse: googleapi.ServerResponse{
  3107. Header: res.Header,
  3108. HTTPStatusCode: res.StatusCode,
  3109. },
  3110. }
  3111. target := &ret
  3112. if err := gensupport.DecodeResponse(target, res); err != nil {
  3113. return nil, err
  3114. }
  3115. return ret, nil
  3116. // {
  3117. // "description": "Lists sessions previously created.",
  3118. // "httpMethod": "GET",
  3119. // "id": "fitness.users.sessions.list",
  3120. // "parameterOrder": [
  3121. // "userId"
  3122. // ],
  3123. // "parameters": {
  3124. // "endTime": {
  3125. // "description": "An RFC3339 timestamp. Only sessions ending between the start and end times will be included in the response.",
  3126. // "location": "query",
  3127. // "type": "string"
  3128. // },
  3129. // "includeDeleted": {
  3130. // "description": "If true, deleted sessions will be returned. When set to true, sessions returned in this response will only have an ID and will not have any other fields.",
  3131. // "location": "query",
  3132. // "type": "boolean"
  3133. // },
  3134. // "pageToken": {
  3135. // "description": "The continuation token, which is used for incremental syncing. To get the next batch of changes, set this parameter to the value of nextPageToken from the previous response. This token is treated as a timestamp (in millis since epoch). If specified, the API returns sessions modified since this time. The page token is ignored if either start or end time is specified. If none of start time, end time, and the page token is specified, sessions modified in the last 30 days are returned.",
  3136. // "location": "query",
  3137. // "type": "string"
  3138. // },
  3139. // "startTime": {
  3140. // "description": "An RFC3339 timestamp. Only sessions ending between the start and end times will be included in the response.",
  3141. // "location": "query",
  3142. // "type": "string"
  3143. // },
  3144. // "userId": {
  3145. // "description": "List sessions for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  3146. // "location": "path",
  3147. // "required": true,
  3148. // "type": "string"
  3149. // }
  3150. // },
  3151. // "path": "{userId}/sessions",
  3152. // "response": {
  3153. // "$ref": "ListSessionsResponse"
  3154. // },
  3155. // "scopes": [
  3156. // "https://www.googleapis.com/auth/fitness.activity.read",
  3157. // "https://www.googleapis.com/auth/fitness.activity.write",
  3158. // "https://www.googleapis.com/auth/fitness.blood_glucose.read",
  3159. // "https://www.googleapis.com/auth/fitness.blood_glucose.write",
  3160. // "https://www.googleapis.com/auth/fitness.blood_pressure.read",
  3161. // "https://www.googleapis.com/auth/fitness.blood_pressure.write",
  3162. // "https://www.googleapis.com/auth/fitness.body.read",
  3163. // "https://www.googleapis.com/auth/fitness.body.write",
  3164. // "https://www.googleapis.com/auth/fitness.body_temperature.read",
  3165. // "https://www.googleapis.com/auth/fitness.body_temperature.write",
  3166. // "https://www.googleapis.com/auth/fitness.location.read",
  3167. // "https://www.googleapis.com/auth/fitness.location.write",
  3168. // "https://www.googleapis.com/auth/fitness.nutrition.read",
  3169. // "https://www.googleapis.com/auth/fitness.nutrition.write",
  3170. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
  3171. // "https://www.googleapis.com/auth/fitness.oxygen_saturation.write",
  3172. // "https://www.googleapis.com/auth/fitness.reproductive_health.read",
  3173. // "https://www.googleapis.com/auth/fitness.reproductive_health.write"
  3174. // ]
  3175. // }
  3176. }
  3177. // Pages invokes f for each page of results.
  3178. // A non-nil error returned from f will halt the iteration.
  3179. // The provided context supersedes any context provided to the Context method.
  3180. func (c *UsersSessionsListCall) Pages(ctx context.Context, f func(*ListSessionsResponse) error) error {
  3181. c.ctx_ = ctx
  3182. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3183. for {
  3184. x, err := c.Do()
  3185. if err != nil {
  3186. return err
  3187. }
  3188. if err := f(x); err != nil {
  3189. return err
  3190. }
  3191. if x.NextPageToken == "" {
  3192. return nil
  3193. }
  3194. c.PageToken(x.NextPageToken)
  3195. }
  3196. }
  3197. // method id "fitness.users.sessions.update":
  3198. type UsersSessionsUpdateCall struct {
  3199. s *Service
  3200. userId string
  3201. sessionId string
  3202. session *Session
  3203. urlParams_ gensupport.URLParams
  3204. ctx_ context.Context
  3205. header_ http.Header
  3206. }
  3207. // Update: Updates or insert a given session.
  3208. func (r *UsersSessionsService) Update(userId string, sessionId string, session *Session) *UsersSessionsUpdateCall {
  3209. c := &UsersSessionsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3210. c.userId = userId
  3211. c.sessionId = sessionId
  3212. c.session = session
  3213. return c
  3214. }
  3215. // CurrentTimeMillis sets the optional parameter "currentTimeMillis":
  3216. // The client's current time in milliseconds since epoch.
  3217. func (c *UsersSessionsUpdateCall) CurrentTimeMillis(currentTimeMillis int64) *UsersSessionsUpdateCall {
  3218. c.urlParams_.Set("currentTimeMillis", fmt.Sprint(currentTimeMillis))
  3219. return c
  3220. }
  3221. // Fields allows partial responses to be retrieved. See
  3222. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3223. // for more information.
  3224. func (c *UsersSessionsUpdateCall) Fields(s ...googleapi.Field) *UsersSessionsUpdateCall {
  3225. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3226. return c
  3227. }
  3228. // Context sets the context to be used in this call's Do method. Any
  3229. // pending HTTP request will be aborted if the provided context is
  3230. // canceled.
  3231. func (c *UsersSessionsUpdateCall) Context(ctx context.Context) *UsersSessionsUpdateCall {
  3232. c.ctx_ = ctx
  3233. return c
  3234. }
  3235. // Header returns an http.Header that can be modified by the caller to
  3236. // add HTTP headers to the request.
  3237. func (c *UsersSessionsUpdateCall) Header() http.Header {
  3238. if c.header_ == nil {
  3239. c.header_ = make(http.Header)
  3240. }
  3241. return c.header_
  3242. }
  3243. func (c *UsersSessionsUpdateCall) doRequest(alt string) (*http.Response, error) {
  3244. reqHeaders := make(http.Header)
  3245. for k, v := range c.header_ {
  3246. reqHeaders[k] = v
  3247. }
  3248. reqHeaders.Set("User-Agent", c.s.userAgent())
  3249. var body io.Reader = nil
  3250. body, err := googleapi.WithoutDataWrapper.JSONReader(c.session)
  3251. if err != nil {
  3252. return nil, err
  3253. }
  3254. reqHeaders.Set("Content-Type", "application/json")
  3255. c.urlParams_.Set("alt", alt)
  3256. c.urlParams_.Set("prettyPrint", "false")
  3257. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/sessions/{sessionId}")
  3258. urls += "?" + c.urlParams_.Encode()
  3259. req, err := http.NewRequest("PUT", urls, body)
  3260. if err != nil {
  3261. return nil, err
  3262. }
  3263. req.Header = reqHeaders
  3264. googleapi.Expand(req.URL, map[string]string{
  3265. "userId": c.userId,
  3266. "sessionId": c.sessionId,
  3267. })
  3268. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3269. }
  3270. // Do executes the "fitness.users.sessions.update" call.
  3271. // Exactly one of *Session or error will be non-nil. Any non-2xx status
  3272. // code is an error. Response headers are in either
  3273. // *Session.ServerResponse.Header or (if a response was returned at all)
  3274. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3275. // check whether the returned error was because http.StatusNotModified
  3276. // was returned.
  3277. func (c *UsersSessionsUpdateCall) Do(opts ...googleapi.CallOption) (*Session, error) {
  3278. gensupport.SetOptions(c.urlParams_, opts...)
  3279. res, err := c.doRequest("json")
  3280. if res != nil && res.StatusCode == http.StatusNotModified {
  3281. if res.Body != nil {
  3282. res.Body.Close()
  3283. }
  3284. return nil, &googleapi.Error{
  3285. Code: res.StatusCode,
  3286. Header: res.Header,
  3287. }
  3288. }
  3289. if err != nil {
  3290. return nil, err
  3291. }
  3292. defer googleapi.CloseBody(res)
  3293. if err := googleapi.CheckResponse(res); err != nil {
  3294. return nil, err
  3295. }
  3296. ret := &Session{
  3297. ServerResponse: googleapi.ServerResponse{
  3298. Header: res.Header,
  3299. HTTPStatusCode: res.StatusCode,
  3300. },
  3301. }
  3302. target := &ret
  3303. if err := gensupport.DecodeResponse(target, res); err != nil {
  3304. return nil, err
  3305. }
  3306. return ret, nil
  3307. // {
  3308. // "description": "Updates or insert a given session.",
  3309. // "httpMethod": "PUT",
  3310. // "id": "fitness.users.sessions.update",
  3311. // "parameterOrder": [
  3312. // "userId",
  3313. // "sessionId"
  3314. // ],
  3315. // "parameters": {
  3316. // "currentTimeMillis": {
  3317. // "description": "The client's current time in milliseconds since epoch.",
  3318. // "format": "int64",
  3319. // "location": "query",
  3320. // "type": "string"
  3321. // },
  3322. // "sessionId": {
  3323. // "description": "The ID of the session to be created.",
  3324. // "location": "path",
  3325. // "required": true,
  3326. // "type": "string"
  3327. // },
  3328. // "userId": {
  3329. // "description": "Create sessions for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.",
  3330. // "location": "path",
  3331. // "required": true,
  3332. // "type": "string"
  3333. // }
  3334. // },
  3335. // "path": "{userId}/sessions/{sessionId}",
  3336. // "request": {
  3337. // "$ref": "Session"
  3338. // },
  3339. // "response": {
  3340. // "$ref": "Session"
  3341. // },
  3342. // "scopes": [
  3343. // "https://www.googleapis.com/auth/fitness.activity.write"
  3344. // ]
  3345. // }
  3346. }