From 210a7cd63e81101cc7e9c1cb1b14569542a8e56c Mon Sep 17 00:00:00 2001
From: Diptipowervs <dipti.kumari2@ibm.com>
Date: Wed, 21 Feb 2024 02:12:34 +0530
Subject: [PATCH 1/2] Refactor network attach

---
 ibm/service/power/ibm_pi_constants.go         |  1 +
 ..._ibm_pi_cloud_connection_network_attach.go | 48 +++++++++----------
 ...pi_cloud_connection_network_attach_test.go |  3 +-
 ...ud_connection_network_attach.html.markdown | 12 ++---
 4 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go
index e8c354ef90..40a16ad10b 100644
--- a/ibm/service/power/ibm_pi_constants.go
+++ b/ibm/service/power/ibm_pi_constants.go
@@ -29,6 +29,7 @@ const (
 	Arg_VolumeGroupID                       = "pi_volume_group_id"
 	Arg_VolumeID                            = "pi_volume_id"
 	Arg_VolumeOnboardingID                  = "pi_volume_onboarding_id"
+	Arg_CloudConnectionID                   = "pi_cloud_connection_id"
 
 	// Attributes
 	Attr_AccessConfig                                = "access_config"
diff --git a/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go b/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go
index 24b472ed2c..7985420fea 100644
--- a/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go
+++ b/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go
@@ -9,17 +9,15 @@ import (
 	"log"
 	"time"
 
-	"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
-	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
-
-	st "github.com/IBM-Cloud/power-go-client/clients/instance"
-	"github.com/IBM-Cloud/power-go-client/helpers"
+	"github.com/IBM-Cloud/power-go-client/clients/instance"
 	"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
 	"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
+	"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
 )
 
 const (
-	PICloudConnectionNetworkId = "pi_network_id"
+	Arg_CloudConnectionNetworkId = "pi_network_id"
 )
 
 func ResourceIBMPICloudConnectionNetworkAttach() *schema.Resource {
@@ -36,23 +34,23 @@ func ResourceIBMPICloudConnectionNetworkAttach() *schema.Resource {
 
 		Schema: map[string]*schema.Schema{
 			// Required Attributes
-			helpers.PICloudInstanceId: {
+			Arg_CloudInstanceID: {
+				Description: "The GUID of the service instance associated with an account",
+				ForceNew:    true,
 				Type:        schema.TypeString,
 				Required:    true,
-				ForceNew:    true,
-				Description: "PI cloud instance ID",
 			},
-			helpers.PICloudConnectionId: {
+			Arg_CloudConnectionID: {
+				Description: "The Cloud Connection ID",
+				ForceNew:    true,
 				Type:        schema.TypeString,
 				Required:    true,
-				ForceNew:    true,
-				Description: "Cloud Connection ID",
 			},
-			PICloudConnectionNetworkId: {
+			Arg_CloudConnectionNetworkId: {
+				Description: "The Network ID to attach to this cloud connection",
+				ForceNew:    true,
 				Type:        schema.TypeString,
 				Required:    true,
-				ForceNew:    true,
-				Description: "Network ID to attach to this cloud connection",
 			},
 		},
 	}
@@ -64,12 +62,12 @@ func resourceIBMPICloudConnectionNetworkAttachCreate(ctx context.Context, d *sch
 		return diag.FromErr(err)
 	}
 
-	cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string)
-	cloudConnectionID := d.Get(helpers.PICloudConnectionId).(string)
-	networkID := d.Get(PICloudConnectionNetworkId).(string)
+	cloudInstanceID := d.Get(Arg_CloudInstanceID).(string)
+	cloudConnectionID := d.Get(Arg_CloudConnectionID).(string)
+	networkID := d.Get(Arg_CloudConnectionNetworkId).(string)
 
-	client := st.NewIBMPICloudConnectionClient(ctx, sess, cloudInstanceID)
-	jobClient := st.NewIBMPIJobClient(ctx, sess, cloudInstanceID)
+	client := instance.NewIBMPICloudConnectionClient(ctx, sess, cloudInstanceID)
+	jobClient := instance.NewIBMPIJobClient(ctx, sess, cloudInstanceID)
 
 	_, jobReference, err := client.AddNetwork(cloudConnectionID, networkID)
 	if err != nil {
@@ -97,9 +95,9 @@ func resourceIBMPICloudConnectionNetworkAttachRead(ctx context.Context, d *schem
 	cloudConnectionID := parts[1]
 	networkID := parts[2]
 
-	d.Set(helpers.PICloudInstanceId, cloudInstanceID)
-	d.Set(helpers.PICloudConnectionId, cloudConnectionID)
-	d.Set(PICloudConnectionNetworkId, networkID)
+	d.Set(Arg_CloudInstanceID, cloudInstanceID)
+	d.Set(Arg_CloudConnectionID, cloudConnectionID)
+	d.Set(Arg_CloudConnectionNetworkId, networkID)
 
 	return nil
 }
@@ -119,8 +117,8 @@ func resourceIBMPICloudConnectionNetworkAttachDelete(ctx context.Context, d *sch
 	cloudConnectionID := parts[1]
 	networkID := parts[2]
 
-	client := st.NewIBMPICloudConnectionClient(ctx, sess, cloudInstanceID)
-	jobClient := st.NewIBMPIJobClient(ctx, sess, cloudInstanceID)
+	client := instance.NewIBMPICloudConnectionClient(ctx, sess, cloudInstanceID)
+	jobClient := instance.NewIBMPIJobClient(ctx, sess, cloudInstanceID)
 
 	_, jobReference, err := client.DeleteNetwork(cloudConnectionID, networkID)
 	if err != nil {
diff --git a/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach_test.go b/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach_test.go
index d951b02a47..7ebe525031 100644
--- a/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach_test.go
+++ b/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach_test.go
@@ -55,6 +55,5 @@ func testAccCheckIBMPICloudConnectionNetworkAttachConfig(name string) string {
 		depends_on					= [ibm_pi_cloud_connection_network_attach.example]
 		pi_cloud_instance_id		= "%[1]s"
 		pi_cloud_connection_name	= "%[2]s"
-	  }
-	`, acc.Pi_cloud_instance_id, name)
+	  }`, acc.Pi_cloud_instance_id, name)
 }
diff --git a/website/docs/r/pi_cloud_connection_network_attach.html.markdown b/website/docs/r/pi_cloud_connection_network_attach.html.markdown
index d562c7770d..8b1a415c8a 100644
--- a/website/docs/r/pi_cloud_connection_network_attach.html.markdown
+++ b/website/docs/r/pi_cloud_connection_network_attach.html.markdown
@@ -23,14 +23,14 @@ resource "ibm_pi_cloud_connection_network_attach" "example" {
 }
 ```
 
-**Note**
+**Notes**
 
-* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints.
-* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows:
-  * `region` - `lon`
-  * `zone` - `lon04`
+- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints.
+- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows:
+  - `region` - `lon`
+  - `zone` - `lon04`
   
-  Example usage:
+Example usage:
   
   ```terraform
     provider "ibm" {

From b9ffaa28c4c6dd78809d2fadcfa150dde5d04ba6 Mon Sep 17 00:00:00 2001
From: Diptipowervs <dipti.kumari2@ibm.com>
Date: Mon, 11 Mar 2024 12:47:01 +0530
Subject: [PATCH 2/2] Add comment

---
 .../power/resource_ibm_pi_cloud_connection_network_attach.go    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go b/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go
index 7985420fea..7975818731 100644
--- a/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go
+++ b/ibm/service/power/resource_ibm_pi_cloud_connection_network_attach.go
@@ -33,7 +33,7 @@ func ResourceIBMPICloudConnectionNetworkAttach() *schema.Resource {
 		},
 
 		Schema: map[string]*schema.Schema{
-			// Required Attributes
+			// Arguments
 			Arg_CloudInstanceID: {
 				Description: "The GUID of the service instance associated with an account",
 				ForceNew:    true,