subscriptions
Creates, updates, deletes, gets or lists a subscriptions resource.
Overview
| Name | subscriptions |
| Type | Resource |
| Id | google.health.subscriptions |
Fields
The following fields are returned by SELECT queries:
- list
| Name | Datatype | Description |
|---|---|---|
name | string | Identifier. The resource name of the Subscription. Format: projects/{project}/subscribers/{subscriber}/subscriptions/{subscription} Example: projects/my-project/subscribers/my-subscriber-123/subscriptions/my-subscription-456 The {project} ID is mandatory (6-30 characters, matching /a-z{6,30}/) The {subscriber} ID is user-settable (4-36 characters, matching /a-z/) if provided during creation, or system-generated otherwise. The {subscription} ID is user-settable (4-36 chars, matching /a-z/) or system-generated otherwise. |
dataTypes | array | Optional. Data types subscribed to. A subscriber will only receive notifications for data types that are declared here. A subscription can only subscribe to the data types of the subscriber. The values should be in the format "users/{health_user_id}/dataTypes/{data_type}" where {data_type} is one of "altitude", "distance", "floors", "sleep", "steps", "weight". |
user | string | Immutable. The resource name of the user for whom this subscription is active. Format: users/{user} where {user} is the public healthUserId as returned by the GetIdentity action in the profile PAPI (see google.devicesandservices.health.v4main.HealthProfileService.GetIdentity). |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | projectsId, subscribersId | filter, pageSize, pageToken | Lists all active subscriptions for a given subscriber. This can be filtered, for example, by user or data type. |
create | insert | projectsId, subscribersId | subscriptionId | Creates a subscription for a specific user to a specific subscriber. This method requires the subscriber to have a SubscriptionCreatePolicy set to MANUAL for the given data types. |
patch | update | projectsId, subscribersId, subscriptionsId | updateMask | Updates the data types for an existing user subscription. |
delete | delete | projectsId, subscribersId, subscriptionsId | Deletes a specific user subscription, stopping notifications for this user to this subscriber. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
projectsId | string | |
subscribersId | string | |
subscriptionsId | string | |
filter | string | |
pageSize | integer (int32) | |
pageToken | string | |
subscriptionId | string | |
updateMask | string (google-fieldmask) |
SELECT examples
- list
Lists all active subscriptions for a given subscriber. This can be filtered, for example, by user or data type.
SELECT
name,
dataTypes,
user
FROM google.health.subscriptions
WHERE projectsId = '{{ projectsId }}' -- required
AND subscribersId = '{{ subscribersId }}' -- required
AND filter = '{{ filter }}'
AND pageSize = '{{ pageSize }}'
AND pageToken = '{{ pageToken }}'
;
INSERT examples
- create
- Manifest
Creates a subscription for a specific user to a specific subscriber. This method requires the subscriber to have a SubscriptionCreatePolicy set to MANUAL for the given data types.
INSERT INTO google.health.subscriptions (
data__dataTypes,
data__user,
projectsId,
subscribersId,
subscriptionId
)
SELECT
'{{ dataTypes }}',
'{{ user }}',
'{{ projectsId }}',
'{{ subscribersId }}',
'{{ subscriptionId }}'
RETURNING
name,
dataTypes,
user
;
# Description fields are for documentation purposes
- name: subscriptions
props:
- name: projectsId
value: "{{ projectsId }}"
description: Required parameter for the subscriptions resource.
- name: subscribersId
value: "{{ subscribersId }}"
description: Required parameter for the subscriptions resource.
- name: dataTypes
value:
- "{{ dataTypes }}"
description: |
Optional. Data types subscribed to.
- name: user
value: "{{ user }}"
description: |
Required. Immutable. The resource name of the user for whom this subscription is active. Format: `users/{user}` where `{user}` is the public `healthUserId` as returned by the `GetIdentity` action in the profile PAPI (see `google.devicesandservices.health.v4main.HealthProfileService.GetIdentity`).
- name: subscriptionId
value: "{{ subscriptionId }}"
UPDATE examples
- patch
Updates the data types for an existing user subscription.
UPDATE google.health.subscriptions
SET
data__dataTypes = '{{ dataTypes }}',
data__user = '{{ user }}',
data__name = '{{ name }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND subscribersId = '{{ subscribersId }}' --required
AND subscriptionsId = '{{ subscriptionsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
dataTypes,
user;
DELETE examples
- delete
Deletes a specific user subscription, stopping notifications for this user to this subscriber.
DELETE FROM google.health.subscriptions
WHERE projectsId = '{{ projectsId }}' --required
AND subscribersId = '{{ subscribersId }}' --required
AND subscriptionsId = '{{ subscriptionsId }}' --required
;