From 732d5d86b02745550052059abc60ad8406493e2d Mon Sep 17 00:00:00 2001 From: cloudant-sdks-automation <71659186+cloudant-sdks-automation@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:11:53 +0000 Subject: [PATCH] fix(generated): improve _up examples Generated SDK source code using: - Generator version 3.107.1 - Specification version 1.0.0-dev0.1.30 - Automation (cloudant-sdks) version e8e7dee --- examples/README.md | 26 ++++++++++++++----- .../getUpInformation/example_request.java | 20 +++++++++++--- .../headUpInformation/example_request.java | 20 ++++++++++++++ 3 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 examples/snippets/headUpInformation/example_request.java diff --git a/examples/README.md b/examples/README.md index 41a2f1ff8..c8c4a198f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -701,13 +701,25 @@ _GET `/_up`_ // section: code imports import com.ibm.cloud.cloudant.v1.Cloudant; import com.ibm.cloud.cloudant.v1.model.UpInformation; -// section: code -Cloudant service = Cloudant.newInstance(); - -UpInformation response = - service.getUpInformation().execute().getResult(); - -System.out.println(response); +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; +import com.ibm.cloud.sdk.core.service.exception.ServiceUnavailableException; +// section: code +Cloudant service = Cloudant.newInstance(); + +try { + // Execute the health check + Response response = service.getUpInformation().execute(); + // Check the status code to determine service health + System.out.println("Service is up and healthy"); + System.out.println(response.getResult()); +} catch (ServiceUnavailableException e) { + System.out.println("Service unavailable:" + " \"" + e.getMessage() + "\" " + "Status code: " + + e.getStatusCode()); +} catch (ServiceResponseException e) { + System.out.println("Issue performing health check: \"" + e.getMessage() + "\" Status code: " + + e.getStatusCode()); +} ``` ## getUuids diff --git a/examples/snippets/getUpInformation/example_request.java b/examples/snippets/getUpInformation/example_request.java index 49abe4f1a..f8a0ac810 100644 --- a/examples/snippets/getUpInformation/example_request.java +++ b/examples/snippets/getUpInformation/example_request.java @@ -1,10 +1,22 @@ // section: code imports import com.ibm.cloud.cloudant.v1.Cloudant; import com.ibm.cloud.cloudant.v1.model.UpInformation; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; +import com.ibm.cloud.sdk.core.service.exception.ServiceUnavailableException; // section: code Cloudant service = Cloudant.newInstance(); -UpInformation response = - service.getUpInformation().execute().getResult(); - -System.out.println(response); +try { + // Execute the health check + Response response = service.getUpInformation().execute(); + // Check the status code to determine service health + System.out.println("Service is up and healthy"); + System.out.println(response.getResult()); +} catch (ServiceUnavailableException e) { + System.out.println("Service unavailable:" + " \"" + e.getMessage() + "\" " + "Status code: " + + e.getStatusCode()); +} catch (ServiceResponseException e) { + System.out.println("Issue performing health check: \"" + e.getMessage() + "\" Status code: " + + e.getStatusCode()); +} diff --git a/examples/snippets/headUpInformation/example_request.java b/examples/snippets/headUpInformation/example_request.java new file mode 100644 index 000000000..75a98e3ea --- /dev/null +++ b/examples/snippets/headUpInformation/example_request.java @@ -0,0 +1,20 @@ +// section: code imports +import com.ibm.cloud.cloudant.v1.Cloudant; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; +import com.ibm.cloud.sdk.core.service.exception.ServiceUnavailableException; +// section: code +Cloudant service = Cloudant.newInstance(); + +try { + // Execute the health check + Response response = service.headUpInformation().execute(); + // Check the status code to determine service health + System.out.println("Service is up and healthy"); +} catch (ServiceUnavailableException e) { + System.out.println("Service unavailable:" + " \"" + e.getMessage() + "\" " + "Status code: " + + e.getStatusCode()); +} catch (ServiceResponseException e) { + System.out.println("Issue performing health check: \"" + e.getMessage() + "\" Status code: " + + e.getStatusCode()); +}