From f7dff16d52c15552b87a1da121e73296f8a17ec6 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Thu, 24 Aug 2023 10:42:49 +0300 Subject: [PATCH] Update nsxt_nat_rule with firewall_match firewall_match attribute replace nat_pass in nsxt_nat_rule resource. Signed-off-by: Kobi Samoray --- nsxt/resource_nsxt_nat_rule.go | 150 ++++--- .../logical_routers/nat/NatPackageTypes.go | 11 + .../nsx/logical_routers/nat/RulesClient.go | 348 +++++++++++++++ .../nsx/logical_routers/nat/RulesTypes.go | 400 ++++++++++++++++++ vendor/modules.txt | 1 + 5 files changed, 831 insertions(+), 79 deletions(-) create mode 100644 vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/NatPackageTypes.go create mode 100644 vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesClient.go create mode 100644 vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesTypes.go diff --git a/nsxt/resource_nsxt_nat_rule.go b/nsxt/resource_nsxt_nat_rule.go index 3dcbbe7e8..b227aeee2 100644 --- a/nsxt/resource_nsxt_nat_rule.go +++ b/nsxt/resource_nsxt_nat_rule.go @@ -5,23 +5,21 @@ package nsxt import ( "fmt" - "log" - "net/http" "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/vmware/go-vmware-nsxt/manager" - "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" + "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat" + "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/model" ) var natRuleActionValues = []string{ - model.PolicyNatRule_ACTION_SNAT, - model.PolicyNatRule_ACTION_DNAT, - model.PolicyNatRule_ACTION_REFLEXIVE, - model.PolicyNatRule_ACTION_NO_SNAT, - model.PolicyNatRule_ACTION_NO_DNAT, - model.PolicyNatRule_ACTION_NAT64, + model.NatRule_ACTION_SNAT, + model.NatRule_ACTION_DNAT, + model.NatRule_ACTION_REFLEXIVE, + model.NatRule_ACTION_NO_SNAT, + model.NatRule_ACTION_NO_DNAT, + model.NatRule_ACTION_NAT64, "NO_NAT", // NSX < 3.0.0 only } @@ -111,10 +109,8 @@ func resourceNsxtNatRule() *schema.Resource { } func resourceNsxtNatRuleCreate(d *schema.ResourceData, m interface{}) error { - nsxClient := m.(nsxtClients).NsxtClient - if nsxClient == nil { - return resourceNotSupportedError() - } + connector := getPolicyConnector(m) + client := nat.NewRulesClient(connector) logicalRouterID := d.Get("logical_router_id").(string) if logicalRouterID == "" { @@ -123,7 +119,7 @@ func resourceNsxtNatRuleCreate(d *schema.ResourceData, m interface{}) error { description := d.Get("description").(string) displayName := d.Get("display_name").(string) - tags := getTagsFromSchema(d) + tags := getMPTagsFromSchema(d) action := d.Get("action").(string) if action == "NO_NAT" && nsxVersionHigherOrEqual("3.0.0") { return fmt.Errorf("NO_NAT action is not supported in NSX versions 3.0.0 and greater. Use NO_SNAT and NO_DNAT instead") @@ -134,45 +130,43 @@ func resourceNsxtNatRuleCreate(d *schema.ResourceData, m interface{}) error { //match_service := d.Get("match_service").(*NsServiceElement) matchSourceNetwork := d.Get("match_source_network").(string) natPass := d.Get("nat_pass").(bool) + firewallMatch := model.NatRule_FIREWALL_MATCH_MATCH_INTERNAL_ADDRESS + if natPass { + firewallMatch = model.NatRule_FIREWALL_MATCH_BYPASS + } rulePriority := int64(d.Get("rule_priority").(int)) translatedNetwork := d.Get("translated_network").(string) translatedPorts := d.Get("translated_ports").(string) - natRule := manager.NatRule{ - Description: description, - DisplayName: displayName, + natRule := model.NatRule{ + Description: &description, + DisplayName: &displayName, Tags: tags, - Action: action, - Enabled: enabled, - Logging: logging, - LogicalRouterId: logicalRouterID, - MatchDestinationNetwork: matchDestinationNetwork, + Action: &action, + Enabled: &enabled, + Logging: &logging, + LogicalRouterId: &logicalRouterID, + MatchDestinationNetwork: &matchDestinationNetwork, //MatchService: match_service, - MatchSourceNetwork: matchSourceNetwork, - NatPass: natPass, - RulePriority: rulePriority, - TranslatedNetwork: translatedNetwork, - TranslatedPorts: translatedPorts, + MatchSourceNetwork: &matchSourceNetwork, + RulePriority: &rulePriority, + TranslatedNetwork: &translatedNetwork, + TranslatedPorts: &translatedPorts, + FirewallMatch: &firewallMatch, } - natRule, resp, err := nsxClient.LogicalRoutingAndServicesApi.AddNatRule(nsxClient.Context, logicalRouterID, natRule) + natRule, err := client.Create(logicalRouterID, natRule) if err != nil { return fmt.Errorf("Error during NatRule create: %v", err) } - if resp.StatusCode != http.StatusCreated { - return fmt.Errorf("Unexpected status returned during NatRule create: %v", resp.StatusCode) - } - d.SetId(natRule.Id) - + d.SetId(*natRule.Id) return resourceNsxtNatRuleRead(d, m) } func resourceNsxtNatRuleRead(d *schema.ResourceData, m interface{}) error { - nsxClient := m.(nsxtClients).NsxtClient - if nsxClient == nil { - return resourceNotSupportedError() - } + connector := getPolicyConnector(m) + client := nat.NewRulesClient(connector) id := d.Id() if id == "" { @@ -184,22 +178,25 @@ func resourceNsxtNatRuleRead(d *schema.ResourceData, m interface{}) error { return fmt.Errorf("Error obtaining logical object id") } - natRule, resp, err := nsxClient.LogicalRoutingAndServicesApi.GetNatRule(nsxClient.Context, logicalRouterID, id) - if resp != nil && (resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusNotFound) { - // Due to platform bug, 400 response is returned when NAT rule is not found - // In this case terraform should not error out - log.Printf("[DEBUG] NatRule %s not found", id) - d.SetId("") - return nil - } + natRule, err := client.Get(logicalRouterID, id) + if err != nil { return fmt.Errorf("Error during NatRule read: %v", err) } + var natPass bool + if *natRule.FirewallMatch == model.NatRule_FIREWALL_MATCH_MATCH_INTERNAL_ADDRESS { + natPass = false + } else if *natRule.FirewallMatch == model.NatRule_FIREWALL_MATCH_BYPASS { + natPass = true + } else { + return fmt.Errorf("could not determine nat_pass value from firewall_match attribute value %s", *natRule.FirewallMatch) + } + d.Set("revision", natRule.Revision) d.Set("description", natRule.Description) d.Set("display_name", natRule.DisplayName) - setTagsInSchema(d, natRule.Tags) + setMPTagsInSchema(d, natRule.Tags) d.Set("action", natRule.Action) d.Set("enabled", natRule.Enabled) d.Set("logging", natRule.Logging) @@ -207,19 +204,16 @@ func resourceNsxtNatRuleRead(d *schema.ResourceData, m interface{}) error { d.Set("match_destination_network", natRule.MatchDestinationNetwork) //d.Set("match_service", natRule.MatchService) d.Set("match_source_network", natRule.MatchSourceNetwork) - d.Set("nat_pass", natRule.NatPass) + d.Set("nat_pass", natPass) d.Set("rule_priority", natRule.RulePriority) d.Set("translated_network", natRule.TranslatedNetwork) d.Set("translated_ports", natRule.TranslatedPorts) - return nil } func resourceNsxtNatRuleUpdate(d *schema.ResourceData, m interface{}) error { - nsxClient := m.(nsxtClients).NsxtClient - if nsxClient == nil { - return resourceNotSupportedError() - } + connector := getPolicyConnector(m) + client := nat.NewRulesClient(connector) id := d.Id() if id == "" { @@ -234,7 +228,7 @@ func resourceNsxtNatRuleUpdate(d *schema.ResourceData, m interface{}) error { revision := int64(d.Get("revision").(int)) description := d.Get("description").(string) displayName := d.Get("display_name").(string) - tags := getTagsFromSchema(d) + tags := getMPTagsFromSchema(d) action := d.Get("action").(string) if action == "NO_NAT" && nsxVersionHigherOrEqual("3.0.0") { return fmt.Errorf("NO_NAT action is not supported in NSX versions 3.0.0 and greater. Use NO_SNAT and NO_DNAT instead") @@ -245,30 +239,34 @@ func resourceNsxtNatRuleUpdate(d *schema.ResourceData, m interface{}) error { //match_service := d.Get("match_service").(*NsServiceElement) matchSourceNetwork := d.Get("match_source_network").(string) natPass := d.Get("nat_pass").(bool) + firewallMatch := model.NatRule_FIREWALL_MATCH_MATCH_INTERNAL_ADDRESS + if natPass { + firewallMatch = model.NatRule_FIREWALL_MATCH_BYPASS + } rulePriority := int64(d.Get("rule_priority").(int)) translatedNetwork := d.Get("translated_network").(string) translatedPorts := d.Get("translated_ports").(string) - natRule := manager.NatRule{ - Revision: revision, - Description: description, - DisplayName: displayName, + natRule := model.NatRule{ + Revision: &revision, + Description: &description, + DisplayName: &displayName, Tags: tags, - Action: action, - Enabled: enabled, - Logging: logging, - LogicalRouterId: logicalRouterID, - MatchDestinationNetwork: matchDestinationNetwork, + Action: &action, + Enabled: &enabled, + Logging: &logging, + LogicalRouterId: &logicalRouterID, + MatchDestinationNetwork: &matchDestinationNetwork, //MatchService: match_service, - MatchSourceNetwork: matchSourceNetwork, - NatPass: natPass, - RulePriority: rulePriority, - TranslatedNetwork: translatedNetwork, - TranslatedPorts: translatedPorts, + MatchSourceNetwork: &matchSourceNetwork, + RulePriority: &rulePriority, + TranslatedNetwork: &translatedNetwork, + TranslatedPorts: &translatedPorts, + FirewallMatch: &firewallMatch, } - _, resp, err := nsxClient.LogicalRoutingAndServicesApi.UpdateNatRule(nsxClient.Context, logicalRouterID, id, natRule) + _, err := client.Update(logicalRouterID, id, natRule) - if err != nil || resp.StatusCode == http.StatusNotFound { + if err != nil { return fmt.Errorf("Error during NatRule update: %v", err) } @@ -276,10 +274,8 @@ func resourceNsxtNatRuleUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNsxtNatRuleDelete(d *schema.ResourceData, m interface{}) error { - nsxClient := m.(nsxtClients).NsxtClient - if nsxClient == nil { - return resourceNotSupportedError() - } + connector := getPolicyConnector(m) + client := nat.NewRulesClient(connector) id := d.Id() if id == "" { @@ -290,15 +286,11 @@ func resourceNsxtNatRuleDelete(d *schema.ResourceData, m interface{}) error { return fmt.Errorf("Error obtaining logical object id") } - resp, err := nsxClient.LogicalRoutingAndServicesApi.DeleteNatRule(nsxClient.Context, logicalRouterID, id) + err := client.Delete(logicalRouterID, id) if err != nil { return fmt.Errorf("Error during NatRule delete: %v", err) } - if resp.StatusCode == http.StatusNotFound { - log.Printf("[DEBUG] NatRule %s not found", id) - d.SetId("") - } return nil } diff --git a/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/NatPackageTypes.go b/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/NatPackageTypes.go new file mode 100644 index 000000000..88bdfb72f --- /dev/null +++ b/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/NatPackageTypes.go @@ -0,0 +1,11 @@ +// Copyright © 2019-2021 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: BSD-2-Clause + +// Auto generated code. DO NOT EDIT. + +// Data type definitions file for package: com.vmware.nsx.logical_routers.nat. +// Includes binding types of a top level structures and enumerations. +// Shared by client-side stubs and server-side skeletons to ensure type +// compatibility. + +package nat diff --git a/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesClient.go b/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesClient.go new file mode 100644 index 000000000..dc6d7479c --- /dev/null +++ b/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesClient.go @@ -0,0 +1,348 @@ +// Copyright © 2019-2021 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: BSD-2-Clause + +// Auto generated code. DO NOT EDIT. + +// Interface file for service: Rules +// Used by client-side stubs. + +package nat + +import ( + vapiStdErrors_ "github.com/vmware/vsphere-automation-sdk-go/lib/vapi/std/errors" + vapiBindings_ "github.com/vmware/vsphere-automation-sdk-go/runtime/bindings" + vapiCore_ "github.com/vmware/vsphere-automation-sdk-go/runtime/core" + vapiProtocolClient_ "github.com/vmware/vsphere-automation-sdk-go/runtime/protocol/client" + nsxModel "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/model" +) + +const _ = vapiCore_.SupportedByRuntimeVersion2 + +type RulesClient interface { + + // Add a NAT rule in a specific logical router. + // + // Deprecated: This API element is deprecated. + // + // @param logicalRouterIdParam (required) + // @param natRuleParam (required) + // @return com.vmware.nsx.model.NatRule + // + // @throws InvalidRequest Bad Request, Precondition Failed + // @throws Unauthorized Forbidden + // @throws ServiceUnavailable Service Unavailable + // @throws InternalServerError Internal Server Error + // @throws NotFound Not Found + Create(logicalRouterIdParam string, natRuleParam nsxModel.NatRule) (nsxModel.NatRule, error) + + // Create multiple NAT rules in a specific logical router. The API succeeds only when all rules are accepted and created successfully. Any one validation voilation will fail the API, no rule will be created. The ruleIds of each rules can be found from the responsed message. + // + // Please use below hierarchical Policy API to create multiple nat rule. + // POST /policy/api/v1/infra + // + // Deprecated: This API element is deprecated. + // + // @param logicalRouterIdParam (required) + // @param natRuleListParam (required) + // @return com.vmware.nsx.model.NatRuleList + // + // @throws InvalidRequest Bad Request, Precondition Failed + // @throws Unauthorized Forbidden + // @throws ServiceUnavailable Service Unavailable + // @throws InternalServerError Internal Server Error + // @throws NotFound Not Found + Createmultiple(logicalRouterIdParam string, natRuleListParam nsxModel.NatRuleList) (nsxModel.NatRuleList, error) + + // Delete a specific NAT rule from a logical router + // + // Deprecated: This API element is deprecated. + // + // @param logicalRouterIdParam (required) + // @param ruleIdParam (required) + // + // @throws InvalidRequest Bad Request, Precondition Failed + // @throws Unauthorized Forbidden + // @throws ServiceUnavailable Service Unavailable + // @throws InternalServerError Internal Server Error + // @throws NotFound Not Found + Delete(logicalRouterIdParam string, ruleIdParam string) error + + // Get a specific NAT rule from a given logical router + // + // Deprecated: This API element is deprecated. + // + // @param logicalRouterIdParam (required) + // @param ruleIdParam (required) + // @return com.vmware.nsx.model.NatRule + // + // @throws InvalidRequest Bad Request, Precondition Failed + // @throws Unauthorized Forbidden + // @throws ServiceUnavailable Service Unavailable + // @throws InternalServerError Internal Server Error + // @throws NotFound Not Found + Get(logicalRouterIdParam string, ruleIdParam string) (nsxModel.NatRule, error) + + // Returns paginated list of all user defined NAT rules of the specific logical router. If a rule_type is provided, only the given type of rules will be returned. If no rule_type is specified, the rule_type will be defaulted to NATv4, i.e. only the NATv4 rules will be listed. + // + // Deprecated: This API element is deprecated. + // + // @param logicalRouterIdParam (required) + // @param cursorParam Opaque cursor to be used for getting next page of records (supplied by current result page) (optional) + // @param includedFieldsParam Comma separated list of fields that should be included in query result (optional) + // @param pageSizeParam Maximum number of results to return in this page (server may return fewer) (optional, default to 1000) + // @param ruleTypeParam Action type for getting NAT rules (optional) + // @param sortAscendingParam (optional) + // @param sortByParam Field by which records are sorted (optional) + // @return com.vmware.nsx.model.NatRuleListResult + // + // @throws InvalidRequest Bad Request, Precondition Failed + // @throws Unauthorized Forbidden + // @throws ServiceUnavailable Service Unavailable + // @throws InternalServerError Internal Server Error + // @throws NotFound Not Found + List(logicalRouterIdParam string, cursorParam *string, includedFieldsParam *string, pageSizeParam *int64, ruleTypeParam *string, sortAscendingParam *bool, sortByParam *string) (nsxModel.NatRuleListResult, error) + + // Update a specific NAT rule from a given logical router. + // + // Deprecated: This API element is deprecated. + // + // @param logicalRouterIdParam (required) + // @param ruleIdParam (required) + // @param natRuleParam (required) + // @return com.vmware.nsx.model.NatRule + // + // @throws InvalidRequest Bad Request, Precondition Failed + // @throws Unauthorized Forbidden + // @throws ServiceUnavailable Service Unavailable + // @throws InternalServerError Internal Server Error + // @throws NotFound Not Found + Update(logicalRouterIdParam string, ruleIdParam string, natRuleParam nsxModel.NatRule) (nsxModel.NatRule, error) +} + +type rulesClient struct { + connector vapiProtocolClient_.Connector + interfaceDefinition vapiCore_.InterfaceDefinition + errorsBindingMap map[string]vapiBindings_.BindingType +} + +func NewRulesClient(connector vapiProtocolClient_.Connector) *rulesClient { + interfaceIdentifier := vapiCore_.NewInterfaceIdentifier("com.vmware.nsx.logical_routers.nat.rules") + methodIdentifiers := map[string]vapiCore_.MethodIdentifier{ + "create": vapiCore_.NewMethodIdentifier(interfaceIdentifier, "create"), + "createmultiple": vapiCore_.NewMethodIdentifier(interfaceIdentifier, "createmultiple"), + "delete": vapiCore_.NewMethodIdentifier(interfaceIdentifier, "delete"), + "get": vapiCore_.NewMethodIdentifier(interfaceIdentifier, "get"), + "list": vapiCore_.NewMethodIdentifier(interfaceIdentifier, "list"), + "update": vapiCore_.NewMethodIdentifier(interfaceIdentifier, "update"), + } + interfaceDefinition := vapiCore_.NewInterfaceDefinition(interfaceIdentifier, methodIdentifiers) + errorsBindingMap := make(map[string]vapiBindings_.BindingType) + + rIface := rulesClient{interfaceDefinition: interfaceDefinition, errorsBindingMap: errorsBindingMap, connector: connector} + return &rIface +} + +func (rIface *rulesClient) GetErrorBindingType(errorName string) vapiBindings_.BindingType { + if entry, ok := rIface.errorsBindingMap[errorName]; ok { + return entry + } + return vapiStdErrors_.ERROR_BINDINGS_MAP[errorName] +} + +func (rIface *rulesClient) Create(logicalRouterIdParam string, natRuleParam nsxModel.NatRule) (nsxModel.NatRule, error) { + typeConverter := rIface.connector.TypeConverter() + executionContext := rIface.connector.NewExecutionContext() + operationRestMetaData := rulesCreateRestMetadata() + executionContext.SetConnectionMetadata(vapiCore_.RESTMetadataKey, operationRestMetaData) + executionContext.SetConnectionMetadata(vapiCore_.ResponseTypeKey, vapiCore_.NewResponseType(true, false)) + + sv := vapiBindings_.NewStructValueBuilder(rulesCreateInputType(), typeConverter) + sv.AddStructField("LogicalRouterId", logicalRouterIdParam) + sv.AddStructField("NatRule", natRuleParam) + inputDataValue, inputError := sv.GetStructValue() + if inputError != nil { + var emptyOutput nsxModel.NatRule + return emptyOutput, vapiBindings_.VAPIerrorsToError(inputError) + } + + methodResult := rIface.connector.GetApiProvider().Invoke("com.vmware.nsx.logical_routers.nat.rules", "create", inputDataValue, executionContext) + var emptyOutput nsxModel.NatRule + if methodResult.IsSuccess() { + output, errorInOutput := typeConverter.ConvertToGolang(methodResult.Output(), RulesCreateOutputType()) + if errorInOutput != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInOutput) + } + return output.(nsxModel.NatRule), nil + } else { + methodError, errorInError := typeConverter.ConvertToGolang(methodResult.Error(), rIface.GetErrorBindingType(methodResult.Error().Name())) + if errorInError != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInError) + } + return emptyOutput, methodError.(error) + } +} + +func (rIface *rulesClient) Createmultiple(logicalRouterIdParam string, natRuleListParam nsxModel.NatRuleList) (nsxModel.NatRuleList, error) { + typeConverter := rIface.connector.TypeConverter() + executionContext := rIface.connector.NewExecutionContext() + operationRestMetaData := rulesCreatemultipleRestMetadata() + executionContext.SetConnectionMetadata(vapiCore_.RESTMetadataKey, operationRestMetaData) + executionContext.SetConnectionMetadata(vapiCore_.ResponseTypeKey, vapiCore_.NewResponseType(true, false)) + + sv := vapiBindings_.NewStructValueBuilder(rulesCreatemultipleInputType(), typeConverter) + sv.AddStructField("LogicalRouterId", logicalRouterIdParam) + sv.AddStructField("NatRuleList", natRuleListParam) + inputDataValue, inputError := sv.GetStructValue() + if inputError != nil { + var emptyOutput nsxModel.NatRuleList + return emptyOutput, vapiBindings_.VAPIerrorsToError(inputError) + } + + methodResult := rIface.connector.GetApiProvider().Invoke("com.vmware.nsx.logical_routers.nat.rules", "createmultiple", inputDataValue, executionContext) + var emptyOutput nsxModel.NatRuleList + if methodResult.IsSuccess() { + output, errorInOutput := typeConverter.ConvertToGolang(methodResult.Output(), RulesCreatemultipleOutputType()) + if errorInOutput != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInOutput) + } + return output.(nsxModel.NatRuleList), nil + } else { + methodError, errorInError := typeConverter.ConvertToGolang(methodResult.Error(), rIface.GetErrorBindingType(methodResult.Error().Name())) + if errorInError != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInError) + } + return emptyOutput, methodError.(error) + } +} + +func (rIface *rulesClient) Delete(logicalRouterIdParam string, ruleIdParam string) error { + typeConverter := rIface.connector.TypeConverter() + executionContext := rIface.connector.NewExecutionContext() + operationRestMetaData := rulesDeleteRestMetadata() + executionContext.SetConnectionMetadata(vapiCore_.RESTMetadataKey, operationRestMetaData) + executionContext.SetConnectionMetadata(vapiCore_.ResponseTypeKey, vapiCore_.NewResponseType(true, false)) + + sv := vapiBindings_.NewStructValueBuilder(rulesDeleteInputType(), typeConverter) + sv.AddStructField("LogicalRouterId", logicalRouterIdParam) + sv.AddStructField("RuleId", ruleIdParam) + inputDataValue, inputError := sv.GetStructValue() + if inputError != nil { + return vapiBindings_.VAPIerrorsToError(inputError) + } + + methodResult := rIface.connector.GetApiProvider().Invoke("com.vmware.nsx.logical_routers.nat.rules", "delete", inputDataValue, executionContext) + if methodResult.IsSuccess() { + return nil + } else { + methodError, errorInError := typeConverter.ConvertToGolang(methodResult.Error(), rIface.GetErrorBindingType(methodResult.Error().Name())) + if errorInError != nil { + return vapiBindings_.VAPIerrorsToError(errorInError) + } + return methodError.(error) + } +} + +func (rIface *rulesClient) Get(logicalRouterIdParam string, ruleIdParam string) (nsxModel.NatRule, error) { + typeConverter := rIface.connector.TypeConverter() + executionContext := rIface.connector.NewExecutionContext() + operationRestMetaData := rulesGetRestMetadata() + executionContext.SetConnectionMetadata(vapiCore_.RESTMetadataKey, operationRestMetaData) + executionContext.SetConnectionMetadata(vapiCore_.ResponseTypeKey, vapiCore_.NewResponseType(true, false)) + + sv := vapiBindings_.NewStructValueBuilder(rulesGetInputType(), typeConverter) + sv.AddStructField("LogicalRouterId", logicalRouterIdParam) + sv.AddStructField("RuleId", ruleIdParam) + inputDataValue, inputError := sv.GetStructValue() + if inputError != nil { + var emptyOutput nsxModel.NatRule + return emptyOutput, vapiBindings_.VAPIerrorsToError(inputError) + } + + methodResult := rIface.connector.GetApiProvider().Invoke("com.vmware.nsx.logical_routers.nat.rules", "get", inputDataValue, executionContext) + var emptyOutput nsxModel.NatRule + if methodResult.IsSuccess() { + output, errorInOutput := typeConverter.ConvertToGolang(methodResult.Output(), RulesGetOutputType()) + if errorInOutput != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInOutput) + } + return output.(nsxModel.NatRule), nil + } else { + methodError, errorInError := typeConverter.ConvertToGolang(methodResult.Error(), rIface.GetErrorBindingType(methodResult.Error().Name())) + if errorInError != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInError) + } + return emptyOutput, methodError.(error) + } +} + +func (rIface *rulesClient) List(logicalRouterIdParam string, cursorParam *string, includedFieldsParam *string, pageSizeParam *int64, ruleTypeParam *string, sortAscendingParam *bool, sortByParam *string) (nsxModel.NatRuleListResult, error) { + typeConverter := rIface.connector.TypeConverter() + executionContext := rIface.connector.NewExecutionContext() + operationRestMetaData := rulesListRestMetadata() + executionContext.SetConnectionMetadata(vapiCore_.RESTMetadataKey, operationRestMetaData) + executionContext.SetConnectionMetadata(vapiCore_.ResponseTypeKey, vapiCore_.NewResponseType(true, false)) + + sv := vapiBindings_.NewStructValueBuilder(rulesListInputType(), typeConverter) + sv.AddStructField("LogicalRouterId", logicalRouterIdParam) + sv.AddStructField("Cursor", cursorParam) + sv.AddStructField("IncludedFields", includedFieldsParam) + sv.AddStructField("PageSize", pageSizeParam) + sv.AddStructField("RuleType", ruleTypeParam) + sv.AddStructField("SortAscending", sortAscendingParam) + sv.AddStructField("SortBy", sortByParam) + inputDataValue, inputError := sv.GetStructValue() + if inputError != nil { + var emptyOutput nsxModel.NatRuleListResult + return emptyOutput, vapiBindings_.VAPIerrorsToError(inputError) + } + + methodResult := rIface.connector.GetApiProvider().Invoke("com.vmware.nsx.logical_routers.nat.rules", "list", inputDataValue, executionContext) + var emptyOutput nsxModel.NatRuleListResult + if methodResult.IsSuccess() { + output, errorInOutput := typeConverter.ConvertToGolang(methodResult.Output(), RulesListOutputType()) + if errorInOutput != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInOutput) + } + return output.(nsxModel.NatRuleListResult), nil + } else { + methodError, errorInError := typeConverter.ConvertToGolang(methodResult.Error(), rIface.GetErrorBindingType(methodResult.Error().Name())) + if errorInError != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInError) + } + return emptyOutput, methodError.(error) + } +} + +func (rIface *rulesClient) Update(logicalRouterIdParam string, ruleIdParam string, natRuleParam nsxModel.NatRule) (nsxModel.NatRule, error) { + typeConverter := rIface.connector.TypeConverter() + executionContext := rIface.connector.NewExecutionContext() + operationRestMetaData := rulesUpdateRestMetadata() + executionContext.SetConnectionMetadata(vapiCore_.RESTMetadataKey, operationRestMetaData) + executionContext.SetConnectionMetadata(vapiCore_.ResponseTypeKey, vapiCore_.NewResponseType(true, false)) + + sv := vapiBindings_.NewStructValueBuilder(rulesUpdateInputType(), typeConverter) + sv.AddStructField("LogicalRouterId", logicalRouterIdParam) + sv.AddStructField("RuleId", ruleIdParam) + sv.AddStructField("NatRule", natRuleParam) + inputDataValue, inputError := sv.GetStructValue() + if inputError != nil { + var emptyOutput nsxModel.NatRule + return emptyOutput, vapiBindings_.VAPIerrorsToError(inputError) + } + + methodResult := rIface.connector.GetApiProvider().Invoke("com.vmware.nsx.logical_routers.nat.rules", "update", inputDataValue, executionContext) + var emptyOutput nsxModel.NatRule + if methodResult.IsSuccess() { + output, errorInOutput := typeConverter.ConvertToGolang(methodResult.Output(), RulesUpdateOutputType()) + if errorInOutput != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInOutput) + } + return output.(nsxModel.NatRule), nil + } else { + methodError, errorInError := typeConverter.ConvertToGolang(methodResult.Error(), rIface.GetErrorBindingType(methodResult.Error().Name())) + if errorInError != nil { + return emptyOutput, vapiBindings_.VAPIerrorsToError(errorInError) + } + return emptyOutput, methodError.(error) + } +} diff --git a/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesTypes.go b/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesTypes.go new file mode 100644 index 000000000..3d76dd9e3 --- /dev/null +++ b/vendor/github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat/RulesTypes.go @@ -0,0 +1,400 @@ +// Copyright © 2019-2021 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: BSD-2-Clause + +// Auto generated code. DO NOT EDIT. + +// Data type definitions file for service: Rules. +// Includes binding types of a structures and enumerations defined in the service. +// Shared by client-side stubs and server-side skeletons to ensure type +// compatibility. + +package nat + +import ( + vapiBindings_ "github.com/vmware/vsphere-automation-sdk-go/runtime/bindings" + vapiData_ "github.com/vmware/vsphere-automation-sdk-go/runtime/data" + vapiProtocol_ "github.com/vmware/vsphere-automation-sdk-go/runtime/protocol" + nsxModel "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/model" + "reflect" +) + +// Possible value for ``ruleType`` of method Rules#list. +const Rules_LIST_RULE_TYPE_ALL = "ALL" + +// Possible value for ``ruleType`` of method Rules#list. +const Rules_LIST_RULE_TYPE_NATV4 = "NATv4" + +// Possible value for ``ruleType`` of method Rules#list. +const Rules_LIST_RULE_TYPE_NAT64 = "NAT64" + +func rulesCreateInputType() vapiBindings_.StructType { + fields := make(map[string]vapiBindings_.BindingType) + fieldNameMap := make(map[string]string) + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["nat_rule"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["nat_rule"] = "NatRule" + var validators = []vapiBindings_.Validator{} + return vapiBindings_.NewStructType("operation-input", fields, reflect.TypeOf(vapiData_.StructValue{}), fieldNameMap, validators) +} + +func RulesCreateOutputType() vapiBindings_.BindingType { + return vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) +} + +func rulesCreateRestMetadata() vapiProtocol_.OperationRestMetadata { + fields := map[string]vapiBindings_.BindingType{} + fieldNameMap := map[string]string{} + paramsTypeMap := map[string]vapiBindings_.BindingType{} + pathParams := map[string]string{} + queryParams := map[string]string{} + headerParams := map[string]string{} + dispatchHeaderParams := map[string]string{} + bodyFieldsMap := map[string]string{} + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["nat_rule"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["nat_rule"] = "NatRule" + paramsTypeMap["logical_router_id"] = vapiBindings_.NewStringType() + paramsTypeMap["nat_rule"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) + paramsTypeMap["logicalRouterId"] = vapiBindings_.NewStringType() + pathParams["logical_router_id"] = "logicalRouterId" + resultHeaders := map[string]string{} + errorHeaders := map[string]map[string]string{} + return vapiProtocol_.NewOperationRestMetadata( + fields, + fieldNameMap, + paramsTypeMap, + pathParams, + queryParams, + headerParams, + dispatchHeaderParams, + bodyFieldsMap, + "", + "nat_rule", + "POST", + "/api/v1/logical-routers/{logicalRouterId}/nat/rules", + "", + resultHeaders, + 201, + "", + errorHeaders, + map[string]int{"com.vmware.vapi.std.errors.invalid_request": 400, "com.vmware.vapi.std.errors.unauthorized": 403, "com.vmware.vapi.std.errors.service_unavailable": 503, "com.vmware.vapi.std.errors.internal_server_error": 500, "com.vmware.vapi.std.errors.not_found": 404}) +} + +func rulesCreatemultipleInputType() vapiBindings_.StructType { + fields := make(map[string]vapiBindings_.BindingType) + fieldNameMap := make(map[string]string) + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["nat_rule_list"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleListBindingType) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["nat_rule_list"] = "NatRuleList" + var validators = []vapiBindings_.Validator{} + return vapiBindings_.NewStructType("operation-input", fields, reflect.TypeOf(vapiData_.StructValue{}), fieldNameMap, validators) +} + +func RulesCreatemultipleOutputType() vapiBindings_.BindingType { + return vapiBindings_.NewReferenceType(nsxModel.NatRuleListBindingType) +} + +func rulesCreatemultipleRestMetadata() vapiProtocol_.OperationRestMetadata { + fields := map[string]vapiBindings_.BindingType{} + fieldNameMap := map[string]string{} + paramsTypeMap := map[string]vapiBindings_.BindingType{} + pathParams := map[string]string{} + queryParams := map[string]string{} + headerParams := map[string]string{} + dispatchHeaderParams := map[string]string{} + bodyFieldsMap := map[string]string{} + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["nat_rule_list"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleListBindingType) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["nat_rule_list"] = "NatRuleList" + paramsTypeMap["logical_router_id"] = vapiBindings_.NewStringType() + paramsTypeMap["nat_rule_list"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleListBindingType) + paramsTypeMap["logicalRouterId"] = vapiBindings_.NewStringType() + pathParams["logical_router_id"] = "logicalRouterId" + resultHeaders := map[string]string{} + errorHeaders := map[string]map[string]string{} + return vapiProtocol_.NewOperationRestMetadata( + fields, + fieldNameMap, + paramsTypeMap, + pathParams, + queryParams, + headerParams, + dispatchHeaderParams, + bodyFieldsMap, + "action=create_multiple", + "nat_rule_list", + "POST", + "/api/v1/logical-routers/{logicalRouterId}/nat/rules", + "", + resultHeaders, + 200, + "", + errorHeaders, + map[string]int{"com.vmware.vapi.std.errors.invalid_request": 400, "com.vmware.vapi.std.errors.unauthorized": 403, "com.vmware.vapi.std.errors.service_unavailable": 503, "com.vmware.vapi.std.errors.internal_server_error": 500, "com.vmware.vapi.std.errors.not_found": 404}) +} + +func rulesDeleteInputType() vapiBindings_.StructType { + fields := make(map[string]vapiBindings_.BindingType) + fieldNameMap := make(map[string]string) + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["rule_id"] = vapiBindings_.NewStringType() + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["rule_id"] = "RuleId" + var validators = []vapiBindings_.Validator{} + return vapiBindings_.NewStructType("operation-input", fields, reflect.TypeOf(vapiData_.StructValue{}), fieldNameMap, validators) +} + +func RulesDeleteOutputType() vapiBindings_.BindingType { + return vapiBindings_.NewVoidType() +} + +func rulesDeleteRestMetadata() vapiProtocol_.OperationRestMetadata { + fields := map[string]vapiBindings_.BindingType{} + fieldNameMap := map[string]string{} + paramsTypeMap := map[string]vapiBindings_.BindingType{} + pathParams := map[string]string{} + queryParams := map[string]string{} + headerParams := map[string]string{} + dispatchHeaderParams := map[string]string{} + bodyFieldsMap := map[string]string{} + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["rule_id"] = vapiBindings_.NewStringType() + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["rule_id"] = "RuleId" + paramsTypeMap["logical_router_id"] = vapiBindings_.NewStringType() + paramsTypeMap["rule_id"] = vapiBindings_.NewStringType() + paramsTypeMap["logicalRouterId"] = vapiBindings_.NewStringType() + paramsTypeMap["ruleId"] = vapiBindings_.NewStringType() + pathParams["rule_id"] = "ruleId" + pathParams["logical_router_id"] = "logicalRouterId" + resultHeaders := map[string]string{} + errorHeaders := map[string]map[string]string{} + return vapiProtocol_.NewOperationRestMetadata( + fields, + fieldNameMap, + paramsTypeMap, + pathParams, + queryParams, + headerParams, + dispatchHeaderParams, + bodyFieldsMap, + "", + "", + "DELETE", + "/api/v1/logical-routers/{logicalRouterId}/nat/rules/{ruleId}", + "", + resultHeaders, + 204, + "", + errorHeaders, + map[string]int{"com.vmware.vapi.std.errors.invalid_request": 400, "com.vmware.vapi.std.errors.unauthorized": 403, "com.vmware.vapi.std.errors.service_unavailable": 503, "com.vmware.vapi.std.errors.internal_server_error": 500, "com.vmware.vapi.std.errors.not_found": 404}) +} + +func rulesGetInputType() vapiBindings_.StructType { + fields := make(map[string]vapiBindings_.BindingType) + fieldNameMap := make(map[string]string) + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["rule_id"] = vapiBindings_.NewStringType() + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["rule_id"] = "RuleId" + var validators = []vapiBindings_.Validator{} + return vapiBindings_.NewStructType("operation-input", fields, reflect.TypeOf(vapiData_.StructValue{}), fieldNameMap, validators) +} + +func RulesGetOutputType() vapiBindings_.BindingType { + return vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) +} + +func rulesGetRestMetadata() vapiProtocol_.OperationRestMetadata { + fields := map[string]vapiBindings_.BindingType{} + fieldNameMap := map[string]string{} + paramsTypeMap := map[string]vapiBindings_.BindingType{} + pathParams := map[string]string{} + queryParams := map[string]string{} + headerParams := map[string]string{} + dispatchHeaderParams := map[string]string{} + bodyFieldsMap := map[string]string{} + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["rule_id"] = vapiBindings_.NewStringType() + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["rule_id"] = "RuleId" + paramsTypeMap["logical_router_id"] = vapiBindings_.NewStringType() + paramsTypeMap["rule_id"] = vapiBindings_.NewStringType() + paramsTypeMap["logicalRouterId"] = vapiBindings_.NewStringType() + paramsTypeMap["ruleId"] = vapiBindings_.NewStringType() + pathParams["rule_id"] = "ruleId" + pathParams["logical_router_id"] = "logicalRouterId" + resultHeaders := map[string]string{} + errorHeaders := map[string]map[string]string{} + return vapiProtocol_.NewOperationRestMetadata( + fields, + fieldNameMap, + paramsTypeMap, + pathParams, + queryParams, + headerParams, + dispatchHeaderParams, + bodyFieldsMap, + "", + "", + "GET", + "/api/v1/logical-routers/{logicalRouterId}/nat/rules/{ruleId}", + "", + resultHeaders, + 200, + "", + errorHeaders, + map[string]int{"com.vmware.vapi.std.errors.invalid_request": 400, "com.vmware.vapi.std.errors.unauthorized": 403, "com.vmware.vapi.std.errors.service_unavailable": 503, "com.vmware.vapi.std.errors.internal_server_error": 500, "com.vmware.vapi.std.errors.not_found": 404}) +} + +func rulesListInputType() vapiBindings_.StructType { + fields := make(map[string]vapiBindings_.BindingType) + fieldNameMap := make(map[string]string) + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["cursor"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fields["included_fields"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fields["page_size"] = vapiBindings_.NewOptionalType(vapiBindings_.NewIntegerType()) + fields["rule_type"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fields["sort_ascending"] = vapiBindings_.NewOptionalType(vapiBindings_.NewBooleanType()) + fields["sort_by"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["cursor"] = "Cursor" + fieldNameMap["included_fields"] = "IncludedFields" + fieldNameMap["page_size"] = "PageSize" + fieldNameMap["rule_type"] = "RuleType" + fieldNameMap["sort_ascending"] = "SortAscending" + fieldNameMap["sort_by"] = "SortBy" + var validators = []vapiBindings_.Validator{} + return vapiBindings_.NewStructType("operation-input", fields, reflect.TypeOf(vapiData_.StructValue{}), fieldNameMap, validators) +} + +func RulesListOutputType() vapiBindings_.BindingType { + return vapiBindings_.NewReferenceType(nsxModel.NatRuleListResultBindingType) +} + +func rulesListRestMetadata() vapiProtocol_.OperationRestMetadata { + fields := map[string]vapiBindings_.BindingType{} + fieldNameMap := map[string]string{} + paramsTypeMap := map[string]vapiBindings_.BindingType{} + pathParams := map[string]string{} + queryParams := map[string]string{} + headerParams := map[string]string{} + dispatchHeaderParams := map[string]string{} + bodyFieldsMap := map[string]string{} + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["cursor"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fields["included_fields"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fields["page_size"] = vapiBindings_.NewOptionalType(vapiBindings_.NewIntegerType()) + fields["rule_type"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fields["sort_ascending"] = vapiBindings_.NewOptionalType(vapiBindings_.NewBooleanType()) + fields["sort_by"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["cursor"] = "Cursor" + fieldNameMap["included_fields"] = "IncludedFields" + fieldNameMap["page_size"] = "PageSize" + fieldNameMap["rule_type"] = "RuleType" + fieldNameMap["sort_ascending"] = "SortAscending" + fieldNameMap["sort_by"] = "SortBy" + paramsTypeMap["logical_router_id"] = vapiBindings_.NewStringType() + paramsTypeMap["cursor"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + paramsTypeMap["rule_type"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + paramsTypeMap["sort_ascending"] = vapiBindings_.NewOptionalType(vapiBindings_.NewBooleanType()) + paramsTypeMap["included_fields"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + paramsTypeMap["sort_by"] = vapiBindings_.NewOptionalType(vapiBindings_.NewStringType()) + paramsTypeMap["page_size"] = vapiBindings_.NewOptionalType(vapiBindings_.NewIntegerType()) + paramsTypeMap["logicalRouterId"] = vapiBindings_.NewStringType() + pathParams["logical_router_id"] = "logicalRouterId" + queryParams["cursor"] = "cursor" + queryParams["rule_type"] = "rule_type" + queryParams["sort_ascending"] = "sort_ascending" + queryParams["included_fields"] = "included_fields" + queryParams["sort_by"] = "sort_by" + queryParams["page_size"] = "page_size" + resultHeaders := map[string]string{} + errorHeaders := map[string]map[string]string{} + return vapiProtocol_.NewOperationRestMetadata( + fields, + fieldNameMap, + paramsTypeMap, + pathParams, + queryParams, + headerParams, + dispatchHeaderParams, + bodyFieldsMap, + "", + "", + "GET", + "/api/v1/logical-routers/{logicalRouterId}/nat/rules", + "", + resultHeaders, + 200, + "", + errorHeaders, + map[string]int{"com.vmware.vapi.std.errors.invalid_request": 400, "com.vmware.vapi.std.errors.unauthorized": 403, "com.vmware.vapi.std.errors.service_unavailable": 503, "com.vmware.vapi.std.errors.internal_server_error": 500, "com.vmware.vapi.std.errors.not_found": 404}) +} + +func rulesUpdateInputType() vapiBindings_.StructType { + fields := make(map[string]vapiBindings_.BindingType) + fieldNameMap := make(map[string]string) + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["rule_id"] = vapiBindings_.NewStringType() + fields["nat_rule"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["rule_id"] = "RuleId" + fieldNameMap["nat_rule"] = "NatRule" + var validators = []vapiBindings_.Validator{} + return vapiBindings_.NewStructType("operation-input", fields, reflect.TypeOf(vapiData_.StructValue{}), fieldNameMap, validators) +} + +func RulesUpdateOutputType() vapiBindings_.BindingType { + return vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) +} + +func rulesUpdateRestMetadata() vapiProtocol_.OperationRestMetadata { + fields := map[string]vapiBindings_.BindingType{} + fieldNameMap := map[string]string{} + paramsTypeMap := map[string]vapiBindings_.BindingType{} + pathParams := map[string]string{} + queryParams := map[string]string{} + headerParams := map[string]string{} + dispatchHeaderParams := map[string]string{} + bodyFieldsMap := map[string]string{} + fields["logical_router_id"] = vapiBindings_.NewStringType() + fields["rule_id"] = vapiBindings_.NewStringType() + fields["nat_rule"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) + fieldNameMap["logical_router_id"] = "LogicalRouterId" + fieldNameMap["rule_id"] = "RuleId" + fieldNameMap["nat_rule"] = "NatRule" + paramsTypeMap["logical_router_id"] = vapiBindings_.NewStringType() + paramsTypeMap["rule_id"] = vapiBindings_.NewStringType() + paramsTypeMap["nat_rule"] = vapiBindings_.NewReferenceType(nsxModel.NatRuleBindingType) + paramsTypeMap["logicalRouterId"] = vapiBindings_.NewStringType() + paramsTypeMap["ruleId"] = vapiBindings_.NewStringType() + pathParams["rule_id"] = "ruleId" + pathParams["logical_router_id"] = "logicalRouterId" + resultHeaders := map[string]string{} + errorHeaders := map[string]map[string]string{} + return vapiProtocol_.NewOperationRestMetadata( + fields, + fieldNameMap, + paramsTypeMap, + pathParams, + queryParams, + headerParams, + dispatchHeaderParams, + bodyFieldsMap, + "", + "nat_rule", + "PUT", + "/api/v1/logical-routers/{logicalRouterId}/nat/rules/{ruleId}", + "", + resultHeaders, + 200, + "", + errorHeaders, + map[string]int{"com.vmware.vapi.std.errors.invalid_request": 400, "com.vmware.vapi.std.errors.unauthorized": 403, "com.vmware.vapi.std.errors.service_unavailable": 503, "com.vmware.vapi.std.errors.internal_server_error": 500, "com.vmware.vapi.std.errors.not_found": 404}) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 55d8e1ad1..4e5216898 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -314,6 +314,7 @@ github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/search ## explicit; go 1.17 github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/fabric +github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/logical_routers/nat github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/model github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp/nsx/node # github.com/zclconf/go-cty v1.10.0