-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from nifcloud/feature/add_custom_deserializer_…
…for_elb Add custom deserializers for ELB
- Loading branch information
Showing
3 changed files
with
205 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
package deserializers | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
|
||
smithyxml "github.com/aws/smithy-go/encoding/xml" | ||
"github.com/aws/smithy-go/ptr" | ||
"github.com/nifcloud/nifcloud-sdk-go/service/computing/types" | ||
) | ||
|
||
// DeserializeDocumentSessionStickinessPolicy is custom deserializer to parse empty 'ExpirationPeriod' | ||
func DeserializeDocumentSessionStickinessPolicy( | ||
v **types.SessionStickinessPolicy, | ||
decoder smithyxml.NodeDecoder, | ||
) error { | ||
if v == nil { | ||
return fmt.Errorf("unexpected nil of type %T", v) | ||
} | ||
var sv *types.SessionStickinessPolicy | ||
if *v == nil { | ||
sv = &types.SessionStickinessPolicy{} | ||
} else { | ||
sv = *v | ||
} | ||
|
||
for { | ||
t, done, err := decoder.Token() | ||
if err != nil { | ||
return err | ||
} | ||
if done { | ||
break | ||
} | ||
originalDecoder := decoder | ||
decoder = smithyxml.WrapNodeDecoder(originalDecoder.Decoder, t) | ||
switch { | ||
case strings.EqualFold("Enabled", t.Name.Local): | ||
val, err := decoder.Value() | ||
if err != nil { | ||
return err | ||
} | ||
if val == nil { | ||
break | ||
} | ||
{ | ||
xtv, err := strconv.ParseBool(string(val)) | ||
if err != nil { | ||
return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) | ||
} | ||
sv.Enabled = ptr.Bool(xtv) | ||
} | ||
|
||
case strings.EqualFold("ExpirationPeriod", t.Name.Local): | ||
val, err := decoder.Value() | ||
if err != nil { | ||
return err | ||
} | ||
if val == nil { | ||
break | ||
} | ||
{ | ||
xtv := string(val) | ||
if xtv != "" { | ||
i64, err := strconv.ParseInt(xtv, 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
sv.ExpirationPeriod = ptr.Int32(int32(i64)) | ||
} | ||
} | ||
|
||
default: | ||
// Do nothing and ignore the unexpected tag element | ||
err = decoder.Decoder.Skip() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
} | ||
decoder = originalDecoder | ||
} | ||
*v = sv | ||
return nil | ||
} | ||
|
||
// DeserializeDocumentSessionStickinessPolicyOfNiftyDescribeElasticLoadBalancers is custom deserializer | ||
// to parse empty 'ExpirationPeriod' | ||
func DeserializeDocumentSessionStickinessPolicyOfNiftyDescribeElasticLoadBalancers( | ||
v **types.SessionStickinessPolicyOfNiftyDescribeElasticLoadBalancers, | ||
decoder smithyxml.NodeDecoder, | ||
) error { | ||
if v == nil { | ||
return fmt.Errorf("unexpected nil of type %T", v) | ||
} | ||
var sv *types.SessionStickinessPolicyOfNiftyDescribeElasticLoadBalancers | ||
if *v == nil { | ||
sv = &types.SessionStickinessPolicyOfNiftyDescribeElasticLoadBalancers{} | ||
} else { | ||
sv = *v | ||
} | ||
|
||
for { | ||
t, done, err := decoder.Token() | ||
if err != nil { | ||
return err | ||
} | ||
if done { | ||
break | ||
} | ||
originalDecoder := decoder | ||
decoder = smithyxml.WrapNodeDecoder(originalDecoder.Decoder, t) | ||
switch { | ||
case strings.EqualFold("Enabled", t.Name.Local): | ||
val, err := decoder.Value() | ||
if err != nil { | ||
return err | ||
} | ||
if val == nil { | ||
break | ||
} | ||
{ | ||
xtv, err := strconv.ParseBool(string(val)) | ||
if err != nil { | ||
return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) | ||
} | ||
sv.Enabled = ptr.Bool(xtv) | ||
} | ||
|
||
case strings.EqualFold("ExpirationPeriod", t.Name.Local): | ||
val, err := decoder.Value() | ||
if err != nil { | ||
return err | ||
} | ||
if val == nil { | ||
break | ||
} | ||
{ | ||
xtv := string(val) | ||
if xtv != "" { | ||
i64, err := strconv.ParseInt(xtv, 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
sv.ExpirationPeriod = ptr.Int32(int32(i64)) | ||
} | ||
} | ||
|
||
case strings.EqualFold("Method", t.Name.Local): | ||
val, err := decoder.Value() | ||
if err != nil { | ||
return err | ||
} | ||
if val == nil { | ||
break | ||
} | ||
{ | ||
xtv := string(val) | ||
i64, err := strconv.ParseInt(xtv, 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
sv.Method = ptr.Int32(int32(i64)) | ||
} | ||
|
||
default: | ||
// Do nothing and ignore the unexpected tag element | ||
err = decoder.Decoder.Skip() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
} | ||
decoder = originalDecoder | ||
} | ||
*v = sv | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.