forked from oracle/oci-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListDBVersionExample.java
More file actions
55 lines (44 loc) · 2.38 KB
/
ListDBVersionExample.java
File metadata and controls
55 lines (44 loc) · 2.38 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
46
47
48
49
50
51
52
53
54
55
/**
* 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.ListDbVersionsRequest;
import com.oracle.bmc.database.responses.ListDbVersionsResponse;
/*
* Example Class to show the usage of List DB Version DBaaS API.
*/
public class ListDBVersionExample {
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 != 2) {
throw new Exception(
"This example expects 2 arguments: a compartment OCID, a DB System Shape");
}
// 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, CONFIG_PROFILE);
final ConfigFileReader.ConfigFile configFile = ConfigFileReader.parseDefault();
final AuthenticationDetailsProvider provider =
new ConfigFileAuthenticationDetailsProvider(configFile);
String compartmentId = args[0];
String dbSystemShape = args[1];
DatabaseClient databaseClient = new DatabaseClient(provider);
ListDbVersionsRequest dbVersionsRequest =
ListDbVersionsRequest.builder()
.dbSystemShape(dbSystemShape)
.compartmentId(compartmentId)
.build();
ListDbVersionsResponse listDbVersionsResponse =
databaseClient.listDbVersions(dbVersionsRequest);
System.out.printf(
"DB Versions Fetched for Shape %s and compartment ocid: %s\n",
compartmentId,
dbSystemShape);
System.out.println(listDbVersionsResponse.getItems());
}
}