diff --git a/examples/README.md b/examples/README.md index 3331e4b2..6012bf94 100644 --- a/examples/README.md +++ b/examples/README.md @@ -549,12 +549,19 @@ _GET `/_up`_ ```py # section: code from ibmcloudant.cloudant_v1 import CloudantV1 +from ibm_cloud_sdk_core.api_exception import ApiException service = CloudantV1.new_instance() +try: + response = service.get_up_information() -response = service.get_up_information().get_result() - -print(response) + print("Service is up and healthy") + print(response.get_result()) +except ApiException as ae: + if ae.code == 503: + print(f"Service is unavailable, status code: {ae.code}") + else: + print(f"Issue performing health check, status code: {ae.code}, message: {ae.http_response.reason}") ``` ## getUuids diff --git a/examples/snippets/getUpInformation/example_request.py b/examples/snippets/getUpInformation/example_request.py index 4e6be59e..215a2208 100644 --- a/examples/snippets/getUpInformation/example_request.py +++ b/examples/snippets/getUpInformation/example_request.py @@ -1,8 +1,15 @@ # section: code from ibmcloudant.cloudant_v1 import CloudantV1 +from ibm_cloud_sdk_core.api_exception import ApiException service = CloudantV1.new_instance() +try: + response = service.get_up_information() -response = service.get_up_information().get_result() - -print(response) + print("Service is up and healthy") + print(response.get_result()) +except ApiException as ae: + if ae.code == 503: + print(f"Service is unavailable, status code: {ae.code}") + else: + print(f"Issue performing health check, status code: {ae.code}, message: {ae.http_response.reason}") diff --git a/examples/snippets/headUpInformation/example_request.py b/examples/snippets/headUpInformation/example_request.py new file mode 100644 index 00000000..9942e6d6 --- /dev/null +++ b/examples/snippets/headUpInformation/example_request.py @@ -0,0 +1,14 @@ +# section: code +from ibmcloudant.cloudant_v1 import CloudantV1 +from ibm_cloud_sdk_core.api_exception import ApiException + +service = CloudantV1.new_instance() +try: + response = service.head_up_information() + + print("Service is up and healthy") +except ApiException as ae: + if ae.code == 503: + print(f"Service is unavailable, status code: {ae.code}") + else: + print(f"Issue performing health check, status code: {ae.code}, message: {ae.http_response.reason}")