-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 (#11996) (#19856) [upstream:dd763c2c460db8d79056c0bf33f2b89c5f9b3ab8] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
e8f2586
commit fc8e5fb
Showing
5 changed files
with
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-datasource | ||
`google_oracle_database_cloud_exadata_infrastructure` | ||
``` |
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
38 changes: 38 additions & 0 deletions
38
google/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,38 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
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 | ||
} |
44 changes: 44 additions & 0 deletions
44
.../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,44 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
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
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. |