RobertIndie commented on code in PR #2437:
URL: https://github.com/apache/streampipes/pull/2437#discussion_r1469477260


##########
streampipes-client-go/streampipes/internal/StatuCode/ErrorCode.go:
##########
@@ -0,0 +1,43 @@
+//
+// 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 StatuCode
+
+type ErrorCode interface {
+       Error() string
+       Code() int
+       Message() string
+}
+
+type Code struct {
+       code int
+       msg  string
+}
+
+//var _ ErrorCode = (*Code)(nil)

Review Comment:
   We can remove this line.



##########
streampipes-client-go/streampipes/examples/main.go:
##########
@@ -0,0 +1,48 @@
+//
+// 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 main
+
+import (
+       "fmt"
+       "streampipes-client-go/streampipes/internal"
+       "streampipes-client-go/streampipes/internal/config"
+       "streampipes-client-go/streampipes/internal/credential"
+)
+
+func main() {
+       Config := config.StreamPipesClientConnectionConfig{
+               Credential: credential.StreamPipesApiKeyCredentials{
+                       Username: "[email protected]",
+                       ApiKey:   "LNrsh8YrgEyQTzSKSGmaAXb1",

Review Comment:
   We shouldn't expose the API key to the code. You could leave it as a 
placeholder.



##########
streampipes-client-go/streampipes/internal/StreamPipesHttp/HttpRequest.go:
##########


Review Comment:
   We could abstract these Request implementation to a Request interface.



##########
streampipes-client-go/streampipes/internal/StreamPipesHttp/GetRequest.go:
##########
@@ -0,0 +1,59 @@
+//
+// 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 StreamPipesHttp
+
+import (
+       "io/ioutil"
+       "log"
+       "streampipes-client-go/streampipes/internal/config"
+       "streampipes-client-go/streampipes/internal/serializer"
+)
+
+type GetRequest struct {
+       HttpRequest *HttpRequest
+       Serializer  *serializer.UnBaseSerializer
+}
+
+func NewGetRequest(clientConfig config.StreamPipesClientConnectionConfig, 
Serializer *serializer.UnBaseSerializer) *GetRequest {
+       return &GetRequest{
+               HttpRequest: NewHttpRequest(clientConfig),
+               Serializer:  Serializer,
+       }
+}
+
+func (g *GetRequest) ExecuteGetRequest(Type interface{}) {
+       //Process complete GET requests
+       g.HttpRequest.ExecuteRequest("GET", Type)
+       g.HttpRequest.AfterRequest = func(Type interface{}) {
+               g.afterRequest(Type)
+       }
+       g.HttpRequest.AfterRequest(Type)
+}
+
+func (g *GetRequest) afterRequest(Type interface{}) {
+       ////Process complete GET requests
+       defer g.HttpRequest.Response.Body.Close()
+       body, err := ioutil.ReadAll(g.HttpRequest.Response.Body)
+       if err != nil {
+               log.Fatal(err)

Review Comment:
   We are using Golang 1.21. It's worth trying the new logging lib `slog`.



##########
streampipes-client-go/streampipes/internal/config/ClientConnectionConfig.go:
##########
@@ -0,0 +1,67 @@
+//
+// 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 config
+
+import (
+       "streampipes-client-go/streampipes/internal/credential"
+       Path "streampipes-client-go/streampipes/internal/util"
+)
+
+type ClientConnectionConfigResolver interface {
+       GetStreamPipesHost() string
+       GetStreamPipesPort() string
+       IsHttpsDisabled() bool
+       GetBaseUrl() string
+       GetCredentials() credential.StreamPipesApiKeyCredentials
+}
+
+type StreamPipesClientConnectionConfig struct {
+       Credential      credential.StreamPipesApiKeyCredentials 
//credential.StreamPipesApiKeyCredentials
+       StreamPipesHost string
+       StreamPipesPort string
+       HttpsDisabled   bool

Review Comment:
   Is it possible that we combine these configurations into just 1 
configuration: `StreamPipesURL`? We can also check the https using the URL.



##########
streampipes-client-go/streampipes/internal/StatuCode/code.go:
##########
@@ -0,0 +1,27 @@
+//
+// 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 StatuCode
+
+var (
+       Unauthorized = Add(401, "The StreamPipes Backend returned an 
unauthorized error.\nPlease check your user name and/or password to be 
correct.")

Review Comment:
   The name of `Add` seems confusing. `NewErrorCode` would be more appropriate.



##########
streampipes-client-go/streampipes/internal/api/DataLakeMeasureApi.go:
##########
@@ -0,0 +1,79 @@
+//
+// 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 api
+
+import (
+       "fmt"
+       "streampipes-client-go/streampipes/internal/StreamPipesHttp"
+       "streampipes-client-go/streampipes/internal/config"
+       "streampipes-client-go/streampipes/internal/serializer"
+       "streampipes-client-go/streampipes/model/DataLake"
+)
+
+type DataLakeMeasureApi struct {
+       config     config.StreamPipesClientConnectionConfig
+       getRequest *StreamPipesHttp.GetRequest
+}
+
+func NewDataLakeMeasureApi(clientConfig 
config.StreamPipesClientConnectionConfig) *DataLakeMeasureApi {
+
+       return &DataLakeMeasureApi{config: clientConfig, getRequest: 
StreamPipesHttp.NewGetRequest(clientConfig, nil)}
+}
+
+func (api *DataLakeMeasureApi) All() []DataLake.DataLakeMeasure {
+       Serializer := 
serializer.NewBaseUnSerializer(serializer.WithUnSerializerDataLakeMeasures(new([]DataLake.DataLakeMeasure)))
+       api.getRequest.Serializer = Serializer
+       api.ResourcePath(nil)
+       
api.getRequest.ExecuteGetRequest(api.getRequest.Serializer.UnSerializerDataLakeMeasures)
+       return *api.getRequest.Serializer.UnSerializerDataLakeMeasures
+}
+
+func (api *DataLakeMeasureApi) Len() int {
+       measures := api.All()
+       return len(measures[0].EventSchema.EventProperties)
+}

Review Comment:
   What does this `Len` represent? Why getting the length of EventPorperties 
here?



##########
streampipes-client-go/streampipes/internal/util/StreamPipesApiPath.go:
##########
@@ -0,0 +1,97 @@
+//
+// 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 util
+
+import (
+       "strings"
+)
+
+// PathItems stores URL fragments
+// QueryParameters stores query parameters
+
+type StreamPipesApiPath struct {
+       PathItems       []string
+       QueryParameters map[string]string
+}
+
+func NewStreamPipesApiPath(initialPathItems []string) *StreamPipesApiPath {
+
+       return &StreamPipesApiPath{
+               PathItems:       initialPathItems,
+               QueryParameters: make(map[string]string),
+       }
+}
+
+func (s *StreamPipesApiPath) FromStreamPipesBasePath() *StreamPipesApiPath {
+       path := "streampipes-backend"
+       s.PathItems = append(s.PathItems, path)
+       return s
+}
+
+func (s *StreamPipesApiPath) FromBaseApiPath() *StreamPipesApiPath {
+       initialPaths := []string{"streampipes-backend", "api", "v2"}
+       s.PathItems = append(s.PathItems, initialPaths...)
+       return s
+}
+
+func (s *StreamPipesApiPath) FromStreamPipesBasePathWithSubPaths(allSubPaths 
[]string) *StreamPipesApiPath {
+       return s.FromStreamPipesBasePath().AddToPath(allSubPaths)
+}
+
+func (s *StreamPipesApiPath) AddToPath(pathItem []string) *StreamPipesApiPath {
+       s.PathItems = append(s.PathItems, pathItem...)
+       return s
+}
+
+func (s *StreamPipesApiPath) WithQueryParameters(queryParameters 
map[string]string) *StreamPipesApiPath {
+       for key, value := range queryParameters {
+               s.QueryParameters[key] = value
+       }
+       return s
+}
+
+func (s *StreamPipesApiPath) ToString() string {
+       //Splicing URLs
+       //Query parameter concatenation is still being implemented
+       if len(s.PathItems) == 1 {
+               return s.PathItems[0]
+       }
+       path := strings.Join(s.PathItems, "/")
+       //todo
+       s.PathItems = []string{path}
+       return path
+}
+
+// Splicing query parameters into a URL : ? or &
+//func (s *StreamPipesApiPath) AppendQueryParameters() string {
+//     if len(s.QueryParameters) == 0 {
+//             return s.PathItems[0]
+//     }
+//     var queryParams []string
+//     for key, value := range s.QueryParameters {
+//             queryParams = append(queryParams, fmt.Sprintf("%s=%s", 
applyEncoding(key), applyEncoding(value)))
+//     }
+//
+//     queryString := strings.Join(queryParams, "&")
+//     return fmt.Sprintf("%s?%s", s.PathItems[0], queryString)
+//}

Review Comment:
   Please remove all the useless comments in this PR.



##########
streampipes-client-go/streampipes/internal/StreamPipesHttp/DeleteRequest.go:
##########
@@ -0,0 +1,35 @@
+//
+// 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 StreamPipesHttp
+
+import "streampipes-client-go/streampipes/internal/config"
+
+type DeleteRequest struct {
+       HttpRequest *HttpRequest
+}
+
+func NewDeleteRequest(clientConfig config.StreamPipesClientConnectionConfig) 
*DeleteRequest {
+       httpRequest := NewHttpRequest(clientConfig)
+       return &DeleteRequest{
+               HttpRequest: httpRequest,
+       }
+}
+
+func (d *DeleteRequest) ExecuteDeleteRequest() {
+       //d.HttpRequest.ExecuteRequest("Delete")

Review Comment:
   Empty implementation.



##########
streampipes-client-go/streampipes/model/DataConversion/DataLakeConversion.go:
##########
@@ -0,0 +1,18 @@
+//
+// 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 DataConversion

Review Comment:
   This seems to be an empty package.



##########
streampipes-client-go/streampipes/internal/api/DataStreamApi.go:
##########


Review Comment:
   This is an empty file.



##########
streampipes-client-go/streampipes/internal/api/DataLakeMeasureApi.go:
##########


Review Comment:
   The `DataLakeMeasureApi` should be exposed to the user. We need to move it 
out of the `internal` folder.



##########
streampipes-client-go/streampipes/model/DataLake/DataLakeMeasure.go:
##########
@@ -0,0 +1,104 @@
+//
+// 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 DataLake
+
+import "streampipes-client-go/streampipes/model"
+
+type DataLakeMeasure struct {
+       ClassName         string            `alias:"@class" 
default:"org.apache.streampipes.model.datalake.DataLakeMeasure"`
+       MeasureName       string            `json:"measureName"`
+       TimestampField    string            `json:"timestampField"`
+       EventSchema       model.EventSchema `json:"eventSchema,omitempty"`
+       PipelineId        string            `json:"pipelineId,omitempty"`
+       PipelineName      string            `json:"pipelineName,omitempty"`
+       PipelineIsRunning bool              `json:"pipelineIsRunning"`
+       SchemaVersion     string            `json:"schemaVersion,omitempty"`
+       //SchemaUpdateStrategy DataLakeMeasureSchemaUpdateStrategy 
`json:"schemaUpdateStrategy,omitempty"`
+       ElementId string `json:"elementId"`
+       Rev       string `json:"_rev"`
+}
+
+func (d *DataLakeMeasure) GetElementId() string {
+       return d.ElementId
+}
+
+func (d *DataLakeMeasure) SetElementId(elementId string) {
+       d.ElementId = elementId
+}
+
+func (d *DataLakeMeasure) GetRev() string {
+       return d.Rev
+}
+
+func (d *DataLakeMeasure) SetRev(rev string) {
+       d.Rev = rev
+}
+
+func (d *DataLakeMeasure) GetMeasureName() string {
+       return d.MeasureName
+}
+
+func (d *DataLakeMeasure) SetMeasureName(measureName string) {
+       d.MeasureName = measureName
+}
+
+func (d *DataLakeMeasure) GetTimestampField() string {
+       return d.TimestampField
+}
+
+func (d *DataLakeMeasure) SetTimestampField(timestampField string) {
+       d.TimestampField = timestampField
+}
+
+func (d *DataLakeMeasure) GetEventSchema() model.EventSchema {
+       return d.EventSchema
+}
+
+func (d *DataLakeMeasure) SetEventSchema(eventSchema model.EventSchema) {
+       d.EventSchema = eventSchema
+}
+
+func (d *DataLakeMeasure) GetPipelineId() string {
+       return d.PipelineId
+}
+
+func (d *DataLakeMeasure) SetPipelineId(pipelineId string) {
+       d.PipelineId = pipelineId
+}
+
+func (d *DataLakeMeasure) GetPipelineName() string {
+       return d.PipelineName
+}
+
+func (d *DataLakeMeasure) SetPipelineName(pipelineName string) {
+       d.PipelineName = pipelineName
+}
+func (d *DataLakeMeasure) IsPipelineIsRunning() bool {
+       return d.PipelineIsRunning
+}
+
+func (d *DataLakeMeasure) SetPipelineIsRunning(pipelineIsRunning bool) {
+       d.PipelineIsRunning = pipelineIsRunning
+}
+func (d *DataLakeMeasure) GetSchemaVersion() string {
+       return d.SchemaVersion
+}
+
+func (d *DataLakeMeasure) SetSchemaVersion(schemaVersion string) {
+       d.SchemaVersion = schemaVersion
+}

Review Comment:
   It's not like Java. We have made these fields public accessible. We don't 
need to implement the `Get` and `Set` methods for them.



-- 
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