forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add google_oracle_database_cloud_exadata_infrastructure datasou…
…rce (GoogleCloudPlatform#11996)
- Loading branch information
1 parent
8beed02
commit 608a306
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...aform/services/oracledatabase/data_source_oracle_database_cloud_exadata_infrastructure.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package oracledatabase | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-provider-google/google/tpgresource" | ||
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" | ||
) | ||
|
||
func DataSourceOracleDatabaseCloudExadataInfrastructure() *schema.Resource { | ||
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceOracleDatabaseCloudExadataInfrastructure().Schema) | ||
tpgresource.AddRequiredFieldsToSchema(dsSchema, "location", "cloud_exadata_infrastructure_id") | ||
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project") | ||
return &schema.Resource{ | ||
Read: dataSourceOracleDatabaseCloudExadataInfrastructureRead, | ||
Schema: dsSchema, | ||
} | ||
|
||
} | ||
|
||
func dataSourceOracleDatabaseCloudExadataInfrastructureRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*transport_tpg.Config) | ||
|
||
id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/cloudExadataInfrastructures/{{cloud_exadata_infrastructure_id}}") | ||
if err != nil { | ||
return fmt.Errorf("Error constructing id: %s", err) | ||
} | ||
err = resourceOracleDatabaseCloudExadataInfrastructureRead(d, meta) | ||
if err != nil { | ||
return err | ||
} | ||
d.SetId(id) | ||
|
||
return nil | ||
} |
42 changes: 42 additions & 0 deletions
42
.../services/oracledatabase/data_source_oracle_database_cloud_exadata_infrastructure_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package oracledatabase_test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
"testing" | ||
) | ||
|
||
func TestAccOracleDatabaseCloudExadataInfrastructure_basic(t *testing.T) { | ||
t.Parallel() | ||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccOracleDatabaseCloudExadataInfrastructure_basic(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "display_name"), | ||
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "name"), | ||
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "gcp_oracle_zone"), | ||
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.#"), | ||
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.compute_count"), | ||
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "display_name", "ofake-exadata-for-vm display name"), | ||
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "gcp_oracle_zone", "us-east4-b-r1"), | ||
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.state", "AVAILABLE"), | ||
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_exadata_infrastructure.my-exadata", "properties.0.shape", "Exadata.X9M"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccOracleDatabaseCloudExadataInfrastructure_basic() string { | ||
return fmt.Sprintf(` | ||
data "google_oracle_database_cloud_exadata_infrastructure" "my-exadata"{ | ||
cloud_exadata_infrastructure_id = "ofake-do-not-delete-tf-exadata" | ||
project = "oci-terraform-testing" | ||
location = "us-east4" | ||
} | ||
`) | ||
} |
34 changes: 34 additions & 0 deletions
34
...aform/website/docs/d/oracle_database_cloud_exadata_infrastructure.html.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
subcategory: "Oracle Database" | ||
description: |- | ||
Get information about an ExadataInfrastructure. | ||
--- | ||
|
||
# google_oracle_database_cloud_exadata_infrastructure | ||
|
||
Get information about an ExadataInfrastructure. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "google_oracle_database_cloud_exadata_infrastructure" "my-instance"{ | ||
location = "us-east4" | ||
cloud_exadata_infrastructure_id = "exadata-id" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `cloud_exadata_infrastructure_id` - (Required) The ID of the ExadataInfrastructure. | ||
|
||
* `location` - (Required) The location of the resource. | ||
|
||
- - - | ||
* `project` - (Optional) The project to which the resource belongs. If it | ||
is not provided, the provider project is used. | ||
|
||
## Attributes Reference | ||
|
||
See [google_oracle_database_cloud_exadata_infrastructure](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_oracle_database_cloud_exadata_infrastructure#argument-reference) resource for details of the available attributes. |