Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade NSX Golang SDK #1087

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/infra/ip_address_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ func NewIpBlocksClient(sessionContext utl.SessionContext, connector vapiProtocol
return &IpAddressBlockClientContext{Client: client, ClientType: sessionContext.ClientType, ProjectID: sessionContext.ProjectID}
}

func (c IpAddressBlockClientContext) Get(ipBlockIdParam string) (model0.IpAddressBlock, error) {
func (c IpAddressBlockClientContext) Get(ipBlockIdParam string, ignoreIpblockUsageParam *bool) (model0.IpAddressBlock, error) {
var obj model0.IpAddressBlock
var err error

switch c.ClientType {

case utl.Local:
client := c.Client.(client0.IpBlocksClient)
obj, err = client.Get(ipBlockIdParam)
obj, err = client.Get(ipBlockIdParam, ignoreIpblockUsageParam)
if err != nil {
return obj, err
}

case utl.Multitenancy:
client := c.Client.(client1.IpBlocksClient)
obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, ipBlockIdParam)
obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, ipBlockIdParam, ignoreIpblockUsageParam)
if err != nil {
return obj, err
}
Expand Down
6 changes: 3 additions & 3 deletions api/infra/ip_pools/ip_subnets_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ func (c StructValueClientContext) Get(ipPoolIdParam string, ipSubnetIdParam stri
return obj, err
}

func (c StructValueClientContext) Delete(ipPoolIdParam string, ipSubnetIdParam string) error {
func (c StructValueClientContext) Delete(ipPoolIdParam string, ipSubnetIdParam string, ignoreIpAllocationsParam *bool) error {
var err error

switch c.ClientType {

case utl.Local:
client := c.Client.(client0.IpSubnetsClient)
err = client.Delete(ipPoolIdParam, ipSubnetIdParam)
err = client.Delete(ipPoolIdParam, ipSubnetIdParam, ignoreIpAllocationsParam)

case utl.Multitenancy:
client := c.Client.(client1.IpSubnetsClient)
err = client.Delete(utl.DefaultOrgID, c.ProjectID, ipPoolIdParam, ipSubnetIdParam)
err = client.Delete(utl.DefaultOrgID, c.ProjectID, ipPoolIdParam, ipSubnetIdParam, ignoreIpAllocationsParam)

default:
err = errors.New("invalid infrastructure for model")
Expand Down
8 changes: 4 additions & 4 deletions api/infra/segments/segment_configuration_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ func NewStateClient(sessionContext utl.SessionContext, connector vapiProtocolCli
return &SegmentConfigurationStateClientContext{Client: client, ClientType: sessionContext.ClientType, ProjectID: sessionContext.ProjectID}
}

func (c SegmentConfigurationStateClientContext) Get(segmentsIdParam string, cursorParam *string, edgePathParam *string, enforcementPointPathParam *string, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string) (model0.SegmentConfigurationState, error) {
func (c SegmentConfigurationStateClientContext) Get(segmentsIdParam string, cursorParam *string, edgePathParam *string, enforcementPointPathParam *string, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string, sourceParam *string, statsTypeParam *string, transportNodeIdParam *string) (model0.SegmentConfigurationState, error) {
var obj model0.SegmentConfigurationState
var err error

switch c.ClientType {

case utl.Local:
client := c.Client.(client0.StateClient)
obj, err = client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
obj, err = client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam, sourceParam, statsTypeParam, transportNodeIdParam)
if err != nil {
return obj, err
}

case utl.Global:
client := c.Client.(client1.StateClient)
gmObj, err1 := client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
gmObj, err1 := client.Get(segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam, sourceParam, statsTypeParam, transportNodeIdParam)
if err1 != nil {
return obj, err1
}
Expand All @@ -62,7 +62,7 @@ func (c SegmentConfigurationStateClientContext) Get(segmentsIdParam string, curs

case utl.Multitenancy:
client := c.Client.(client2.StateClient)
obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, segmentsIdParam, cursorParam, edgePathParam, enforcementPointPathParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam, sourceParam, statsTypeParam, transportNodeIdParam)
if err != nil {
return obj, err
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ require (
github.com/vmware/go-vmware-nsxt v0.0.0-20220328155605-f49a14c1ef5f
github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0
github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.11.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.8.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.5.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b
)

Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0 h1:pT+oqJ8FD5eUBQkl+e7LZw
github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0/go.mod h1:f3+6YVZpNcK2pYyiQ94BoHWmjMj9BnYav0vNFuTiDVM=
github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.0 h1:pSBxa9Agh6bgW8Hr0A1eQxuwnxGTnuAVox8iQb023hg=
github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.0/go.mod h1:qdzEFm2iK3dvlmm99EYYNxs70HbzuiHyENFD24Ps8fQ=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.11.0 h1:JLHgS3ffV52HXc9hXFDiFOqSwKv39hKiJIcEsGJ5S60=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.11.0/go.mod h1:upLH9b9zpG86P0wwO4+gREf0lBXr8gYcs7P1FRZ9n30=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.8.0 h1:jA01sHGXq1CLewDTN1EuowpaIrNIOm3yVYcbVAVBXGE=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.8.0/go.mod h1:gcEvyczWPFMZX2gkBiBVpOwvUGSNXSpxU19Sx9aiouY=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.5.0 h1:+b0V9ePiSnyHiqXNlgxfdmS0MWX6JEAzSPOWARUTOzQ=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.5.0/go.mod h1:ugk9I4YM62SSAox57l5NAVBCRIkPQ1RNLb3URxyTADc=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0 h1:+kcDO69bfIB87KZUAYQ4AqrXlnZhpZz+QwzIB+TseqU=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0/go.mod h1:upLH9b9zpG86P0wwO4+gREf0lBXr8gYcs7P1FRZ9n30=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.0 h1:vaWjTOvt9vPKZjA8ojTRC1o92Rm9ScR/GwWEd6JLMOk=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.9.0/go.mod h1:gcEvyczWPFMZX2gkBiBVpOwvUGSNXSpxU19Sx9aiouY=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0 h1:+jS0YH9dEp8rC00SsaY5feFpVgp4Lu0YBnBe3T7zfqo=
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0/go.mod h1:ugk9I4YM62SSAox57l5NAVBCRIkPQ1RNLb3URxyTADc=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc=
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ip_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func dataSourceNsxtPolicyIPBlockRead(d *schema.ResourceData, m interface{}) erro
var obj model.IpAddressBlock
if objID != "" {
// Get by id
objGet, err := client.Get(objID)
objGet, err := client.Get(objID, nil)
if err != nil {
return handleDataSourceReadError(d, "IpAddressBlock", objID, err)
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func dataSourceNsxtPolicyProjectRead(d *schema.ResourceData, m interface{}) erro
var obj model.Project
if objID != "" {
// Get by id
objGet, err := client.Get(defaultOrgID, objID)
objGet, err := client.Get(defaultOrgID, objID, nil)
if err != nil {
return handleDataSourceReadError(d, "Project", objID, err)
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func testAccDataSourceNsxtPolicyProjectDeleteByName(name string) error {
}
for _, objInList := range objList.Results {
if *objInList.DisplayName == name {
err := client.Delete(defaultOrgID, *objInList.Id)
err := client.Delete(defaultOrgID, *objInList.Id, nil)
if err != nil {
return handleDeleteError("Project", *objInList.Id, err)
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_segment_realization.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func dataSourceNsxtPolicySegmentRealizationRead(d *schema.ResourceData, m interf
Pending: pendingStates,
Target: targetStates,
Refresh: func() (interface{}, string, error) {
state, err := client.Get(segmentID, nil, nil, &enforcementPointPath, nil, nil, nil, nil, nil)
state, err := client.Get(segmentID, nil, nil, &enforcementPointPath, nil, nil, nil, nil, nil, nil, nil, nil)
if err != nil {
return state, model.SegmentConfigurationState_STATE_ERROR, logAPIError("Error while waiting for realization of segment", err)
}
Expand Down
4 changes: 2 additions & 2 deletions nsxt/resource_nsxt_policy_ip_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func resourceNsxtPolicyIPBlock() *schema.Resource {
func resourceNsxtPolicyIPBlockExists(sessionContext utl.SessionContext, id string, connector client.Connector) (bool, error) {
client := infra.NewIpBlocksClient(sessionContext, connector)

_, err := client.Get(id)
_, err := client.Get(id, nil)
if err == nil {
return true, nil
}
Expand All @@ -67,7 +67,7 @@ func resourceNsxtPolicyIPBlockRead(d *schema.ResourceData, m interface{}) error
return fmt.Errorf("Error obtaining IP Block ID")
}

block, err := client.Get(id)
block, err := client.Get(id, nil)
if err != nil {
return handleReadError(d, "IP Block", id, err)
}
Expand Down
4 changes: 2 additions & 2 deletions nsxt/resource_nsxt_policy_ip_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func testAccNSXPolicyIPBlockCheckExists(resourceName string) resource.TestCheckF
return fmt.Errorf("NSX Policy IP Block resource ID not set in resources ")
}

_, err := client.Get(resourceID)
_, err := client.Get(resourceID, nil)
if err != nil {
return fmt.Errorf("Error while retrieving policy IP Block ID %s. Error: %v", resourceID, err)
}
Expand All @@ -177,7 +177,7 @@ func testAccNSXPolicyIPBlockCheckDestroy(state *terraform.State) error {
}

resourceID := rs.Primary.Attributes["id"]
_, err := client.Get(resourceID)
_, err := client.Get(resourceID, nil)
if err == nil {
return fmt.Errorf("Policy IP Block %s still exists", resourceID)
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_ip_pool_block_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func resourceNsxtPolicyIPPoolBlockSubnetDelete(d *schema.ResourceData, m interfa
}

log.Printf("[INFO] Deleting Block Subnet with ID %s", id)
err := client.Delete(poolID, id)
err := client.Delete(poolID, id, nil)
if err != nil {
return handleDeleteError("Block Subnet", id, err)
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_ip_pool_static_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func resourceNsxtPolicyIPPoolStaticSubnetDelete(d *schema.ResourceData, m interf
}

log.Printf("[INFO] Deleting Static Subnet with ID %s", id)
err := client.Delete(poolID, id)
err := client.Delete(poolID, id, nil)
if err != nil {
return handleDeleteError("Static Subnet", id, err)
}
Expand Down
6 changes: 3 additions & 3 deletions nsxt/resource_nsxt_policy_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func resourceNsxtPolicyProject() *schema.Resource {
func resourceNsxtPolicyProjectExists(id string, connector client.Connector, isGlobalManager bool) (bool, error) {
var err error
client := infra.NewProjectsClient(connector)
_, err = client.Get(defaultOrgID, id)
_, err = client.Get(defaultOrgID, id, nil)

if err == nil {
return true, nil
Expand Down Expand Up @@ -146,7 +146,7 @@ func resourceNsxtPolicyProjectRead(d *schema.ResourceData, m interface{}) error
var obj model.Project
client := infra.NewProjectsClient(connector)
var err error
obj, err = client.Get(defaultOrgID, id)
obj, err = client.Get(defaultOrgID, id, nil)
if err != nil {
return handleReadError(d, "Project", id, err)
}
Expand Down Expand Up @@ -197,7 +197,7 @@ func resourceNsxtPolicyProjectDelete(d *schema.ResourceData, m interface{}) erro
connector := getPolicyConnector(m)
var err error
client := infra.NewProjectsClient(connector)
err = client.Delete(defaultOrgID, id)
err = client.Delete(defaultOrgID, id, nil)

if err != nil {
return handleDeleteError("Project", id, err)
Expand Down