Skip to content

Commit

Permalink
Add FloodProtectionProfile support
Browse files Browse the repository at this point in the history
Signed-off-by: graysonwu <wgrayson@vmware.com>
  • Loading branch information
GraysonWu committed Nov 21, 2023
1 parent 27829a2 commit 392cd62
Show file tree
Hide file tree
Showing 13 changed files with 1,652 additions and 207 deletions.
27 changes: 27 additions & 0 deletions api/api_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -877,3 +877,30 @@
supported_method:
- New
- List
- api_packages:
- client: github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra
model: github.com/vmware/vsphere-automation-sdk-go/runtime/data
list_result_model: github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model
type: Local
- client: github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/global_infra
model: github.com/vmware/vsphere-automation-sdk-go/runtime/data
list_result_model: github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/model
type: Global
- client: github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/infra
model: github.com/vmware/vsphere-automation-sdk-go/runtime/data
list_result_model: github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model
type: Multitenancy
model_name: StructValue
obj_name: FloodProtectionProfiles
client_name: FloodProtectionProfilesClient
list_result_name: FloodProtectionProfileListResult
model_prefix: vapiData_
model_pass_ptr: true
file_name: FloodProtectionProfilesClient
supported_method:
- New
- Get
- Delete
- Patch
- Update
- List
174 changes: 174 additions & 0 deletions api/infra/flood_protection_profiles_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
//nolint:revive
package infra

// The following file has been autogenerated. Please avoid any changes!
import (
"errors"

model0 "github.com/vmware/vsphere-automation-sdk-go/runtime/data"
vapiProtocolClient_ "github.com/vmware/vsphere-automation-sdk-go/runtime/protocol/client"
client1 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/global_infra"
lrmodel1 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/model"
client0 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra"
lrmodel0 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"
client2 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/infra"

utl "github.com/vmware/terraform-provider-nsxt/api/utl"
)

type StructValueClientContext utl.ClientContext

func NewFloodProtectionProfilesClient(sessionContext utl.SessionContext, connector vapiProtocolClient_.Connector) *StructValueClientContext {
var client interface{}

switch sessionContext.ClientType {

case utl.Local:
client = client0.NewFloodProtectionProfilesClient(connector)

case utl.Global:
client = client1.NewFloodProtectionProfilesClient(connector)

case utl.Multitenancy:
client = client2.NewFloodProtectionProfilesClient(connector)

default:
return nil
}
return &StructValueClientContext{Client: client, ClientType: sessionContext.ClientType, ProjectID: sessionContext.ProjectID}
}

func (c StructValueClientContext) Get(floodProtectionProfileIdParam string) (*model0.StructValue, error) {
var obj *model0.StructValue
var err error

switch c.ClientType {

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

case utl.Global:
client := c.Client.(client1.FloodProtectionProfilesClient)
obj, err = client.Get(floodProtectionProfileIdParam)
if err != nil {
return obj, err
}

case utl.Multitenancy:
client := c.Client.(client2.FloodProtectionProfilesClient)
obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam)
if err != nil {
return obj, err
}

default:
return obj, errors.New("invalid infrastructure for model")
}
return obj, err
}

func (c StructValueClientContext) Delete(floodProtectionProfileIdParam string, overrideParam *bool) error {
var err error

switch c.ClientType {

case utl.Local:
client := c.Client.(client0.FloodProtectionProfilesClient)
err = client.Delete(floodProtectionProfileIdParam, overrideParam)

case utl.Global:
client := c.Client.(client1.FloodProtectionProfilesClient)
err = client.Delete(floodProtectionProfileIdParam, overrideParam)

case utl.Multitenancy:
client := c.Client.(client2.FloodProtectionProfilesClient)
err = client.Delete(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam, overrideParam)

default:
err = errors.New("invalid infrastructure for model")
}
return err
}

