Skip to content

Commit e2be97c

Browse files
authored
chore: fix output formatting of HL7v2 notificationConfigs (GoogleCloudPlatform#6511)
## Description Fixes b/176801387 ## Checklist - [X] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md) - [X] README is updated to include [all relevant information](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#readme-file) - [X] **Tests** pass: `nox -s py-3.6` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [X] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] These samples need a new **API enabled** in testing projects to pass (let us know which ones) - [ ] These samples need a new/updated **env vars** in testing projects set to pass (let us know which ones) - [X] Please **merge** this PR for me once it is approved. - [ ] This sample adds a new sample directory, and I updated the [CODEOWNERS file](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/.github/CODEOWNERS) with the codeowners for this sample
1 parent b6c2a08 commit e2be97c

File tree

2 files changed

+70
-28
lines changed

2 files changed

+70
-28
lines changed

healthcare/api-client/v1/hl7v2/README.rst

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,29 @@ To run this sample:
100100
positional arguments:
101101
{create-hl7v2-store,delete-hl7v2-store,get-hl7v2-store,list-hl7v2-stores,patch-hl7v2-store,get_iam_policy,set_iam_policy}
102102
create-hl7v2-store Creates a new HL7v2 store within the parent dataset.
103-
delete-hl7v2-store Deletes the specified HL7v2 store.
104-
get-hl7v2-store Gets the specified HL7v2 store.
105-
list-hl7v2-stores Lists the HL7v2 stores in the given dataset.
106-
patch-hl7v2-store Updates the HL7v2 store.
107-
get_iam_policy Gets the IAM policy for the specified HL7v2 store.
103+
See https://github.com/GoogleCloudPlatform/python-
104+
docs-samples/tree/master/healthcare/api-
105+
client/v1/hl7v2 before running the sample.
106+
delete-hl7v2-store Deletes the specified HL7v2 store. See
107+
https://github.com/GoogleCloudPlatform/python-docs-
108+
samples/tree/master/healthcare/api-client/v1/hl7v2
109+
before running the sample.
110+
get-hl7v2-store Gets the specified HL7v2 store. See
111+
https://github.com/GoogleCloudPlatform/python-docs-
112+
samples/tree/master/healthcare/api-client/v1/hl7v2
113+
before running the sample.
114+
list-hl7v2-stores Lists the HL7v2 stores in the given dataset. See
115+
https://github.com/GoogleCloudPlatform/python-docs-
116+
samples/tree/master/healthcare/api-client/v1/hl7v2
117+
before running the sample.
118+
patch-hl7v2-store Updates the HL7v2 store. See
119+
https://github.com/GoogleCloudPlatform/python-docs-
120+
samples/tree/master/healthcare/api-client/v1/hl7v2
121+
before running the sample.
122+
get_iam_policy Gets the IAM policy for the specified HL7v2 store. See
123+
https://github.com/GoogleCloudPlatform/python-docs-
124+
samples/tree/master/healthcare/api-client/v1/hl7v2
125+
before running the sample.
108126
set_iam_policy Sets the IAM policy for the specified HL7v2 store. A
109127
single member will be assigned a single role. A member
110128
can be any of: - allUsers, that is, anyone -
@@ -116,7 +134,10 @@ To run this sample:
116134
'serviceAccount:my-other-
117135
[email protected]' A role can be any IAM
118136
role, such as 'roles/viewer', 'roles/owner', or
119-
'roles/editor'
137+
'roles/editor'. See
138+
https://github.com/GoogleCloudPlatform/python-docs-
139+
samples/tree/master/healthcare/api-client/v1/hl7v2
140+
before running the sample.
120141
121142
optional arguments:
122143
-h, --help show this help message and exit
@@ -164,20 +185,38 @@ To run this sample:
164185
{create-hl7v2-message,delete-hl7v2-message,get-hl7v2-message,ingest-hl7v2-message,list-hl7v2-messages,patch-hl7v2-message}
165186
create-hl7v2-message
166187
Creates an HL7v2 message and sends a notification to
167-
the Cloud Pub/Sub topic.
188+
the Cloud Pub/Sub topic. See
189+
https://github.com/GoogleCloudPlatform/python-docs-
190+
samples/tree/master/healthcare/api-client/v1/hl7v2
191+
before running the sample.
168192
delete-hl7v2-message
169-
Deletes an HL7v2 message.
170-
get-hl7v2-message Gets an HL7v2 message.
193+
Deletes an HL7v2 message. See
194+
https://github.com/GoogleCloudPlatform/python-docs-
195+
samples/tree/master/healthcare/api-client/v1/hl7v2
196+
before running the sample.
197+
get-hl7v2-message Gets an HL7v2 message. See
198+
https://github.com/GoogleCloudPlatform/python-docs-
199+
samples/tree/master/healthcare/api-client/v1/hl7v2
200+
before running the sample.
171201
ingest-hl7v2-message
172202
Ingests a new HL7v2 message from the hospital and
173203
sends a notification to the Cloud Pub/Sub topic.
174204
Return is an HL7v2 ACK message if the message was
175-
successfully stored.
205+
successfully stored. See
206+
https://github.com/GoogleCloudPlatform/python-docs-
207+
samples/tree/master/healthcare/api-client/v1/hl7v2
208+
before running the sample.
176209
list-hl7v2-messages
177210
Lists all the messages in the given HL7v2 store with
178-
support for filtering.
211+
support for filtering. See
212+
https://github.com/GoogleCloudPlatform/python-docs-
213+
samples/tree/master/healthcare/api-client/v1/hl7v2
214+
before running the sample.
179215
patch-hl7v2-message
180-
Updates the message.
216+
Updates the message. See
217+
https://github.com/GoogleCloudPlatform/python-docs-
218+
samples/tree/master/healthcare/api-client/v1/hl7v2
219+
before running the sample.
181220
182221
optional arguments:
183222
-h, --help show this help message and exit
@@ -216,4 +255,4 @@ to `browse the source`_ and `report issues`_.
216255
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
217256
218257
219-
.. _Google Cloud SDK: https://cloud.google.com/sdk/
258+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

healthcare/api-client/v1/hl7v2/hl7v2_stores.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,13 @@ def get_hl7v2_store(project_id, location, dataset_id, hl7v2_store_id):
125125
hl7v2_store = hl7v2_stores.get(name=hl7v2_store_name).execute()
126126

127127
print("Name: {}".format(hl7v2_store.get("name")))
128-
print("Notification config:")
129-
if hl7v2_store.get("notificationConfig") is not None:
130-
notification_config = hl7v2_store.get("notificationConfig")
131-
print(
132-
"\tCloud Pub/Sub topic: {}".format(notification_config.get("pubsubTopic"))
133-
)
128+
if hl7v2_store.get("notificationConfigs") is not None:
129+
print("Notification configs:")
130+
for notification_config in hl7v2_store.get("notificationConfigs"):
131+
print(
132+
"\tPub/Sub topic: {}".format(notification_config.get("pubsubTopic")),
133+
"\tFilter: {}".format(notification_config.get("filter")),
134+
)
134135

135136
return hl7v2_store
136137

@@ -172,14 +173,16 @@ def list_hl7v2_stores(project_id, location, dataset_id):
172173
)
173174

174175
for hl7v2_store in hl7v2_stores:
175-
print(
176-
"HL7v2 store: {}\n"
177-
"Notification config: {}".format(
178-
hl7v2_store.get("name"),
179-
hl7v2_store.get("notificationConfig"),
180-
)
181-
)
182-
176+
print("HL7v2 store:\nName: {}".format(hl7v2_store.get("name")))
177+
if hl7v2_store.get("notificationConfigs") is not None:
178+
print("Notification configs:")
179+
for notification_config in hl7v2_store.get("notificationConfigs"):
180+
print(
181+
"\tPub/Sub topic: {}".format(
182+
notification_config.get("pubsubTopic")
183+
),
184+
"\tFilter: {}".format(notification_config.get("filter")),
185+
)
183186
return hl7v2_stores
184187

185188

@@ -287,7 +290,7 @@ def set_hl7v2_store_iam_policy(
287290
- serviceAccount:email,
288291
as in 'serviceAccount:[email protected]'
289292
A role can be any IAM role, such as 'roles/viewer', 'roles/owner',
290-
or 'roles/editor'
293+
or 'roles/editor'.
291294
292295
See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/healthcare/api-client/v1/hl7v2
293296
before running the sample."""

0 commit comments

Comments
 (0)