@@ -5,7 +5,6 @@ package odb
55import (
66 "context"
77 "errors"
8- "github.com/hashicorp/terraform-plugin-framework/path"
98 "time"
109
1110 "github.com/aws/aws-sdk-go-v2/aws"
@@ -15,6 +14,7 @@ import (
1514 "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
1615 "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
1716 "github.com/hashicorp/terraform-plugin-framework/attr"
17+ "github.com/hashicorp/terraform-plugin-framework/path"
1818 "github.com/hashicorp/terraform-plugin-framework/resource"
1919 "github.com/hashicorp/terraform-plugin-framework/resource/schema"
2020 "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
@@ -56,7 +56,7 @@ type resourceNetwork struct {
5656 framework.WithImportByID
5757}
5858
59- var OdbNetwork = newResourceNetwork
59+ var OracleDBNetwork = newResourceNetwork
6060var managedServiceTimeout = 15 * time .Minute
6161
6262func (r * resourceNetwork ) Schema (ctx context.Context , req resource.SchemaRequest , resp * resource.SchemaResponse ) {
@@ -68,7 +68,7 @@ func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest
6868 Attributes : map [string ]schema.Attribute {
6969 names .AttrARN : framework .ARNAttributeComputedOnly (),
7070 names .AttrID : framework .IDAttribute (),
71- "display_name" : schema.StringAttribute {
71+ names . AttrDisplayName : schema.StringAttribute {
7272 Required : true ,
7373 Description : "The user-friendly name for the odb network. Changing this will force terraform to create a new resource." ,
7474 PlanModifiers : []planmodifier.String {
@@ -155,7 +155,7 @@ func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest
155155 Description : "The DNS resolver endpoint in OCI for forwarding DNS queries for the ociPrivateZone domain." ,
156156 ElementType : types.ObjectType {
157157 AttrTypes : map [string ]attr.Type {
158- "domain_name" : types .StringType ,
158+ names . AttrDomainName : types .StringType ,
159159 "oci_dns_listener_ip" : types .StringType ,
160160 },
161161 },
@@ -199,7 +199,7 @@ func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest
199199 Computed : true ,
200200 Description : "Additional information about the current status of the ODB network." ,
201201 },
202- "created_at" : schema.StringAttribute {
202+ names . AttrCreatedAt : schema.StringAttribute {
203203 Computed : true ,
204204 CustomType : timetypes.RFC3339Type {},
205205 Description : "The date and time when the ODB network was created." ,
@@ -323,7 +323,7 @@ func (r *resourceNetwork) Read(ctx context.Context, req resource.ReadRequest, re
323323 return
324324 }
325325
326- out , err := FindOdbNetworkResourceByID (ctx , conn , state .OdbNetworkId .ValueString ())
326+ out , err := FindOracleDBNetworkResourceByID (ctx , conn , state .OdbNetworkId .ValueString ())
327327 if tfresource .NotFound (err ) {
328328 resp .Diagnostics .Append (fwdiag .NewResourceNotFoundWarningDiagnostic (err ))
329329 resp .State .RemoveResource (ctx )
@@ -520,7 +520,10 @@ func waitNetworkCreated(ctx context.Context, conn *odb.Client, id string, timeou
520520}
521521
522522func waitForManagedService (ctx context.Context , targetStatus odbtypes.Access , conn * odb.Client , id string , timeout time.Duration , managedResourceStatus func (managedService * odbtypes.ManagedServices ) odbtypes.ManagedResourceStatus ) (* odbtypes.OdbNetwork , error ) {
523- if targetStatus == odbtypes .AccessEnabled {
523+
524+ switch targetStatus {
525+
526+ case odbtypes .AccessEnabled :
524527 stateConf := & retry.StateChangeConf {
525528 Pending : enum .Slice (odbtypes .ManagedResourceStatusEnabling ),
526529 Target : enum .Slice (odbtypes .ManagedResourceStatusEnabled ),
@@ -533,7 +536,7 @@ func waitForManagedService(ctx context.Context, targetStatus odbtypes.Access, co
533536 return out , err
534537 }
535538 return nil , err
536- } else if targetStatus == odbtypes .AccessDisabled {
539+ case odbtypes .AccessDisabled :
537540 stateConf := & retry.StateChangeConf {
538541 Pending : enum .Slice (odbtypes .ManagedResourceStatusDisabling ),
539542 Target : enum .Slice (odbtypes .ManagedResourceStatusDisabled ),
@@ -545,16 +548,16 @@ func waitForManagedService(ctx context.Context, targetStatus odbtypes.Access, co
545548 if out , ok := outputRaw .(* odbtypes.OdbNetwork ); ok {
546549 return out , err
547550 }
548-
549551 return nil , err
550- }
551552
552- return nil , errors .New ("odb network invalid manged service status" )
553+ default :
554+ return nil , errors .New ("odb network invalid manged service status" )
555+ }
553556}
554557
555558func statusManagedService (ctx context.Context , conn * odb.Client , id string , managedResourceStatus func (managedService * odbtypes.ManagedServices ) odbtypes.ManagedResourceStatus ) retry.StateRefreshFunc {
556559 return func () (any , string , error ) {
557- out , err := FindOdbNetworkResourceByID (ctx , conn , id )
560+ out , err := FindOracleDBNetworkResourceByID (ctx , conn , id )
558561
559562 if err != nil {
560563 return nil , "" , err
@@ -602,7 +605,7 @@ func waitNetworkDeleted(ctx context.Context, conn *odb.Client, id string, timeou
602605
603606func statusNetwork (ctx context.Context , conn * odb.Client , id string ) retry.StateRefreshFunc {
604607 return func () (any , string , error ) {
605- out , err := FindOdbNetworkResourceByID (ctx , conn , id )
608+ out , err := FindOracleDBNetworkResourceByID (ctx , conn , id )
606609 if tfresource .NotFound (err ) {
607610 return nil , "" , nil
608611 }
@@ -625,7 +628,7 @@ func mapManagedServiceStatusToAccessStatus(mangedStatus odbtypes.ManagedResource
625628 return "" , errors .New ("can not convert managed status to access status" )
626629}
627630
628- func FindOdbNetworkResourceByID (ctx context.Context , conn * odb.Client , id string ) (* odbtypes.OdbNetwork , error ) {
631+ func FindOracleDBNetworkResourceByID (ctx context.Context , conn * odb.Client , id string ) (* odbtypes.OdbNetwork , error ) {
629632 input := odb.GetOdbNetworkInput {
630633 OdbNetworkId : aws .String (id ),
631634 }
0 commit comments