import 'package:softplayer_dart_proto/main.dart'; import 'package:softplayer_web/api/grpc/creds.dart'; class EnvironmentLocalData { EnvironmentLocalData({ required this.uuid, required this.token, }); String uuid; String token; } class EnvironmentsGrpc { // final GrpcWebClientChannel channel; final EnvironmentsClient envStub; // Init the grpc channel for environments EnvironmentsGrpc(channel) : envStub = EnvironmentsClient(channel); // Get environments from the API Future get(String name, SoftplayerCreds creds) async { final request = GetOptions( name: EnvironmentName(name: name), ownerId: OwnerId(uuid: creds.uuid), token: Token(token: creds.token), ); try { final response = await envStub.get(request); return response; } catch (e) { rethrow; } } Stream> list(SoftplayerCreds creds) async* { List envs = []; try { await for (var feature in envStub.list( ListOptions( ownerId: OwnerId(uuid: creds.uuid), token: Token(token: creds.token), ), )) { envs.add(EnvironmentFull( data: feature.data, name: feature.name, )); } } catch (e) { rethrow; } yield envs; } }