Skip to content

Commit bfcdd19

Browse files
NagendraNagendraNigade
authored andcommitted
Added Support for - OCI - Data Labeling Service [DLS]
1 parent 31a9454 commit bfcdd19

File tree

6 files changed

+83
-22
lines changed

6 files changed

+83
-22
lines changed

internal/integrationtest/data_labeling_service_dataset_test.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import (
1010
"testing"
1111
"time"
1212

13+
"github.com/terraform-providers/terraform-provider-oci/internal/acctest"
14+
tf_client "github.com/terraform-providers/terraform-provider-oci/internal/client"
15+
"github.com/terraform-providers/terraform-provider-oci/internal/resourcediscovery"
16+
"github.com/terraform-providers/terraform-provider-oci/internal/tfresource"
17+
"github.com/terraform-providers/terraform-provider-oci/internal/utils"
18+
1319
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
1420
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
1521
"github.com/hashicorp/terraform-plugin-sdk/terraform"
@@ -18,11 +24,6 @@ import (
1824
"github.com/oracle/oci-go-sdk/v55/objectstorage"
1925

2026
"github.com/terraform-providers/terraform-provider-oci/httpreplay"
21-
"github.com/terraform-providers/terraform-provider-oci/internal/acctest"
22-
tf_client "github.com/terraform-providers/terraform-provider-oci/internal/client"
23-
"github.com/terraform-providers/terraform-provider-oci/internal/resourcediscovery"
24-
"github.com/terraform-providers/terraform-provider-oci/internal/tfresource"
25-
"github.com/terraform-providers/terraform-provider-oci/internal/utils"
2627
)
2728

2829
var (
@@ -48,6 +49,10 @@ var (
4849
"values": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_data_labeling_service_dataset.test_dataset.id}`}},
4950
}
5051

52+
datasetIgnoreDefinedTagsChangesRep = map[string]interface{}{
53+
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}},
54+
}
55+
5156
datasetRepresentation = map[string]interface{}{
5257
"annotation_format": acctest.Representation{RepType: acctest.Required, Create: `BOUNDING_BOX`},
5358
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
@@ -58,7 +63,9 @@ var (
5863
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
5964
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
6065
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
61-
//"initial_record_generation_configuration": acctest.RepresentationGroup{RepType: acctest.Optional, Group: datasetInitialRecordGenerationConfigurationRepresentation},
66+
//"initial_record_generation_configuration": acctest.RepresentationGroup{acctest.Optional, datasetInitialRecordGenerationConfigurationRepresentation},
67+
//"labeling_instructions": acctest.Representation{RepType: acctest.Optional, Create: `labelingInstructions`, Update: `labelingInstructions2`},
68+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: datasetIgnoreDefinedTagsChangesRep},
6269
}
6370
datasetDatasetFormatDetailsRepresentation = map[string]interface{}{
6471
"format_type": acctest.Representation{RepType: acctest.Required, Create: `IMAGE`},
@@ -100,7 +107,8 @@ func TestDataLabelingServiceDatasetResource_basic(t *testing.T) {
100107
config := acctest.ProviderTestConfig()
101108

102109
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
103-
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
110+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id" +
111+
"\" { default = \"%s\" }\n", compartmentId)
104112

105113
compartmentIdU := utils.GetEnvSettingWithDefault("compartment_id_for_Update", compartmentId)
106114
compartmentIdUVariableStr := fmt.Sprintf("variable \"compartment_id_for_Update\" { default = \"%s\" }\n", compartmentIdU)
@@ -113,7 +121,7 @@ func TestDataLabelingServiceDatasetResource_basic(t *testing.T) {
113121
objectstorageBucket := "tf_dataset_objectstoragebucket"
114122

115123
var resId, resId2 string
116-
// Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "Create with optionals" step in the test.
124+
// Save TF content to Create resource with optional propeTestCheckResourceAttrrties. This has to be exactly the same as the config part in the "Create with optionals" step in the test.
117125
acctest.SaveConfigContent(config+compartmentIdVariableStr+DatasetResourceDependencies+
118126
acctest.GenerateResourceFromRepresentationMap("oci_data_labeling_service_dataset", "test_dataset", acctest.Optional, acctest.Create, datasetRepresentation), "datalabelingservice", "dataset", t)
119127

@@ -168,6 +176,7 @@ func TestDataLabelingServiceDatasetResource_basic(t *testing.T) {
168176
resource.TestCheckResourceAttr(resourceName, "label_set.#", "1"),
169177
resource.TestCheckResourceAttr(resourceName, "label_set.0.items.#", "1"),
170178
resource.TestCheckResourceAttr(resourceName, "label_set.0.items.0.name", "name"),
179+
//resource.TestCheckResourceAttr(resourceName, "labeling_instructions", "labelingInstructions"),
171180
resource.TestCheckResourceAttrSet(resourceName, "state"),
172181
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
173182
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
@@ -209,6 +218,7 @@ func TestDataLabelingServiceDatasetResource_basic(t *testing.T) {
209218
resource.TestCheckResourceAttr(resourceName, "label_set.#", "1"),
210219
resource.TestCheckResourceAttr(resourceName, "label_set.0.items.#", "1"),
211220
resource.TestCheckResourceAttr(resourceName, "label_set.0.items.0.name", "name"),
221+
//resource.TestCheckResourceAttr(resourceName, "labeling_instructions", "labelingInstructions"),
212222
resource.TestCheckResourceAttrSet(resourceName, "state"),
213223
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
214224
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
@@ -245,6 +255,7 @@ func TestDataLabelingServiceDatasetResource_basic(t *testing.T) {
245255
resource.TestCheckResourceAttr(resourceName, "label_set.#", "1"),
246256
resource.TestCheckResourceAttr(resourceName, "label_set.0.items.#", "1"),
247257
resource.TestCheckResourceAttr(resourceName, "label_set.0.items.0.name", "name2"),
258+
//resource.TestCheckResourceAttr(resourceName, "labeling_instructions", "labelingInstructions2"),
248259
resource.TestCheckResourceAttrSet(resourceName, "state"),
249260
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
250261
resource.TestCheckResourceAttrSet(resourceName, "time_updated"),
@@ -300,6 +311,7 @@ func TestDataLabelingServiceDatasetResource_basic(t *testing.T) {
300311
resource.TestCheckResourceAttr(singularDatasourceName, "label_set.#", "1"),
301312
resource.TestCheckResourceAttr(singularDatasourceName, "label_set.0.items.#", "1"),
302313
resource.TestCheckResourceAttr(singularDatasourceName, "label_set.0.items.0.name", "name2"),
314+
//resource.TestCheckResourceAttr(singularDatasourceName, "labeling_instructions", "labelingInstructions2"),
303315
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
304316
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
305317
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_updated"),

internal/service/data_labeling_service/data_labeling_service_dataset_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ func (s *DataLabelingServiceDatasetDataSourceCrud) SetData() error {
120120
s.D.Set("label_set", nil)
121121
}
122122

123+
if s.Res.LabelingInstructions != nil {
124+
s.D.Set("labeling_instructions", *s.Res.LabelingInstructions)
125+
}
126+
123127
if s.Res.LifecycleDetails != nil {
124128
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
125129
}

internal/service/data_labeling_service/data_labeling_service_dataset_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ func DataLabelingServiceDatasetResource() *schema.Resource {
179179
},
180180
},
181181
},
182+
"labeling_instructions": {
183+
Type: schema.TypeString,
184+
Optional: true,
185+
Computed: true,
186+
},
182187

183188
// Computed
184189
"lifecycle_details": {
@@ -349,6 +354,11 @@ func (s *DataLabelingServiceDatasetResourceCrud) Create() error {
349354
}
350355
}
351356

357+
if labelingInstructions, ok := s.D.GetOkExists("labeling_instructions"); ok {
358+
tmp := labelingInstructions.(string)
359+
request.LabelingInstructions = &tmp
360+
}
361+
352362
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "data_labeling_service")
353363

354364
response, err := s.Client.CreateDataset(context.Background(), request)
@@ -547,6 +557,11 @@ func (s *DataLabelingServiceDatasetResourceCrud) Update() error {
547557
request.FreeformTags = utils.ObjectMapToStringMap(freeformTags.(map[string]interface{}))
548558
}
549559

560+
if labelingInstructions, ok := s.D.GetOkExists("labeling_instructions"); ok {
561+
tmp := labelingInstructions.(string)
562+
request.LabelingInstructions = &tmp
563+
}
564+
550565
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "data_labeling_service")
551566

552567
response, err := s.Client.UpdateDataset(context.Background(), request)
@@ -633,6 +648,10 @@ func (s *DataLabelingServiceDatasetResourceCrud) SetData() error {
633648
s.D.Set("label_set", nil)
634649
}
635650

651+
if s.Res.LabelingInstructions != nil {
652+
s.D.Set("labeling_instructions", *s.Res.LabelingInstructions)
653+
}
654+
636655
if s.Res.LifecycleDetails != nil {
637656
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
638657
}

website/docs/d/data_labeling_service_dataset.html.markdown

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,24 @@ The following attributes are exported:
3939
* `dataset_source_details` - This allows the customer to specify the source of the dataset.
4040
* `bucket` - The object storage bucket that contains the dataset data source
4141
* `namespace` - Namespace of the bucket that contains the dataset data source
42-
* `prefix` - A common path prefix shared by the objects that make up the dataset.
42+
* `prefix` - A common path prefix shared by the objects that make up the dataset. Records will not be generated for objects whose name match exactly with prefix.
4343
* `source_type` - Source type. OBJECT_STORAGE allows the customer to describe where the dataset is in object storage.
44-
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{"foo-namespace.bar-key": "value"}`
44+
* `defined_tags` - The defined tags for this resource. Each key is predefined and scoped to a namespace. For example: `{"foo-namespace": {"bar-key": "value"}}`
4545
* `description` - A user provided description of the dataset
4646
* `display_name` - A user-friendly display name for the resource.
47-
* `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"}`
47+
* `freeform_tags` - A simple key-value pair that is applied without any predefined name, type, or scope. It exists for cross-compatibility only. For example: `{"bar-key": "value"}`
4848
* `id` - The OCID of the Dataset.
4949
* `initial_record_generation_configuration` - Initial Generate Records configuration, generates records from the Dataset's source.
5050
* `label_set` - An ordered collection of Labels that are unique by name.
5151
* `items` - An ordered collection of Labels that are unique by name.
5252
* `name` - An unique name for a label within its dataset.
53+
* `labeling_instructions` - The labeling instructions for human labelers in rich text format
5354
* `lifecycle_details` - A message describing the current state in more detail. For example, it can be used to provide actionable information for a resource in FAILED or NEEDS_ATTENTION state.
5455
* `state` - The state of a dataset. CREATING - The dataset is being created. It will transition to ACTIVE when it is ready for labeling. ACTIVE - The dataset is ready for labeling. UPDATING - The dataset is being updated. It and its related resources may be unavailable for other updates until it returns to ACTIVE. NEEDS_ATTENTION - A dataset updation operation has failed due to validation or other errors and needs attention. DELETING - The dataset and its related resources are being deleted. DELETED - The dataset has been deleted and is no longer available. FAILED - The dataset has failed due to validation or other errors.
56+
<<<<<<< ours
57+
* `system_tags` - The usage of system tag keys. These predefined keys are scoped to namespaces. For example: `{"orcl-cloud": {"free-tier-retained": "true"}}`
58+
=======
59+
>>>>>>> theirs
5560
* `time_created` - The date and time the resource was created, in the timestamp format defined by RFC3339.
5661
* `time_updated` - The date and time the resource was last updated, in the timestamp format defined by RFC3339.
5762

website/docs/d/data_labeling_service_datasets.html.markdown

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,24 @@ The following attributes are exported:
5656
* `dataset_source_details` - This allows the customer to specify the source of the dataset.
5757
* `bucket` - The object storage bucket that contains the dataset data source
5858
* `namespace` - Namespace of the bucket that contains the dataset data source
59-
* `prefix` - A common path prefix shared by the objects that make up the dataset.
59+
* `prefix` - A common path prefix shared by the objects that make up the dataset. Records will not be generated for objects whose name match exactly with prefix.
6060
* `source_type` - Source type. OBJECT_STORAGE allows the customer to describe where the dataset is in object storage.
61-
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{"foo-namespace.bar-key": "value"}`
61+
* `defined_tags` - The defined tags for this resource. Each key is predefined and scoped to a namespace. For example: `{"foo-namespace": {"bar-key": "value"}}`
6262
* `description` - A user provided description of the dataset
6363
* `display_name` - A user-friendly display name for the resource.
64-
* `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"}`
64+
* `freeform_tags` - A simple key-value pair that is applied without any predefined name, type, or scope. It exists for cross-compatibility only. For example: `{"bar-key": "value"}`
6565
* `id` - The OCID of the Dataset.
6666
* `initial_record_generation_configuration` - Initial Generate Records configuration, generates records from the Dataset's source.
6767
* `label_set` - An ordered collection of Labels that are unique by name.
6868
* `items` - An ordered collection of Labels that are unique by name.
6969
* `name` - An unique name for a label within its dataset.
70+
* `labeling_instructions` - The labeling instructions for human labelers in rich text format
7071
* `lifecycle_details` - A message describing the current state in more detail. For example, it can be used to provide actionable information for a resource in FAILED or NEEDS_ATTENTION state.
7172
* `state` - The state of a dataset. CREATING - The dataset is being created. It will transition to ACTIVE when it is ready for labeling. ACTIVE - The dataset is ready for labeling. UPDATING - The dataset is being updated. It and its related resources may be unavailable for other updates until it returns to ACTIVE. NEEDS_ATTENTION - A dataset updation operation has failed due to validation or other errors and needs attention. DELETING - The dataset and its related resources are being deleted. DELETED - The dataset has been deleted and is no longer available. FAILED - The dataset has failed due to validation or other errors.
73+
<<<<<<< ours
74+
* `system_tags` - The usage of system tag keys. These predefined keys are scoped to namespaces. For example: `{"orcl-cloud": {"free-tier-retained": "true"}}`
75+
=======
76+
>>>>>>> theirs
7277
* `time_created` - The date and time the resource was created, in the timestamp format defined by RFC3339.
7378
* `time_updated` - The date and time the resource was last updated, in the timestamp format defined by RFC3339.
7479

0 commit comments

Comments
 (0)