diff --git a/docs/data-sources/setting.md b/docs/data-sources/setting.md
index a7b27cb..8d0a8fd 100644
--- a/docs/data-sources/setting.md
+++ b/docs/data-sources/setting.md
@@ -66,12 +66,15 @@ Optional:
### Nested Schema for `semantic_types`
+Required:
+
+- `id` (String) The semantic type unique uuid.
+- `title` (String) The semantic type title. Required.
+
Optional:
- `algorithm` (Block List, Max: 1) The semantic type algorithm. Required. (see [below for nested schema](#nestedblock--semantic_types--algorithm))
- `description` (String) The semantic type description. Optional.
-- `id` (String) The semantic type unique uuid.
-- `title` (String) The semantic type title. Required.
### Nested Schema for `semantic_types.algorithm`
@@ -86,7 +89,7 @@ Optional:
### Nested Schema for `semantic_types.algorithm.full_mask`
-Optional:
+Required:
- `substitution` (String) Substitution is the string used to replace the original value, the max length of the string is 16 bytes.
@@ -94,18 +97,18 @@ Optional:
### Nested Schema for `semantic_types.algorithm.inner_outer_mask`
-Optional:
+Required:
-- `prefix_len` (Number)
-- `substitution` (String)
-- `suffix_len` (Number)
-- `type` (String)
+- `prefix_len` (Number) The length of prefix.
+- `substitution` (String) Substitution is the string used to replace the inner or outer substring.
+- `suffix_len` (Number) The length of suffix.
+- `type` (String) INNER or OUTER.
### Nested Schema for `semantic_types.algorithm.md5_mask`
-Optional:
+Required:
- `salt` (String) Salt is the salt value to generate a different hash that with the word alone.
@@ -120,7 +123,7 @@ Optional:
### Nested Schema for `semantic_types.algorithm.range_mask.slices`
-Optional:
+Required:
- `end` (Number) End is the stop index of the original value, should be less than the length of the original value.
- `start` (Number) Start is the start index of the original value, start from 0 and should be less than stop.
diff --git a/docs/resources/setting.md b/docs/resources/setting.md
index da630a5..b282a8e 100644
--- a/docs/resources/setting.md
+++ b/docs/resources/setting.md
@@ -121,12 +121,15 @@ Optional:
### Nested Schema for `semantic_types`
+Required:
+
+- `id` (String) The semantic type unique uuid.
+- `title` (String) The semantic type title. Required.
+
Optional:
- `algorithm` (Block List, Max: 1) The semantic type algorithm. Required. (see [below for nested schema](#nestedblock--semantic_types--algorithm))
- `description` (String) The semantic type description. Optional.
-- `id` (String) The semantic type unique uuid.
-- `title` (String) The semantic type title. Required.
### Nested Schema for `semantic_types.algorithm`
@@ -141,7 +144,7 @@ Optional:
### Nested Schema for `semantic_types.algorithm.full_mask`
-Optional:
+Required:
- `substitution` (String) Substitution is the string used to replace the original value, the max length of the string is 16 bytes.
@@ -149,18 +152,18 @@ Optional:
### Nested Schema for `semantic_types.algorithm.inner_outer_mask`
-Optional:
+Required:
-- `prefix_len` (Number)
-- `substitution` (String)
-- `suffix_len` (Number)
-- `type` (String)
+- `prefix_len` (Number) The length of prefix.
+- `substitution` (String) Substitution is the string used to replace the inner or outer substring.
+- `suffix_len` (Number) The length of suffix.
+- `type` (String) INNER or OUTER.
### Nested Schema for `semantic_types.algorithm.md5_mask`
-Optional:
+Required:
- `salt` (String) Salt is the salt value to generate a different hash that with the word alone.
@@ -175,7 +178,7 @@ Optional:
### Nested Schema for `semantic_types.algorithm.range_mask.slices`
-Optional:
+Required:
- `end` (Number) End is the stop index of the original value, should be less than the length of the original value.
- `start` (Number) Start is the start index of the original value, start from 0 and should be less than stop.
diff --git a/provider/data_source_setting.go b/provider/data_source_setting.go
index b5e6b62..4886711 100644
--- a/provider/data_source_setting.go
+++ b/provider/data_source_setting.go
@@ -50,14 +50,12 @@ func getSemanticTypesSetting(computed bool) *schema.Schema {
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
- Computed: computed,
- Optional: true,
+ Required: true,
Description: "The semantic type unique uuid.",
},
"title": {
Type: schema.TypeString,
- Computed: computed,
- Optional: true,
+ Required: true,
Description: "The semantic type title. Required.",
},
"description": {
@@ -85,8 +83,7 @@ func getSemanticTypesSetting(computed bool) *schema.Schema {
Schema: map[string]*schema.Schema{
"substitution": {
Type: schema.TypeString,
- Computed: computed,
- Optional: true,
+ Required: true,
Description: "Substitution is the string used to replace the original value, the max length of the string is 16 bytes.",
},
},
@@ -109,20 +106,17 @@ func getSemanticTypesSetting(computed bool) *schema.Schema {
Schema: map[string]*schema.Schema{
"start": {
Type: schema.TypeInt,
- Computed: computed,
- Optional: true,
+ Required: true,
Description: "Start is the start index of the original value, start from 0 and should be less than stop.",
},
"end": {
Type: schema.TypeInt,
- Computed: computed,
- Optional: true,
+ Required: true,
Description: "End is the stop index of the original value, should be less than the length of the original value.",
},
"substitution": {
Type: schema.TypeString,
- Computed: computed,
- Optional: true,
+ Required: true,
Description: "Substitution is the string used to replace the OriginalValue[start:end).",
},
},
@@ -141,8 +135,7 @@ func getSemanticTypesSetting(computed bool) *schema.Schema {
Schema: map[string]*schema.Schema{
"salt": {
Type: schema.TypeString,
- Computed: computed,
- Optional: true,
+ Required: true,
Description: "Salt is the salt value to generate a different hash that with the word alone.",
},
},
@@ -157,24 +150,24 @@ func getSemanticTypesSetting(computed bool) *schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"prefix_len": {
- Type: schema.TypeInt,
- Computed: computed,
- Optional: true,
+ Type: schema.TypeInt,
+ Required: true,
+ Description: "The length of prefix.",
},
"suffix_len": {
- Type: schema.TypeInt,
- Computed: computed,
- Optional: true,
+ Type: schema.TypeInt,
+ Required: true,
+ Description: "The length of suffix.",
},
"substitution": {
- Type: schema.TypeString,
- Computed: computed,
- Optional: true,
+ Type: schema.TypeString,
+ Required: true,
+ Description: "Substitution is the string used to replace the inner or outer substring.",
},
"type": {
- Type: schema.TypeString,
- Computed: computed,
- Optional: true,
+ Type: schema.TypeString,
+ Required: true,
+ Description: "INNER or OUTER.",
ValidateFunc: validation.StringInSlice([]string{
v1pb.Algorithm_InnerOuterMask_INNER.String(),
v1pb.Algorithm_InnerOuterMask_OUTER.String(),
diff --git a/provider/resource_setting.go b/provider/resource_setting.go
index 2bd22cc..e5543a1 100644
--- a/provider/resource_setting.go
+++ b/provider/resource_setting.go
@@ -387,6 +387,12 @@ func convertToV1SemanticTypeSetting(d *schema.ResourceData) (*v1pb.SemanticTypeS
}
} else if innerOuterMasks, ok := rawAlgorithm["inner_outer_mask"].([]interface{}); ok && len(innerOuterMasks) == 1 {
innerOuterMask := innerOuterMasks[0].(map[string]interface{})
+ t := v1pb.Algorithm_InnerOuterMask_MaskType(
+ v1pb.Algorithm_InnerOuterMask_MaskType_value[innerOuterMask["type"].(string)],
+ )
+ if t == v1pb.Algorithm_InnerOuterMask_MASK_TYPE_UNSPECIFIED {
+ return nil, errors.Errorf("invalid inner_outer_mask type: %s", innerOuterMask["type"].(string))
+ }
semanticType.Algorithm = &v1pb.Algorithm{
Mask: &v1pb.Algorithm_InnerOuterMask_{
InnerOuterMask: &v1pb.Algorithm_InnerOuterMask{