@@ -826,6 +826,53 @@ Sampling is not applied if 'sampling_percent' is not specified, 0 or 100.`,
826826 Optional : true ,
827827 Description : `User friendly display name.` ,
828828 },
829+ "execution_identity" : {
830+ Type : schema .TypeList ,
831+ Optional : true ,
832+ ForceNew : true ,
833+ Description : `The identity to run the datascan. If not specified, defaults to the Dataplex Service Agent.` ,
834+ MaxItems : 1 ,
835+ Elem : & schema.Resource {
836+ Schema : map [string ]* schema.Schema {
837+ "dataplex_service_agent" : {
838+ Type : schema .TypeList ,
839+ Optional : true ,
840+ Description : `The Dataplex service agent associated with the user's project.` ,
841+ MaxItems : 1 ,
842+ Elem : & schema.Resource {
843+ Schema : map [string ]* schema.Schema {},
844+ },
845+ ExactlyOneOf : []string {"execution_identity.0.dataplex_service_agent" , "execution_identity.0.service_account" , "execution_identity.0.user_credential" },
846+ },
847+ "service_account" : {
848+ Type : schema .TypeList ,
849+ Optional : true ,
850+ Description : `Service account to use to execute a datascan.` ,
851+ MaxItems : 1 ,
852+ Elem : & schema.Resource {
853+ Schema : map [string ]* schema.Schema {
854+ "email" : {
855+ Type : schema .TypeString ,
856+ Required : true ,
857+ Description : `Service account email.` ,
858+ },
859+ },
860+ },
861+ ExactlyOneOf : []string {"execution_identity.0.dataplex_service_agent" , "execution_identity.0.service_account" , "execution_identity.0.user_credential" },
862+ },
863+ "user_credential" : {
864+ Type : schema .TypeList ,
865+ Optional : true ,
866+ Description : `The credential of the calling user. Supports only ONE_TIME trigger type.` ,
867+ MaxItems : 1 ,
868+ Elem : & schema.Resource {
869+ Schema : map [string ]* schema.Schema {},
870+ },
871+ ExactlyOneOf : []string {"execution_identity.0.dataplex_service_agent" , "execution_identity.0.service_account" , "execution_identity.0.user_credential" },
872+ },
873+ },
874+ },
875+ },
829876 "labels" : {
830877 Type : schema .TypeMap ,
831878 Optional : true ,
@@ -856,12 +903,12 @@ Please refer to the field 'effective_labels' for all of the labels present on th
856903 "latest_job_end_time" : {
857904 Type : schema .TypeString ,
858905 Computed : true ,
859- Description : `The time when the latest DataScanJob started .` ,
906+ Description : `The time when the latest DataScanJob ended .` ,
860907 },
861908 "latest_job_start_time" : {
862909 Type : schema .TypeString ,
863910 Computed : true ,
864- Description : `The time when the latest DataScanJob ended .` ,
911+ Description : `The time when the latest DataScanJob started .` ,
865912 },
866913 },
867914 },
@@ -941,6 +988,12 @@ func resourceDataplexDatascanCreate(d *schema.ResourceData, meta interface{}) er
941988 } else if v , ok := d .GetOkExists ("execution_spec" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (executionSpecProp )) && (ok || ! reflect .DeepEqual (v , executionSpecProp )) {
942989 obj ["executionSpec" ] = executionSpecProp
943990 }
991+ executionIdentityProp , err := expandDataplexDatascanExecutionIdentity (d .Get ("execution_identity" ), d , config )
992+ if err != nil {
993+ return err
994+ } else if v , ok := d .GetOkExists ("execution_identity" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (executionIdentityProp )) && (ok || ! reflect .DeepEqual (v , executionIdentityProp )) {
995+ obj ["executionIdentity" ] = executionIdentityProp
996+ }
944997 dataQualitySpecProp , err := expandDataplexDatascanDataQualitySpec (d .Get ("data_quality_spec" ), d , config )
945998 if err != nil {
946999 return err
@@ -1126,6 +1179,9 @@ func resourceDataplexDatascanRead(d *schema.ResourceData, meta interface{}) erro
11261179 if err := d .Set ("execution_status" , flattenDataplexDatascanExecutionStatus (res ["executionStatus" ], d , config )); err != nil {
11271180 return fmt .Errorf ("Error reading Datascan: %s" , err )
11281181 }
1182+ if err := d .Set ("execution_identity" , flattenDataplexDatascanExecutionIdentity (res ["executionIdentity" ], d , config )); err != nil {
1183+ return fmt .Errorf ("Error reading Datascan: %s" , err )
1184+ }
11291185 if err := d .Set ("type" , flattenDataplexDatascanType (res ["type" ], d , config )); err != nil {
11301186 return fmt .Errorf ("Error reading Datascan: %s" , err )
11311187 }
@@ -1584,6 +1640,56 @@ func flattenDataplexDatascanExecutionStatusLatestJobStartTime(v interface{}, d *
15841640 return v
15851641}
15861642
1643+ func flattenDataplexDatascanExecutionIdentity (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1644+ if v == nil {
1645+ return nil
1646+ }
1647+ original := v .(map [string ]interface {})
1648+ if len (original ) == 0 {
1649+ return nil
1650+ }
1651+ transformed := make (map [string ]interface {})
1652+ transformed ["dataplex_service_agent" ] =
1653+ flattenDataplexDatascanExecutionIdentityDataplexServiceAgent (original ["dataplexServiceAgent" ], d , config )
1654+ transformed ["user_credential" ] =
1655+ flattenDataplexDatascanExecutionIdentityUserCredential (original ["userCredential" ], d , config )
1656+ transformed ["service_account" ] =
1657+ flattenDataplexDatascanExecutionIdentityServiceAccount (original ["serviceAccount" ], d , config )
1658+ return []interface {}{transformed }
1659+ }
1660+ func flattenDataplexDatascanExecutionIdentityDataplexServiceAgent (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1661+ if v == nil {
1662+ return nil
1663+ }
1664+ transformed := make (map [string ]interface {})
1665+ return []interface {}{transformed }
1666+ }
1667+
1668+ func flattenDataplexDatascanExecutionIdentityUserCredential (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1669+ if v == nil {
1670+ return nil
1671+ }
1672+ transformed := make (map [string ]interface {})
1673+ return []interface {}{transformed }
1674+ }
1675+
1676+ func flattenDataplexDatascanExecutionIdentityServiceAccount (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1677+ if v == nil {
1678+ return nil
1679+ }
1680+ original := v .(map [string ]interface {})
1681+ if len (original ) == 0 {
1682+ return nil
1683+ }
1684+ transformed := make (map [string ]interface {})
1685+ transformed ["email" ] =
1686+ flattenDataplexDatascanExecutionIdentityServiceAccountEmail (original ["email" ], d , config )
1687+ return []interface {}{transformed }
1688+ }
1689+ func flattenDataplexDatascanExecutionIdentityServiceAccountEmail (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1690+ return v
1691+ }
1692+
15871693func flattenDataplexDatascanType (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
15881694 return v
15891695}
@@ -2423,6 +2529,104 @@ func expandDataplexDatascanExecutionSpecField(v interface{}, d tpgresource.Terra
24232529 return v , nil
24242530}
24252531
2532+ func expandDataplexDatascanExecutionIdentity (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2533+ if v == nil {
2534+ return nil , nil
2535+ }
2536+ l := v .([]interface {})
2537+ if len (l ) == 0 || l [0 ] == nil {
2538+ return nil , nil
2539+ }
2540+ raw := l [0 ]
2541+ original := raw .(map [string ]interface {})
2542+ transformed := make (map [string ]interface {})
2543+
2544+ transformedDataplexServiceAgent , err := expandDataplexDatascanExecutionIdentityDataplexServiceAgent (original ["dataplex_service_agent" ], d , config )
2545+ if err != nil {
2546+ return nil , err
2547+ } else {
2548+ transformed ["dataplexServiceAgent" ] = transformedDataplexServiceAgent
2549+ }
2550+
2551+ transformedUserCredential , err := expandDataplexDatascanExecutionIdentityUserCredential (original ["user_credential" ], d , config )
2552+ if err != nil {
2553+ return nil , err
2554+ } else {
2555+ transformed ["userCredential" ] = transformedUserCredential
2556+ }
2557+
2558+ transformedServiceAccount , err := expandDataplexDatascanExecutionIdentityServiceAccount (original ["service_account" ], d , config )
2559+ if err != nil {
2560+ return nil , err
2561+ } else if val := reflect .ValueOf (transformedServiceAccount ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2562+ transformed ["serviceAccount" ] = transformedServiceAccount
2563+ }
2564+
2565+ return transformed , nil
2566+ }
2567+
2568+ func expandDataplexDatascanExecutionIdentityDataplexServiceAgent (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2569+ if v == nil {
2570+ return nil , nil
2571+ }
2572+ l := v .([]interface {})
2573+ if len (l ) == 0 {
2574+ return nil , nil
2575+ }
2576+
2577+ if l [0 ] == nil {
2578+ transformed := make (map [string ]interface {})
2579+ return transformed , nil
2580+ }
2581+ transformed := make (map [string ]interface {})
2582+
2583+ return transformed , nil
2584+ }
2585+
2586+ func expandDataplexDatascanExecutionIdentityUserCredential (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2587+ if v == nil {
2588+ return nil , nil
2589+ }
2590+ l := v .([]interface {})
2591+ if len (l ) == 0 {
2592+ return nil , nil
2593+ }
2594+
2595+ if l [0 ] == nil {
2596+ transformed := make (map [string ]interface {})
2597+ return transformed , nil
2598+ }
2599+ transformed := make (map [string ]interface {})
2600+
2601+ return transformed , nil
2602+ }
2603+
2604+ func expandDataplexDatascanExecutionIdentityServiceAccount (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2605+ if v == nil {
2606+ return nil , nil
2607+ }
2608+ l := v .([]interface {})
2609+ if len (l ) == 0 || l [0 ] == nil {
2610+ return nil , nil
2611+ }
2612+ raw := l [0 ]
2613+ original := raw .(map [string ]interface {})
2614+ transformed := make (map [string ]interface {})
2615+
2616+ transformedEmail , err := expandDataplexDatascanExecutionIdentityServiceAccountEmail (original ["email" ], d , config )
2617+ if err != nil {
2618+ return nil , err
2619+ } else if val := reflect .ValueOf (transformedEmail ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
2620+ transformed ["email" ] = transformedEmail
2621+ }
2622+
2623+ return transformed , nil
2624+ }
2625+
2626+ func expandDataplexDatascanExecutionIdentityServiceAccountEmail (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2627+ return v , nil
2628+ }
2629+
24262630func expandDataplexDatascanDataQualitySpec (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
24272631 if v == nil {
24282632 return nil , nil
0 commit comments