| 383 | << std::endl; |
| 384 | } |
| 385 | int main() { |
| 386 | // Create CouchbaseOperations instance for high-level operations |
| 387 | brpc::CouchbaseOperations couchbase_ops; |
| 388 | |
| 389 | // std::cout << GREEN << "Using high-level CouchbaseOperations interface" |
| 390 | // << RESET << std::endl; |
| 391 | |
| 392 | // Ask username and password for authentication |
| 393 | std::string username = "Administrator"; |
| 394 | std::string password = "password"; |
| 395 | while (username.empty() || password.empty()) { |
| 396 | std::cout << "Enter Couchbase username: "; |
| 397 | std::cin >> username; |
| 398 | if (username.empty()) { |
| 399 | std::cout << "Username cannot be empty. Please enter again." << std::endl; |
| 400 | continue; |
| 401 | } |
| 402 | std::cout << "Enter Couchbase password: "; |
| 403 | std::cin >> password; |
| 404 | if (password.empty()) { |
| 405 | std::cout << "Password cannot be empty. Please enter again." << std::endl; |
| 406 | continue; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | // Use high-level authentication method |
| 411 | // when connecting to capella use couchbase_ops.authenticate(username, |
| 412 | // password, FLAGS_server, true, "path/to/cert.txt"); |
| 413 | brpc::CouchbaseOperations::Result auth_result = |
| 414 | couchbase_ops.authenticate(username, password, FLAGS_server, "testing"); |
| 415 | if (!auth_result.success) { |
| 416 | LOG(ERROR) << "Authentication failed: " << auth_result.error_message; |
| 417 | return -1; |
| 418 | } |
| 419 | |
| 420 | std::cout |
| 421 | << GREEN |
| 422 | << "Authentication successful, proceeding with Couchbase operations..." |
| 423 | << RESET << std::endl; |
| 424 | |
| 425 | performOperations(couchbase_ops); |
| 426 | |
| 427 | // Change bucket Selection |
| 428 | std::string bucket_name = "testing"; |
| 429 | while (bucket_name.empty()) { |
| 430 | std::cout << "Enter Couchbase bucket name: "; |
| 431 | std::cin >> bucket_name; |
| 432 | if (bucket_name.empty()) { |
| 433 | std::cout << "Bucket name cannot be empty. Please enter again." |
| 434 | << std::endl; |
| 435 | continue; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | // Use high-level bucket selection method |
| 440 | brpc::CouchbaseOperations::Result bucket_result = |
| 441 | couchbase_ops.selectBucket(bucket_name); |
| 442 | if (!bucket_result.success) { |
nothing calls this directly
no test coverage detected