### Get Detailed Compute Instance Information in Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Retrieves comprehensive details for a specific compute instance, including its display name, VNIC information (public and private IPs), and attached volumes. Requires the InstanceWrapper and ComputeInstanceClient. ```java import com.oracle.oci.eclipse.sdkclients.InstanceWrapper; ComputeInstanceClient computeClient = ComputeInstanceClient.getInstance(); String instanceId = "ocid1.instance.oc1..exampleid"; try { // Get comprehensive instance details InstanceWrapper instanceDetails = computeClient.getInstanceDetails(instanceId); Instance instance = instanceDetails.getInstance(); System.out.println("Instance: " + instance.getDisplayName()); // Access VNIC information (network interfaces) if (instanceDetails.getVnic() != null) { System.out.println("Public IP: " + instanceDetails.getVnic().getPublicIp()); System.out.println("Private IP: " + instanceDetails.getVnic().getPrivateIp()); } // Access volume attachments List volumes = instanceDetails.getVolumeAttachmentList(); for (VolumeAttachment vol : volumes) { System.out.println("Attached Volume: " + vol.getVolumeId()); } } catch (Exception e) { ErrorHandler.logErrorStack("Failed to get instance details", e); } ``` -------------------------------- ### Control Autonomous Database Lifecycle (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Control the lifecycle state of Autonomous Database instances, including starting, stopping, and restarting. This requires an ADBInstanceClient and the instance OCID. ```java ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); String instanceId = "ocid1.autonomousdatabase.oc1..exampleid"; try { // Start a stopped database adbClient.startInstance(instanceId); System.out.println("Started database: " + instanceId); // Stop a running database adbClient.stopInstance(instanceId); System.out.println("Stopped database: " + instanceId); // Restart a database adbClient.restartInstance(instanceId); System.out.println("Restarted database: " + instanceId); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to change database state", e); } ``` -------------------------------- ### Control Compute Instance Power State in Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Manages the power state of a compute instance, allowing it to be started, stopped, soft reset, or hard reset. Requires the ComputeInstanceClient and a valid instance OCID. ```java ComputeInstanceClient computeClient = ComputeInstanceClient.getInstance(); String instanceId = "ocid1.instance.oc1..exampleid"; try { // Start instance computeClient.runInstanceAction(instanceId, "START"); // Stop instance computeClient.runInstanceAction(instanceId, "STOP"); // Soft reset instance computeClient.runInstanceAction(instanceId, "SOFTRESET"); // Hard reset instance computeClient.runInstanceAction(instanceId, "RESET"); System.out.println("Instance action completed"); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to execute instance action", e); } ``` -------------------------------- ### Get Object Metadata using Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Retrieves metadata for an object in Oracle Cloud Infrastructure Object Storage without downloading the entire object. It demonstrates fetching headers and full object details, handling potential exceptions. ```java import com.oracle.bmc.objectstorage.responses.HeadObjectResponse; import com.oracle.bmc.objectstorage.responses.GetObjectResponse; ObjStorageClient storageClient = ObjStorageClient.getInstance(); String bucketName = "my-data-bucket"; String objectName = "report.pdf"; try { // Get object header (metadata only, faster) HeadObjectResponse headerResponse = storageClient.getObjectHeader(bucketName, objectName); System.out.println("Content-Length: " + headerResponse.getContentLength()); System.out.println("Content-Type: " + headerResponse.getContentType()); System.out.println("ETag: " + headerResponse.getETag()); // Get full object details (includes content stream) GetObjectResponse objectResponse = storageClient.getObjectDetails(bucketName, objectName); // Process stream from objectResponse.getInputStream() } catch (Exception e) { ErrorHandler.logErrorStack("Failed to get object metadata", e); } ``` -------------------------------- ### Initialize and Configure OCI Authentication Provider (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt This snippet demonstrates how to initialize the AuthProvider singleton, retrieve an AuthenticationDetailsProvider for SDK clients, access compartment and region information, and update these settings. It also shows how to generate an auth token and create an OCI client using the configured provider. ```java import com.oracle.bmc.auth.AuthenticationDetailsProvider; import com.oracle.bmc.auth.Region; import com.oracle.bmc.database.DatabaseClient; import com.oracle.oci.eclipse.auth.AuthProvider; // Initialize authentication provider AuthProvider authProvider = AuthProvider.getInstance(); // Get the authentication details provider for SDK clients AuthenticationDetailsProvider provider = authProvider.getProvider(); // Access current compartment and region String compartmentId = authProvider.getCompartmentId(); Region region = authProvider.getRegion(); // Update compartment (triggers property change events) authProvider.updateCompartmentId("ocid1.compartment.oc1..example"); // Update region (triggers property change events) authProvider.updateRegion("us-phoenix-1"); // Generate or retrieve auth token for object storage String authToken = authProvider.getAuthToken(); // Example: Creating an OCI client with authentication DatabaseClient dbClient = new DatabaseClient(provider); dbClient.setRegion(region); ``` -------------------------------- ### Extend OCI Eclipse Plugin with Custom Actions using Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Demonstrates how to extend the OCI Eclipse Toolkit plugin with custom database actions by implementing action factories. Registration is typically done via the plugin.xml file, and factories are retrieved through the Activator. ```java import com.oracle.oci.eclipse.Activator; import com.oracle.oci.eclipse.ui.explorer.database.actions.CustomADBInstanceActionFactory; // Register custom action factory via plugin.xml // // // // Retrieve registered action factories List actionFactories = Activator.getDatabaseActionFactories(); for (CustomADBInstanceActionFactory factory : actionFactories) { // Use custom actions } ``` -------------------------------- ### Create an Autonomous Database Instance (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt This snippet illustrates how to create a new Autonomous Database instance, specifically an Always Free ATP instance. It constructs a CreateAutonomousDatabaseDetails object with various parameters like compartment ID, database name, CPU cores, storage size, admin password, workload type, and license model, then sends the creation request using the ADBInstanceClient. ```java import com.oracle.bmc.database.model.CreateAutonomousDatabaseDetails; import com.oracle.bmc.database.model.CreateAutonomousDatabaseBase.DbWorkload; import com.oracle.bmc.database.model.CreateAutonomousDatabaseBase.LicenseModel; import com.oracle.bmc.database.responses.CreateAutonomousDatabaseResponse; import com.oracle.oci.eclipse.sdkclients.ADBInstanceClient; import com.oracle.oci.eclipse.ErrorHandler; ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); try { // Build create request for Always Free ATP CreateAutonomousDatabaseDetails createRequest = CreateAutonomousDatabaseDetails.builder() .compartmentId("ocid1.compartment.oc1..examplecompartment") .dbName("MyATPDB") .displayName("My ATP Database") .cpuCoreCount(1) .dataStorageSizeInTBs(1) .adminPassword("SecurePass123!@#") .dbWorkload(DbWorkload.Oltp) .licenseModel(LicenseModel.LicenseIncluded) .dbVersion("19c") .isAutoScalingEnabled(true) .isFreeTier(true) .build(); // Create the database CreateAutonomousDatabaseResponse response = adbClient.createInstance(createRequest); System.out.println("Created database: " + response.getAutonomousDatabase().getId()); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to create ADB", e); } ``` -------------------------------- ### List Compute Instances in Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Retrieves a list of all compute instances within the current compartment. It also fetches associated VNIC and volume attachment details. Requires the ComputeInstanceClient and AuthProvider. ```java import com.oracle.bmc.core.model.Instance; import com.oracle.oci.eclipse.sdkclients.ComputeInstanceClient; ComputeInstanceClient computeClient = ComputeInstanceClient.getInstance(); try { List instances = computeClient.getComputeInstances(); for (Instance instance : instances) { System.out.println("Instance: " + instance.getDisplayName()); System.out.println("State: " + instance.getLifecycleState()); System.out.println("Shape: " + instance.getShape()); System.out.println("OCID: " + instance.getId()); } // Get detailed instance information including VNICs and volumes String compartmentId = AuthProvider.getInstance().getCompartmentId(); computeClient.listVnicAttachments(compartmentId); computeClient.listVolumeAttachments(compartmentId); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to list instances", e); } ``` -------------------------------- ### Upload and Download Objects using Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Handles file transfers to and from Oracle Cloud Infrastructure Object Storage. This snippet demonstrates uploading a local file and downloading an object to a specified path, including error handling. ```java import java.io.File; ObjStorageClient storageClient = ObjStorageClient.getInstance(); String bucketName = "my-data-bucket"; try { // Upload a file to object storage File localFile = new File("/home/user/documents/report.pdf"); storageClient.uploadObject(bucketName, localFile); System.out.println("Uploaded: " + localFile.getName()); // Download an object from storage String objectName = "report.pdf"; String downloadPath = "/home/user/downloads/report.pdf"; storageClient.downloadObject(bucketName, objectName, downloadPath); System.out.println("Downloaded to: " + downloadPath); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to transfer object", e); } ``` -------------------------------- ### Create and Delete Object Storage Buckets in Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Manages object storage buckets by creating a new bucket with public read access and subsequently deleting it. Requires the ObjStorageClient and Bucket. ```java import com.oracle.bmc.objectstorage.model.Bucket; ObjStorageClient storageClient = ObjStorageClient.getInstance(); try { // Create a new bucket with public read access String bucketName = "my-data-bucket"; Bucket newBucket = storageClient.createBucket(bucketName); System.out.println("Created bucket: " + newBucket.getName()); // Delete a bucket (automatically deletes all objects first) storageClient.deleteBucket(bucketName); System.out.println("Deleted bucket: " + bucketName); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to manage bucket", e); } ``` -------------------------------- ### List Objects in Bucket using Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Retrieves and displays information about all objects within a specified Oracle Cloud Infrastructure Object Storage bucket. It requires the ObjStorageClient and handles potential exceptions. ```java import com.oracle.bmc.objectstorage.model.ObjectSummary; ObjStorageClient storageClient = ObjStorageClient.getInstance(); String bucketName = "my-data-bucket"; try { List objects = storageClient.getBucketObjects(bucketName); for (ObjectSummary object : objects) { System.out.println("Object: " + object.getName()); System.out.println("Size: " + object.getSize() + " bytes"); System.out.println("Created: " + object.getTimeCreated()); System.out.println("MD5: " + object.getMd5()); } } catch (Exception e) { ErrorHandler.logErrorStack("Failed to list objects", e); } ``` -------------------------------- ### List Object Storage Buckets in Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Retrieves a list of all object storage buckets within the current compartment. It also fetches the tenancy's namespace. Requires the ObjStorageClient and BucketSummary. ```java import com.oracle.bmc.objectstorage.model.BucketSummary; import com.oracle.oci.eclipse.sdkclients.ObjStorageClient; ObjStorageClient storageClient = ObjStorageClient.getInstance(); try { // Get namespace for the tenancy String namespace = storageClient.getNamespace(); System.out.println("Namespace: " + namespace); // List all buckets List buckets = storageClient.getBuckets(); for (BucketSummary bucket : buckets) { System.out.println("Bucket: " + bucket.getName()); System.out.println("Created: " + bucket.getTimeCreated()); System.out.println("Compartment: " + bucket.getCompartmentId()); } } catch (Exception e) { ErrorHandler.logErrorStack("Failed to list buckets", e); } ``` -------------------------------- ### Download Autonomous Database Wallet (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Download client credentials (wallet) for secure database connections. This method supports downloading both instance-specific and regional wallets. Requires the instance details, wallet type, password, and a target directory. ```java import com.oracle.oci.eclipse.ui.explorer.database.ADBConstants; ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); AutonomousDatabaseSummary instance = /* retrieve instance */; try { String walletPassword = "WalletPass123!"; String walletDirectory = "/home/user/wallets/mydb"; // Download instance-specific wallet adbClient.downloadWallet( instance, ADBConstants.INSTANCE_WALLET, walletPassword, walletDirectory ); // Download regional wallet (works for all instances in region) adbClient.downloadWallet( instance, ADBConstants.REGIONAL_WALLET, walletPassword, walletDirectory ); System.out.println("Wallet downloaded to: " + walletDirectory); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to download wallet", e); } ``` -------------------------------- ### OCI Eclipse Plugin Lifecycle Management using Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Manages the activation and deactivation of the OCI Eclipse Toolkit plugin using the Activator class. It includes initialization logic and resource cleanup during deactivation, utilizing OSGi framework. ```java import com.oracle.oci.eclipse.Activator; import org.osgi.framework.BundleContext; public class Activator extends AbstractUIPlugin { public static final String PLUGIN_ID = "com.oracle.oci.eclipse.plugin"; @Override public void start(BundleContext context) throws Exception { super.start(context); // Plugin is now active // SDK clients are initialized on first use } @Override public void stop(BundleContext context) throws Exception { try { // Clean up resources ADBInstanceClient.getInstance().dispose(); AuthProvider.getInstance().dispose(); } catch (Throwable e) { ErrorHandler.logErrorStack("Disposing bundle", e); } super.stop(context); } // Access plugin instance public static Activator getDefault() { return plugin; } } ``` -------------------------------- ### Clone Autonomous Database (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Create a clone of an existing Autonomous Database instance. This requires specifying the source database OCID, compartment OCID, desired DB name, display name, CPU core count, storage size, and clone type (Full or Metadata). ```java import com.oracle.bmc.database.model.CreateAutonomousDatabaseCloneDetails; import com.oracle.bmc.database.model.CreateAutonomousDatabaseBase.CloneType; ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); try { // Build clone request CreateAutonomousDatabaseCloneDetails cloneRequest = CreateAutonomousDatabaseCloneDetails.builder() .sourceId("ocid1.autonomousdatabase.oc1..sourceid") .compartmentId("ocid1.compartment.oc1..examplecompartment") .dbName("ClonedDB") .displayName("Cloned Database") .cpuCoreCount(2) .dataStorageSizeInTBs(1) .cloneType(CloneType.Full) .build(); // Create the clone adbClient.createClone(cloneRequest); System.out.println("Clone initiated successfully"); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to clone database", e); } ``` -------------------------------- ### Log and Report OCI Errors in Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt This Java code snippet demonstrates how to use the ErrorHandler utility from the OCI Eclipse Toolkit to manage errors during OCI operations. It shows logging with stack traces, reporting exceptions to the user, and logging informational messages. Dependencies include the OCI Eclipse Toolkit's ErrorHandler class. ```java import com.oracle.oci.eclipse.ErrorHandler; try { // Perform OCI operations ADBInstanceClient.getInstance().getInstances(DbWorkload.Oltp); } catch (Exception e) { // Log error with stack trace ErrorHandler.logErrorStack("Failed to retrieve instances", e); // Report error to user with dialog ErrorHandler.reportException("Operation failed", e); // Report error and show dialog ErrorHandler.reportAndShowException("Cannot connect to OCI", e); // Log informational message ErrorHandler.logInfo("Operation completed successfully"); // Log error message only ErrorHandler.logError("Configuration missing"); } ``` -------------------------------- ### Scale Autonomous Database Resources (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Modify the CPU core count and storage size for an Autonomous Database instance. This involves retrieving the instance details and calling the scaleUpDownInstance method with desired parameters. Auto-scaling can also be enabled. ```java import com.oracle.bmc.database.model.AutonomousDatabaseSummary; ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); AutonomousDatabaseSummary instance = /* retrieve instance */; try { // Scale to 4 CPU cores, 2 TB storage, enable auto-scaling adbClient.scaleUpDownInstance( instance, 4, // cpuCoreCount 2, // dataStorageSizeInTBs Boolean.TRUE // isAutoScalingEnabled ); System.out.println("Scaled database: " + instance.getDbName()); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to scale database", e); } ``` -------------------------------- ### List Autonomous Databases by Workload Type (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt This code retrieves Autonomous Database instances within the current compartment, filtering them by their workload type (ATP for Online Transaction Processing or ADW for Data Warehousing). It uses the ADBInstanceClient and handles potential exceptions during the API call. ```java import com.oracle.bmc.database.model.AutonomousDatabaseSummary; import com.oracle.bmc.database.model.AutonomousDatabaseSummary.DbWorkload; import com.oracle.oci.eclipse.sdkclients.ADBInstanceClient; import com.oracle.oci.eclipse.ErrorHandler; import java.util.List; // Get ADB client instance ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); try { // List ATP (Transaction Processing) instances List atpInstances = adbClient.getInstances(DbWorkload.Oltp); // List ADW (Data Warehouse) instances List adwInstances = adbClient.getInstances(DbWorkload.Dw); // Process instances for (AutonomousDatabaseSummary instance : atpInstances) { System.out.println("Database: " + instance.getDbName()); System.out.println("Display Name: " + instance.getDisplayName()); System.out.println("State: " + instance.getLifecycleState()); System.out.println("OCID: " + instance.getId()); } } catch (Exception e) { ErrorHandler.logErrorStack("Failed to list ADB instances", e); } ``` -------------------------------- ### Update Autonomous Database License Type (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Change the license model for an Autonomous Database instance, allowing a switch between 'Bring Your Own License' (BYOL) and 'License Included'. This operation requires the instance details and the desired LicenseModel enum. ```java import com.oracle.bmc.database.model.UpdateAutonomousDatabaseDetails.LicenseModel; ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); AutonomousDatabaseSummary instance = /* retrieve instance */; try { // Switch to BYOL (Bring Your Own License) adbClient.updateLicenseType(instance, LicenseModel.BringYourOwnLicense); // Or switch to License Included adbClient.updateLicenseType(instance, LicenseModel.LicenseIncluded); System.out.println("Updated license type"); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to update license", e); } ``` -------------------------------- ### Terminate Autonomous Database (Java) Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Permanently delete an Autonomous Database instance. This action is irreversible and requires the database OCID. Ensure all necessary data is backed up before proceeding. ```java ADBInstanceClient adbClient = ADBInstanceClient.getInstance(); String databaseId = "ocid1.autonomousdatabase.oc1..exampleid"; try { adbClient.terminate(databaseId); System.out.println("Database terminated: " + databaseId); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to terminate database", e); } ``` -------------------------------- ### Sign Commits for OCA Verification in Git Source: https://github.com/oracle/oci-toolkit-eclipse/blob/main/CONTRIBUTING.md When contributing code, your commits must include a 'Signed-off-by' line to verify you have signed the Oracle Contributor Agreement (OCA). This line is automatically added using the '--signoff' or '-s' flag with the git commit command. ```text Signed-off-by: Your Name ``` ```bash git commit --signoff ``` ```bash git commit -s ``` -------------------------------- ### Delete Objects using Java Source: https://context7.com/oracle/oci-toolkit-eclipse/llms.txt Removes a specified object from an Oracle Cloud Infrastructure Object Storage bucket. It requires the bucket name and the object name, with error handling included. ```java ObjStorageClient storageClient = ObjStorageClient.getInstance(); String bucketName = "my-data-bucket"; String objectName = "old-report.pdf"; try { storageClient.deleteObject(bucketName, objectName); System.out.println("Deleted object: " + objectName); } catch (Exception e) { ErrorHandler.logErrorStack("Failed to delete object", e); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.