|
| 1 | +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. |
| 2 | +// All rights reserved. |
| 3 | +// |
| 4 | +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// |
| 8 | +// https://mozilla.org/MPL/2.0/ |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | +// |
| 16 | +// SPDX-License-Identifier: MPL-2.0 |
| 17 | + |
| 18 | +package provider |
| 19 | + |
| 20 | +// Section below is generated&owned by "gen/generator.go". //template:begin imports |
| 21 | +import ( |
| 22 | + "context" |
| 23 | + "fmt" |
| 24 | + "net/url" |
| 25 | + |
| 26 | + "github.com/hashicorp/terraform-plugin-framework/types" |
| 27 | + "github.com/tidwall/gjson" |
| 28 | + "github.com/tidwall/sjson" |
| 29 | +) |
| 30 | + |
| 31 | +// End of section. //template:end imports |
| 32 | + |
| 33 | +// Section below is generated&owned by "gen/generator.go". //template:begin types |
| 34 | +type FabricEWLC struct { |
| 35 | + Id types.String `tfsdk:"id"` |
| 36 | + FabricId types.String `tfsdk:"fabric_id"` |
| 37 | + NetworkDeviceId types.String `tfsdk:"network_device_id"` |
| 38 | + EnableWireless types.Bool `tfsdk:"enable_wireless"` |
| 39 | + EnableRollingApUpgrade types.Bool `tfsdk:"enable_rolling_ap_upgrade"` |
| 40 | + ApRebootPercentage types.Int64 `tfsdk:"ap_reboot_percentage"` |
| 41 | +} |
| 42 | + |
| 43 | +// End of section. //template:end types |
| 44 | + |
| 45 | +// Section below is generated&owned by "gen/generator.go". //template:begin getPath |
| 46 | +func (data FabricEWLC) getPath() string { |
| 47 | + return fmt.Sprintf("/dna/intent/api/v1/sda/fabrics/%v/switchWirelessSetting", url.QueryEscape(data.FabricId.ValueString())) |
| 48 | +} |
| 49 | + |
| 50 | +// End of section. //template:end getPath |
| 51 | + |
| 52 | +// Section below is generated&owned by "gen/generator.go". //template:begin getFallbackPath |
| 53 | +func (data FabricEWLC) getFallbackPath() string { |
| 54 | + return fmt.Sprintf("", url.QueryEscape(data.FabricId.ValueString())) |
| 55 | +} |
| 56 | + |
| 57 | +// End of section. //template:end getFallbackPath |
| 58 | + |
| 59 | +// Section below is generated&owned by "gen/generator.go". //template:begin getPathDelete |
| 60 | + |
| 61 | +// End of section. //template:end getPathDelete |
| 62 | + |
| 63 | +// Section below is generated&owned by "gen/generator.go". //template:begin toBody |
| 64 | +func (data FabricEWLC) toBody(ctx context.Context, state FabricEWLC) string { |
| 65 | + body := "" |
| 66 | + put := false |
| 67 | + if state.Id.ValueString() != "" { |
| 68 | + put = true |
| 69 | + } |
| 70 | + _ = put |
| 71 | + if !data.NetworkDeviceId.IsNull() { |
| 72 | + body, _ = sjson.Set(body, "id", data.NetworkDeviceId.ValueString()) |
| 73 | + } |
| 74 | + if !data.EnableWireless.IsNull() { |
| 75 | + body, _ = sjson.Set(body, "enableWireless", data.EnableWireless.ValueBool()) |
| 76 | + } |
| 77 | + if !data.EnableRollingApUpgrade.IsNull() { |
| 78 | + body, _ = sjson.Set(body, "rollingApUpgrade.enableRollingApUpgrade", data.EnableRollingApUpgrade.ValueBool()) |
| 79 | + } |
| 80 | + if !data.ApRebootPercentage.IsNull() { |
| 81 | + body, _ = sjson.Set(body, "rollingApUpgrade.apRebootPercentage", data.ApRebootPercentage.ValueInt64()) |
| 82 | + } |
| 83 | + return body |
| 84 | +} |
| 85 | + |
| 86 | +// End of section. //template:end toBody |
| 87 | + |
| 88 | +// Section below is generated&owned by "gen/generator.go". //template:begin fromBody |
| 89 | +func (data *FabricEWLC) fromBody(ctx context.Context, res gjson.Result) { |
| 90 | + if value := res.Get("id"); value.Exists() { |
| 91 | + data.NetworkDeviceId = types.StringValue(value.String()) |
| 92 | + } else { |
| 93 | + data.NetworkDeviceId = types.StringNull() |
| 94 | + } |
| 95 | + if value := res.Get("enableWireless"); value.Exists() { |
| 96 | + data.EnableWireless = types.BoolValue(value.Bool()) |
| 97 | + } else { |
| 98 | + data.EnableWireless = types.BoolNull() |
| 99 | + } |
| 100 | + if value := res.Get("rollingApUpgrade.enableRollingApUpgrade"); value.Exists() { |
| 101 | + data.EnableRollingApUpgrade = types.BoolValue(value.Bool()) |
| 102 | + } else { |
| 103 | + data.EnableRollingApUpgrade = types.BoolNull() |
| 104 | + } |
| 105 | + if value := res.Get("rollingApUpgrade.apRebootPercentage"); value.Exists() { |
| 106 | + data.ApRebootPercentage = types.Int64Value(value.Int()) |
| 107 | + } else { |
| 108 | + data.ApRebootPercentage = types.Int64Null() |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +// End of section. //template:end fromBody |
| 113 | + |
| 114 | +// Section below is generated&owned by "gen/generator.go". //template:begin updateFromBody |
| 115 | +func (data *FabricEWLC) updateFromBody(ctx context.Context, res gjson.Result) { |
| 116 | + if value := res.Get("id"); value.Exists() && !data.NetworkDeviceId.IsNull() { |
| 117 | + data.NetworkDeviceId = types.StringValue(value.String()) |
| 118 | + } else { |
| 119 | + data.NetworkDeviceId = types.StringNull() |
| 120 | + } |
| 121 | + if value := res.Get("enableWireless"); value.Exists() && !data.EnableWireless.IsNull() { |
| 122 | + data.EnableWireless = types.BoolValue(value.Bool()) |
| 123 | + } else { |
| 124 | + data.EnableWireless = types.BoolNull() |
| 125 | + } |
| 126 | + if value := res.Get("rollingApUpgrade.enableRollingApUpgrade"); value.Exists() && !data.EnableRollingApUpgrade.IsNull() { |
| 127 | + data.EnableRollingApUpgrade = types.BoolValue(value.Bool()) |
| 128 | + } else { |
| 129 | + data.EnableRollingApUpgrade = types.BoolNull() |
| 130 | + } |
| 131 | + if value := res.Get("rollingApUpgrade.apRebootPercentage"); value.Exists() && !data.ApRebootPercentage.IsNull() { |
| 132 | + data.ApRebootPercentage = types.Int64Value(value.Int()) |
| 133 | + } else { |
| 134 | + data.ApRebootPercentage = types.Int64Null() |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +// End of section. //template:end updateFromBody |
| 139 | + |
| 140 | +// Section below is generated&owned by "gen/generator.go". //template:begin isNull |
| 141 | +func (data *FabricEWLC) isNull(ctx context.Context, res gjson.Result) bool { |
| 142 | + if !data.EnableWireless.IsNull() { |
| 143 | + return false |
| 144 | + } |
| 145 | + if !data.EnableRollingApUpgrade.IsNull() { |
| 146 | + return false |
| 147 | + } |
| 148 | + if !data.ApRebootPercentage.IsNull() { |
| 149 | + return false |
| 150 | + } |
| 151 | + return true |
| 152 | +} |
| 153 | + |
| 154 | +// End of section. //template:end isNull |
0 commit comments