Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions docs/data-sources/setting.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ Optional:
<a id="nestedblock--semantic_types"></a>
### 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.

<a id="nestedblock--semantic_types--algorithm"></a>
### Nested Schema for `semantic_types.algorithm`
Expand All @@ -86,26 +89,26 @@ Optional:
<a id="nestedblock--semantic_types--algorithm--full_mask"></a>
### 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.


<a id="nestedblock--semantic_types--algorithm--inner_outer_mask"></a>
### 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.


<a id="nestedblock--semantic_types--algorithm--md5_mask"></a>
### 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.

Expand All @@ -120,7 +123,7 @@ Optional:
<a id="nestedblock--semantic_types--algorithm--range_mask--slices"></a>
### 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.
Expand Down
23 changes: 13 additions & 10 deletions docs/resources/setting.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,15 @@ Optional:
<a id="nestedblock--semantic_types"></a>
### 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.

<a id="nestedblock--semantic_types--algorithm"></a>
### Nested Schema for `semantic_types.algorithm`
Expand All @@ -141,26 +144,26 @@ Optional:
<a id="nestedblock--semantic_types--algorithm--full_mask"></a>
### 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.


<a id="nestedblock--semantic_types--algorithm--inner_outer_mask"></a>
### 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.


<a id="nestedblock--semantic_types--algorithm--md5_mask"></a>
### 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.

Expand All @@ -175,7 +178,7 @@ Optional:
<a id="nestedblock--semantic_types--algorithm--range_mask--slices"></a>
### 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.
Expand Down
45 changes: 19 additions & 26 deletions provider/data_source_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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.",
},
},
Expand All @@ -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).",
},
},
Expand All @@ -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.",
},
},
Expand All @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions provider/resource_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down