Skip to content

Commit 3477e6a

Browse files
authored
fix: update deprecated notificationConfig in healthcare api (#12586)
* fix: update deprecated notificationConfig in healthcare api * fix pubsub field * fix test * fix test
1 parent 506c933 commit 3477e6a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

healthcare/api-client/v1/fhir/fhir_stores.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def list_fhir_stores(project_id, location, dataset_id):
223223

224224

225225
# [START healthcare_patch_fhir_store]
226-
def patch_fhir_store(project_id, location, dataset_id, fhir_store_id):
226+
def patch_fhir_store(project_id, location, dataset_id, fhir_store_id, pubsub_topic):
227227
"""Updates the FHIR store.
228228
229229
See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
@@ -242,24 +242,28 @@ def patch_fhir_store(project_id, location, dataset_id, fhir_store_id):
242242
# location = 'us-central1' # replace with the dataset's location
243243
# dataset_id = 'my-dataset' # replace with your dataset ID
244244
# fhir_store_id = 'my-fhir-store' # replace with the FHIR store's ID
245+
# pubsub_topic = 'projects/{project_id}/topics/{topic_id}' # replace with your Pub/Sub topic
245246
fhir_store_parent = "projects/{}/locations/{}/datasets/{}".format(
246247
project_id, location, dataset_id
247248
)
248249
fhir_store_name = f"{fhir_store_parent}/fhirStores/{fhir_store_id}"
249250

250-
# TODO(developer): Replace with the full URI of an existing Pub/Sub topic
251-
patch = {"notificationConfig": None}
251+
patch = {
252+
"notificationConfigs": [{"pubsubTopic": pubsub_topic}] if pubsub_topic else []
253+
}
252254

253255
request = (
254256
client.projects()
255257
.locations()
256258
.datasets()
257259
.fhirStores()
258-
.patch(name=fhir_store_name, updateMask="notificationConfig", body=patch)
260+
.patch(name=fhir_store_name, updateMask="notificationConfigs", body=patch)
259261
)
260262

261263
response = request.execute()
262-
print(f"Patched FHIR store {fhir_store_id} with Cloud Pub/Sub topic: None")
264+
print(
265+
f"Patched FHIR store {fhir_store_id} with Cloud Pub/Sub topic: {pubsub_topic or 'None'}"
266+
)
263267

264268
return response
265269

healthcare/api-client/v1/fhir/fhir_stores_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
dataset_id = f"test_dataset_{uuid.uuid4()}"
3737
fhir_store_id = f"test_fhir_store-{uuid.uuid4()}"
3838
version = "R4"
39+
pubsub_topic = ""
3940

4041
gcs_uri = os.environ["CLOUD_STORAGE_BUCKET"]
4142
RESOURCES = os.path.join(os.path.dirname(__file__), "resources")
@@ -241,7 +242,9 @@ def test_get_fhir_store_metadata(test_dataset, test_fhir_store, capsys):
241242

242243

243244
def test_patch_fhir_store(test_dataset, test_fhir_store, capsys):
244-
fhir_stores.patch_fhir_store(project_id, location, dataset_id, fhir_store_id)
245+
fhir_stores.patch_fhir_store(
246+
project_id, location, dataset_id, fhir_store_id, pubsub_topic
247+
)
245248

246249
out, _ = capsys.readouterr()
247250

0 commit comments

Comments
 (0)