1515 */
1616
1717// tag::imports[]
18+ import com .couchbase .client .core .env .WanDevelopmentProfile ;
19+ import com .couchbase .client .core .error .CouchbaseException ;
20+ import com .couchbase .client .java .Bucket ;
1821import com .couchbase .client .java .Cluster ;
1922import com .couchbase .client .java .ClusterOptions ;
23+ import com .couchbase .client .java .Collection ;
2024import com .couchbase .client .java .env .ClusterEnvironment ;
21- import com .couchbase .client .java .env .SecurityConfig ;
2225import com .couchbase .client .java .json .JsonObject ;
2326import com .couchbase .client .java .kv .GetResult ;
2427import com .couchbase .client .java .kv .ReplaceOptions ;
2528
2629import java .time .Duration ;
2730import java .util .UUID ;
31+
32+ import static com .couchbase .client .core .msg .kv .DurabilityLevel .MAJORITY ;
2833// end::imports[]
2934
30- public class Cloud {
35+ public class StartUsingCapella {
3136 public static void main (String [] args ) {
3237 // tag::connect[]
3338 // Update this to your cluster
@@ -37,11 +42,11 @@ public static void main(String[] args) {
3742 String bucketName = "travel-sample" ;
3843
3944 ClusterEnvironment env = ClusterEnvironment .builder ()
40- .securityConfig (SecurityConfig .enableTls (true ))
45+ .securityConfig (sc -> sc .enableTls (true ))
4146 // Sets a pre-configured profile called "wan-development" to help avoid latency issues
4247 // when accessing Capella from a different Wide Area Network
4348 // or Availability Zone (e.g. your laptop).
44- .applyProfile (ClusterEnvironment . WanDevelopmentProfile . INSTANCE )
49+ .applyProfile (new WanDevelopmentProfile (). name () )
4550 .build ();
4651
4752 Cluster cluster = Cluster .connect (
@@ -51,12 +56,12 @@ public static void main(String[] args) {
5156 // end::connect[]
5257
5358 // tag::bucket[]
54- var bucket = cluster .bucket (bucketName );
59+ Bucket bucket = cluster .bucket (bucketName );
5560 bucket .waitUntilReady (Duration .ofSeconds (30 ));
5661 // end::bucket[]
5762
5863 // tag::collection[]
59- var collection = bucket .scope ("inventory" ).collection ("airport" );
64+ Collection collection = bucket .scope ("inventory" ).collection ("airport" );
6065 // end::collection[]
6166
6267 // tag::json[]
@@ -102,7 +107,7 @@ public static void main(String[] args) {
102107 json ,
103108 ReplaceOptions .replaceOptions ()
104109 .expiry (Duration .ofSeconds (10 ))
105- .durability (com . couchbase . client . java . kv . Durability . MAJORITY )
110+ .durability (MAJORITY )
106111 );
107112 } catch (Exception e ) {
108113 System .err .println ("Error: " + e .getMessage ());
@@ -115,7 +120,7 @@ public static void main(String[] args) {
115120 docId ,
116121 json ,
117122 ReplaceOptions .replaceOptions ()
118- .durability (com . couchbase . client . java . kv . Durability . MAJORITY )
123+ .durability (MAJORITY )
119124 );
120125 } catch (Exception e ) {
121126 System .err .println ("Error: " + e .getMessage ());
0 commit comments