88 "log"
99
1010 "github.com/IBM-Cloud/power-go-client/clients/instance"
11- "github.com/IBM-Cloud/power-go-client/helpers"
1211 "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
1312 "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
1413 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -27,11 +26,22 @@ func DataSourceIBMPINetwork() *schema.Resource {
2726 Type : schema .TypeString ,
2827 ValidateFunc : validation .NoZeroValues ,
2928 },
29+ Arg_NetworkID : {
30+ AtLeastOneOf : []string {Arg_NetworkID , Arg_NetworkName },
31+ ConflictsWith : []string {Arg_NetworkName },
32+ Description : "The network ID." ,
33+ Optional : true ,
34+ Type : schema .TypeString ,
35+ ValidateFunc : validation .NoZeroValues ,
36+ },
3037 Arg_NetworkName : {
31- Description : "The unique identifier or name of a network." ,
32- Required : true ,
33- Type : schema .TypeString ,
34- ValidateFunc : validation .NoZeroValues ,
38+ AtLeastOneOf : []string {Arg_NetworkID , Arg_NetworkName },
39+ ConflictsWith : []string {Arg_NetworkID },
40+ Deprecated : "The pi_network_name field is deprecated. Please use pi_network_id instead" ,
41+ Description : "The unique identifier or name of a network." ,
42+ Optional : true ,
43+ Type : schema .TypeString ,
44+ ValidateFunc : validation .NoZeroValues ,
3545 },
3646
3747 // Attributes
@@ -140,9 +150,15 @@ func dataSourceIBMPINetworkRead(ctx context.Context, d *schema.ResourceData, met
140150 }
141151
142152 cloudInstanceID := d .Get (Arg_CloudInstanceID ).(string )
153+ var networkID string
154+ if v , ok := d .GetOk (Arg_NetworkID ); ok {
155+ networkID = v .(string )
156+ } else if v , ok := d .GetOk (Arg_NetworkName ); ok {
157+ networkID = v .(string )
158+ }
143159
144160 networkC := instance .NewIBMPINetworkClient (ctx , sess , cloudInstanceID )
145- networkdata , err := networkC .Get (d . Get ( helpers . PINetworkName ).( string ) )
161+ networkdata , err := networkC .Get (networkID )
146162 if err != nil || networkdata == nil {
147163 return diag .FromErr (err )
148164 }
0 commit comments