From 2fccf608a1be76fff46022f8a895df5aef119b5a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 12 Mar 2024 20:41:07 +0530 Subject: [PATCH] microseg sdk pointing to internals --- go.mod | 3 +- go.sum | 2 ++ nutanix/sdks/v4/microseg/microseg.go | 4 +-- .../data_source_nutanix_address_group_v2.go | 4 +-- .../data_source_nutanix_address_groups_v2.go | 16 ++++----- ...ce_nutanix_network_security_policies_v2.go | 4 +-- ...urce_nutanix_network_security_policy_v2.go | 28 +++++++-------- .../data_source_nutanix_service_group_v2.go | 6 ++-- .../data_source_nutanix_service_groups_v2.go | 16 ++++----- .../resource_nutanix_address_groups_V2.go | 14 ++++---- ...ce_nutanix_network_security_policies_v2.go | 34 +++++++++---------- .../resource_nutanix_service_groups_v2.go | 14 ++++---- 12 files changed, 74 insertions(+), 71 deletions(-) diff --git a/go.mod b/go.mod index cc7ec7018..37232731d 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,9 @@ require ( github.com/hashicorp/go-uuid v1.0.2 github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 github.com/mitchellh/gox v1.0.1 + github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16 v16.9.0-4944 // indirect github.com/nutanix-core/ntnx-api-golang-sdk-internal/prism-go-client/v16 v16.9.0-4914 // indirect - github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4 v4.0.1-alpha.1 // indirect + // github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4 v4.0.1-alpha.1 // indirect github.com/nutanix/ntnx-api-golang-clients/networking-go-client/v4 v4.0.1-beta.1 // indirect // github.com/nutanix/ntnx-api-golang-clients/prism-go-client/v4 v4.0.3-alpha.2 // indirect github.com/sirupsen/logrus v1.9.0 // indirect diff --git a/go.sum b/go.sum index ab705d3f9..c67a8b071 100644 --- a/go.sum +++ b/go.sum @@ -444,6 +444,8 @@ github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96d github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= +github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16 v16.9.0-4944 h1:NGBOf7hUy0nsQgPSCes8sArsGUF1EAm3Po3wV77p3zg= +github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16 v16.9.0-4944/go.mod h1:1SI3/z0o6uKsLVEDy1qHutEhaSnjnA89ppjas0RwEMI= github.com/nutanix-core/ntnx-api-golang-sdk-internal/networking-go-client/v16 v16.8.0-3635 h1:eVNonw1w8i0lVNNK4Ep/P8fAb2j6EEe+VNXAQXPLThc= github.com/nutanix-core/ntnx-api-golang-sdk-internal/networking-go-client/v16 v16.8.0-3635/go.mod h1:vHyQVF3IKxmip+xGxXDQznKk1ffrVa4HSiEEueiekaE= github.com/nutanix-core/ntnx-api-golang-sdk-internal/prism-go-client/v16 v16.9.0-4914 h1:xl9+7uyYFvhFRkNdgzn5mWsrNjoRd0ookC4n/x42GH0= diff --git a/nutanix/sdks/v4/microseg/microseg.go b/nutanix/sdks/v4/microseg/microseg.go index a34b87a41..b2f243805 100644 --- a/nutanix/sdks/v4/microseg/microseg.go +++ b/nutanix/sdks/v4/microseg/microseg.go @@ -1,8 +1,8 @@ package microseg import ( - "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/api" - microseg "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/client" + "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/api" + microseg "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/client" "github.com/terraform-providers/terraform-provider-nutanix/nutanix/client" ) diff --git a/nutanix/services/v2/networking/data_source_nutanix_address_group_v2.go b/nutanix/services/v2/networking/data_source_nutanix_address_group_v2.go index 0161aebe6..07ae69aca 100644 --- a/nutanix/services/v2/networking/data_source_nutanix_address_group_v2.go +++ b/nutanix/services/v2/networking/data_source_nutanix_address_group_v2.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -79,7 +79,7 @@ func DatasourceNutanixAddressGroupV4Read(ctx context.Context, d *schema.Resource conn := meta.(*conns.Client).MicroSegAPI extID := d.Get("ext_id") - resp, err := conn.AddressGroupAPIInstance.GetAddressGroupByExtId(utils.StringPtr(extID.(string))) + resp, err := conn.AddressGroupAPIInstance.GetAddressGroupById(utils.StringPtr(extID.(string))) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) diff --git a/nutanix/services/v2/networking/data_source_nutanix_address_groups_v2.go b/nutanix/services/v2/networking/data_source_nutanix_address_groups_v2.go index a8b6f9f8a..e3a192e95 100644 --- a/nutanix/services/v2/networking/data_source_nutanix_address_groups_v2.go +++ b/nutanix/services/v2/networking/data_source_nutanix_address_groups_v2.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -109,7 +109,7 @@ func DatasourceNutanixAddressGroupsV4Read(ctx context.Context, d *schema.Resourc conn := meta.(*conns.Client).MicroSegAPI // initialize query params - var filter, orderBy *string + var filter, orderBy, selects *string var page, limit *int if pagef, ok := d.GetOk("page"); ok { @@ -132,13 +132,13 @@ func DatasourceNutanixAddressGroupsV4Read(ctx context.Context, d *schema.Resourc } else { orderBy = nil } - // if selectf, ok := d.GetOk("select"); ok { - // selects = utils.StringPtr(selectf.(string)) - // } else { - // selects = nil - // } + if selectf, ok := d.GetOk("select"); ok { + selects = utils.StringPtr(selectf.(string)) + } else { + selects = nil + } - resp, err := conn.AddressGroupAPIInstance.ListAddressGroups(page, limit, filter, orderBy) + resp, err := conn.AddressGroupAPIInstance.ListAddressGroups(page, limit, filter, orderBy, selects) fmt.Println("HEELLLLLLLLL") if err != nil { fmt.Println(err) diff --git a/nutanix/services/v2/networking/data_source_nutanix_network_security_policies_v2.go b/nutanix/services/v2/networking/data_source_nutanix_network_security_policies_v2.go index 8ecf8fa47..e9d424362 100644 --- a/nutanix/services/v2/networking/data_source_nutanix_network_security_policies_v2.go +++ b/nutanix/services/v2/networking/data_source_nutanix_network_security_policies_v2.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -341,7 +341,7 @@ func DataSourceNutanixNetworkSecurityPoliciesV4Read(ctx context.Context, d *sche selects = nil } - resp, err := conn.NetworkingSecurityInstance.GetNetworkSecurityPolicyList(page, limit, filter, orderBy, selects) + resp, err := conn.NetworkingSecurityInstance.ListNetworkSecurityPolicies(page, limit, filter, orderBy, selects) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) diff --git a/nutanix/services/v2/networking/data_source_nutanix_network_security_policy_v2.go b/nutanix/services/v2/networking/data_source_nutanix_network_security_policy_v2.go index 5af5dc6c0..530976b4c 100644 --- a/nutanix/services/v2/networking/data_source_nutanix_network_security_policy_v2.go +++ b/nutanix/services/v2/networking/data_source_nutanix_network_security_policy_v2.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - config "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/common/v1/config" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" + config "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/common/v1/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -285,7 +285,7 @@ func DataSourceNutanixNetworkSecurityPolicyV4Read(ctx context.Context, d *schema extID := d.Get("ext_id") - resp, err := conn.NetworkingSecurityInstance.GetNetworkSecurityPolicyByExtId(utils.StringPtr((extID.(string)))) + resp, err := conn.NetworkingSecurityInstance.GetNetworkSecurityPolicyById(utils.StringPtr((extID.(string)))) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -386,20 +386,20 @@ func flattenOneOfNetworkSecurityPolicyRuleSpec(pr *import1.OneOfNetworkSecurityP getVal := pr.ObjectType_ if utils.StringValue(getVal) == "microseg.v4.r0.b1.config.TwoEnvIsolationRuleSpec" { - twoIsolationRule := pr.GetValue().(import1.NSPTwoEnvIsolationRuleSpec) + twoIsolationRule := pr.GetValue().(import1.TwoEnvIsolationRuleSpec) assc["first_isolation_group"] = twoIsolationRule.FirstIsolationGroup assc["second_isolation_group"] = twoIsolationRule.SecondIsolationGroup } else if utils.StringValue(getVal) == "microseg.v4.r0.b1.config.ApplicationRuleSpec" { - appRules := pr.GetValue().(import1.NSPApplicationRuleSpec) + appRules := pr.GetValue().(import1.ApplicationRuleSpec) - if appRules.SourceAllowSpec != nil { - assc["src_allow_spec"] = flattenAllowType(appRules.SourceAllowSpec) + if appRules.SrcAllowSpec != nil { + assc["src_allow_spec"] = flattenAllowType(appRules.SrcAllowSpec) } if appRules.DestAllowSpec != nil { assc["dest_allow_spec"] = flattenAllowType(appRules.DestAllowSpec) } - if appRules.SourceSubnet != nil { - assc["src_subnet"] = flattenIPv4Address(appRules.SourceSubnet) + if appRules.SrcSubnet != nil { + assc["src_subnet"] = flattenIPv4Address(appRules.SrcSubnet) } if appRules.DestSubnet != nil { assc["dest_subnet"] = flattenIPv4Address(appRules.DestSubnet) @@ -417,7 +417,7 @@ func flattenOneOfNetworkSecurityPolicyRuleSpec(pr *import1.OneOfNetworkSecurityP assc["icmp_services"] = flattenIcmpTypeCodeSpec(appRules.IcmpServices) } } else if utils.StringValue(getVal) == "microseg.v4.r0.b1.config.IntraEntityGroupRuleSpec" { - intraRuleSpec := pr.GetValue().(import1.NSPIntraEntityGroupRuleSpec) + intraRuleSpec := pr.GetValue().(import1.IntraEntityGroupRuleSpec) if intraRuleSpec.SecuredGroupAction != nil { assc["secured_group_action"] = intraRuleSpec.SecuredGroupAction @@ -464,16 +464,16 @@ func flattenAllowType(pr *import1.AllowType) string { return "UNKNOWN" } -func flattenPolicyState(pr *import1.PolicyState) string { +func flattenPolicyState(pr *import1.SecurityPolicyState) string { const two, three, four = 2, 3, 4 if pr != nil { - if *pr == import1.PolicyState(two) { + if *pr == import1.SecurityPolicyState(two) { return "SAVE" } - if *pr == import1.PolicyState(three) { + if *pr == import1.SecurityPolicyState(three) { return "MONITOR" } - if *pr == import1.PolicyState(four) { + if *pr == import1.SecurityPolicyState(four) { return "ENFORCE" } } diff --git a/nutanix/services/v2/networking/data_source_nutanix_service_group_v2.go b/nutanix/services/v2/networking/data_source_nutanix_service_group_v2.go index 492de1dbe..898715f33 100644 --- a/nutanix/services/v2/networking/data_source_nutanix_service_group_v2.go +++ b/nutanix/services/v2/networking/data_source_nutanix_service_group_v2.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -119,7 +119,7 @@ func DatasourceNutanixServiceGroupV4Read(ctx context.Context, d *schema.Resource extID := d.Get("ext_id") - resp, err := conn.ServiceGroupAPIInstance.GetServiceGroupByExtId(utils.StringPtr(extID.(string))) + resp, err := conn.ServiceGroupAPIInstance.GetServiceGroupById(utils.StringPtr(extID.(string))) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -207,7 +207,7 @@ func flattenIcmpTypeCodeSpec(pr []import1.IcmpTypeCodeSpec) []interface{} { for k, v := range pr { rg := make(map[string]interface{}) - rg["is_allowed"] = v.IsAllCodeTypeAllowed + rg["is_allowed"] = v.IsAllAllowed rg["type"] = v.Type rg["code"] = v.Code diff --git a/nutanix/services/v2/networking/data_source_nutanix_service_groups_v2.go b/nutanix/services/v2/networking/data_source_nutanix_service_groups_v2.go index 8d477e2db..6388aabc6 100644 --- a/nutanix/services/v2/networking/data_source_nutanix_service_groups_v2.go +++ b/nutanix/services/v2/networking/data_source_nutanix_service_groups_v2.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -147,7 +147,7 @@ func DatasourceNutanixServiceGroupsV4Read(ctx context.Context, d *schema.Resourc conn := meta.(*conns.Client).MicroSegAPI // initialize query params - var filter, orderBy *string + var filter, orderBy, selects *string var page, limit *int if pagef, ok := d.GetOk("page"); ok { @@ -170,13 +170,13 @@ func DatasourceNutanixServiceGroupsV4Read(ctx context.Context, d *schema.Resourc } else { orderBy = nil } - // if selectf, ok := d.GetOk("select"); ok { - // selects = utils.StringPtr(selectf.(string)) - // } else { - // selects = nil - // } + if selectf, ok := d.GetOk("select"); ok { + selects = utils.StringPtr(selectf.(string)) + } else { + selects = nil + } - resp, err := conn.ServiceGroupAPIInstance.ListServiceGroups(page, limit, filter, orderBy) + resp, err := conn.ServiceGroupAPIInstance.ListServiceGroups(page, limit, filter, orderBy, selects) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) diff --git a/nutanix/services/v2/networking/resource_nutanix_address_groups_V2.go b/nutanix/services/v2/networking/resource_nutanix_address_groups_V2.go index ea912d5e3..44656ecb0 100644 --- a/nutanix/services/v2/networking/resource_nutanix_address_groups_V2.go +++ b/nutanix/services/v2/networking/resource_nutanix_address_groups_V2.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - config "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/common/v1/config" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" - import4 "github.com/nutanix/ntnx-api-golang-clients/networking-go-client/v4/models/prism/v4/config" + config "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/common/v1/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" + import4 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/prism/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -106,7 +106,7 @@ func ResourceNutanixAddressGroupsV4Create(ctx context.Context, d *schema.Resourc func ResourceNutanixAddressGroupsV4Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).MicroSegAPI - resp, err := conn.AddressGroupAPIInstance.GetAddressGroupByExtId(utils.StringPtr(d.Id())) + resp, err := conn.AddressGroupAPIInstance.GetAddressGroupById(utils.StringPtr(d.Id())) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -142,7 +142,7 @@ func ResourceNutanixAddressGroupsV4Read(ctx context.Context, d *schema.ResourceD func ResourceNutanixAddressGroupsV4Update(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).MicroSegAPI updateInput := &import1.AddressGroup{} - resp, err := conn.AddressGroupAPIInstance.GetAddressGroupByExtId(utils.StringPtr(d.Id())) + resp, err := conn.AddressGroupAPIInstance.GetAddressGroupById(utils.StringPtr(d.Id())) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -172,7 +172,7 @@ func ResourceNutanixAddressGroupsV4Update(ctx context.Context, d *schema.Resourc updateInput.IpRanges = expandIPv4Range(d.Get("ip_ranges").([]interface{})) } - updatedResp, err := conn.AddressGroupAPIInstance.UpdateAddressGroupByExtId(utils.StringPtr(d.Id()), updateInput) + updatedResp, err := conn.AddressGroupAPIInstance.UpdateAddressGroupById(utils.StringPtr(d.Id()), updateInput) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -208,7 +208,7 @@ func ResourceNutanixAddressGroupsV4Update(ctx context.Context, d *schema.Resourc func ResourceNutanixAddressGroupsV4Delete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).MicroSegAPI - resp, err := conn.AddressGroupAPIInstance.DeleteAddressGroupByExtId(utils.StringPtr(d.Id())) + resp, err := conn.AddressGroupAPIInstance.DeleteAddressGroupById(utils.StringPtr(d.Id())) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) diff --git a/nutanix/services/v2/networking/resource_nutanix_network_security_policies_v2.go b/nutanix/services/v2/networking/resource_nutanix_network_security_policies_v2.go index 538aad5ee..55c0f43e1 100644 --- a/nutanix/services/v2/networking/resource_nutanix_network_security_policies_v2.go +++ b/nutanix/services/v2/networking/resource_nutanix_network_security_policies_v2.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - config "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/common/v1/config" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" - import4 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/prism/v4/config" + config "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/common/v1/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" + import4 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/prism/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -299,7 +299,7 @@ func ResourceNutanixNetworkSecurityPolicyV2Create(ctx context.Context, d *schema "APPLICATION": 4, } pInt := subMap[types.(string)] - p := import1.PolicyType(pInt.(int)) + p := import1.SecurityPolicyType(pInt.(int)) spec.Type = &p } if desc, ok := d.GetOk("description"); ok { @@ -312,7 +312,7 @@ func ResourceNutanixNetworkSecurityPolicyV2Create(ctx context.Context, d *schema "ENFORCE": "4", } pInt := subMap[state.(string)] - p := import1.PolicyState(pInt.(int)) + p := import1.SecurityPolicyState(pInt.(int)) spec.State = &p } if rules, ok := d.GetOk("rules"); ok { @@ -367,7 +367,7 @@ func ResourceNutanixNetworkSecurityPolicyV2Create(ctx context.Context, d *schema func ResourceNutanixNetworkSecurityPolicyV2Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).MicroSegAPI - resp, err := conn.NetworkingSecurityInstance.GetNetworkSecurityPolicyByExtId(utils.StringPtr((d.Id()))) + resp, err := conn.NetworkingSecurityInstance.GetNetworkSecurityPolicyById(utils.StringPtr((d.Id()))) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -433,7 +433,7 @@ func ResourceNutanixNetworkSecurityPolicyV2Update(ctx context.Context, d *schema updatedSpec := import1.NetworkSecurityPolicy{} - resp, err := conn.NetworkingSecurityInstance.GetNetworkSecurityPolicyByExtId(utils.StringPtr((d.Id()))) + resp, err := conn.NetworkingSecurityInstance.GetNetworkSecurityPolicyById(utils.StringPtr((d.Id()))) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -459,7 +459,7 @@ func ResourceNutanixNetworkSecurityPolicyV2Update(ctx context.Context, d *schema "ENFORCE": "4", } pInt := subMap[state.(string)] - p := import1.PolicyState(pInt.(int)) + p := import1.SecurityPolicyState(pInt.(int)) updatedSpec.State = &p } if d.HasChange("rules") { @@ -472,7 +472,7 @@ func ResourceNutanixNetworkSecurityPolicyV2Update(ctx context.Context, d *schema updatedSpec.IsHitlogEnabled = utils.BoolPtr(d.Get("is_hitlog_enabled").(bool)) } - updatedResp, err := conn.NetworkingSecurityInstance.UpdateNetworkSecurityPolicyByExtId(utils.StringPtr(d.Id()), &updatedSpec) + updatedResp, err := conn.NetworkingSecurityInstance.UpdateNetworkSecurityPolicyById(utils.StringPtr(d.Id()), &updatedSpec) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -508,7 +508,7 @@ func ResourceNutanixNetworkSecurityPolicyV2Update(ctx context.Context, d *schema func ResourceNutanixNetworkSecurityPolicyV2Delete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).MicroSegAPI - resp, err := conn.NetworkingSecurityInstance.DeleteNetworkSecurityPolicyByExtId(utils.StringPtr(d.Id())) + resp, err := conn.NetworkingSecurityInstance.DeleteNetworkSecurityPolicyById(utils.StringPtr(d.Id())) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -580,7 +580,7 @@ func expandOneOfNetworkSecurityPolicyRuleSpec(pr interface{}) *import1.OneOfNetw policyRules := &import1.OneOfNetworkSecurityPolicyRuleSpec{} if firstIso, ok := val["first_isolation_group"]; ok && len(firstIso.([]interface{})) > 0 { - twoEnvIso := policyRules.GetValue().(import1.NSPTwoEnvIsolationRuleSpec) + twoEnvIso := policyRules.GetValue().(import1.TwoEnvIsolationRuleSpec) twoEnvIso.FirstIsolationGroup = utils.StringValueSlice(firstIso.([]*string)) @@ -589,9 +589,9 @@ func expandOneOfNetworkSecurityPolicyRuleSpec(pr interface{}) *import1.OneOfNetw } policyRules.SetValue(twoEnvIso) } else if secGroup, secGroupAction := val["secured_group_category_references"], val["secured_group_action"]; len(secGroup.([]interface{})) > 0 && len(secGroupAction.(string)) < 0 { - appRuleSpec := policyRules.GetValue().(import1.NSPApplicationRuleSpec) + appRuleSpec := policyRules.GetValue().(import1.ApplicationRuleSpec) - appRuleSpec.ServiceGroups = utils.StringValueSlice(secGroup.([]*string)) + appRuleSpec.SecuredGroupCategoryReferences = utils.StringValueSlice(secGroup.([]*string)) if srcAllow, ok := val["src_allow_spec"]; ok { subMap := map[string]interface{}{ @@ -600,7 +600,7 @@ func expandOneOfNetworkSecurityPolicyRuleSpec(pr interface{}) *import1.OneOfNetw } pInt := subMap[srcAllow.(string)] p := import1.AllowType(pInt.(int)) - appRuleSpec.SourceAllowSpec = &p + appRuleSpec.SrcAllowSpec = &p } if denyAllow, ok := val["deny_allow_spec"]; ok { subMap := map[string]interface{}{ @@ -612,7 +612,7 @@ func expandOneOfNetworkSecurityPolicyRuleSpec(pr interface{}) *import1.OneOfNetw appRuleSpec.DestAllowSpec = &p } if srcSubnet, ok := val["source_subnet"]; ok { - appRuleSpec.SourceSubnet = expandIPv4AddressMicroseg(srcSubnet) + appRuleSpec.SrcSubnet = expandIPv4AddressMicroseg(srcSubnet) } if destSubnet, ok := val["dest_subnet"]; ok { appRuleSpec.DestSubnet = expandIPv4AddressMicroseg(destSubnet) @@ -629,9 +629,9 @@ func expandOneOfNetworkSecurityPolicyRuleSpec(pr interface{}) *import1.OneOfNetw policyRules.SetValue(appRuleSpec) } else if secGroup, secGroupAction := val["secured_group_category_references"], val["secured_group_action"]; len(secGroup.([]interface{})) > 0 && len(secGroupAction.(string)) > 0 { - intraRule := policyRules.GetValue().(import1.NSPIntraEntityGroupRuleSpec) + intraRule := policyRules.GetValue().(import1.IntraEntityGroupRuleSpec) - intraRule.SecuredGroup = utils.StringValueSlice(secGroup.([]*string)) + intraRule.SecuredGroupCategoryReferences = utils.StringValueSlice(secGroup.([]*string)) subMap := map[string]interface{}{ "ALLOW": "2", diff --git a/nutanix/services/v2/networking/resource_nutanix_service_groups_v2.go b/nutanix/services/v2/networking/resource_nutanix_service_groups_v2.go index 31a052636..26ca50bdf 100644 --- a/nutanix/services/v2/networking/resource_nutanix_service_groups_v2.go +++ b/nutanix/services/v2/networking/resource_nutanix_service_groups_v2.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - import1 "github.com/nutanix/ntnx-api-golang-clients/microseg-go-client/v4/models/microseg/v4/config" - import4 "github.com/nutanix/ntnx-api-golang-clients/networking-go-client/v4/models/prism/v4/config" + import1 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/microseg/v4/config" + import4 "github.com/nutanix-core/ntnx-api-golang-sdk-internal/microseg-go-client/v16/models/prism/v4/config" conns "github.com/terraform-providers/terraform-provider-nutanix/nutanix" "github.com/terraform-providers/terraform-provider-nutanix/utils" ) @@ -142,7 +142,7 @@ func ResourceNutanixServiceGroupsV4Create(ctx context.Context, d *schema.Resourc func ResourceNutanixServiceGroupsV4Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).MicroSegAPI - resp, err := conn.ServiceGroupAPIInstance.GetServiceGroupByExtId(utils.StringPtr(d.Id())) + resp, err := conn.ServiceGroupAPIInstance.GetServiceGroupById(utils.StringPtr(d.Id())) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -185,7 +185,7 @@ func ResourceNutanixServiceGroupsV4Update(ctx context.Context, d *schema.Resourc conn := meta.(*conns.Client).MicroSegAPI updatedSpec := import1.ServiceGroup{} - resp, err := conn.ServiceGroupAPIInstance.GetServiceGroupByExtId(utils.StringPtr(d.Id())) + resp, err := conn.ServiceGroupAPIInstance.GetServiceGroupById(utils.StringPtr(d.Id())) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -216,7 +216,7 @@ func ResourceNutanixServiceGroupsV4Update(ctx context.Context, d *schema.Resourc updatedSpec.IcmpServices = expandIcmpTypeCodeSpec(d.Get("icmp_services").([]interface{})) } - updatedResp, err := conn.ServiceGroupAPIInstance.UpdateServiceGroupByExtId(utils.StringPtr(d.Id()), &updatedSpec) + updatedResp, err := conn.ServiceGroupAPIInstance.UpdateServiceGroupById(utils.StringPtr(d.Id()), &updatedSpec) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -252,7 +252,7 @@ func ResourceNutanixServiceGroupsV4Update(ctx context.Context, d *schema.Resourc func ResourceNutanixServiceGroupsV4Delete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).MicroSegAPI - resp, err := conn.ServiceGroupAPIInstance.DeleteServiceGroupByExtId(utils.StringPtr(d.Id())) + resp, err := conn.ServiceGroupAPIInstance.DeleteServiceGroupById(utils.StringPtr(d.Id())) if err != nil { var errordata map[string]interface{} e := json.Unmarshal([]byte(err.Error()), &errordata) @@ -336,7 +336,7 @@ func expandIcmpTypeCodeSpec(pr []interface{}) []import1.IcmpTypeCodeSpec { val := v.(map[string]interface{}) if allAllow, ok := val["is_all_allowed"]; ok { - icmp.IsAllCodeTypeAllowed = utils.BoolPtr(allAllow.(bool)) + icmp.IsAllAllowed = utils.BoolPtr(allAllow.(bool)) } if code, ok := val["code"]; ok { icmp.Code = utils.IntPtr(code.(int))