-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaction_response_protocol_ipv6_ping_response.go
386 lines (334 loc) · 12 KB
/
action_response_protocol_ipv6_ping_response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
package gosnappi
import (
"fmt"
"strings"
"github.com/ghodss/yaml"
otg "github.com/open-traffic-generator/snappi/gosnappi/otg"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
// ***** ActionResponseProtocolIpv6PingResponse *****
type actionResponseProtocolIpv6PingResponse struct {
validation
obj *otg.ActionResponseProtocolIpv6PingResponse
marshaller marshalActionResponseProtocolIpv6PingResponse
unMarshaller unMarshalActionResponseProtocolIpv6PingResponse
}
func NewActionResponseProtocolIpv6PingResponse() ActionResponseProtocolIpv6PingResponse {
obj := actionResponseProtocolIpv6PingResponse{obj: &otg.ActionResponseProtocolIpv6PingResponse{}}
obj.setDefault()
return &obj
}
func (obj *actionResponseProtocolIpv6PingResponse) msg() *otg.ActionResponseProtocolIpv6PingResponse {
return obj.obj
}
func (obj *actionResponseProtocolIpv6PingResponse) setMsg(msg *otg.ActionResponseProtocolIpv6PingResponse) ActionResponseProtocolIpv6PingResponse {
proto.Merge(obj.obj, msg)
return obj
}
type marshalactionResponseProtocolIpv6PingResponse struct {
obj *actionResponseProtocolIpv6PingResponse
}
type marshalActionResponseProtocolIpv6PingResponse interface {
// ToProto marshals ActionResponseProtocolIpv6PingResponse to protobuf object *otg.ActionResponseProtocolIpv6PingResponse
ToProto() (*otg.ActionResponseProtocolIpv6PingResponse, error)
// ToPbText marshals ActionResponseProtocolIpv6PingResponse to protobuf text
ToPbText() (string, error)
// ToYaml marshals ActionResponseProtocolIpv6PingResponse to YAML text
ToYaml() (string, error)
// ToJson marshals ActionResponseProtocolIpv6PingResponse to JSON text
ToJson() (string, error)
}
type unMarshalactionResponseProtocolIpv6PingResponse struct {
obj *actionResponseProtocolIpv6PingResponse
}
type unMarshalActionResponseProtocolIpv6PingResponse interface {
// FromProto unmarshals ActionResponseProtocolIpv6PingResponse from protobuf object *otg.ActionResponseProtocolIpv6PingResponse
FromProto(msg *otg.ActionResponseProtocolIpv6PingResponse) (ActionResponseProtocolIpv6PingResponse, error)
// FromPbText unmarshals ActionResponseProtocolIpv6PingResponse from protobuf text
FromPbText(value string) error
// FromYaml unmarshals ActionResponseProtocolIpv6PingResponse from YAML text
FromYaml(value string) error
// FromJson unmarshals ActionResponseProtocolIpv6PingResponse from JSON text
FromJson(value string) error
}
func (obj *actionResponseProtocolIpv6PingResponse) Marshal() marshalActionResponseProtocolIpv6PingResponse {
if obj.marshaller == nil {
obj.marshaller = &marshalactionResponseProtocolIpv6PingResponse{obj: obj}
}
return obj.marshaller
}
func (obj *actionResponseProtocolIpv6PingResponse) Unmarshal() unMarshalActionResponseProtocolIpv6PingResponse {
if obj.unMarshaller == nil {
obj.unMarshaller = &unMarshalactionResponseProtocolIpv6PingResponse{obj: obj}
}
return obj.unMarshaller
}
func (m *marshalactionResponseProtocolIpv6PingResponse) ToProto() (*otg.ActionResponseProtocolIpv6PingResponse, error) {
err := m.obj.validateToAndFrom()
if err != nil {
return nil, err
}
return m.obj.msg(), nil
}
func (m *unMarshalactionResponseProtocolIpv6PingResponse) FromProto(msg *otg.ActionResponseProtocolIpv6PingResponse) (ActionResponseProtocolIpv6PingResponse, error) {
newObj := m.obj.setMsg(msg)
err := newObj.validateToAndFrom()
if err != nil {
return nil, err
}
return newObj, nil
}
func (m *marshalactionResponseProtocolIpv6PingResponse) ToPbText() (string, error) {
vErr := m.obj.validateToAndFrom()
if vErr != nil {
return "", vErr
}
protoMarshal, err := proto.Marshal(m.obj.msg())
if err != nil {
return "", err
}
return string(protoMarshal), nil
}
func (m *unMarshalactionResponseProtocolIpv6PingResponse) FromPbText(value string) error {
retObj := proto.Unmarshal([]byte(value), m.obj.msg())
if retObj != nil {
return retObj
}
vErr := m.obj.validateToAndFrom()
if vErr != nil {
return vErr
}
return retObj
}
func (m *marshalactionResponseProtocolIpv6PingResponse) ToYaml() (string, error) {
vErr := m.obj.validateToAndFrom()
if vErr != nil {
return "", vErr
}
opts := protojson.MarshalOptions{
UseProtoNames: true,
AllowPartial: true,
EmitUnpopulated: false,
}
data, err := opts.Marshal(m.obj.msg())
if err != nil {
return "", err
}
data, err = yaml.JSONToYAML(data)
if err != nil {
return "", err
}
return string(data), nil
}
func (m *unMarshalactionResponseProtocolIpv6PingResponse) FromYaml(value string) error {
if value == "" {
value = "{}"
}
data, err := yaml.YAMLToJSON([]byte(value))
if err != nil {
return err
}
opts := protojson.UnmarshalOptions{
AllowPartial: true,
DiscardUnknown: false,
}
uError := opts.Unmarshal([]byte(data), m.obj.msg())
if uError != nil {
return fmt.Errorf("unmarshal error %s", strings.Replace(
uError.Error(), "\u00a0", " ", -1)[7:])
}
vErr := m.obj.validateToAndFrom()
if vErr != nil {
return vErr
}
return nil
}
func (m *marshalactionResponseProtocolIpv6PingResponse) ToJson() (string, error) {
vErr := m.obj.validateToAndFrom()
if vErr != nil {
return "", vErr
}
opts := protojson.MarshalOptions{
UseProtoNames: true,
AllowPartial: true,
EmitUnpopulated: false,
Indent: " ",
}
data, err := opts.Marshal(m.obj.msg())
if err != nil {
return "", err
}
return string(data), nil
}
func (m *unMarshalactionResponseProtocolIpv6PingResponse) FromJson(value string) error {
opts := protojson.UnmarshalOptions{
AllowPartial: true,
DiscardUnknown: false,
}
if value == "" {
value = "{}"
}
uError := opts.Unmarshal([]byte(value), m.obj.msg())
if uError != nil {
return fmt.Errorf("unmarshal error %s", strings.Replace(
uError.Error(), "\u00a0", " ", -1)[7:])
}
err := m.obj.validateToAndFrom()
if err != nil {
return err
}
return nil
}
func (obj *actionResponseProtocolIpv6PingResponse) validateToAndFrom() error {
// emptyVars()
obj.validateObj(&obj.validation, true)
return obj.validationResult()
}
func (obj *actionResponseProtocolIpv6PingResponse) validate() error {
// emptyVars()
obj.validateObj(&obj.validation, false)
return obj.validationResult()
}
func (obj *actionResponseProtocolIpv6PingResponse) String() string {
str, err := obj.Marshal().ToYaml()
if err != nil {
return err.Error()
}
return str
}
func (obj *actionResponseProtocolIpv6PingResponse) Clone() (ActionResponseProtocolIpv6PingResponse, error) {
vErr := obj.validate()
if vErr != nil {
return nil, vErr
}
newObj := NewActionResponseProtocolIpv6PingResponse()
data, err := proto.Marshal(obj.msg())
if err != nil {
return nil, err
}
pbErr := proto.Unmarshal(data, newObj.msg())
if pbErr != nil {
return nil, pbErr
}
return newObj, nil
}
// ActionResponseProtocolIpv6PingResponse is response for ping initiated between a single source and destination pair.
type ActionResponseProtocolIpv6PingResponse interface {
Validation
// msg marshals ActionResponseProtocolIpv6PingResponse to protobuf object *otg.ActionResponseProtocolIpv6PingResponse
// and doesn't set defaults
msg() *otg.ActionResponseProtocolIpv6PingResponse
// setMsg unmarshals ActionResponseProtocolIpv6PingResponse from protobuf object *otg.ActionResponseProtocolIpv6PingResponse
// and doesn't set defaults
setMsg(*otg.ActionResponseProtocolIpv6PingResponse) ActionResponseProtocolIpv6PingResponse
// provides marshal interface
Marshal() marshalActionResponseProtocolIpv6PingResponse
// provides unmarshal interface
Unmarshal() unMarshalActionResponseProtocolIpv6PingResponse
// validate validates ActionResponseProtocolIpv6PingResponse
validate() error
// A stringer function
String() string
// Clones the object
Clone() (ActionResponseProtocolIpv6PingResponse, error)
validateToAndFrom() error
validateObj(vObj *validation, set_default bool)
setDefault()
// SrcName returns string, set in ActionResponseProtocolIpv6PingResponse.
SrcName() string
// SetSrcName assigns string provided by user to ActionResponseProtocolIpv6PingResponse
SetSrcName(value string) ActionResponseProtocolIpv6PingResponse
// DstIp returns string, set in ActionResponseProtocolIpv6PingResponse.
DstIp() string
// SetDstIp assigns string provided by user to ActionResponseProtocolIpv6PingResponse
SetDstIp(value string) ActionResponseProtocolIpv6PingResponse
// Result returns ActionResponseProtocolIpv6PingResponseResultEnum, set in ActionResponseProtocolIpv6PingResponse
Result() ActionResponseProtocolIpv6PingResponseResultEnum
// SetResult assigns ActionResponseProtocolIpv6PingResponseResultEnum provided by user to ActionResponseProtocolIpv6PingResponse
SetResult(value ActionResponseProtocolIpv6PingResponseResultEnum) ActionResponseProtocolIpv6PingResponse
}
// Name of source IPv6 interface used for ping.
//
// x-constraint:
// - /components/schemas/Device.Ipv6/properties/name
//
// x-constraint:
// - /components/schemas/Device.Ipv6/properties/name
//
// SrcName returns a string
func (obj *actionResponseProtocolIpv6PingResponse) SrcName() string {
return *obj.obj.SrcName
}
// Name of source IPv6 interface used for ping.
//
// x-constraint:
// - /components/schemas/Device.Ipv6/properties/name
//
// x-constraint:
// - /components/schemas/Device.Ipv6/properties/name
//
// SetSrcName sets the string value in the ActionResponseProtocolIpv6PingResponse object
func (obj *actionResponseProtocolIpv6PingResponse) SetSrcName(value string) ActionResponseProtocolIpv6PingResponse {
obj.obj.SrcName = &value
return obj
}
// Destination IPv6 address used for ping.
// DstIp returns a string
func (obj *actionResponseProtocolIpv6PingResponse) DstIp() string {
return *obj.obj.DstIp
}
// Destination IPv6 address used for ping.
// SetDstIp sets the string value in the ActionResponseProtocolIpv6PingResponse object
func (obj *actionResponseProtocolIpv6PingResponse) SetDstIp(value string) ActionResponseProtocolIpv6PingResponse {
obj.obj.DstIp = &value
return obj
}
type ActionResponseProtocolIpv6PingResponseResultEnum string
// Enum of Result on ActionResponseProtocolIpv6PingResponse
var ActionResponseProtocolIpv6PingResponseResult = struct {
SUCCEEDED ActionResponseProtocolIpv6PingResponseResultEnum
FAILED ActionResponseProtocolIpv6PingResponseResultEnum
}{
SUCCEEDED: ActionResponseProtocolIpv6PingResponseResultEnum("succeeded"),
FAILED: ActionResponseProtocolIpv6PingResponseResultEnum("failed"),
}
func (obj *actionResponseProtocolIpv6PingResponse) Result() ActionResponseProtocolIpv6PingResponseResultEnum {
return ActionResponseProtocolIpv6PingResponseResultEnum(obj.obj.Result.Enum().String())
}
func (obj *actionResponseProtocolIpv6PingResponse) SetResult(value ActionResponseProtocolIpv6PingResponseResultEnum) ActionResponseProtocolIpv6PingResponse {
intValue, ok := otg.ActionResponseProtocolIpv6PingResponse_Result_Enum_value[string(value)]
if !ok {
obj.validationErrors = append(obj.validationErrors, fmt.Sprintf(
"%s is not a valid choice on ActionResponseProtocolIpv6PingResponseResultEnum", string(value)))
return obj
}
enumValue := otg.ActionResponseProtocolIpv6PingResponse_Result_Enum(intValue)
obj.obj.Result = &enumValue
return obj
}
func (obj *actionResponseProtocolIpv6PingResponse) validateObj(vObj *validation, set_default bool) {
if set_default {
obj.setDefault()
}
// SrcName is required
if obj.obj.SrcName == nil {
vObj.validationErrors = append(vObj.validationErrors, "SrcName is required field on interface ActionResponseProtocolIpv6PingResponse")
}
// DstIp is required
if obj.obj.DstIp == nil {
vObj.validationErrors = append(vObj.validationErrors, "DstIp is required field on interface ActionResponseProtocolIpv6PingResponse")
}
if obj.obj.DstIp != nil {
err := obj.validateIpv6(obj.DstIp())
if err != nil {
vObj.validationErrors = append(vObj.validationErrors, fmt.Sprintf("%s %s", err.Error(), "on ActionResponseProtocolIpv6PingResponse.DstIp"))
}
}
// Result is required
if obj.obj.Result == nil {
vObj.validationErrors = append(vObj.validationErrors, "Result is required field on interface ActionResponseProtocolIpv6PingResponse")
}
}
func (obj *actionResponseProtocolIpv6PingResponse) setDefault() {
}