Skip to content

Commit 6be74a8

Browse files
Keyang RuMeharwadeDivya
authored andcommitted
Added - Support for Async Inferencing Support for Anomaly Detection
1 parent d666079 commit 6be74a8

19 files changed

+2125
-47
lines changed

examples/aiAnomalyDetection/main.tf

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,75 @@ variable "model_state" {
147147
default = "ACTIVE"
148148
}
149149

150+
variable "detect_anomaly_job_description" {
151+
default = "description"
152+
}
153+
154+
variable "detect_anomaly_job_display_name" {
155+
default = "displayName"
156+
}
157+
158+
variable "detect_anomaly_job_input_details_content" {
159+
default = "content"
160+
}
161+
162+
variable "detect_anomaly_job_input_details_content_type" {
163+
default = "CSV"
164+
}
165+
166+
variable "detect_anomaly_job_input_details_data_timestamp" {
167+
default = "timestamp"
168+
}
169+
170+
variable "detect_anomaly_job_input_details_data_values" {
171+
default = []
172+
}
173+
174+
variable "detect_anomaly_job_input_details_input_type" {
175+
default = "INLINE"
176+
}
177+
178+
variable "detect_anomaly_job_input_details_object_locations_bucket" {
179+
default = "bucket"
180+
}
181+
182+
variable "detect_anomaly_job_input_details_object_locations_namespace" {
183+
default = "namespace"
184+
}
185+
186+
variable "detect_anomaly_job_input_details_object_locations_object" {
187+
default = "object"
188+
}
189+
190+
variable "detect_anomaly_job_input_details_signal_names" {
191+
default = []
192+
}
193+
194+
variable "detect_anomaly_job_output_details_bucket" {
195+
default = "bucket"
196+
}
197+
198+
variable "detect_anomaly_job_output_details_namespace" {
199+
default = "namespace"
200+
}
201+
202+
variable "detect_anomaly_job_output_details_output_type" {
203+
default = "OBJECT_STORAGE"
204+
}
205+
206+
variable "detect_anomaly_job_output_details_prefix" {
207+
default = "prefix"
208+
}
209+
210+
variable "detect_anomaly_job_sensitivity" {
211+
default = 1.0
212+
}
213+
214+
variable "detect_anomaly_job_state" {
215+
default = "AVAILABLE"
216+
}
217+
218+
150219

151220
provider "oci" {
152221
tenancy_ocid = var.tenancy_ocid
@@ -325,4 +394,56 @@ data "oci_ai_anomaly_detection_models" "test_models" {
325394
state = var.model_state
326395
}
327396

397+
resource "oci_ai_anomaly_detection_detect_anomaly_job" "test_detect_anomaly_job" {
398+
#Required
399+
compartment_id = var.compartment_id
400+
input_details {
401+
#Required
402+
input_type = var.detect_anomaly_job_input_details_input_type
403+
404+
#Optional
405+
content = var.detect_anomaly_job_input_details_content
406+
content_type = var.detect_anomaly_job_input_details_content_type
407+
data {
408+
409+
#Optional
410+
timestamp = var.detect_anomaly_job_input_details_data_timestamp
411+
values = var.detect_anomaly_job_input_details_data_values
412+
}
413+
object_locations {
414+
415+
#Optional
416+
bucket = var.detect_anomaly_job_input_details_object_locations_bucket
417+
namespace = var.detect_anomaly_job_input_details_object_locations_namespace
418+
object = var.detect_anomaly_job_input_details_object_locations_object
419+
}
420+
signal_names = var.detect_anomaly_job_input_details_signal_names
421+
}
422+
model_id = oci_ai_anomaly_detection_model.test_model.id
423+
output_details {
424+
#Required
425+
bucket = var.detect_anomaly_job_output_details_bucket
426+
namespace = var.detect_anomaly_job_output_details_namespace
427+
output_type = var.detect_anomaly_job_output_details_output_type
428+
429+
#Optional
430+
prefix = var.detect_anomaly_job_output_details_prefix
431+
}
432+
433+
#Optional
434+
description = var.detect_anomaly_job_description
435+
display_name = var.detect_anomaly_job_display_name
436+
sensitivity = var.detect_anomaly_job_sensitivity
437+
}
438+
439+
data "oci_ai_anomaly_detection_detect_anomaly_jobs" "test_detect_anomaly_jobs" {
440+
#Required
441+
compartment_id = var.compartment_id
328442

443+
#Optional
444+
detect_anomaly_job_id = oci_ai_anomaly_detection_detect_anomaly_job.test_detect_anomaly_job.id
445+
display_name = var.detect_anomaly_job_display_name
446+
model_id = oci_ai_anomaly_detection_model.test_model.id
447+
project_id = oci_ai_anomaly_detection_project.test_project.id
448+
state = var.detect_anomaly_job_state
449+
}

internal/integrationtest/ai_anomaly_detection_data_asset_test.go

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
22
// Licensed under the Mozilla Public License v2.0
33

44
package integrationtest
@@ -50,18 +50,18 @@ var (
5050
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
5151
"data_source_details": acctest.RepresentationGroup{RepType: acctest.Required, Group: dataAssetDataSourceDetailsObjRepresentation},
5252
"project_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_ai_anomaly_detection_project.test_project.id}`},
53-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
54-
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
55-
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
56-
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
57-
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsChangesRep},
53+
//"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
54+
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
55+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
56+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
57+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDataAssetResultsChangesRep},
5858
}
5959

