Skip to content

Commit 48711d9

Browse files
Terraform Team Automationsahilg11
authored andcommitted
Added - Support for NoSQL - Add functionality in OCI console
1 parent 6999145 commit 48711d9

File tree

8 files changed

+94
-18
lines changed

8 files changed

+94
-18
lines changed

examples/nosql/child_table/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ resource "oci_nosql_table" "test_table" {
4343

4444
table_limits {
4545
#Required
46-
max_read_units = "10"
47-
max_write_units = "10"
48-
max_storage_in_gbs = "1"
46+
max_read_units = "50"
47+
max_write_units = "50"
48+
max_storage_in_gbs = "25"
4949
}
5050
}
5151

examples/nosql/ondemand_table/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ resource "oci_nosql_table" "test_ondemand" {
4141
#Required
4242
max_read_units = "0"
4343
max_write_units = "0"
44-
max_storage_in_gbs = "1"
44+
max_storage_in_gbs = "25"
4545
capacity_mode = "ON_DEMAND"
4646
}
4747
}

examples/nosql/table/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ resource "oci_nosql_table" "test_table" {
4343

4444
table_limits {
4545
#Required
46-
max_read_units = "10"
47-
max_storage_in_gbs = "10"
48-
max_write_units = "10"
46+
max_read_units = "50"
47+
max_write_units = "50"
48+
max_storage_in_gbs = "25"
4949
}
5050
}
5151

internal/integrationtest/nosql_table_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var (
3535
"table_name_or_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_nosql_table.test_table.id}`},
3636
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
3737
}
38-
ddlStatement = "CREATE TABLE IF NOT EXISTS test_table(id INTEGER, name STRING, age STRING, info JSON, PRIMARY KEY(SHARD(id)))"
38+
ddlStatement = "CREATE TABLE IF NOT EXISTS test_table(id INTEGER GENERATED ALWAYS AS IDENTITY, name STRING, age STRING, info JSON, guid STRING AS UUID, PRIMARY KEY(SHARD(id)))"
3939

