damondouglas commented on code in PR #23417: URL: https://github.com/apache/beam/pull/23417#discussion_r984841890
########## learning/tour-of-beam/frontend/lib/repositories/client/client.dart: ########## @@ -0,0 +1,26 @@ +/* + * 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. + */ + +import '../../models/content_tree.dart'; +import '../models/get_sdks_response.dart'; + +abstract class TobClient { Review Comment: I like that we are using an abstract class to encapsulate connection to the backend service. However, is there any way we can follow the same client/service model we use with the current Beam playground? ########## learning/tour-of-beam/frontend/lib/repositories/client/cloud_functions_client.dart: ########## @@ -0,0 +1,50 @@ +/* + * 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. + */ + +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +import '../../models/content_tree.dart'; +import '../models/get_sdks_response.dart'; +import 'client.dart'; + +class CloudFunctionsTobClient extends TobClient { + @override + Future<GetSdksResponse> getSdks() async { + final json = await http.get( + Uri.parse( + 'https://us-central1-tour-of-beam-2.cloudfunctions.net/getSdkList', Review Comment: May we consider not hard-coding URLs in the codebase? ########## learning/tour-of-beam/frontend/lib/repositories/models/group.dart: ########## @@ -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. + */ + +import 'package:json_annotation/json_annotation.dart'; + +import 'node.dart'; + +part 'group.g.dart'; Review Comment: May we version control this file? For example, the official flutter samples shows version controlling the generated json_serialization along with the base class: https://github.com/flutter/samples/tree/main/jsonexample/lib/json_serializable ########## learning/tour-of-beam/frontend/lib/repositories/client/cloud_functions_client.dart: ########## @@ -0,0 +1,50 @@ +/* + * 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. + */ + +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +import '../../models/content_tree.dart'; +import '../models/get_sdks_response.dart'; +import 'client.dart'; + +class CloudFunctionsTobClient extends TobClient { + @override + Future<GetSdksResponse> getSdks() async { + final json = await http.get( + Uri.parse( + 'https://us-central1-tour-of-beam-2.cloudfunctions.net/getSdkList', + ), + ); + + final map = jsonDecode(utf8.decode(json.bodyBytes)) as Map<String, dynamic>; + return GetSdksResponse.fromJson(map); + } + + @override + Future<ContentTreeModel> getContentTree() async { + final json = await http.get( + Uri.parse( + 'https://us-central1-tour-of-beam-2.cloudfunctions.net/getContentTree?sdk=Python', Review Comment: May we consider not hard-coding URLs in the codebase? -- 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]
