@@ -121,6 +121,84 @@ func AnalyticsAnalyticsInstanceResource() *schema.Resource {
121121 string (oci_analytics .AnalyticsInstanceLifecycleStateActive ),
122122 }, true ),
123123 },
124+ "network_endpoint_details" : {
125+ Type : schema .TypeList ,
126+ Optional : true ,
127+ Computed : true ,
128+ ForceNew : true ,
129+ MaxItems : 1 ,
130+ MinItems : 1 ,
131+ Elem : & schema.Resource {
132+ Schema : map [string ]* schema.Schema {
133+ // Required
134+ "network_endpoint_type" : {
135+ Type : schema .TypeString ,
136+ Required : true ,
137+ ForceNew : true ,
138+ DiffSuppressFunc : EqualIgnoreCaseSuppressDiff ,
139+ ValidateFunc : validation .StringInSlice ([]string {
140+ "PRIVATE" ,
141+ "PUBLIC" ,
142+ }, true ),
143+ },
144+
145+ // Optional
146+ "subnet_id" : {
147+ Type : schema .TypeString ,
148+ Optional : true ,
149+ Computed : true ,
150+ ForceNew : true ,
151+ },
152+ "vcn_id" : {
153+ Type : schema .TypeString ,
154+ Optional : true ,
155+ Computed : true ,
156+ ForceNew : true ,
157+ },
158+ "whitelisted_ips" : {
159+ Type : schema .TypeList ,
160+ Optional : true ,
161+ Computed : true ,
162+ ForceNew : true ,
163+ Elem : & schema.Schema {
164+ Type : schema .TypeString ,
165+ },
166+ },
167+ "whitelisted_vcns" : {
168+ Type : schema .TypeList ,
169+ Optional : true ,
170+ Computed : true ,
171+ ForceNew : true ,
172+ Elem : & schema.Resource {
173+ Schema : map [string ]* schema.Schema {
174+ // Required
175+
176+ // Optional
177+ "id" : {
178+ Type : schema .TypeString ,
179+ Optional : true ,
180+ Computed : true ,
181+ ForceNew : true ,
182+ },
183+ "whitelisted_ips" : {
184+ Type : schema .TypeList ,
185+ Optional : true ,
186+ Computed : true ,
187+ ForceNew : true ,
188+ Elem : & schema.Schema {
189+ Type : schema .TypeString ,
190+ },
191+ },
192+
193+ // Computed
194+ },
195+ },
196+ },
197+
198+ // Computed
199+ },
200+ },
201+ },
124202
125203 // Computed
126204 "service_url" : {
@@ -348,6 +426,17 @@ func (s *AnalyticsAnalyticsInstanceResourceCrud) Create() error {
348426 request .Name = & tmp
349427 }
350428
429+ if networkEndpointDetails , ok := s .D .GetOkExists ("network_endpoint_details" ); ok {
430+ if tmpList := networkEndpointDetails .([]interface {}); len (tmpList ) > 0 {
431+ fieldKeyFormat := fmt .Sprintf ("%s.%d.%%s" , "network_endpoint_details" , 0 )
432+ tmp , err := s .mapToNetworkEndpointDetails (fieldKeyFormat )
433+ if err != nil {
434+ return err
435+ }
436+ request .NetworkEndpointDetails = tmp
437+ }
438+ }
439+
351440 request .RequestMetadata .RetryPolicy = getRetryPolicy (s .DisableNotFoundRetries , "analytics" )
352441
353442 response , err := s .Client .CreateAnalyticsInstance (context .Background (), request )
@@ -631,6 +720,16 @@ func (s *AnalyticsAnalyticsInstanceResourceCrud) SetData() error {
631720 s .D .Set ("name" , * s .Res .Name )
632721 }
633722
723+ if s .Res .NetworkEndpointDetails != nil {
724+ networkEndpointDetailsArray := []interface {}{}
725+ if networkEndpointDetailsMap := NetworkEndpointDetailsToMap (& s .Res .NetworkEndpointDetails ); networkEndpointDetailsMap != nil {
726+ networkEndpointDetailsArray = append (networkEndpointDetailsArray , networkEndpointDetailsMap )
727+ }
728+ s .D .Set ("network_endpoint_details" , networkEndpointDetailsArray )
729+ } else {
730+ s .D .Set ("network_endpoint_details" , nil )
731+ }
732+
634733 if s .Res .ServiceUrl != nil {
635734 s .D .Set ("service_url" , * s .Res .ServiceUrl )
636735 }
@@ -675,6 +774,132 @@ func AnalyticsCapacityToMap(obj *oci_analytics.Capacity) map[string]interface{}
675774 return result
676775}
677776
777+ func (s * AnalyticsAnalyticsInstanceResourceCrud ) mapToNetworkEndpointDetails (fieldKeyFormat string ) (oci_analytics.NetworkEndpointDetails , error ) {
778+ var baseObject oci_analytics.NetworkEndpointDetails
779+ //discriminator
780+ networkEndpointTypeRaw , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "network_endpoint_type" ))
781+ var networkEndpointType string
782+ if ok {
783+ networkEndpointType = networkEndpointTypeRaw .(string )
784+ } else {
785+ networkEndpointType = "" // default value
786+ }
787+ switch strings .ToLower (networkEndpointType ) {
788+ case strings .ToLower ("PRIVATE" ):
789+ details := oci_analytics.PrivateEndpointDetails {}
790+ if subnetId , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "subnet_id" )); ok {
791+ tmp := subnetId .(string )
792+ details .SubnetId = & tmp
793+ }
794+ if vcnId , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "vcn_id" )); ok {
795+ tmp := vcnId .(string )
796+ details .VcnId = & tmp
797+ }
798+ baseObject = details
799+ case strings .ToLower ("PUBLIC" ):
800+ details := oci_analytics.PublicEndpointDetails {}
801+ if whitelistedIps , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "whitelisted_ips" )); ok {
802+ interfaces := whitelistedIps .([]interface {})
803+ tmp := make ([]string , len (interfaces ))
804+ for i := range interfaces {
805+ if interfaces [i ] != nil {
806+ tmp [i ] = interfaces [i ].(string )
807+ }
808+ }
809+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "whitelisted_ips" )) {
810+ details .WhitelistedIps = tmp
811+ }
812+ }
813+ if whitelistedVcns , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "whitelisted_vcns" )); ok {
814+ interfaces := whitelistedVcns .([]interface {})
815+ tmp := make ([]oci_analytics.VirtualCloudNetwork , len (interfaces ))
816+ for i := range interfaces {
817+ stateDataIndex := i
818+ fieldKeyFormatNextLevel := fmt .Sprintf ("%s.%d.%%s" , fmt .Sprintf (fieldKeyFormat , "whitelisted_vcns" ), stateDataIndex )
819+ converted , err := s .mapToVirtualCloudNetwork (fieldKeyFormatNextLevel )
820+ if err != nil {
821+ return details , err
822+ }
823+ tmp [i ] = converted
824+ }
825+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "whitelisted_vcns" )) {
826+ details .WhitelistedVcns = tmp
827+ }
828+ }
829+ baseObject = details
830+ default :
831+ return nil , fmt .Errorf ("unknown network_endpoint_type '%v' was specified" , networkEndpointType )
832+ }
833+ return baseObject , nil
834+ }
835+
836+ func NetworkEndpointDetailsToMap (obj * oci_analytics.NetworkEndpointDetails ) map [string ]interface {} {
837+ result := map [string ]interface {}{}
838+ switch v := (* obj ).(type ) {
839+ case oci_analytics.PrivateEndpointDetails :
840+ result ["network_endpoint_type" ] = "PRIVATE"
841+
842+ if v .SubnetId != nil {
843+ result ["subnet_id" ] = string (* v .SubnetId )
844+ }
845+
846+ if v .VcnId != nil {
847+ result ["vcn_id" ] = string (* v .VcnId )
848+ }
849+ case oci_analytics.PublicEndpointDetails :
850+ result ["network_endpoint_type" ] = "PUBLIC"
851+
852+ result ["whitelisted_ips" ] = v .WhitelistedIps
853+
854+ whitelistedVcns := []interface {}{}
855+ for _ , item := range v .WhitelistedVcns {
856+ whitelistedVcns = append (whitelistedVcns , VirtualCloudNetworkToMap (item ))
857+ }
858+ result ["whitelisted_vcns" ] = whitelistedVcns
859+ default :
860+ log .Printf ("[WARN] Received 'network_endpoint_type' of unknown type %v" , * obj )
861+ return nil
862+ }
863+
864+ return result
865+ }
866+
867+ func (s * AnalyticsAnalyticsInstanceResourceCrud ) mapToVirtualCloudNetwork (fieldKeyFormat string ) (oci_analytics.VirtualCloudNetwork , error ) {
868+ result := oci_analytics.VirtualCloudNetwork {}
869+
870+ if id , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "id" )); ok {
871+ tmp := id .(string )
872+ result .Id = & tmp
873+ }
874+
875+ if whitelistedIps , ok := s .D .GetOkExists (fmt .Sprintf (fieldKeyFormat , "whitelisted_ips" )); ok {
876+ interfaces := whitelistedIps .([]interface {})
877+ tmp := make ([]string , len (interfaces ))
878+ for i := range interfaces {
879+ if interfaces [i ] != nil {
880+ tmp [i ] = interfaces [i ].(string )
881+ }
882+ }
883+ if len (tmp ) != 0 || s .D .HasChange (fmt .Sprintf (fieldKeyFormat , "whitelisted_ips" )) {
884+ result .WhitelistedIps = tmp
885+ }
886+ }
887+
888+ return result , nil
889+ }
890+
891+ func VirtualCloudNetworkToMap (obj oci_analytics.VirtualCloudNetwork ) map [string ]interface {} {
892+ result := map [string ]interface {}{}
893+
894+ if obj .Id != nil {
895+ result ["id" ] = string (* obj .Id )
896+ }
897+
898+ result ["whitelisted_ips" ] = obj .WhitelistedIps
899+
900+ return result
901+ }
902+
678903func (s * AnalyticsAnalyticsInstanceResourceCrud ) updateCompartment (compartment interface {}) error {
679904 changeCompartmentRequest := oci_analytics.ChangeAnalyticsInstanceCompartmentRequest {}
680905
0 commit comments