Skip to content

Commit

Permalink
added primary_ip refernce to nac for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
uibm committed Dec 4, 2024
1 parent d5d150f commit 0a81c97
Showing 1 changed file with 120 additions and 1 deletion.
121 changes: 120 additions & 1 deletion ibm/service/vpc/resource_ibm_is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,55 @@ func ResourceIBMISInstance() *schema.Resource {
Computed: true,
Description: "The resource type.",
},
// primary_ip for consistency
"primary_ip": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "The primary IP address of the virtual network interface for the network attachment.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The IP address.If the address has not yet been selected, the value will be `0.0.0.0`.This property may add support for IPv6 addresses in the future. When processing a value in this property, verify that the address is in an expected format. If it is not, log an error. Optionally halt processing and surface the error, or bypass the resource on which the unexpected IP address format was encountered.",
},
"deleted": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "If present, this property indicates the referenced resource has been deleted, and providessome supplementary information.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"more_info": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Link to documentation about deleted resources.",
},
},
},
},
"href": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The URL for this reserved IP.",
},
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The unique identifier for this reserved IP.",
},
"name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The name for this reserved IP. The name is unique across all reserved IPs in a subnet.",
},
"resource_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The resource type.",
},
},
},
},
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1196,7 +1245,55 @@ func ResourceIBMISInstance() *schema.Resource {
},
},
},

// primary_ip for consistency
"primary_ip": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "The primary IP address of the virtual network interface for the network attachment.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The IP address.If the address has not yet been selected, the value will be `0.0.0.0`.This property may add support for IPv6 addresses in the future. When processing a value in this property, verify that the address is in an expected format. If it is not, log an error. Optionally halt processing and surface the error, or bypass the resource on which the unexpected IP address format was encountered.",
},
"deleted": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "If present, this property indicates the referenced resource has been deleted, and providessome supplementary information.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"more_info": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "Link to documentation about deleted resources.",
},
},
},
},
"href": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The URL for this reserved IP.",
},
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The unique identifier for this reserved IP.",
},
"name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The name for this reserved IP. The name is unique across all reserved IPs in a subnet.",
},
"resource_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The resource type.",
},
},
},
},
"virtual_network_interface": &schema.Schema{
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -7249,6 +7346,10 @@ func resourceIBMIsInstanceInstanceNetworkAttachmentReferenceToMap(model *vpcv1.I
vniMap["name"] = pna.VirtualNetworkInterface.Name
vniMap["resource_type"] = pna.VirtualNetworkInterface.ResourceType
}
if model.PrimaryIP != nil {
primaryipmap, _ := resourceIBMIsInstancePrimaryIPReferenceToMap(model.PrimaryIP)
modelMap["primary_ip"] = []map[string]interface{}{primaryipmap}
}
getVirtualNetworkInterfaceOptions := &vpcv1.GetVirtualNetworkInterfaceOptions{
ID: pna.VirtualNetworkInterface.ID,
}
Expand Down Expand Up @@ -7325,6 +7426,24 @@ func resourceIBMIsInstanceReservedIPReferenceToMap(model *vpcv1.ReservedIPRefere
}
return modelMap, nil
}
func resourceIBMIsInstancePrimaryIPReferenceToMap(model *vpcv1.ReservedIPReference) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
modelMap["address"] = model.Address
if model.Deleted != nil {
deletedMap, err := resourceIBMIsInstanceReservedIPReferenceDeletedToMap(model.Deleted)
if err != nil {
return modelMap, err
}
modelMap["deleted"] = []map[string]interface{}{deletedMap}
}
modelMap["href"] = model.Href
modelMap["id"] = model.ID
modelMap["name"] = model.Name
if model.ResourceType != nil {
modelMap["resource_type"] = *model.ResourceType
}
return modelMap, nil
}

func resourceIBMIsInstanceReservedIPReferenceDeletedToMap(model *vpcv1.Deleted) (map[string]interface{}, error) {
modelMap := make(map[string]interface{})
Expand Down

0 comments on commit 0a81c97

Please sign in to comment.