forked from oracle/oci-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetDatabaseExample.java
More file actions
45 lines (34 loc) · 1.98 KB
/
GetDatabaseExample.java
File metadata and controls
45 lines (34 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
*/
import com.oracle.bmc.ConfigFileReader;
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
import com.oracle.bmc.database.DatabaseClient;
import com.oracle.bmc.database.requests.GetDatabaseRequest;
import com.oracle.bmc.database.responses.GetDatabaseResponse;
/*
* Example Class to show the usage of Get Database DBaaS API.
*/
public class GetDatabaseExample {
private static final String CONFIG_LOCATION = "~/.oci/config";
private static final String CONFIG_PROFILE = "DEFAULT";
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new Exception("This example expects 1 argument: A Database OCID");
}
// Configuring the AuthenticationDetailsProvider. It's assuming there is a default OCI config file
// "~/.oci/config", and a profile in that config with the name "DEFAULT". Make changes to the following
// line if needed and use ConfigFileReader.parse(CONFIG_LOCATION, profile);
final ConfigFileReader.ConfigFile configFile = ConfigFileReader.parseDefault();
final AuthenticationDetailsProvider provider =
new ConfigFileAuthenticationDetailsProvider(configFile);
String databaseId = args[0];
DatabaseClient databaseClient = new DatabaseClient(provider);
GetDatabaseRequest getDatabaseRequest =
GetDatabaseRequest.builder().databaseId(databaseId).build();
GetDatabaseResponse database = databaseClient.getDatabase(getDatabaseRequest);
System.out.printf("Database Fetched based on Id:%s\n", databaseId);
}
}