luoluoyuyu commented on code in PR #3104:
URL: https://github.com/apache/streampipes/pull/3104#discussion_r1707347565


##########
streampipes-client-go/streampipes/endpoint.go:
##########
@@ -53,21 +58,21 @@ func (e *endpoint) handleStatusCode(resp *http.Response) 
error {
 
        switch resp.StatusCode {
        case http.StatusUnauthorized:
-               return errors.New("The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
+               return errors.New("401," + "The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
        case http.StatusForbidden:
-               return errors.New("There seems to be an issue with the access 
rights of the given user and the resource you queried.\n" +
+               return errors.New("403," + "There seems to be an issue with the 
access rights of the given user and the resource you queried.\n" +
                        "Apparently, this user is not allowed to query the 
resource.\n" +
                        "Please check the user's permissions or contact your 
StreamPipes admin.")
        case http.StatusNotFound:
-               return errors.New("There seems to be an issue with the Go 
Client calling the API inappropriately.\n" +
+               return errors.New("404," + "There seems to be an issue with the 
Go Client calling the API inappropriately.\n" +
                        "This should not happen, but unfortunately did.\n" +
                        "If you don't mind, it would be awesome to let us know 
by creating an issue at https://github.com/apache/streampipes.\n";)
        case http.StatusMethodNotAllowed:
-               return errors.New("There seems to be an issue with the Go 
Client calling the API inappropriately.\n" +
+               return errors.New("405," + "There seems to be an issue with the 
Go Client calling the API inappropriately.\n" +
                        "This should not happen, but unfortunately did.\n" +
                        "If you don't mind, it would be awesome to let us know 
by creating an issue at https://github.com/apache/streampipes.\n";)
        case http.StatusInternalServerError:
-               return errors.New("streamPipes internal error")
+               return errors.New("500," + "streamPipes internal error")

Review Comment:
   the same as above



##########
streampipes-client-go/streampipes/endpoint.go:
##########
@@ -53,21 +58,21 @@ func (e *endpoint) handleStatusCode(resp *http.Response) 
error {
 
        switch resp.StatusCode {
        case http.StatusUnauthorized:
-               return errors.New("The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
+               return errors.New("401," + "The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
        case http.StatusForbidden:
-               return errors.New("There seems to be an issue with the access 
rights of the given user and the resource you queried.\n" +
+               return errors.New("403," + "There seems to be an issue with the 
access rights of the given user and the resource you queried.\n" +

Review Comment:
   the same as above



##########
streampipes-client-go/streampipes/endpoint.go:
##########
@@ -53,21 +58,21 @@ func (e *endpoint) handleStatusCode(resp *http.Response) 
error {
 
        switch resp.StatusCode {
        case http.StatusUnauthorized:
-               return errors.New("The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
+               return errors.New("401," + "The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")

Review Comment:
   ```suggestion
                return fmt.Errorf("Response Code %d: The streamPipes Backend 
returned an unauthorized error.\nplease check your ApiUser and/or Apikey to be 
correct.", resp.StatusCode)
   ```



##########
streampipes-client-go/streampipes/internal/serializer/deserializer.go:
##########
@@ -267,3 +267,65 @@ func (p *UserAccountDeserializer) Unmarshal(data []byte) 
(interface{}, error) {
        return userAccount, nil
 
 }
+
+type PipelineDeserializer struct{}
+
+func NewPipelineDeserializer() *PipelineDeserializer {
+       return &PipelineDeserializer{}
+}
+
+func (p *PipelineDeserializer) Unmarshal(data []byte) (interface{}, error) {
+       var pipeLine pipeline.Pipeline
+       err := json.Unmarshal(data, &pipeLine)
+       if err != nil {
+               return nil, err
+       }
+       return pipeLine, nil
+
+}
+
+type PipelinesDeserializer struct{}
+
+func NewPipelinesDeserializer() *PipelinesDeserializer {
+       return &PipelinesDeserializer{}
+}
+
+func (p *PipelinesDeserializer) Unmarshal(data []byte) (interface{}, error) {
+       var pipeLine []pipeline.Pipeline
+       err := json.Unmarshal(data, &pipeLine)
+       if err != nil {
+               return nil, err
+       }
+       return pipeLine, nil
+
+}
+
+type PipelineStatusMessagesDeserializer struct{}
+
+func NewPipelineStatusMessagesDeserializer() 
*PipelineStatusMessagesDeserializer {
+       return &PipelineStatusMessagesDeserializer{}
+}
+
+func (p *PipelineStatusMessagesDeserializer) Unmarshal(data []byte) 
(interface{}, error) {
+       var pipeLine []pipeline.PipelineStatusMessage

Review Comment:
   the same as above



##########
streampipes-client-go/streampipes/internal/serializer/serializer.go:
##########
@@ -0,0 +1,37 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package serializer
+
+import (
+       "encoding/json"
+       
"github.com/apache/streampipes/streampipes-client-go/streampipes/model/pipeline"
+)
+
+type PipelineSerializer struct{}
+
+func NewPipelineSerializer() PipelineSerializer {
+       return PipelineSerializer{}
+}
+
+func (p PipelineSerializer) Marshal(pp pipeline.Pipeline) ([]byte, error) {

Review Comment:
   ```suggestion
   func (p PipelineSerializer) Marshal(pipeline pipeline.Pipeline) ([]byte, 
error) {
   ```



##########
streampipes-client-go/streampipes/internal/serializer/deserializer.go:
##########
@@ -267,3 +267,65 @@ func (p *UserAccountDeserializer) Unmarshal(data []byte) 
(interface{}, error) {
        return userAccount, nil
 
 }
+
+type PipelineDeserializer struct{}
+
+func NewPipelineDeserializer() *PipelineDeserializer {
+       return &PipelineDeserializer{}
+}
+
+func (p *PipelineDeserializer) Unmarshal(data []byte) (interface{}, error) {
+       var pipeLine pipeline.Pipeline
+       err := json.Unmarshal(data, &pipeLine)
+       if err != nil {
+               return nil, err
+       }
+       return pipeLine, nil
+
+}
+
+type PipelinesDeserializer struct{}
+
+func NewPipelinesDeserializer() *PipelinesDeserializer {
+       return &PipelinesDeserializer{}
+}
+
+func (p *PipelinesDeserializer) Unmarshal(data []byte) (interface{}, error) {
+       var pipeLine []pipeline.Pipeline

Review Comment:
   ```suggestion
        var pipeline []pipeline.Pipeline
   ```



##########
streampipes-client-go/streampipes/endpoint.go:
##########
@@ -53,21 +58,21 @@ func (e *endpoint) handleStatusCode(resp *http.Response) 
error {
 
        switch resp.StatusCode {
        case http.StatusUnauthorized:
-               return errors.New("The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
+               return errors.New("401," + "The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
        case http.StatusForbidden:
-               return errors.New("There seems to be an issue with the access 
rights of the given user and the resource you queried.\n" +
+               return errors.New("403," + "There seems to be an issue with the 
access rights of the given user and the resource you queried.\n" +
                        "Apparently, this user is not allowed to query the 
resource.\n" +
                        "Please check the user's permissions or contact your 
StreamPipes admin.")
        case http.StatusNotFound:
-               return errors.New("There seems to be an issue with the Go 
Client calling the API inappropriately.\n" +
+               return errors.New("404," + "There seems to be an issue with the 
Go Client calling the API inappropriately.\n" +

Review Comment:
   the same as above



##########
streampipes-client-go/streampipes/endpoint.go:
##########
@@ -53,21 +58,21 @@ func (e *endpoint) handleStatusCode(resp *http.Response) 
error {
 
        switch resp.StatusCode {
        case http.StatusUnauthorized:
-               return errors.New("The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
+               return errors.New("401," + "The streamPipes Backend returned an 
unauthorized error.\nplease check your ApiUser and/or Apikey to be correct.")
        case http.StatusForbidden:
-               return errors.New("There seems to be an issue with the access 
rights of the given user and the resource you queried.\n" +
+               return errors.New("403," + "There seems to be an issue with the 
access rights of the given user and the resource you queried.\n" +
                        "Apparently, this user is not allowed to query the 
resource.\n" +
                        "Please check the user's permissions or contact your 
StreamPipes admin.")
        case http.StatusNotFound:
-               return errors.New("There seems to be an issue with the Go 
Client calling the API inappropriately.\n" +
+               return errors.New("404," + "There seems to be an issue with the 
Go Client calling the API inappropriately.\n" +
                        "This should not happen, but unfortunately did.\n" +
                        "If you don't mind, it would be awesome to let us know 
by creating an issue at https://github.com/apache/streampipes.\n";)
        case http.StatusMethodNotAllowed:
-               return errors.New("There seems to be an issue with the Go 
Client calling the API inappropriately.\n" +
+               return errors.New("405," + "There seems to be an issue with the 
Go Client calling the API inappropriately.\n" +
                        "This should not happen, but unfortunately did.\n" +

Review Comment:
   the same as above



##########
streampipes-client-go/streampipes/internal/serializer/deserializer.go:
##########
@@ -267,3 +267,65 @@ func (p *UserAccountDeserializer) Unmarshal(data []byte) 
(interface{}, error) {
        return userAccount, nil
 
 }
+
+type PipelineDeserializer struct{}
+
+func NewPipelineDeserializer() *PipelineDeserializer {
+       return &PipelineDeserializer{}
+}
+
+func (p *PipelineDeserializer) Unmarshal(data []byte) (interface{}, error) {
+       var pipeLine pipeline.Pipeline
+       err := json.Unmarshal(data, &pipeLine)
+       if err != nil {
+               return nil, err
+       }
+       return pipeLine, nil
+
+}
+
+type PipelinesDeserializer struct{}
+
+func NewPipelinesDeserializer() *PipelinesDeserializer {
+       return &PipelinesDeserializer{}
+}
+
+func (p *PipelinesDeserializer) Unmarshal(data []byte) (interface{}, error) {
+       var pipeLine []pipeline.Pipeline
+       err := json.Unmarshal(data, &pipeLine)
+       if err != nil {
+               return nil, err
+       }
+       return pipeLine, nil
+
+}
+
+type PipelineStatusMessagesDeserializer struct{}
+
+func NewPipelineStatusMessagesDeserializer() 
*PipelineStatusMessagesDeserializer {
+       return &PipelineStatusMessagesDeserializer{}
+}
+
+func (p *PipelineStatusMessagesDeserializer) Unmarshal(data []byte) 
(interface{}, error) {
+       var pipeLine []pipeline.PipelineStatusMessage
+       err := json.Unmarshal(data, &pipeLine)
+       if err != nil {
+               return nil, err
+       }
+       return pipeLine, nil
+}
+
+type PipelineOperationStatusDeserializer struct{}
+
+func NewPipelineOperationStatusDeserializer() 
*PipelineOperationStatusDeserializer {
+       return &PipelineOperationStatusDeserializer{}
+}
+
+func (p *PipelineOperationStatusDeserializer) Unmarshal(data []byte) 
(interface{}, error) {
+       var pipeLine pipeline.PipelineOperationStatus

Review Comment:
   the same as above



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to