2424import com .google .api .services .healthcare .v1 .CloudHealthcare ;
2525import com .google .api .services .healthcare .v1 .CloudHealthcare .Projects .Locations .Datasets .FhirStores ;
2626import com .google .api .services .healthcare .v1 .CloudHealthcareScopes ;
27+ import com .google .api .services .healthcare .v1 .model .FhirNotificationConfig ;
2728import com .google .api .services .healthcare .v1 .model .FhirStore ;
28- import com .google .api .services .healthcare .v1 .model .NotificationConfig ;
2929import com .google .auth .http .HttpCredentialsAdapter ;
3030import com .google .auth .oauth2 .GoogleCredentials ;
3131import java .io .IOException ;
@@ -38,51 +38,58 @@ public class FhirStorePatch {
3838
3939 public static void fhirStorePatch (String fhirStoreName , String pubsubTopic ) throws IOException {
4040 // String fhirStoreName =
41- // String.format(
42- // FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
41+ // String.format(
42+ // FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id",
43+ // "your-fhir-id");
4344 // String pubsubTopic = "projects/your-project-id/topics/your-pubsub-topic";
4445
4546 // Initialize the client, which will be used to interact with the service.
4647 CloudHealthcare client = createClient ();
4748
4849 // Fetch the initial state of the FHIR store.
49- FhirStores .Get getRequest =
50- client .projects ().locations ().datasets ().fhirStores ().get (fhirStoreName );
50+ FhirStores .Get getRequest = client
51+ .projects ()
52+ .locations ()
53+ .datasets ()
54+ .fhirStores ()
55+ .get (fhirStoreName );
5156 FhirStore store = getRequest .execute ();
5257
53- // Update the FhirStore fields as needed as needed. For a full list of FhirStore fields, see:
58+ // Update the FhirStore fields as needed as needed. For a full list of FhirStore
59+ // fields, see:
5460 // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.fhirStores#FhirStore
55- store .setNotificationConfig (new NotificationConfig ().setPubsubTopic (pubsubTopic ));
61+ FhirNotificationConfig notificationConfig = new FhirNotificationConfig ()
62+ .setPubsubTopic (pubsubTopic );
63+ store .setNotificationConfigs (Collections .singletonList (notificationConfig ));
5664
5765 // Create request and configure any parameters.
58- FhirStores .Patch request =
59- client
60- .projects ()
61- .locations ()
62- .datasets ()
63- .fhirStores ()
64- .patch (fhirStoreName , store )
65- .setUpdateMask ("notificationConfig" );
66+ FhirStores .Patch request = client
67+ .projects ()
68+ .locations ()
69+ .datasets ()
70+ .fhirStores ()
71+ .patch (fhirStoreName , store )
72+ .setUpdateMask ("notificationConfigs" );
6673
6774 // Execute the request and process the results.
6875 store = request .execute ();
69- System .out .println ("Fhir store patched: \n " + store .toPrettyString ());
76+ System .out .println ("FHIR store patched: \n " + store .toPrettyString ());
7077 }
7178
7279 private static CloudHealthcare createClient () throws IOException {
7380 // Use Application Default Credentials (ADC) to authenticate the requests
74- // For more information see https://cloud.google.com/docs/authentication/production
75- GoogleCredentials credential =
76- GoogleCredentials .getApplicationDefault ()
77- .createScoped (Collections .singleton (CloudHealthcareScopes .CLOUD_PLATFORM ));
81+ // For more information see
82+ // https://cloud.google.com/docs/authentication/production
83+ GoogleCredentials credential = GoogleCredentials .getApplicationDefault ()
84+ .createScoped (Collections .singleton (CloudHealthcareScopes .CLOUD_PLATFORM ));
7885
79- // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
80- HttpRequestInitializer requestInitializer =
81- request -> {
82- new HttpCredentialsAdapter (credential ).initialize (request );
83- request .setConnectTimeout (60000 ); // 1 minute connect timeout
84- request .setReadTimeout (60000 ); // 1 minute read timeout
85- };
86+ // Create a HttpRequestInitializer, which will provide a baseline configuration
87+ // to all requests.
88+ HttpRequestInitializer requestInitializer = request -> {
89+ new HttpCredentialsAdapter (credential ).initialize (request );
90+ request .setConnectTimeout (60000 ); // 1 minute connect timeout
91+ request .setReadTimeout (60000 ); // 1 minute read timeout
92+ };
8693
8794 // Build the client for interacting with the service.
8895 return new CloudHealthcare .Builder (HTTP_TRANSPORT , JSON_FACTORY , requestInitializer )
0 commit comments