forked from oracle/oci-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateIpv6LoadBalancerExample.java
More file actions
73 lines (64 loc) · 3.39 KB
/
CreateIpv6LoadBalancerExample.java
File metadata and controls
73 lines (64 loc) · 3.39 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* 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.Region;
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider;
import com.oracle.bmc.loadbalancer.LoadBalancerClient;
import com.oracle.bmc.loadbalancer.model.CreateLoadBalancerDetails;
import com.oracle.bmc.loadbalancer.model.CreateLoadBalancerDetails.IpMode;
import com.oracle.bmc.loadbalancer.requests.CreateLoadBalancerRequest;
import java.util.Arrays;
/**
* This class provides an example of how to create an IPv6-Enabled Load Balancer.
* <ul>
* <li>The load balancer will be created within the provided compartment OCID</li>
* <li>The configuration file used by service clients will be sourced from the default
* location (~/.oci/config) and the DEFAULT profile will be used</li>
* <ul>
*/
public class CreateIpv6LoadBalancerExample {
private static String CONFIG_LOCATION = "~/.oci/config";
private static String CONFIG_PROFILE = "DEFAULT";
private static String LB_DISPLAY_NAME = "java-sdk-test-LB1";
private static String LB_SHAPE = "100Mbps";
/**
* The entry point for the example.
*
* @param args Arguments to provide to the example. The following arguments are expected:
* <ul>
* <li>The OCID of the compartment where the load balancer will be created.</li>
* <li>The OCID of the subnet to be assigned to the load balancer.</li>
* </ul>
*/
public static void main(String[] args) throws Exception {
if (args.length < 2) {
throw new IllegalArgumentException(
"This example expects two arguments: compartment OCID, subnet OCID (subnet must be regional!)");
}
final String compartmentId = args[0];
final String loadBalSubnet = args[1];
// 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);
LoadBalancerClient loadBalancerClient = new LoadBalancerClient(provider);
CreateLoadBalancerDetails loadBalancerDetails =
CreateLoadBalancerDetails.builder()
.compartmentId(compartmentId)
.subnetIds(Arrays.asList(loadBalSubnet))
.displayName(LB_DISPLAY_NAME)
.shapeName(LB_SHAPE)
.ipMode(IpMode.Ipv6)
.build();
loadBalancerClient.createLoadBalancer(
CreateLoadBalancerRequest.builder()
.createLoadBalancerDetails(loadBalancerDetails)
.build());
System.out.println("DONE");
}
}