Skip to content

Commit

Permalink
wip adb create
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Nelson <[email protected]>
  • Loading branch information
markxnelson committed Jul 9, 2024
1 parent e8e9b72 commit 9482eff
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ public interface AutonomousDatabase {
* @param compartmentId Compartment OCID where the Autonomous Database needs to be created
* @return CreateAutonomousDatabaseResponse
*/
CreateAutonomousDatabaseResponse createAutonomousDatabase(String databaseName, String compartmentId);
CreateAutonomousDatabaseResponse createAutonomousDatabase(
String databaseName,
String compartmentId,
String adminPassword,
Integer dataStorageSizeInGBs,
Float computeCount
);

/**
* Get details of an Autonomous Database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.oracle.cloud.spring.adb;

import com.oracle.bmc.database.DatabaseClient;
import com.oracle.bmc.database.model.CreateAutonomousDatabaseBase;
import com.oracle.bmc.database.model.CreateAutonomousDatabaseDetails;
import com.oracle.bmc.database.model.GenerateAutonomousDatabaseWalletDetails;
import com.oracle.bmc.database.responses.CreateAutonomousDatabaseResponse;
Expand Down Expand Up @@ -41,11 +42,21 @@ public DatabaseClient getDatatbaseClient() {
* @param compartmentId Compartment OCID where the Autonomous Database needs to be created
* @return CreateAutonomousDatabaseResponse
*/
public CreateAutonomousDatabaseResponse createAutonomousDatabase(String databaseName, String compartmentId) {
public CreateAutonomousDatabaseResponse createAutonomousDatabase(
String databaseName,
String compartmentId,
String adminPassword,
Integer dataStorageSizeInGBs,
Float computeCount
) {
CreateAutonomousDatabaseRequest createAutonomousDatabaseRequest = CreateAutonomousDatabaseRequest.builder()
.createAutonomousDatabaseDetails(CreateAutonomousDatabaseDetails.builder()
.compartmentId(compartmentId)
.dbName(databaseName)
.adminPassword(adminPassword)
.dataStorageSizeInGBs(dataStorageSizeInGBs)
.computeModel(CreateAutonomousDatabaseBase.ComputeModel.Ecpu)
.computeCount(computeCount)
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ void testDatbaseImpl() {
when(client.generateAutonomousDatabaseWallet(any())).thenReturn(mock(GenerateAutonomousDatabaseWalletResponse.class));
when(client.deleteAutonomousDatabase(any())).thenReturn(mock(DeleteAutonomousDatabaseResponse.class));

CreateAutonomousDatabaseResponse cadr = autonomousDatabase.createAutonomousDatabase("name", "compartment");
CreateAutonomousDatabaseResponse cadr = autonomousDatabase.createAutonomousDatabase(
"name", "compartment", "password", 200, 2f);
assertNotNull(cadr);

GetAutonomousDatabaseResponse gadr = autonomousDatabase.getAutonomousDatabase("ocid");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ public class AdbController {
@PostMapping
ResponseEntity<?> createAutonomousDatabase(
@Parameter(required = true, example = "databaseName") @RequestParam String databaseName,
@Parameter(required = true, example = "compartmentId") @RequestParam String compartmentId
@Parameter(required = true, example = "compartmentId") @RequestParam String compartmentId,
@Parameter(required = true, example = "adminPassword") @RequestParam String adminPassword,
@Parameter(required = true, example = "200") @RequestParam Integer dataStorageSizeInGBs,
@Parameter(required = true, example = "2.0") @RequestParam Float computeCount
) {
CreateAutonomousDatabaseResponse response = autonomousDatabase.createAutonomousDatabase(databaseName, compartmentId);
CreateAutonomousDatabaseResponse response = autonomousDatabase.createAutonomousDatabase(
databaseName, compartmentId, adminPassword, dataStorageSizeInGBs, computeCount);
return ResponseEntity.accepted().body("database id : " + response.getAutonomousDatabase().getAutonomousContainerDatabaseId());
}

Expand Down

0 comments on commit 9482eff

Please sign in to comment.