Skip to content

Commit 0f662b5

Browse files
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
1 parent fb70a24 commit 0f662b5

3 files changed

Lines changed: 55 additions & 11 deletions

File tree

examples/README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,25 @@ _GET `/_up`_
701701
// section: code imports
702702
import com.ibm.cloud.cloudant.v1.Cloudant;
703703
import com.ibm.cloud.cloudant.v1.model.UpInformation;
704-
// section: code
705-
Cloudant service = Cloudant.newInstance();
706-
707-
UpInformation response =
708-
service.getUpInformation().execute().getResult();
709-
710-
System.out.println(response);
704+
import com.ibm.cloud.sdk.core.http.Response;
705+
import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException;
706+
import com.ibm.cloud.sdk.core.service.exception.ServiceUnavailableException;
707+
// section: code
708+
Cloudant service = Cloudant.newInstance();
709+
710+
try {
711+
// Execute the health check
712+
Response<UpInformation> response = service.getUpInformation().execute();
713+
// Check the status code to determine service health
714+
System.out.println("Service is up and healthy");
715+
System.out.println(response.getResult());
716+
} catch (ServiceUnavailableException e) {
717+
System.out.println("Service unavailable:" + " \"" + e.getMessage() + "\" " + "Status code: "
718+
+ e.getStatusCode());
719+
} catch (ServiceResponseException e) {
720+
System.out.println("Issue performing health check: \"" + e.getMessage() + "\" Status code: "
721+
+ e.getStatusCode());
722+
}
711723
```
712724

713725
## getUuids
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
// section: code imports
22
import com.ibm.cloud.cloudant.v1.Cloudant;
33
import com.ibm.cloud.cloudant.v1.model.UpInformation;
4+
import com.ibm.cloud.sdk.core.http.Response;
5+
import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException;
6+
import com.ibm.cloud.sdk.core.service.exception.ServiceUnavailableException;
47
// section: code
58
Cloudant service = Cloudant.newInstance();
69

7-
UpInformation response =
8-
service.getUpInformation().execute().getResult();
9-
10-
System.out.println(response);
10+
try {
11+
// Execute the health check
12+
Response<UpInformation> response = service.getUpInformation().execute();
13+
// Check the status code to determine service health
14+
System.out.println("Service is up and healthy");
15+
System.out.println(response.getResult());
16+
} catch (ServiceUnavailableException e) {
17+
System.out.println("Service unavailable:" + " \"" + e.getMessage() + "\" " + "Status code: "
18+
+ e.getStatusCode());
19+
} catch (ServiceResponseException e) {
20+
System.out.println("Issue performing health check: \"" + e.getMessage() + "\" Status code: "
21+
+ e.getStatusCode());
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// section: code imports
2+
import com.ibm.cloud.cloudant.v1.Cloudant;
3+
import com.ibm.cloud.sdk.core.http.Response;
4+
import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException;
5+
import com.ibm.cloud.sdk.core.service.exception.ServiceUnavailableException;
6+
// section: code
7+
Cloudant service = Cloudant.newInstance();
8+
9+
try {
10+
// Execute the health check
11+
Response<Void> response = service.headUpInformation().execute();
12+
// Check the status code to determine service health
13+
System.out.println("Service is up and healthy");
14+
} catch (ServiceUnavailableException e) {
15+
System.out.println("Service unavailable:" + " \"" + e.getMessage() + "\" " + "Status code: "
16+
+ e.getStatusCode());
17+
} catch (ServiceResponseException e) {
18+
System.out.println("Issue performing health check: \"" + e.getMessage() + "\" Status code: "
19+
+ e.getStatusCode());
20+
}

0 commit comments

Comments
 (0)