|
| 1 | +//nolint:revive |
| 2 | +package infra |
| 3 | + |
| 4 | +// The following file has been autogenerated. Please avoid any changes! |
| 5 | +import ( |
| 6 | + "errors" |
| 7 | + |
| 8 | + model0 "github.com/vmware/vsphere-automation-sdk-go/runtime/data" |
| 9 | + vapiProtocolClient_ "github.com/vmware/vsphere-automation-sdk-go/runtime/protocol/client" |
| 10 | + client1 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/global_infra" |
| 11 | + lrmodel1 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm/model" |
| 12 | + client0 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra" |
| 13 | + lrmodel0 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" |
| 14 | + client2 "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects/infra" |
| 15 | + |
| 16 | + utl "github.com/vmware/terraform-provider-nsxt/api/utl" |
| 17 | +) |
| 18 | + |
| 19 | +type StructValueClientContext utl.ClientContext |
| 20 | + |
| 21 | +func NewFloodProtectionProfilesClient(sessionContext utl.SessionContext, connector vapiProtocolClient_.Connector) *StructValueClientContext { |
| 22 | + var client interface{} |
| 23 | + |
| 24 | + switch sessionContext.ClientType { |
| 25 | + |
| 26 | + case utl.Local: |
| 27 | + client = client0.NewFloodProtectionProfilesClient(connector) |
| 28 | + |
| 29 | + case utl.Global: |
| 30 | + client = client1.NewFloodProtectionProfilesClient(connector) |
| 31 | + |
| 32 | + case utl.Multitenancy: |
| 33 | + client = client2.NewFloodProtectionProfilesClient(connector) |
| 34 | + |
| 35 | + default: |
| 36 | + return nil |
| 37 | + } |
| 38 | + return &StructValueClientContext{Client: client, ClientType: sessionContext.ClientType, ProjectID: sessionContext.ProjectID} |
| 39 | +} |
| 40 | + |
| 41 | +func (c StructValueClientContext) Get(floodProtectionProfileIdParam string) (*model0.StructValue, error) { |
| 42 | + var obj *model0.StructValue |
| 43 | + var err error |
| 44 | + |
| 45 | + switch c.ClientType { |
| 46 | + |
| 47 | + case utl.Local: |
| 48 | + client := c.Client.(client0.FloodProtectionProfilesClient) |
| 49 | + obj, err = client.Get(floodProtectionProfileIdParam) |
| 50 | + if err != nil { |
| 51 | + return obj, err |
| 52 | + } |
| 53 | + |
| 54 | + case utl.Global: |
| 55 | + client := c.Client.(client1.FloodProtectionProfilesClient) |
| 56 | + obj, err = client.Get(floodProtectionProfileIdParam) |
| 57 | + if err != nil { |
| 58 | + return obj, err |
| 59 | + } |
| 60 | + |
| 61 | + case utl.Multitenancy: |
| 62 | + client := c.Client.(client2.FloodProtectionProfilesClient) |
| 63 | + obj, err = client.Get(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam) |
| 64 | + if err != nil { |
| 65 | + return obj, err |
| 66 | + } |
| 67 | + |
| 68 | + default: |
| 69 | + return obj, errors.New("invalid infrastructure for model") |
| 70 | + } |
| 71 | + return obj, err |
| 72 | +} |
| 73 | + |
| 74 | +func (c StructValueClientContext) Delete(floodProtectionProfileIdParam string, overrideParam *bool) error { |
| 75 | + var err error |
| 76 | + |
| 77 | + switch c.ClientType { |
| 78 | + |
| 79 | + case utl.Local: |
| 80 | + client := c.Client.(client0.FloodProtectionProfilesClient) |
| 81 | + err = client.Delete(floodProtectionProfileIdParam, overrideParam) |
| 82 | + |
| 83 | + case utl.Global: |
| 84 | + client := c.Client.(client1.FloodProtectionProfilesClient) |
| 85 | + err = client.Delete(floodProtectionProfileIdParam, overrideParam) |
| 86 | + |
| 87 | + case utl.Multitenancy: |
| 88 | + client := c.Client.(client2.FloodProtectionProfilesClient) |
| 89 | + err = client.Delete(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam, overrideParam) |
| 90 | + |
| 91 | + default: |
| 92 | + err = errors.New("invalid infrastructure for model") |
| 93 | + } |
| 94 | + return err |
| 95 | +} |
| 96 | + |
| 97 | +func (c StructValueClientContext) Patch(floodProtectionProfileIdParam string, floodProtectionProfileParam *model0.StructValue, overrideParam *bool) error { |
| 98 | + var err error |
| 99 | + |
| 100 | + switch c.ClientType { |
| 101 | + |
| 102 | + case utl.Local: |
| 103 | + client := c.Client.(client0.FloodProtectionProfilesClient) |
| 104 | + err = client.Patch(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam) |
| 105 | + |
| 106 | + case utl.Global: |
| 107 | + client := c.Client.(client1.FloodProtectionProfilesClient) |
| 108 | + err = client.Patch(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam) |
| 109 | + |
| 110 | + case utl.Multitenancy: |
| 111 | + client := c.Client.(client2.FloodProtectionProfilesClient) |
| 112 | + err = client.Patch(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam) |
| 113 | + |
| 114 | + default: |
| 115 | + err = errors.New("invalid infrastructure for model") |
| 116 | + } |
| 117 | + return err |
| 118 | +} |
| 119 | + |
| 120 | +func (c StructValueClientContext) Update(floodProtectionProfileIdParam string, floodProtectionProfileParam *model0.StructValue, overrideParam *bool) (*model0.StructValue, error) { |
| 121 | + var err error |
| 122 | + var obj *model0.StructValue |
| 123 | + |
| 124 | + switch c.ClientType { |
| 125 | + |
| 126 | + case utl.Local: |
| 127 | + client := c.Client.(client0.FloodProtectionProfilesClient) |
| 128 | + obj, err = client.Update(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam) |
| 129 | + |
| 130 | + case utl.Global: |
| 131 | + client := c.Client.(client1.FloodProtectionProfilesClient) |
| 132 | + obj, err = client.Update(floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam) |
| 133 | + |
| 134 | + case utl.Multitenancy: |
| 135 | + client := c.Client.(client2.FloodProtectionProfilesClient) |
| 136 | + obj, err = client.Update(utl.DefaultOrgID, c.ProjectID, floodProtectionProfileIdParam, floodProtectionProfileParam, overrideParam) |
| 137 | + |
| 138 | + default: |
| 139 | + err = errors.New("invalid infrastructure for model") |
| 140 | + } |
| 141 | + return obj, err |
| 142 | +} |
| 143 | + |
| 144 | +func (c StructValueClientContext) List(cursorParam *string, includeMarkForDeleteObjectsParam *bool, includedFieldsParam *string, pageSizeParam *int64, sortAscendingParam *bool, sortByParam *string) (lrmodel0.FloodProtectionProfileListResult, error) { |
| 145 | + var err error |
| 146 | + var obj lrmodel0.FloodProtectionProfileListResult |
| 147 | + |
| 148 | + switch c.ClientType { |
| 149 | + |
| 150 | + case utl.Local: |
| 151 | + client := c.Client.(client0.FloodProtectionProfilesClient) |
| 152 | + obj, err = client.List(cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam) |
| 153 | + |
| 154 | + case utl.Global: |
| 155 | + client := c.Client.(client1.FloodProtectionProfilesClient) |
| 156 | + gmObj, err := client.List(cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam) |
| 157 | + if err != nil { |
| 158 | + return obj, err |
| 159 | + } |
| 160 | + obj1, err1 := utl.ConvertModelBindingType(gmObj, lrmodel1.FloodProtectionProfileListResultBindingType(), lrmodel0.FloodProtectionProfileListResultBindingType()) |
| 161 | + if err1 != nil { |
| 162 | + return obj, err1 |
| 163 | + } |
| 164 | + obj = obj1.(lrmodel0.FloodProtectionProfileListResult) |
| 165 | + |
| 166 | + case utl.Multitenancy: |
| 167 | + client := c.Client.(client2.FloodProtectionProfilesClient) |
| 168 | + obj, err = client.List(utl.DefaultOrgID, c.ProjectID, cursorParam, includeMarkForDeleteObjectsParam, includedFieldsParam, pageSizeParam, sortAscendingParam, sortByParam) |
| 169 | + |
| 170 | + default: |
| 171 | + err = errors.New("invalid infrastructure for model") |
| 172 | + } |
| 173 | + return obj, err |
| 174 | +} |
0 commit comments