Skip to content

Commit

Permalink
new: RawRespond export field raw & add func Parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
khorevaa committed Jan 25, 2021
1 parent 38993fe commit 7edced1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (i ClustersList) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &list)
err := Unmarshal(res.Raw, &list)
res.Error = err
res.parsedRespond = list
return err
Expand All @@ -93,7 +93,7 @@ func (i ClustersInfo) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down
4 changes: 2 additions & 2 deletions connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (i ConnectionsList) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &list)
err := Unmarshal(res.Raw, &list)
res.Error = err

if i.FilterFunc != nil {
Expand Down Expand Up @@ -150,7 +150,7 @@ func (i ConnectionsInfo) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down
8 changes: 6 additions & 2 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ func infobaseAuthParams(auth InfobaseAuth) map[string]string {

type RawRespond struct {
Status bool
raw []byte
Raw []byte
parsedRespond interface{}
Error error
}

func (r *RawRespond) Parsed() interface{} {
return r.parsedRespond
}

func newRawRespond(data []byte, err error) *RawRespond {

res := &RawRespond{
raw: data,
Raw: data,
Error: err,
Status: true,
}
Expand Down
14 changes: 7 additions & 7 deletions infobases.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (i InfobasesList) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &list)
err := Unmarshal(res.Raw, &list)
res.Error = err
res.parsedRespond = list

Expand Down Expand Up @@ -119,7 +119,7 @@ func (i InfobasesSummaryInfo) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down Expand Up @@ -152,7 +152,7 @@ func (i InfobaseFullInfo) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down Expand Up @@ -197,7 +197,7 @@ func (i InfobaseDrop) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down Expand Up @@ -360,7 +360,7 @@ func (i InfobaseUpdate) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down Expand Up @@ -397,7 +397,7 @@ func (i InfobaseUpdateDescription) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down Expand Up @@ -492,7 +492,7 @@ func (i InfobaseCreate) Parse(res *RawRespond) error {
return res.Error
}

err := Unmarshal(res.raw, &info)
err := Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down
6 changes: 3 additions & 3 deletions sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (i SessionsList) Parse(res *RawRespond) error {
return res.Error
}

err = Unmarshal(res.raw, &list)
err = Unmarshal(res.Raw, &list)

if l, ok := list.([]SessionsInfo); ok {
list = i.filter(l)
Expand Down Expand Up @@ -151,7 +151,7 @@ func (i SessionsInfo) Parse(res *RawRespond) error {
return res.Error
}

err = Unmarshal(res.raw, &info)
err = Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down Expand Up @@ -182,7 +182,7 @@ func (i SessionsTerminate) Parse(res *RawRespond) error {
return res.Error
}

err = Unmarshal(res.raw, &info)
err = Unmarshal(res.Raw, &info)
res.Error = err
res.parsedRespond = info
return err
Expand Down

0 comments on commit 7edced1

Please sign in to comment.