4040
NosqlNosqlTableDataSourceRepresentation = map[string]interface{}{
4141
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
@@ -229,6 +229,17 @@ func TestNosqlTableResource_basic(t *testing.T) {
229229
resource.TestCheckResourceAttr(singularDatasourceName, "is_auto_reclaimable", "false"),
230230
resource.TestCheckResourceAttr(singularDatasourceName, "name", "test_table"),
231231
resource.TestCheckResourceAttr(singularDatasourceName, "schema.#", "1"),
232+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.identity.#", "1"),
233+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.identity.0.column_name", "id"),
234+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.identity.0.is_always", "true"),
235+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.identity.0.is_null", "false"),
236+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.columns.#", "5"),
237+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.columns.0.name", "id"),
238+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.columns.0.is_as_uuid", "false"),
239+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.columns.0.is_generated", "false"),
240+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.columns.4.name", "guid"),
241+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.columns.4.is_as_uuid", "true"),
242+
resource.TestCheckResourceAttr(singularDatasourceName, "schema.0.columns.4.is_generated", "false"),
232243
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
233244
resource.TestCheckResourceAttr(singularDatasourceName, "table_limits.#", "1"),
234245
resource.TestCheckResourceAttr(singularDatasourceName, "table_limits.0.capacity_mode", "PROVISIONED"),

internal/service/nosql/nosql_table_resource.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ func NosqlTableResource() *schema.Resource {
130130
Type: schema.TypeString,
131131
Computed: true,
132132
},
133+
"is_as_uuid": {
134+
Type: schema.TypeBool,
135+
Computed: true,
136+
},
137+
"is_generated": {
138+
Type: schema.TypeBool,
139+
Computed: true,
140+
},
133141
"is_nullable": {
134142
Type: schema.TypeBool,
135143
Computed: true,
@@ -145,6 +153,31 @@ func NosqlTableResource() *schema.Resource {
145153
},
146154
},
147155
},
156+
"identity": {
157+
Type: schema.TypeList,
158+
Computed: true,
159+
Elem: &schema.Resource{
160+
Schema: map[string]*schema.Schema{
161+
// Required
162+
163+
// Optional
164+
165+
// Computed
166+
"column_name": {
167+
Type: schema.TypeString,
168+
Computed: true,
169+
},
170+
"is_always": {
171+
Type: schema.TypeBool,
172+
Computed: true,
173+
},
174+
"is_null": {
175+
Type: schema.TypeBool,
176+
Computed: true,
177+
},
178+
},
179+
},
180+
},
148181
"primary_key": {
149182
Type: schema.TypeList,
150183
Computed: true,
@@ -686,6 +719,14 @@ func ColumnToMap(obj oci_nosql.Column) map[string]interface{} {
686719
result["default_value"] = string(*obj.DefaultValue)
687720
}
688721

722+
if obj.IsAsUuid != nil {
723+
result["is_as_uuid"] = bool(*obj.IsAsUuid)
724+
}
725+
726+
if obj.IsGenerated != nil {
727+
result["is_generated"] = bool(*obj.IsGenerated)
728+
}
729+
689730
if obj.IsNullable != nil {
690731
result["is_nullable"] = bool(*obj.IsNullable)
691732
}
@@ -701,6 +742,24 @@ func ColumnToMap(obj oci_nosql.Column) map[string]interface{} {
701742
return result
702743
}
703744

745+
func IdentityToMap(obj *oci_nosql.Identity) map[string]interface{} {
746+
result := map[string]interface{}{}
747+
748+
if obj.ColumnName != nil {
749+
result["column_name"] = string(*obj.ColumnName)
750+
}
751+
752+
if obj.IsAlways != nil {
753+
result["is_always"] = bool(*obj.IsAlways)
754+
}
755+
756+
if obj.IsNull != nil {
757+
result["is_null"] = bool(*obj.IsNull)
758+
}
759+
760+
return result
761+
}
762+
704763
func SchemaToMap(obj *oci_nosql.Schema) map[string]interface{} {
705764
result := map[string]interface{}{}
706765

@@ -710,6 +769,10 @@ func SchemaToMap(obj *oci_nosql.Schema) map[string]interface{} {
710769
}
711770
result["columns"] = columns
712771

772+
if obj.Identity != nil {
773+
result["identity"] = []interface{}{IdentityToMap(obj.Identity)}
774+
}
775+
713776
result["primary_key"] = obj.PrimaryKey
714777

715778
result["shard_key"] = obj.ShardKey

website/docs/d/nosql_table.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ The following attributes are exported:
4747
* `schema` - The table schema information as a JSON object.
4848
* `columns` - The columns of a table.
4949
* `default_value` - The column default value.
50+
* `is_as_uuid` - True if the STRING column was declared AS UUID.
51+
* `is_generated` - True if the STRING AS UUID column is also GENERATED BY DEFAULT.
5052
* `is_nullable` - The column nullable flag.
5153
* `name` - The column name.
5254
* `type` - The column type.
55+
* `identity` - The identity properties of a table, if any.
56+
* `column_name` - The name of the identity column.
57+
* `is_always` - True if the identity value is GENERATED ALWAYS.
58+
* `is_null` - True if the identity value is GENERATED BY DEFAULT ON NULL.
5359
* `primary_key` - A list of column names that make up a key.
5460
* `shard_key` - A list of column names that make up a key.
5561
* `ttl` - The default Time-to-Live for the table, in days.

website/docs/d/nosql_tables.html.markdown

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,12 @@ The following attributes are exported:
4545
The following attributes are exported:
4646

4747
* `compartment_id` - Compartment Identifier.
48-
* `ddl_statement` - A DDL statement representing the schema.
4948
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{"foo-namespace": {"bar-key": "value"}}`
5049
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
5150
* `id` - Unique identifier that is immutable.
5251
* `is_auto_reclaimable` - True if this table can be reclaimed after an idle period.
5352
* `lifecycle_details` - A message describing the current state in more detail.
5453
* `name` - Human-friendly table name, immutable.
55-
* `schema` - The table schema information as a JSON object.
56-
* `columns` - The columns of a table.
57-
* `default_value` - The column default value.
58-
* `is_nullable` - The column nullable flag.
59-
* `name` - The column name.
60-
* `type` - The column type.
61-
* `primary_key` - A list of column names that make up a key.
62-
* `shard_key` - A list of column names that make up a key.
63-
* `ttl` - The default Time-to-Live for the table, in days.
6454
* `state` - The state of a table.
6555
* `system_tags` - Read-only system tag. These predefined keys are scoped to namespaces. At present the only supported namespace is `"orcl-cloud"`; and the only key in that namespace is `"free-tier-retained"`. Example: `{"orcl-cloud"": {"free-tier-retained": "true"}}`
6656
* `table_limits` - Throughput and storage limits configuration of a table.

website/docs/r/nosql_table.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ The following attributes are exported:
7272
* `schema` - The table schema information as a JSON object.
7373
* `columns` - The columns of a table.
7474
* `default_value` - The column default value.
75+
* `is_as_uuid` - True if the STRING column was declared AS UUID.
76+
* `is_generated` - True if the STRING AS UUID column is also GENERATED BY DEFAULT.
7577
* `is_nullable` - The column nullable flag.
7678
* `name` - The column name.
7779
* `type` - The column type.
80+
* `identity` - The identity properties of a table, if any.
81+
* `column_name` - The name of the identity column.
82+
* `is_always` - True if the identity value is GENERATED ALWAYS.
83+
* `is_null` - True if the identity value is GENERATED BY DEFAULT ON NULL.
7884
* `primary_key` - A list of column names that make up a key.
7985
* `shard_key` - A list of column names that make up a key.
8086
* `ttl` - The default Time-to-Live for the table, in days.

0 commit comments

Comments
 (0)