func (c StructValueClientContext) Patch(floodProtectionProfileIdParam string, floodProtectionProfileParam *model0.StructValue, overrideParam *bool) error {
var err error

switch c.ClientType {

case utl.Local:
client := c.Client.(client0.FloodProtectionProfilesClient)
err = client.Patch(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam)

case utl.Global:
client := c.Client.(client1.FloodProtectionProfilesClient)
err = client.Patch(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam)

case utl.Multitenancy:
client := c.Client.(client2.FloodProtectionProfilesClient)
err = client.Patch(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam)

default:
err = errors.New("invalid infrastructure for model")
}
return err
}

func (c StructValueClientContext) Update(floodProtectionProfileIdParam string, floodProtectionProfileParam *model0.StructValue, overrideParam *bool) (*model0.StructValue, error) {
var err error
var obj *model0.StructValue

switch c.ClientType {

case utl.Local:
client := c.Client.(client0.FloodProtectionProfilesClient)
obj, err = client.Update(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam)

case utl.Global:
client := c.Client.(client1.FloodProtectionProfilesClient)
obj, err = client.Update(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam)

case utl.Multitenancy:
client := c.Client.(client2.FloodProtectionProfilesClient)
obj, err = client.Update(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam)

default:
err = errors.New("invalid infrastructure for model")
}
return obj, err
}

func (c StructValueClientContext) List(cursorParam *string, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string) (lrmodel0.FloodProtectionProfileListResult, error) {
var err error
var obj lrmodel0.FloodProtectionProfileListResult

switch c.ClientType {

case utl.Local:
client := c.Client.(client0.FloodProtectionProfilesClient)
obj, err = client.List(cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)

case utl.Global:
client := c.Client.(client1.FloodProtectionProfilesClient)
gmObj, err := client.List(cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)
if err != nil {
return obj, err
}
obj1, err1 := utl.ConvertModelBindingType(gmObj, lrmodel1.FloodProtectionProfileListResultBindingType(), lrmodel0.FloodProtectionProfileListResultBindingType())
if err1 != nil {
return obj, err1
}
obj = obj1.(lrmodel0.FloodProtectionProfileListResult)

case utl.Multitenancy:
client := c.Client.(client2.FloodProtectionProfilesClient)
obj, err = client.List(utl.DefaultOrgID, c.ProjectID, cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam)

default:
err = errors.New("invalid infrastructure for model")
}
return obj, err
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright © 2023 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: MPL-2.0 */

package nsxt

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceNsxtPolicyDistributedFloodProtectionProfile() *schema.Resource {
return &schema.Resource{
Read: dataSourceNsxtPolicyDistributedFloodProtectionProfileRead,

Schema: map[string]*schema.Schema{
"id": getDataSourceIDSchema(),
"display_name": getDataSourceExtendedDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
},
}
}

func dataSourceNsxtPolicyDistributedFloodProtectionProfileRead(d *schema.ResourceData, m interface{}) error {
connector := getPolicyConnector(m)

_, err := policyDataSourceResourceRead(d, connector, getSessionContext(d, m), "DistributedFloodProtectionProfile", nil)
if err != nil {
return err
}

return nil
}
33 changes: 33 additions & 0 deletions nsxt/data_source_nsxt_policy_gateway_flood_protection_profile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright © 2023 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: MPL-2.0 */

package nsxt

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceNsxtPolicyGatewayFloodProtectionProfile() *schema.Resource {
return &schema.Resource{
Read: dataSourceNsxtPolicyGatewayFloodProtectionProfileRead,

Schema: map[string]*schema.Schema{
"id": getDataSourceIDSchema(),
"display_name": getDataSourceExtendedDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
},
}
}

func dataSourceNsxtPolicyGatewayFloodProtectionProfileRead(d *schema.ResourceData, m interface{}) error {
connector := getPolicyConnector(m)

_, err := policyDataSourceResourceRead(d, connector, getSessionContext(d, m), "GatewayFloodProtectionProfile", nil)
if err != nil {
return err
}

return nil
}
Loading

0 comments on commit 392cd62

Please sign in to comment.