6060
aiAnomalyDetectionDataAssetAtpRepresentation = map[string]interface{}{
6161
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
6262
"data_source_details": acctest.RepresentationGroup{RepType: acctest.Required, Group: dataAssetDataSourceDetailsAtpRepresentation},
6363
"project_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_ai_anomaly_detection_project.test_project.id}`},
64-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
64+
//"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
6565
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
6666
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
6767
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
@@ -72,7 +72,7 @@ var (
7272
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
7373
"data_source_details": acctest.RepresentationGroup{RepType: acctest.Required, Group: dataAssetDataSourceDetailsInfluxRepresentation},
7474
"project_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_ai_anomaly_detection_project.test_project.id}`},
75-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
75+
//"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
7676
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
7777
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
7878
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
@@ -81,8 +81,8 @@ var (
8181

8282
dataAssetDataSourceDetailsObjRepresentation = map[string]interface{}{
8383
"data_source_type": acctest.Representation{RepType: acctest.Required, Create: `ORACLE_OBJECT_STORAGE`},
84-
"bucket": acctest.Representation{RepType: acctest.Required, Create: `bucket-test`},
85-
"namespace": acctest.Representation{RepType: acctest.Required, Create: `dxterraformtest`},
84+
"bucket": acctest.Representation{RepType: acctest.Required, Create: `mset-idp-test-datasets`},
85+
"namespace": acctest.Representation{RepType: acctest.Required, Create: `id5zda5six9a`},
8686
"object": acctest.Representation{RepType: acctest.Required, Create: `latest_training_data.json`},
8787
}
8888

@@ -116,12 +116,16 @@ var (
116116
"organization_name": acctest.Representation{RepType: acctest.Optional, Create: `organizationName`},
117117
"retention_policy_name": acctest.Representation{RepType: acctest.Optional, Create: `${oci_identity_policy.test_policy.name}`},
118118
}
119+
120+
ignoreDataAssetResultsChangesRep = map[string]interface{}{
121+
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`, `system_tags`}},
122+
}
119123
//Change this to only what is required
120-
AiAnomalyDetectionDataAssetResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_ai_anomaly_detection_project", "test_project", acctest.Required, acctest.Create, aiAnomalyDetectionProjectRepresentation) +
121-
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Optional, acctest.Create, CoreSubnetRepresentation) +
122-
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Optional, acctest.Create, CoreVcnRepresentation) +
123-
AvailabilityDomainConfig +
124-
DefinedTagsDependencies
124+
AiAnomalyDetectionDataAssetResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_ai_anomaly_detection_project", "test_project", acctest.Required, acctest.Create, aiAnomalyDetectionProjectRepresentation)
125+
// acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Optional, acctest.Create, CoreSubnetRepresentation) +
126+
// acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Optional, acctest.Create, CoreVcnRepresentation)
127+
//+ AvailabilityDomainConfig
128+
//+DefinedTagsDependencies
125129
)
126130

127131
func TestAiAnomalyDetectionDataAssetResource_basic(t *testing.T) {
@@ -156,8 +160,8 @@ func TestAiAnomalyDetectionDataAssetResource_basic(t *testing.T) {
156160
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
157161
resource.TestCheckResourceAttr(resourceName, "data_source_details.#", "1"),
158162
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.data_source_type", "ORACLE_OBJECT_STORAGE"),
159-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "bucket-test"),
160-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "dxterraformtest"),
163+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "mset-idp-test-datasets"),
164+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "id5zda5six9a"),
161165
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.object", "latest_training_data.json"),
162166
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
163167

@@ -179,9 +183,9 @@ func TestAiAnomalyDetectionDataAssetResource_basic(t *testing.T) {
179183
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
180184
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
181185
resource.TestCheckResourceAttr(resourceName, "data_source_details.#", "1"),
182-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "bucket-test"),
186+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "mset-idp-test-datasets"),
183187
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.data_source_type", "ORACLE_OBJECT_STORAGE"),
184-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "dxterraformtest"),
188+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "id5zda5six9a"),
185189
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.object", "latest_training_data.json"),
186190
resource.TestCheckResourceAttr(resourceName, "description", "description"),
187191
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
@@ -213,9 +217,9 @@ func TestAiAnomalyDetectionDataAssetResource_basic(t *testing.T) {
213217
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
214218
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
215219
resource.TestCheckResourceAttr(resourceName, "data_source_details.#", "1"),
216-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "bucket-test"),
220+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "mset-idp-test-datasets"),
217221
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.data_source_type", "ORACLE_OBJECT_STORAGE"),
218-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "dxterraformtest"),
222+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "id5zda5six9a"),
219223
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.object", "latest_training_data.json"),
220224
resource.TestCheckResourceAttr(resourceName, "description", "description"),
221225
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
@@ -242,9 +246,9 @@ func TestAiAnomalyDetectionDataAssetResource_basic(t *testing.T) {
242246
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
243247
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
244248
resource.TestCheckResourceAttr(resourceName, "data_source_details.#", "1"),
245-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "bucket-test"),
249+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.bucket", "mset-idp-test-datasets"),
246250
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.data_source_type", "ORACLE_OBJECT_STORAGE"),
247-
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "dxterraformtest"),
251+
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.namespace", "id5zda5six9a"),
248252
resource.TestCheckResourceAttr(resourceName, "data_source_details.0.object", "latest_training_data.json"),
249253
resource.TestCheckResourceAttr(resourceName, "description", "description2"),
250254
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),

0 commit comments

Comments
 (0)