diff --git a/packages/celest_auth/lib/src/auth_impl.dart b/packages/celest_auth/lib/src/auth_impl.dart index c661bb36..702df1ee 100644 --- a/packages/celest_auth/lib/src/auth_impl.dart +++ b/packages/celest_auth/lib/src/auth_impl.dart @@ -72,7 +72,7 @@ final class AuthImpl implements Auth { return const Unauthenticated(); } try { - final user = await cloud.users.get('me'); + final user = await cloud.users.get('users/me'); initialState = Authenticated(user: user.toCelest()); } on UnauthorizedException { initialState = const Unauthenticated(); diff --git a/packages/celest_cloud/lib/celest_cloud.dart b/packages/celest_cloud/lib/celest_cloud.dart index 859f41f4..f686675a 100644 --- a/packages/celest_cloud/lib/celest_cloud.dart +++ b/packages/celest_cloud/lib/celest_cloud.dart @@ -3,7 +3,13 @@ export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; export 'src/cloud/authentication/session_state.dart'; export 'src/cloud/cloud.dart'; export 'src/proto.dart' - show Organization, CreateOrganizationMetadata, OperationMetadata; + show + Organization, + Organization_State, + CreateOrganizationMetadata, + OperationMetadata, + Project, + Project_State; export 'src/proto/celest/cloud/auth/v1alpha1/authentication.pb.dart' show ClientType; export 'src/proto/celest/cloud/auth/v1alpha1/users.pb.dart' diff --git a/packages/celest_cloud/lib/src/cloud/authentication/authentication_protocol.http.dart b/packages/celest_cloud/lib/src/cloud/authentication/authentication_protocol.http.dart index 444b78e0..779f978d 100644 --- a/packages/celest_cloud/lib/src/cloud/authentication/authentication_protocol.http.dart +++ b/packages/celest_cloud/lib/src/cloud/authentication/authentication_protocol.http.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:celest_cloud/src/cloud/authentication/authentication_protocol.dart'; import 'package:celest_cloud/src/cloud/base/base_protocol.dart'; +import 'package:celest_cloud/src/cloud/cloud.dart'; import 'package:celest_cloud/src/proto/celest/cloud/auth/v1alpha1/authentication.pb.dart'; import 'package:http/http.dart' as http; @@ -25,7 +26,9 @@ final class AuthenticationProtocolHttp }; final uri = _baseUri.replace(path: path); final req = http.Request('POST', uri) - ..body = jsonEncode(request.toProto3Json()) + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -36,15 +39,21 @@ final class AuthenticationProtocolHttp body: body, ); } - return Session()..mergeFromProto3Json(jsonDecode(body)); + return Session() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override Future continueSession(ContinueSessionRequest request) async { - final path = '/v1alpha1/auth/sessions/${request.sessionId}:continueSession'; + final path = '/v1alpha1/auth/sessions:continueSession'; final uri = _baseUri.replace(path: path); final req = http.Request('POST', uri) - ..body = jsonEncode(request.toProto3Json()) + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -55,15 +64,21 @@ final class AuthenticationProtocolHttp body: body, ); } - return Session()..mergeFromProto3Json(jsonDecode(body)); + return Session() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override Future endSession(EndSessionRequest request) async { - const path = '/v1alpha1/auth:endSession'; + const path = '/v1alpha1/auth/sessions:endSession'; final uri = _baseUri.replace(path: path); final req = http.Request('POST', uri) - ..body = jsonEncode(request.toProto3Json()) + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -74,6 +89,10 @@ final class AuthenticationProtocolHttp body: body, ); } - return EndSessionResponse()..mergeFromProto3Json(jsonDecode(body)); + return EndSessionResponse() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } } diff --git a/packages/celest_cloud/lib/src/cloud/cloud.dart b/packages/celest_cloud/lib/src/cloud/cloud.dart index ccbdfd88..c2657a70 100644 --- a/packages/celest_cloud/lib/src/cloud/cloud.dart +++ b/packages/celest_cloud/lib/src/cloud/cloud.dart @@ -1,14 +1,16 @@ -import 'package:celest_cloud/celest_cloud.dart'; import 'package:celest_cloud/src/cloud/authentication/authentication.dart'; import 'package:celest_cloud/src/cloud/cloud_protocol.dart'; import 'package:celest_cloud/src/cloud/cloud_protocol.grpc.dart'; import 'package:celest_cloud/src/cloud/cloud_protocol.http.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations.dart'; +import 'package:celest_cloud/src/cloud/projects/projects.dart'; import 'package:celest_cloud/src/cloud/users/users.dart'; +import 'package:celest_cloud/src/proto.dart'; import 'package:celest_core/_internal.dart'; import 'package:http/http.dart' as http; import 'package:logging/logging.dart'; import 'package:os_detect/os_detect.dart' as os; +import 'package:protobuf/protobuf.dart'; class CelestCloud { CelestCloud({ @@ -49,6 +51,16 @@ class CelestCloud { ? ClientType.LINUX : ClientType.CLIENT_TYPE_UNSPECIFIED; + static final typeRegistry = TypeRegistry([ + Empty(), + OperationMetadata(), + Organization(), + CreateOrganizationMetadata(), + Project(), + CreateEnvironmentMetadata(), + DeploymentOperationMetadata(), + ]); + final CloudProtocol _protocol; final ClientType _clientType; final Logger _logger; @@ -69,4 +81,10 @@ class CelestCloud { protocol: _protocol.users, logger: _logger, ); + + late final Projects projects = Projects( + protocol: _protocol.projects, + operations: _protocol.operations, + logger: _logger, + ); } diff --git a/packages/celest_cloud/lib/src/cloud/cloud_protocol.dart b/packages/celest_cloud/lib/src/cloud/cloud_protocol.dart index 15faf156..f4274db7 100644 --- a/packages/celest_cloud/lib/src/cloud/cloud_protocol.dart +++ b/packages/celest_cloud/lib/src/cloud/cloud_protocol.dart @@ -1,6 +1,7 @@ import 'package:celest_cloud/src/cloud/authentication/authentication_protocol.dart'; import 'package:celest_cloud/src/cloud/operations/operations_protocol.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations_protocol.dart'; +import 'package:celest_cloud/src/cloud/projects/projects_protocol.dart'; import 'package:celest_cloud/src/cloud/users/users_protocol.dart'; abstract interface class CloudProtocol { @@ -8,4 +9,5 @@ abstract interface class CloudProtocol { OrganizationsProtocol get organizations; OperationsProtocol get operations; UsersProtocol get users; + ProjectsProtocol get projects; } diff --git a/packages/celest_cloud/lib/src/cloud/cloud_protocol.grpc.dart b/packages/celest_cloud/lib/src/cloud/cloud_protocol.grpc.dart index 817b7720..5e3fdff5 100644 --- a/packages/celest_cloud/lib/src/cloud/cloud_protocol.grpc.dart +++ b/packages/celest_cloud/lib/src/cloud/cloud_protocol.grpc.dart @@ -6,6 +6,8 @@ import 'package:celest_cloud/src/cloud/operations/operations_protocol.dart'; import 'package:celest_cloud/src/cloud/operations/operations_protocol.grpc.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations_protocol.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations_protocol.grpc.dart'; +import 'package:celest_cloud/src/cloud/projects/projects_protocol.dart'; +import 'package:celest_cloud/src/cloud/projects/projects_protocol.grpc.dart'; import 'package:celest_cloud/src/cloud/users/users_protocol.dart'; import 'package:celest_cloud/src/cloud/users/users_protocol.grpc.dart'; import 'package:celest_core/_internal.dart'; @@ -60,4 +62,8 @@ final class CloudProtocolGrpc implements CloudProtocol { @override late final UsersProtocol users = UsersProtocolGrpc(_channel, interceptors: _interceptors); + + @override + late final ProjectsProtocol projects = + ProjectsProtocolGrpc(_channel, interceptors: _interceptors); } diff --git a/packages/celest_cloud/lib/src/cloud/cloud_protocol.http.dart b/packages/celest_cloud/lib/src/cloud/cloud_protocol.http.dart index d86190eb..a112f1ac 100644 --- a/packages/celest_cloud/lib/src/cloud/cloud_protocol.http.dart +++ b/packages/celest_cloud/lib/src/cloud/cloud_protocol.http.dart @@ -1,11 +1,12 @@ import 'package:celest_cloud/src/cloud/authentication/authentication_protocol.dart'; import 'package:celest_cloud/src/cloud/authentication/authentication_protocol.http.dart'; -import 'package:celest_cloud/src/cloud/base/base_http_client.dart'; import 'package:celest_cloud/src/cloud/cloud_protocol.dart'; import 'package:celest_cloud/src/cloud/operations/operations_protocol.dart'; import 'package:celest_cloud/src/cloud/operations/operations_protocol.http.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations_protocol.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations_protocol.http.dart'; +import 'package:celest_cloud/src/cloud/projects/projects_protocol.dart'; +import 'package:celest_cloud/src/cloud/projects/projects_protocol.http.dart'; import 'package:celest_cloud/src/cloud/users/users_protocol.dart'; import 'package:celest_cloud/src/cloud/users/users_protocol.http.dart'; import 'package:celest_core/_internal.dart'; @@ -18,8 +19,8 @@ final class CloudProtocolHttp implements CloudProtocol { required Authenticator authenticator, http.Client? httpClient, Logger? logger, - }) : _client = AuthenticatingHttpClient( - client: httpClient ?? http.Client(), + }) : _client = CelestHttpClient( + baseClient: httpClient, authenticator: authenticator, logger: logger, ), @@ -51,4 +52,10 @@ final class CloudProtocolHttp implements CloudProtocol { uri: _baseUri, httpClient: _client, ); + + @override + late final ProjectsProtocol projects = ProjectsProtocolHttp( + uri: _baseUri, + httpClient: _client, + ); } diff --git a/packages/celest_cloud/lib/src/cloud/operations/operations_protocol.http.dart b/packages/celest_cloud/lib/src/cloud/operations/operations_protocol.http.dart index b53405df..36b9ab86 100644 --- a/packages/celest_cloud/lib/src/cloud/operations/operations_protocol.http.dart +++ b/packages/celest_cloud/lib/src/cloud/operations/operations_protocol.http.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:celest_cloud/src/cloud/base/base_protocol.dart'; +import 'package:celest_cloud/src/cloud/cloud.dart'; import 'package:celest_cloud/src/cloud/operations/operations_protocol.dart'; import 'package:celest_cloud/src/proto.dart'; import 'package:http/http.dart' as http; @@ -22,7 +23,9 @@ final class OperationsProtocolHttp final path = '/v1alpha1/${request.name}:cancel'; final url = _baseUri.replace(path: path); final req = http.Request('POST', url) - ..body = jsonEncode(request.toProto3Json()) + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -50,12 +53,19 @@ final class OperationsProtocolHttp body: body, ); } - return Operation()..mergeFromProto3Json(jsonDecode(body)); + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override Future list(ListOperationsRequest request) async { - const path = '/v1alpha1/operations'; + if (request.name == '') { + throw ArgumentError.value(request.name, 'name', 'must not be empty'); + } + final path = '/v1alpha1/${request.name}/operations'; final url = _baseUri.replace( path: path, queryParameters: { @@ -75,6 +85,10 @@ final class OperationsProtocolHttp body: body, ); } - return ListOperationsResponse()..mergeFromProto3Json(jsonDecode(body)); + return ListOperationsResponse() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } } diff --git a/packages/celest_cloud/lib/src/cloud/organizations/organizations.dart b/packages/celest_cloud/lib/src/cloud/organizations/organizations.dart index 7254128f..e76223ba 100644 --- a/packages/celest_cloud/lib/src/cloud/organizations/organizations.dart +++ b/packages/celest_cloud/lib/src/cloud/organizations/organizations.dart @@ -1,7 +1,7 @@ import 'package:celest_cloud/src/cloud/base/base_service.dart'; import 'package:celest_cloud/src/cloud/operations/operations_protocol.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations_protocol.dart'; -import 'package:celest_cloud/src/proto.dart' hide OperationState; +import 'package:celest_cloud/src/proto.dart' hide OperationState, Duration; import 'package:celest_cloud/src/proto/operations.dart'; import 'package:celest_core/celest_core.dart'; import 'package:logging/logging.dart'; @@ -19,12 +19,12 @@ final class Organizations with BaseService { final OrganizationsProtocol _protocol; final OperationsProtocol _operations; - Stream> create({ + Future create({ String? parent, String? organizationId, Organization? organization, bool validateOnly = false, - }) async* { + }) async { final request = CreateOrganizationRequest( parent: parent, organizationId: organizationId, @@ -36,13 +36,11 @@ final class Organizations with BaseService { request: request, action: _protocol.create, ); - yield* streamOperation( - 'Organizations.Create', - operation: operation, + return operation.wait( operations: _operations, logger: logger, - metadata: CreateOrganizationMetadata(), response: Organization(), + timeout: const Duration(minutes: 1), ); } @@ -65,6 +63,7 @@ final class Organizations with BaseService { String? pageToken, String? filter, String? orderBy, + bool showDeleted = false, }) async { final request = ListOrganizationsRequest( parent: parent, @@ -72,6 +71,7 @@ final class Organizations with BaseService { pageToken: pageToken, filter: filter, orderBy: orderBy, + showDeleted: showDeleted, ); return run( 'Organizations.List', @@ -80,12 +80,12 @@ final class Organizations with BaseService { ); } - Stream> update({ + Future update({ required Organization organization, FieldMask? updateMask, bool allowMissing = false, bool validateOnly = false, - }) async* { + }) async { final request = UpdateOrganizationRequest( organization: organization, updateMask: updateMask, @@ -97,39 +97,46 @@ final class Organizations with BaseService { request: request, action: _protocol.update, ); - yield* streamOperation( - 'Organizations.Update', - operation: operation, + return operation.wait( operations: _operations, logger: logger, - metadata: OperationMetadata(), response: Organization(), + timeout: const Duration(minutes: 1), ); } - Stream> delete(String name) async* { - final request = DeleteOrganizationRequest(name: name); + Future delete( + String name, { + String? etag, + bool allowMissing = false, + bool validateOnly = false, + bool force = false, + }) async { + final request = DeleteOrganizationRequest( + name: name, + force: force, + etag: etag, + allowMissing: allowMissing, + validateOnly: validateOnly, + ); final operation = await run( 'Organizations.Delete', request: request, action: _protocol.delete, ); - yield* streamOperation( - 'Organizations.Delete', - operation: operation, + return operation.wait( operations: _operations, logger: logger, - metadata: OperationMetadata(), response: Empty(), ); } - Stream> rename({ + Future rename({ required String name, required String newAlias, String? etag, bool validateOnly = false, - }) async* { + }) async { final request = RenameOrganizationRequest( name: name, organizationId: newAlias, @@ -141,12 +148,9 @@ final class Organizations with BaseService { request: request, action: _protocol.rename, ); - yield* streamOperation( - 'Organizations.Rename', - operation: operation, + return operation.wait( operations: _operations, logger: logger, - metadata: OperationMetadata(), response: Organization(), ); } diff --git a/packages/celest_cloud/lib/src/cloud/organizations/organizations_protocol.http.dart b/packages/celest_cloud/lib/src/cloud/organizations/organizations_protocol.http.dart index ca512e6f..08e6bb3d 100644 --- a/packages/celest_cloud/lib/src/cloud/organizations/organizations_protocol.http.dart +++ b/packages/celest_cloud/lib/src/cloud/organizations/organizations_protocol.http.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:celest_cloud/src/cloud/base/base_protocol.dart'; +import 'package:celest_cloud/src/cloud/cloud.dart'; import 'package:celest_cloud/src/cloud/organizations/organizations_protocol.dart'; import 'package:celest_cloud/src/proto/celest/cloud/v1alpha1/organizations.pb.dart'; import 'package:celest_cloud/src/proto/google/longrunning/operations.pb.dart'; @@ -32,7 +33,9 @@ final class OrganizationsProtocolHttp }, ); final req = http.Request('POST', uri) - ..body = jsonEncode(request.organization.toProto3Json()) + ..body = jsonEncode(request.organization.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -43,7 +46,11 @@ final class OrganizationsProtocolHttp body: body, ); } - return Operation()..mergeFromProto3Json(jsonDecode(body)); + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -61,7 +68,9 @@ final class OrganizationsProtocolHttp }, ); final req = http.Request('DELETE', uri) - ..body = request.writeToJson() + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -72,7 +81,13 @@ final class OrganizationsProtocolHttp body: body, ); } - return Operation()..mergeFromProto3Json(jsonDecode(body)); + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + // JSON for Empty has `value` field for some reason. + ignoreUnknownFields: true, + ); } @override @@ -89,7 +104,11 @@ final class OrganizationsProtocolHttp body: body, ); } - return Organization()..mergeFromProto3Json(jsonDecode(body)); + return Organization() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -104,6 +123,8 @@ final class OrganizationsProtocolHttp if (request.hasPageToken()) 'pageToken': request.pageToken, if (request.hasFilter()) 'filter': request.filter, if (request.hasOrderBy()) 'orderBy': request.orderBy, + if (request.hasShowDeleted()) + 'showDeleted': request.showDeleted.toString(), }, ); final req = http.Request('GET', uri) @@ -116,7 +137,11 @@ final class OrganizationsProtocolHttp body: body, ); } - return ListOrganizationsResponse()..mergeFromProto3Json(jsonDecode(body)); + return ListOrganizationsResponse() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -134,7 +159,9 @@ final class OrganizationsProtocolHttp }, ); final req = http.Request('PATCH', uri) - ..body = jsonEncode(request.organization.toProto3Json()) + ..body = jsonEncode(request.organization.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -145,7 +172,11 @@ final class OrganizationsProtocolHttp body: body, ); } - return Operation()..mergeFromProto3Json(jsonDecode(body)); + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -153,7 +184,9 @@ final class OrganizationsProtocolHttp final path = '/v1alpha1/${request.name}:rename'; final uri = _baseUri.replace(path: path); final req = http.Request('POST', uri) - ..body = jsonEncode(request.toProto3Json()) + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -164,6 +197,10 @@ final class OrganizationsProtocolHttp body: body, ); } - return Operation()..mergeFromProto3Json(jsonDecode(body)); + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } } diff --git a/packages/celest_cloud/lib/src/cloud/projects/projects.dart b/packages/celest_cloud/lib/src/cloud/projects/projects.dart new file mode 100644 index 00000000..e2711af3 --- /dev/null +++ b/packages/celest_cloud/lib/src/cloud/projects/projects.dart @@ -0,0 +1,161 @@ +import 'package:celest_cloud/src/cloud/base/base_service.dart'; +import 'package:celest_cloud/src/cloud/operations/operations_protocol.dart'; +import 'package:celest_cloud/src/cloud/projects/projects_protocol.dart'; +import 'package:celest_cloud/src/proto.dart' hide OperationState; +import 'package:celest_cloud/src/proto/operations.dart'; +import 'package:celest_core/celest_core.dart'; +import 'package:logging/logging.dart'; + +final class Projects with BaseService { + Projects({ + required ProjectsProtocol protocol, + required OperationsProtocol operations, + this.logger, + }) : _protocol = protocol, + _operations = operations; + + @override + final Logger? logger; + final ProjectsProtocol _protocol; + final OperationsProtocol _operations; + + Future create({ + required String parent, + required String projectId, + required String displayName, + required String region, + Map? annotations, + bool validateOnly = false, + }) async { + final request = CreateProjectRequest( + parent: parent, + projectId: projectId, + project: Project( + displayName: displayName, + region: region, + annotations: annotations, + ), + validateOnly: validateOnly, + ); + final operation = await run( + 'Projects.Create', + request: request, + action: _protocol.create, + ); + return operation.wait( + operations: _operations, + response: Project(), + logger: logger, + ); + } + + Future get(String name) async { + try { + final request = GetProjectRequest(name: name); + return await run( + 'Projects.Get', + request: request, + action: _protocol.get, + ); + } on NotFoundException { + return null; + } + } + + Future list({ + String? parent, + int? pageSize, + String? pageToken, + String? filter, + String? orderBy, + bool showDeleted = false, + }) async { + final request = ListProjectsRequest( + parent: parent, + pageSize: pageSize, + pageToken: pageToken, + filter: filter, + orderBy: orderBy, + showDeleted: showDeleted, + ); + return run( + 'Projects.List', + request: request, + action: _protocol.list, + ); + } + + Future update({ + required Project project, + FieldMask? updateMask, + bool allowMissing = false, + bool validateOnly = false, + }) async { + final request = UpdateProjectRequest( + project: project, + updateMask: updateMask, + validateOnly: validateOnly, + allowMissing: allowMissing, + ); + final operation = await run( + 'Projects.Update', + request: request, + action: _protocol.update, + ); + return operation.wait( + operations: _operations, + logger: logger, + response: Project(), + ); + } + + Future delete( + String name, { + String? etag, + bool allowMissing = false, + bool validateOnly = false, + bool force = false, + }) async { + final request = DeleteProjectRequest( + name: name, + etag: etag, + allowMissing: allowMissing, + validateOnly: validateOnly, + force: force, + ); + final operation = await run( + 'Projects.Delete', + request: request, + action: _protocol.delete, + ); + return operation.wait( + operations: _operations, + logger: logger, + response: Empty(), + ); + } + + Future rename({ + required String name, + required String newAlias, + String? etag, + bool validateOnly = false, + }) async { + final request = RenameProjectRequest( + name: name, + projectId: newAlias, + etag: etag, + validateOnly: validateOnly, + ); + final operation = await run( + 'Projects.Rename', + request: request, + action: _protocol.rename, + ); + return operation.wait( + operations: _operations, + logger: logger, + response: Project(), + ); + } +} diff --git a/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.dart b/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.dart new file mode 100644 index 00000000..c0afd8b5 --- /dev/null +++ b/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.dart @@ -0,0 +1,10 @@ +import 'package:celest_cloud/src/proto.dart'; + +abstract interface class ProjectsProtocol { + Future create(CreateProjectRequest request); + Future get(GetProjectRequest request); + Future list(ListProjectsRequest request); + Future update(UpdateProjectRequest request); + Future delete(DeleteProjectRequest request); + Future rename(RenameProjectRequest request); +} diff --git a/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.grpc.dart b/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.grpc.dart new file mode 100644 index 00000000..406bd37d --- /dev/null +++ b/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.grpc.dart @@ -0,0 +1,42 @@ +import 'package:celest_cloud/src/cloud/projects/projects_protocol.dart'; +import 'package:celest_cloud/src/grpc.dart'; +import 'package:grpc/grpc.dart'; + +final class ProjectsProtocolGrpc implements ProjectsProtocol { + ProjectsProtocolGrpc( + ClientChannel channel, { + List? interceptors, + }) : _client = ProjectsClient(channel, interceptors: interceptors); + + final ProjectsClient _client; + + @override + Future create(CreateProjectRequest request) { + return _client.createProject(request); + } + + @override + Future delete(DeleteProjectRequest request) { + return _client.deleteProject(request); + } + + @override + Future get(GetProjectRequest request) { + return _client.getProject(request); + } + + @override + Future list(ListProjectsRequest request) { + return _client.listProjects(request); + } + + @override + Future update(UpdateProjectRequest request) { + return _client.updateProject(request); + } + + @override + Future rename(RenameProjectRequest request) { + return _client.renameProject(request); + } +} diff --git a/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.http.dart b/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.http.dart new file mode 100644 index 00000000..a193bc71 --- /dev/null +++ b/packages/celest_cloud/lib/src/cloud/projects/projects_protocol.http.dart @@ -0,0 +1,203 @@ +import 'dart:convert'; + +import 'package:celest_cloud/src/cloud/base/base_protocol.dart'; +import 'package:celest_cloud/src/cloud/cloud.dart'; +import 'package:celest_cloud/src/cloud/projects/projects_protocol.dart'; +import 'package:celest_cloud/src/proto/celest/cloud/v1alpha1/projects.pb.dart'; +import 'package:celest_cloud/src/proto/google/longrunning/operations.pb.dart'; +import 'package:http/http.dart' as http; + +final class ProjectsProtocolHttp with BaseProtocol implements ProjectsProtocol { + ProjectsProtocolHttp({ + required Uri uri, + http.Client? httpClient, + }) : _client = httpClient ?? http.Client(), + _baseUri = uri; + + final http.Client _client; + final Uri _baseUri; + + @override + Future create(CreateProjectRequest request) async { + final path = '/v1alpha1/${request.parent}/projects'; + final uri = _baseUri.replace( + path: path, + queryParameters: { + if (request.hasParent()) 'parent': request.parent, + if (request.hasProjectId()) 'projectId': request.projectId, + if (request.hasValidateOnly()) + 'validateOnly': request.validateOnly.toString(), + }, + ); + final req = http.Request('POST', uri) + ..body = jsonEncode(request.project.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) + ..headers['content-type'] = 'application/json' + ..headers['accept'] = 'application/json'; + final res = await _client.send(req); + final body = await res.stream.bytesToString(); + if (res.statusCode != 200) { + httpError( + statusCode: res.statusCode, + body: body, + ); + } + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); + } + + @override + Future delete(DeleteProjectRequest request) async { + final path = '/v1alpha1/${request.name}'; + final uri = _baseUri.replace( + path: path, + queryParameters: { + if (request.hasForce()) 'force': request.force.toString(), + if (request.hasEtag()) 'etag': request.etag, + if (request.hasAllowMissing()) + 'allowMissing': request.allowMissing.toString(), + if (request.hasValidateOnly()) + 'validateOnly': request.validateOnly.toString(), + }, + ); + final req = http.Request('DELETE', uri) + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) + ..headers['content-type'] = 'application/json' + ..headers['accept'] = 'application/json'; + final res = await _client.send(req); + final body = await res.stream.bytesToString(); + if (res.statusCode != 200) { + httpError( + statusCode: res.statusCode, + body: body, + ); + } + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + // JSON for Empty has `value` field for some reason. + ignoreUnknownFields: true, + ); + } + + @override + Future get(GetProjectRequest request) async { + final path = '/v1alpha1/${request.name}'; + final uri = _baseUri.replace(path: path); + final req = http.Request('GET', uri) + ..headers['accept'] = 'application/json'; + final res = await _client.send(req); + final body = await res.stream.bytesToString(); + if (res.statusCode != 200) { + httpError( + statusCode: res.statusCode, + body: body, + ); + } + return Project() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); + } + + @override + Future list( + ListProjectsRequest request, + ) async { + final path = '/v1alpha1/${request.parent}/projects'; + final uri = _baseUri.replace( + path: path, + queryParameters: { + if (request.hasPageSize()) 'pageSize': request.pageSize.toString(), + if (request.hasPageToken()) 'pageToken': request.pageToken, + if (request.hasFilter()) 'filter': request.filter, + if (request.hasOrderBy()) 'orderBy': request.orderBy, + if (request.hasShowDeleted()) + 'showDeleted': request.showDeleted.toString(), + }, + ); + final req = http.Request('GET', uri) + ..headers['accept'] = 'application/json'; + final res = await _client.send(req); + final body = await res.stream.bytesToString(); + if (res.statusCode != 200) { + httpError( + statusCode: res.statusCode, + body: body, + ); + } + return ListProjectsResponse() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); + } + + @override + Future update(UpdateProjectRequest request) async { + final path = '/v1alpha1/${request.project.name}'; + final uri = _baseUri.replace( + path: path, + queryParameters: { + if (request.hasUpdateMask()) + 'updateMask': request.updateMask.paths.join(','), + if (request.hasAllowMissing()) + 'allowMissing': request.allowMissing.toString(), + if (request.hasValidateOnly()) + 'validateOnly': request.validateOnly.toString(), + }, + ); + final req = http.Request('PATCH', uri) + ..body = jsonEncode(request.project.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) + ..headers['content-type'] = 'application/json' + ..headers['accept'] = 'application/json'; + final res = await _client.send(req); + final body = await res.stream.bytesToString(); + if (res.statusCode != 200) { + httpError( + statusCode: res.statusCode, + body: body, + ); + } + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); + } + + @override + Future rename(RenameProjectRequest request) async { + final path = '/v1alpha1/${request.name}:rename'; + final uri = _baseUri.replace(path: path); + final req = http.Request('POST', uri) + ..body = jsonEncode(request.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) + ..headers['content-type'] = 'application/json' + ..headers['accept'] = 'application/json'; + final res = await _client.send(req); + final body = await res.stream.bytesToString(); + if (res.statusCode != 200) { + httpError( + statusCode: res.statusCode, + body: body, + ); + } + return Operation() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); + } +} diff --git a/packages/celest_cloud/lib/src/cloud/users/users_protocol.http.dart b/packages/celest_cloud/lib/src/cloud/users/users_protocol.http.dart index 3e420a76..4554c2c8 100644 --- a/packages/celest_cloud/lib/src/cloud/users/users_protocol.http.dart +++ b/packages/celest_cloud/lib/src/cloud/users/users_protocol.http.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:celest_cloud/celest_cloud.dart'; import 'package:celest_cloud/src/cloud/base/base_protocol.dart'; import 'package:celest_cloud/src/cloud/users/users_protocol.dart'; import 'package:celest_cloud/src/proto/celest/cloud/auth/v1alpha1/users.pb.dart'; @@ -31,7 +32,11 @@ final class UsersProtocolHttp with BaseProtocol implements UsersProtocol { body: body, ); } - return User()..mergeFromProto3Json(jsonDecode(body)); + return User() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -49,7 +54,11 @@ final class UsersProtocolHttp with BaseProtocol implements UsersProtocol { body: body, ); } - return UserMembership()..mergeFromProto3Json(jsonDecode(body)); + return UserMembership() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -78,7 +87,11 @@ final class UsersProtocolHttp with BaseProtocol implements UsersProtocol { body: body, ); } - return ListUsersResponse()..mergeFromProto3Json(jsonDecode(body)); + return ListUsersResponse() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -105,7 +118,11 @@ final class UsersProtocolHttp with BaseProtocol implements UsersProtocol { body: body, ); } - return ListUserMembershipsResponse()..mergeFromProto3Json(jsonDecode(body)); + return ListUserMembershipsResponse() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override @@ -121,7 +138,9 @@ final class UsersProtocolHttp with BaseProtocol implements UsersProtocol { }, ); final req = http.Request('PATCH', url) - ..body = jsonEncode(request.user.toProto3Json()) + ..body = jsonEncode(request.user.toProto3Json( + typeRegistry: CelestCloud.typeRegistry, + )) ..headers['content-type'] = 'application/json' ..headers['accept'] = 'application/json'; final res = await _client.send(req); @@ -132,7 +151,11 @@ final class UsersProtocolHttp with BaseProtocol implements UsersProtocol { body: body, ); } - return User()..mergeFromProto3Json(jsonDecode(body)); + return User() + ..mergeFromProto3Json( + jsonDecode(body), + typeRegistry: CelestCloud.typeRegistry, + ); } @override diff --git a/packages/celest_cloud/lib/src/grpc.dart b/packages/celest_cloud/lib/src/grpc.dart index f380c0dc..edb582e9 100644 --- a/packages/celest_cloud/lib/src/grpc.dart +++ b/packages/celest_cloud/lib/src/grpc.dart @@ -7,12 +7,14 @@ export 'proto/celest/cloud/auth/v1alpha1/users.pbgrpc.dart'; export 'proto/celest/cloud/v1alpha1/deployments.pbgrpc.dart'; export 'proto/celest/cloud/v1alpha1/environments.pbgrpc.dart'; export 'proto/celest/cloud/v1alpha1/functions.pbgrpc.dart'; +export 'proto/celest/cloud/v1alpha1/operations.pbgrpc.dart' + show OperationsClient; export 'proto/celest/cloud/v1alpha1/organizations.pbgrpc.dart'; export 'proto/celest/cloud/v1alpha1/projects.pbgrpc.dart'; /// GCP export 'proto/google/logging/v2/logging.pbgrpc.dart'; -export 'proto/google/longrunning/operations.pbgrpc.dart'; +export 'proto/google/longrunning/operations.pb.dart'; /// Helpers export 'proto/operations.dart'; diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/auth/v1alpha1/users.pbjson.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/auth/v1alpha1/users.pbjson.dart index 527bb083..2b5a5444 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/auth/v1alpha1/users.pbjson.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/auth/v1alpha1/users.pbjson.dart @@ -260,10 +260,9 @@ const GetUserRequest$json = { /// Descriptor for `GetUserRequest`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List getUserRequestDescriptor = $convert.base64Decode( - 'Cg5HZXRVc2VyUmVxdWVzdBKcAQoEbmFtZRgBIAEoCUKHAeBBAvpBFwoVY2xvdWQuY2VsZXN0Lm' - 'Rldi9Vc2VyukhnugFkChh2YWxpZF91c2VyX3Jlc291cmNlX25hbWUSGmludmFsaWQgdXNlciBy' - 'ZXNvdXJjZSBuYW1lGix0aGlzID09ICdtZScgfHwgdGhpcy5tYXRjaGVzKCd1c2Vycy9bXi9dKy' - 'QnKVIEbmFtZQ=='); + 'Cg5HZXRVc2VyUmVxdWVzdBKLAQoEbmFtZRgBIAEoCUJ34EEC+kEXChVjbG91ZC5jZWxlc3QuZG' + 'V2L1VzZXK6SFe6AVQKGHZhbGlkX3VzZXJfcmVzb3VyY2VfbmFtZRIaaW52YWxpZCB1c2VyIHJl' + 'c291cmNlIG5hbWUaHHRoaXMubWF0Y2hlcygndXNlcnMvW14vXSskJylSBG5hbWU='); @$core.Deprecated('Use listUsersRequestDescriptor instead') const ListUsersRequest$json = { @@ -348,10 +347,11 @@ final $typed_data.Uint8List updateUserRequestDescriptor = $convert.base64Decode( 'ChFVcGRhdGVVc2VyUmVxdWVzdBI5CgR1c2VyGAEgASgLMiAuY2VsZXN0LmNsb3VkLmF1dGgudj' 'FhbHBoYTEuVXNlckID4EECUgR1c2VyEkAKC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnBy' 'b3RvYnVmLkZpZWxkTWFza0ID4EEBUgp1cGRhdGVNYXNrEigKDXZhbGlkYXRlX29ubHkYAyABKA' - 'hCA+BBAVIMdmFsaWRhdGVPbmx5OqwBukioARqlAQoQdmFsaWRfZmllbGRfbWFzaxIqYSBmaWVs' - 'ZCBtYXNrIHBhdGggbXVzdCBiZSB2YWxpZCBmb3IgYSB1c2VyGmV0aGlzLnVwZGF0ZV9tYXNrLn' - 'BhdGhzLmFsbChwYXRoLCBwYXRoIGluIFsnZ2l2ZW5fbmFtZScsICdmYW1pbHlfbmFtZScsICd0' - 'aW1lX3pvbmUnLCAnbGFuZ3VhZ2VfY29kZSddKQ=='); + 'hCA+BBAVIMdmFsaWRhdGVPbmx5OuEBukjdARraAQoQdmFsaWRfZmllbGRfbWFzaxJXdXBkYXRl' + 'X21hc2sgbWF5IG9ubHkgaW5jbHVkZTogJ2dpdmVuX25hbWUnLCAnZmFtaWx5X25hbWUnLCAndG' + 'ltZV96b25lJywgJ2xhbmd1YWdlX2NvZGUnGm10aGlzLnVwZGF0ZV9tYXNrLnBhdGhzLmFsbChw' + 'YXRoLCBwYXRoIGluIFsnbmFtZScsICdnaXZlbl9uYW1lJywgJ2ZhbWlseV9uYW1lJywgJ3RpbW' + 'Vfem9uZScsICdsYW5ndWFnZV9jb2RlJ10p'); @$core.Deprecated('Use deleteUserRequestDescriptor instead') const DeleteUserRequest$json = { @@ -381,12 +381,12 @@ const DeleteUserRequest$json = { /// Descriptor for `DeleteUserRequest`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List deleteUserRequestDescriptor = $convert.base64Decode( - 'ChFEZWxldGVVc2VyUmVxdWVzdBKcAQoEbmFtZRgBIAEoCUKHAeBBAvpBFwoVY2xvdWQuY2VsZX' - 'N0LmRldi9Vc2VyukhnugFkChh2YWxpZF91c2VyX3Jlc291cmNlX25hbWUSGmludmFsaWQgdXNl' - 'ciByZXNvdXJjZSBuYW1lGix0aGlzID09ICdtZScgfHwgdGhpcy5tYXRjaGVzKCd1c2Vycy9bXi' - '9dKyQnKVIEbmFtZRIXCgRldGFnGAIgASgJQgPgQQFSBGV0YWcSKAoNYWxsb3dfbWlzc2luZxgD' - 'IAEoCEID4EEBUgxhbGxvd01pc3NpbmcSKAoNdmFsaWRhdGVfb25seRgEIAEoCEID4EEBUgx2YW' - 'xpZGF0ZU9ubHkSGQoFZm9yY2UYBSABKAhCA+BBAVIFZm9yY2U='); + 'ChFEZWxldGVVc2VyUmVxdWVzdBKLAQoEbmFtZRgBIAEoCUJ34EEC+kEXChVjbG91ZC5jZWxlc3' + 'QuZGV2L1VzZXK6SFe6AVQKGHZhbGlkX3VzZXJfcmVzb3VyY2VfbmFtZRIaaW52YWxpZCB1c2Vy' + 'IHJlc291cmNlIG5hbWUaHHRoaXMubWF0Y2hlcygndXNlcnMvW14vXSskJylSBG5hbWUSFwoEZX' + 'RhZxgCIAEoCUID4EEBUgRldGFnEigKDWFsbG93X21pc3NpbmcYAyABKAhCA+BBAVIMYWxsb3dN' + 'aXNzaW5nEigKDXZhbGlkYXRlX29ubHkYBCABKAhCA+BBAVIMdmFsaWRhdGVPbmx5EhkKBWZvcm' + 'NlGAUgASgIQgPgQQFSBWZvcmNl'); @$core.Deprecated('Use userMembershipDescriptor instead') const UserMembership$json = { @@ -436,12 +436,12 @@ const ListUserMembershipsRequest$json = { /// Descriptor for `ListUserMembershipsRequest`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List listUserMembershipsRequestDescriptor = $convert.base64Decode( - 'ChpMaXN0VXNlck1lbWJlcnNoaXBzUmVxdWVzdBKhAQoGcGFyZW50GAEgASgJQogB4EEC+kEhEh' - '9jbG91ZC5jZWxlc3QuZGV2L1VzZXJNZW1iZXJzaGlwukheugFbCgx2YWxpZF9wYXJlbnQSHXBh' - 'cmVudCBtdXN0IGJlIGEgdmFsaWQgcGFyZW50Gix0aGlzID09ICdtZScgfHwgdGhpcy5tYXRjaG' - 'VzKCd1c2Vycy9bXi9dKyQnKVIGcGFyZW50EicKCXBhZ2Vfc2l6ZRgCIAEoBUIK4EEBukgEGgIo' - 'AFIIcGFnZVNpemUSIgoKcGFnZV90b2tlbhgDIAEoCUID4EEBUglwYWdlVG9rZW4SGwoGZmlsdG' - 'VyGAQgASgJQgPgQQFSBmZpbHRlcg=='); + 'ChpMaXN0VXNlck1lbWJlcnNoaXBzUmVxdWVzdBKQAQoGcGFyZW50GAEgASgJQnjgQQL6QSESH2' + 'Nsb3VkLmNlbGVzdC5kZXYvVXNlck1lbWJlcnNoaXC6SE66AUsKDHZhbGlkX3BhcmVudBIdcGFy' + 'ZW50IG11c3QgYmUgYSB2YWxpZCBwYXJlbnQaHHRoaXMubWF0Y2hlcygndXNlcnMvW14vXSskJy' + 'lSBnBhcmVudBInCglwYWdlX3NpemUYAiABKAVCCuBBAbpIBBoCKABSCHBhZ2VTaXplEiIKCnBh' + 'Z2VfdG9rZW4YAyABKAlCA+BBAVIJcGFnZVRva2VuEhsKBmZpbHRlchgEIAEoCUID4EEBUgZmaW' + 'x0ZXI='); @$core.Deprecated('Use listUserMembershipsResponseDescriptor instead') const ListUserMembershipsResponse$json = { diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pb.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pb.dart index bf35329f..7a36cb05 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pb.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pb.dart @@ -25,6 +25,7 @@ class PageToken extends $pb.GeneratedMessage { factory PageToken({ $fixnum.Int64? offset, $20.Timestamp? startTime, + $core.bool? showDeleted, }) { final $result = create(); if (offset != null) { @@ -33,6 +34,9 @@ class PageToken extends $pb.GeneratedMessage { if (startTime != null) { $result.startTime = startTime; } + if (showDeleted != null) { + $result.showDeleted = showDeleted; + } return $result; } PageToken._() : super(); @@ -51,6 +55,7 @@ class PageToken extends $pb.GeneratedMessage { ..aInt64(1, _omitFieldNames ? '' : 'offset') ..aOM<$20.Timestamp>(2, _omitFieldNames ? '' : 'startTime', subBuilder: $20.Timestamp.create) + ..aOB(3, _omitFieldNames ? '' : 'showDeleted') ..hasRequiredFields = false; @$core.Deprecated('Using this can add significant overhead to your binary. ' @@ -101,6 +106,19 @@ class PageToken extends $pb.GeneratedMessage { void clearStartTime() => clearField(2); @$pb.TagNumber(2) $20.Timestamp ensureStartTime() => $_ensure(1); + + /// Whether to show deleted items. + @$pb.TagNumber(3) + $core.bool get showDeleted => $_getBF(2); + @$pb.TagNumber(3) + set showDeleted($core.bool v) { + $_setBool(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasShowDeleted() => $_has(2); + @$pb.TagNumber(3) + void clearShowDeleted() => clearField(3); } const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pbjson.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pbjson.dart index c3b84bb4..07b334e5 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pbjson.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/common.pbjson.dart @@ -26,6 +26,7 @@ const PageToken$json = { '6': '.google.protobuf.Timestamp', '10': 'startTime' }, + {'1': 'show_deleted', '3': 3, '4': 1, '5': 8, '10': 'showDeleted'}, ], '7': {}, }; @@ -33,5 +34,5 @@ const PageToken$json = { /// Descriptor for `PageToken`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List pageTokenDescriptor = $convert.base64Decode( 'CglQYWdlVG9rZW4SFgoGb2Zmc2V0GAEgASgDUgZvZmZzZXQSOQoKc3RhcnRfdGltZRgCIAEoCz' - 'IaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBSCXN0YXJ0VGltZToQ+tLkkwIKEghJTlRFUk5B' - 'TA=='); + 'IaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBSCXN0YXJ0VGltZRIhCgxzaG93X2RlbGV0ZWQY' + 'AyABKAhSC3Nob3dEZWxldGVkOhD60uSTAgoSCElOVEVSTkFM'); diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/operations.pbgrpc.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/operations.pbgrpc.dart new file mode 100644 index 00000000..7fa9b003 --- /dev/null +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/operations.pbgrpc.dart @@ -0,0 +1,172 @@ +// +// Generated code. Do not modify. +// source: celest/cloud/v1alpha1/operations.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:async' as $async; +import 'dart:core' as $core; + +import 'package:grpc/service_api.dart' as $grpc; +import 'package:protobuf/protobuf.dart' as $pb; + +import '../../../google/longrunning/operations.pb.dart' as $2; +import '../../../google/protobuf/empty.pb.dart' as $1; + +export 'operations.pb.dart'; + +@$pb.GrpcServiceName('celest.cloud.v1alpha1.Operations') +class OperationsClient extends $grpc.Client { + static final _$listOperations = + $grpc.ClientMethod<$2.ListOperationsRequest, $2.ListOperationsResponse>( + '/celest.cloud.v1alpha1.Operations/ListOperations', + ($2.ListOperationsRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => + $2.ListOperationsResponse.fromBuffer(value)); + static final _$getOperation = + $grpc.ClientMethod<$2.GetOperationRequest, $2.Operation>( + '/celest.cloud.v1alpha1.Operations/GetOperation', + ($2.GetOperationRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => $2.Operation.fromBuffer(value)); + static final _$deleteOperation = + $grpc.ClientMethod<$2.DeleteOperationRequest, $1.Empty>( + '/celest.cloud.v1alpha1.Operations/DeleteOperation', + ($2.DeleteOperationRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => $1.Empty.fromBuffer(value)); + static final _$cancelOperation = + $grpc.ClientMethod<$2.CancelOperationRequest, $1.Empty>( + '/celest.cloud.v1alpha1.Operations/CancelOperation', + ($2.CancelOperationRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => $1.Empty.fromBuffer(value)); + static final _$waitOperation = + $grpc.ClientMethod<$2.WaitOperationRequest, $2.Operation>( + '/celest.cloud.v1alpha1.Operations/WaitOperation', + ($2.WaitOperationRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => $2.Operation.fromBuffer(value)); + + OperationsClient($grpc.ClientChannel channel, + {$grpc.CallOptions? options, + $core.Iterable<$grpc.ClientInterceptor>? interceptors}) + : super(channel, options: options, interceptors: interceptors); + + $grpc.ResponseFuture<$2.ListOperationsResponse> listOperations( + $2.ListOperationsRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$listOperations, request, options: options); + } + + $grpc.ResponseFuture<$2.Operation> getOperation( + $2.GetOperationRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$getOperation, request, options: options); + } + + $grpc.ResponseFuture<$1.Empty> deleteOperation( + $2.DeleteOperationRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$deleteOperation, request, options: options); + } + + $grpc.ResponseFuture<$1.Empty> cancelOperation( + $2.CancelOperationRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$cancelOperation, request, options: options); + } + + $grpc.ResponseFuture<$2.Operation> waitOperation( + $2.WaitOperationRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$waitOperation, request, options: options); + } +} + +@$pb.GrpcServiceName('celest.cloud.v1alpha1.Operations') +abstract class OperationsServiceBase extends $grpc.Service { + $core.String get $name => 'celest.cloud.v1alpha1.Operations'; + + OperationsServiceBase() { + $addMethod($grpc.ServiceMethod<$2.ListOperationsRequest, + $2.ListOperationsResponse>( + 'ListOperations', + listOperations_Pre, + false, + false, + ($core.List<$core.int> value) => + $2.ListOperationsRequest.fromBuffer(value), + ($2.ListOperationsResponse value) => value.writeToBuffer())); + $addMethod($grpc.ServiceMethod<$2.GetOperationRequest, $2.Operation>( + 'GetOperation', + getOperation_Pre, + false, + false, + ($core.List<$core.int> value) => + $2.GetOperationRequest.fromBuffer(value), + ($2.Operation value) => value.writeToBuffer())); + $addMethod($grpc.ServiceMethod<$2.DeleteOperationRequest, $1.Empty>( + 'DeleteOperation', + deleteOperation_Pre, + false, + false, + ($core.List<$core.int> value) => + $2.DeleteOperationRequest.fromBuffer(value), + ($1.Empty value) => value.writeToBuffer())); + $addMethod($grpc.ServiceMethod<$2.CancelOperationRequest, $1.Empty>( + 'CancelOperation', + cancelOperation_Pre, + false, + false, + ($core.List<$core.int> value) => + $2.CancelOperationRequest.fromBuffer(value), + ($1.Empty value) => value.writeToBuffer())); + $addMethod($grpc.ServiceMethod<$2.WaitOperationRequest, $2.Operation>( + 'WaitOperation', + waitOperation_Pre, + false, + false, + ($core.List<$core.int> value) => + $2.WaitOperationRequest.fromBuffer(value), + ($2.Operation value) => value.writeToBuffer())); + } + + $async.Future<$2.ListOperationsResponse> listOperations_Pre( + $grpc.ServiceCall call, + $async.Future<$2.ListOperationsRequest> request) async { + return listOperations(call, await request); + } + + $async.Future<$2.Operation> getOperation_Pre($grpc.ServiceCall call, + $async.Future<$2.GetOperationRequest> request) async { + return getOperation(call, await request); + } + + $async.Future<$1.Empty> deleteOperation_Pre($grpc.ServiceCall call, + $async.Future<$2.DeleteOperationRequest> request) async { + return deleteOperation(call, await request); + } + + $async.Future<$1.Empty> cancelOperation_Pre($grpc.ServiceCall call, + $async.Future<$2.CancelOperationRequest> request) async { + return cancelOperation(call, await request); + } + + $async.Future<$2.Operation> waitOperation_Pre($grpc.ServiceCall call, + $async.Future<$2.WaitOperationRequest> request) async { + return waitOperation(call, await request); + } + + $async.Future<$2.ListOperationsResponse> listOperations( + $grpc.ServiceCall call, $2.ListOperationsRequest request); + $async.Future<$2.Operation> getOperation( + $grpc.ServiceCall call, $2.GetOperationRequest request); + $async.Future<$1.Empty> deleteOperation( + $grpc.ServiceCall call, $2.DeleteOperationRequest request); + $async.Future<$1.Empty> cancelOperation( + $grpc.ServiceCall call, $2.CancelOperationRequest request); + $async.Future<$2.Operation> waitOperation( + $grpc.ServiceCall call, $2.WaitOperationRequest request); +} diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pb.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pb.dart index 326852e5..71d751eb 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pb.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pb.dart @@ -16,6 +16,9 @@ import 'package:protobuf/protobuf.dart' as $pb; import '../../../google/protobuf/field_mask.pb.dart' as $46; import '../../../google/protobuf/timestamp.pb.dart' as $20; import 'operations.pbenum.dart' as $56; +import 'organizations.pbenum.dart'; + +export 'organizations.pbenum.dart'; /// A root-level organization resource. class Organization extends $pb.GeneratedMessage { @@ -32,6 +35,8 @@ class Organization extends $pb.GeneratedMessage { $core.Map<$core.String, $core.String>? annotations, $core.bool? reconciling, $core.String? primaryRegion, + Organization_State? state, + $20.Timestamp? purgeTime, }) { final $result = create(); if (name != null) { @@ -70,6 +75,12 @@ class Organization extends $pb.GeneratedMessage { if (primaryRegion != null) { $result.primaryRegion = primaryRegion; } + if (state != null) { + $result.state = state; + } + if (purgeTime != null) { + $result.purgeTime = purgeTime; + } return $result; } Organization._() : super(); @@ -104,6 +115,13 @@ class Organization extends $pb.GeneratedMessage { packageName: const $pb.PackageName('celest.cloud.v1alpha1')) ..aOB(11, _omitFieldNames ? '' : 'reconciling') ..aOS(12, _omitFieldNames ? '' : 'primaryRegion') + ..e( + 13, _omitFieldNames ? '' : 'state', $pb.PbFieldType.OE, + defaultOrMaker: Organization_State.STATE_UNSPECIFIED, + valueOf: Organization_State.valueOf, + enumValues: Organization_State.values) + ..aOM<$20.Timestamp>(14, _omitFieldNames ? '' : 'purgeTime', + subBuilder: $20.Timestamp.create) ..hasRequiredFields = false; @$core.Deprecated('Using this can add significant overhead to your binary. ' @@ -291,6 +309,34 @@ class Organization extends $pb.GeneratedMessage { $core.bool hasPrimaryRegion() => $_has(11); @$pb.TagNumber(12) void clearPrimaryRegion() => clearField(12); + + /// Output only. The lifecycle state of the organization. + @$pb.TagNumber(13) + Organization_State get state => $_getN(12); + @$pb.TagNumber(13) + set state(Organization_State v) { + setField(13, v); + } + + @$pb.TagNumber(13) + $core.bool hasState() => $_has(12); + @$pb.TagNumber(13) + void clearState() => clearField(13); + + /// Output only. The time the organization is scheduled for permanent deletion. + @$pb.TagNumber(14) + $20.Timestamp get purgeTime => $_getN(13); + @$pb.TagNumber(14) + set purgeTime($20.Timestamp v) { + setField(14, v); + } + + @$pb.TagNumber(14) + $core.bool hasPurgeTime() => $_has(13); + @$pb.TagNumber(14) + void clearPurgeTime() => clearField(14); + @$pb.TagNumber(14) + $20.Timestamp ensurePurgeTime() => $_ensure(13); } /// Request message for the `CreateOrganization` method. @@ -773,6 +819,7 @@ class ListOrganizationsRequest extends $pb.GeneratedMessage { $core.String? pageToken, $core.String? filter, $core.String? orderBy, + $core.bool? showDeleted, }) { final $result = create(); if (parent != null) { @@ -790,6 +837,9 @@ class ListOrganizationsRequest extends $pb.GeneratedMessage { if (orderBy != null) { $result.orderBy = orderBy; } + if (showDeleted != null) { + $result.showDeleted = showDeleted; + } return $result; } ListOrganizationsRequest._() : super(); @@ -810,6 +860,7 @@ class ListOrganizationsRequest extends $pb.GeneratedMessage { ..aOS(3, _omitFieldNames ? '' : 'pageToken') ..aOS(4, _omitFieldNames ? '' : 'filter') ..aOS(5, _omitFieldNames ? '' : 'orderBy') + ..aOB(6, _omitFieldNames ? '' : 'showDeleted') ..hasRequiredFields = false; @$core.Deprecated('Using this can add significant overhead to your binary. ' @@ -901,6 +952,19 @@ class ListOrganizationsRequest extends $pb.GeneratedMessage { $core.bool hasOrderBy() => $_has(4); @$pb.TagNumber(5) void clearOrderBy() => clearField(5); + + /// Include soft-deleted organizations in the results. + @$pb.TagNumber(6) + $core.bool get showDeleted => $_getBF(5); + @$pb.TagNumber(6) + set showDeleted($core.bool v) { + $_setBool(5, v); + } + + @$pb.TagNumber(6) + $core.bool hasShowDeleted() => $_has(5); + @$pb.TagNumber(6) + void clearShowDeleted() => clearField(6); } /// Response message for the `ListOrganizations` method. @@ -1052,8 +1116,9 @@ class DeleteOrganizationRequest extends $pb.GeneratedMessage { $pb.GeneratedMessage.$_defaultFor(create); static DeleteOrganizationRequest? _defaultInstance; - /// The name of the organization to delete. - /// Format: `organizations/{organization}` + /// Required. The name of the organization to delete. + /// + /// Format: `organizations/{organization}` @$pb.TagNumber(1) $core.String get name => $_getSZ(0); @$pb.TagNumber(1) @@ -1066,7 +1131,7 @@ class DeleteOrganizationRequest extends $pb.GeneratedMessage { @$pb.TagNumber(1) void clearName() => clearField(1); - /// If set to true, any resources associated with the organization will also be marked for deletion. + /// Optional. If set to true, any resources associated with the organization will also be marked for deletion. /// (Otherwise, the request will only work if the organization has no resources.) @$pb.TagNumber(2) $core.bool get force => $_getBF(1); @@ -1094,7 +1159,7 @@ class DeleteOrganizationRequest extends $pb.GeneratedMessage { @$pb.TagNumber(3) void clearEtag() => clearField(3); - /// If set to true, and the organization is not found, the request will succeed + /// Optional. If set to true, and the organization is not found, the request will succeed /// but no action will be taken on the server. @$pb.TagNumber(4) $core.bool get allowMissing => $_getBF(3); @@ -1108,7 +1173,7 @@ class DeleteOrganizationRequest extends $pb.GeneratedMessage { @$pb.TagNumber(4) void clearAllowMissing() => clearField(4); - /// If set to true, the request is validated but not actually executed. + /// Optional. If set to true, the request is validated but not actually executed. @$pb.TagNumber(5) $core.bool get validateOnly => $_getBF(4); @$pb.TagNumber(5) @@ -1122,6 +1187,113 @@ class DeleteOrganizationRequest extends $pb.GeneratedMessage { void clearValidateOnly() => clearField(5); } +/// Request message for the `UndeleteOrganization` method. +class UndeleteOrganizationRequest extends $pb.GeneratedMessage { + factory UndeleteOrganizationRequest({ + $core.String? name, + $core.bool? validateOnly, + $core.String? etag, + }) { + final $result = create(); + if (name != null) { + $result.name = name; + } + if (validateOnly != null) { + $result.validateOnly = validateOnly; + } + if (etag != null) { + $result.etag = etag; + } + return $result; + } + UndeleteOrganizationRequest._() : super(); + factory UndeleteOrganizationRequest.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory UndeleteOrganizationRequest.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'UndeleteOrganizationRequest', + package: const $pb.PackageName( + _omitMessageNames ? '' : 'celest.cloud.v1alpha1'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'name') + ..aOB(2, _omitFieldNames ? '' : 'validateOnly') + ..aOS(3, _omitFieldNames ? '' : 'etag') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + UndeleteOrganizationRequest clone() => + UndeleteOrganizationRequest()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + UndeleteOrganizationRequest copyWith( + void Function(UndeleteOrganizationRequest) updates) => + super.copyWith( + (message) => updates(message as UndeleteOrganizationRequest)) + as UndeleteOrganizationRequest; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static UndeleteOrganizationRequest create() => + UndeleteOrganizationRequest._(); + UndeleteOrganizationRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static UndeleteOrganizationRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static UndeleteOrganizationRequest? _defaultInstance; + + /// Required. The name of the organization to undelete. + /// + /// Format: `organizations/{organization}` + @$pb.TagNumber(1) + $core.String get name => $_getSZ(0); + @$pb.TagNumber(1) + set name($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasName() => $_has(0); + @$pb.TagNumber(1) + void clearName() => clearField(1); + + /// Optional. If set to true, the request is validated but not actually executed. + @$pb.TagNumber(2) + $core.bool get validateOnly => $_getBF(1); + @$pb.TagNumber(2) + set validateOnly($core.bool v) { + $_setBool(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasValidateOnly() => $_has(1); + @$pb.TagNumber(2) + void clearValidateOnly() => clearField(2); + + /// Optional. The etag of the organization. + /// If this is provided, it must match the server's etag. + @$pb.TagNumber(3) + $core.String get etag => $_getSZ(2); + @$pb.TagNumber(3) + set etag($core.String v) { + $_setString(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasEtag() => $_has(2); + @$pb.TagNumber(3) + void clearEtag() => clearField(3); +} + /// Request message for the `RenameOrganization` operation. class RenameOrganizationRequest extends $pb.GeneratedMessage { factory RenameOrganizationRequest({ diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbenum.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbenum.dart index d09e36f1..00d496a5 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbenum.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbenum.dart @@ -8,3 +8,37 @@ // ignore_for_file: constant_identifier_names, library_prefixes // ignore_for_file: non_constant_identifier_names, prefer_final_fields // ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +/// Project lifecycle states. +class Organization_State extends $pb.ProtobufEnum { + static const Organization_State STATE_UNSPECIFIED = + Organization_State._(0, _omitEnumNames ? '' : 'STATE_UNSPECIFIED'); + static const Organization_State CREATING = + Organization_State._(1, _omitEnumNames ? '' : 'CREATING'); + static const Organization_State CREATION_FAILED = + Organization_State._(2, _omitEnumNames ? '' : 'CREATION_FAILED'); + static const Organization_State ACTIVE = + Organization_State._(3, _omitEnumNames ? '' : 'ACTIVE'); + static const Organization_State DELETED = + Organization_State._(4, _omitEnumNames ? '' : 'DELETED'); + + static const $core.List values = [ + STATE_UNSPECIFIED, + CREATING, + CREATION_FAILED, + ACTIVE, + DELETED, + ]; + + static final $core.Map<$core.int, Organization_State> _byValue = + $pb.ProtobufEnum.initByValue(values); + static Organization_State? valueOf($core.int value) => _byValue[value]; + + const Organization_State._($core.int v, $core.String n) : super(v, n); +} + +const _omitEnumNames = $core.bool.fromEnvironment('protobuf.omit_enum_names'); diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbgrpc.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbgrpc.dart index c732c535..af047618 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbgrpc.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbgrpc.dart @@ -48,6 +48,11 @@ class OrganizationsClient extends $grpc.Client { '/celest.cloud.v1alpha1.Organizations/DeleteOrganization', ($8.DeleteOrganizationRequest value) => value.writeToBuffer(), ($core.List<$core.int> value) => $2.Operation.fromBuffer(value)); + static final _$undeleteOrganization = + $grpc.ClientMethod<$8.UndeleteOrganizationRequest, $2.Operation>( + '/celest.cloud.v1alpha1.Organizations/UndeleteOrganization', + ($8.UndeleteOrganizationRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => $2.Operation.fromBuffer(value)); static final _$renameOrganization = $grpc.ClientMethod<$8.RenameOrganizationRequest, $2.Operation>( '/celest.cloud.v1alpha1.Organizations/RenameOrganization', @@ -89,6 +94,12 @@ class OrganizationsClient extends $grpc.Client { return $createUnaryCall(_$deleteOrganization, request, options: options); } + $grpc.ResponseFuture<$2.Operation> undeleteOrganization( + $8.UndeleteOrganizationRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$undeleteOrganization, request, options: options); + } + $grpc.ResponseFuture<$2.Operation> renameOrganization( $8.RenameOrganizationRequest request, {$grpc.CallOptions? options}) { @@ -142,6 +153,15 @@ abstract class OrganizationsServiceBase extends $grpc.Service { ($core.List<$core.int> value) => $8.DeleteOrganizationRequest.fromBuffer(value), ($2.Operation value) => value.writeToBuffer())); + $addMethod( + $grpc.ServiceMethod<$8.UndeleteOrganizationRequest, $2.Operation>( + 'UndeleteOrganization', + undeleteOrganization_Pre, + false, + false, + ($core.List<$core.int> value) => + $8.UndeleteOrganizationRequest.fromBuffer(value), + ($2.Operation value) => value.writeToBuffer())); $addMethod($grpc.ServiceMethod<$8.RenameOrganizationRequest, $2.Operation>( 'RenameOrganization', renameOrganization_Pre, @@ -178,6 +198,11 @@ abstract class OrganizationsServiceBase extends $grpc.Service { return deleteOrganization(call, await request); } + $async.Future<$2.Operation> undeleteOrganization_Pre($grpc.ServiceCall call, + $async.Future<$8.UndeleteOrganizationRequest> request) async { + return undeleteOrganization(call, await request); + } + $async.Future<$2.Operation> renameOrganization_Pre($grpc.ServiceCall call, $async.Future<$8.RenameOrganizationRequest> request) async { return renameOrganization(call, await request); @@ -193,6 +218,8 @@ abstract class OrganizationsServiceBase extends $grpc.Service { $grpc.ServiceCall call, $8.UpdateOrganizationRequest request); $async.Future<$2.Operation> deleteOrganization( $grpc.ServiceCall call, $8.DeleteOrganizationRequest request); + $async.Future<$2.Operation> undeleteOrganization( + $grpc.ServiceCall call, $8.UndeleteOrganizationRequest request); $async.Future<$2.Operation> renameOrganization( $grpc.ServiceCall call, $8.RenameOrganizationRequest request); } diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbjson.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbjson.dart index eed75ae3..e0599dc3 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbjson.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/organizations.pbjson.dart @@ -19,23 +19,23 @@ const Organization$json = { '2': [ {'1': 'name', '3': 1, '4': 1, '5': 9, '8': {}, '10': 'name'}, {'1': 'uid', '3': 2, '4': 1, '5': 9, '8': {}, '10': 'uid'}, + {'1': 'parent', '3': 3, '4': 1, '5': 9, '8': {}, '10': 'parent'}, { - '1': 'parent', - '3': 3, + '1': 'organization_id', + '3': 4, '4': 1, '5': 9, '8': {}, - '9': 0, - '10': 'parent', - '17': true + '10': 'organizationId' }, { - '1': 'organization_id', - '3': 4, + '1': 'state', + '3': 13, '4': 1, - '5': 9, + '5': 14, + '6': '.celest.cloud.v1alpha1.Organization.State', '8': {}, - '10': 'organizationId' + '10': 'state' }, {'1': 'display_name', '3': 5, '4': 1, '5': 9, '8': {}, '10': 'displayName'}, { @@ -65,6 +65,15 @@ const Organization$json = { '8': {}, '10': 'deleteTime' }, + { + '1': 'purge_time', + '3': 14, + '4': 1, + '5': 11, + '6': '.google.protobuf.Timestamp', + '8': {}, + '10': 'purgeTime' + }, {'1': 'etag', '3': 9, '4': 1, '5': 9, '8': {}, '10': 'etag'}, { '1': 'annotations', @@ -86,10 +95,8 @@ const Organization$json = { }, ], '3': [Organization_AnnotationsEntry$json], + '4': [Organization_State$json], '7': {}, - '8': [ - {'1': '_parent'}, - ], }; @$core.Deprecated('Use organizationDescriptor instead') @@ -102,31 +109,45 @@ const Organization_AnnotationsEntry$json = { '7': {'7': true}, }; +@$core.Deprecated('Use organizationDescriptor instead') +const Organization_State$json = { + '1': 'State', + '2': [ + {'1': 'STATE_UNSPECIFIED', '2': 0}, + {'1': 'CREATING', '2': 1}, + {'1': 'CREATION_FAILED', '2': 2}, + {'1': 'ACTIVE', '2': 3}, + {'1': 'DELETED', '2': 4}, + ], +}; + /// Descriptor for `Organization`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List organizationDescriptor = $convert.base64Decode( 'CgxPcmdhbml6YXRpb24SFwoEbmFtZRgBIAEoCUID4EEIUgRuYW1lEh0KA3VpZBgCIAEoCUIL4E' - 'ED4ozP1wgCCAFSA3VpZBIgCgZwYXJlbnQYAyABKAlCA+BBAUgAUgZwYXJlbnSIAQESLwoPb3Jn' - 'YW5pemF0aW9uX2lkGAQgASgJQgbgQQXgQQNSDm9yZ2FuaXphdGlvbklkEikKDGRpc3BsYXlfbm' - 'FtZRgFIAEoCUIG4EEC4EEEUgtkaXNwbGF5TmFtZRJACgtjcmVhdGVfdGltZRgGIAEoCzIaLmdv' - 'b2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBCA+BBA1IKY3JlYXRlVGltZRJACgt1cGRhdGVfdGltZR' - 'gHIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBCA+BBA1IKdXBkYXRlVGltZRJACgtk' - 'ZWxldGVfdGltZRgIIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBCA+BBA1IKZGVsZX' - 'RlVGltZRIXCgRldGFnGAkgASgJQgPgQQNSBGV0YWcS3AMKC2Fubm90YXRpb25zGAogAygLMjQu' - 'Y2VsZXN0LmNsb3VkLnYxYWxwaGExLk9yZ2FuaXphdGlvbi5Bbm5vdGF0aW9uc0VudHJ5QoMD4E' - 'EBukj8ApoB+AIQQCLNAboByQEKFHZhbGlkX2Fubm90YXRpb25fa2V5EocBa2V5cyBtdXN0IGJl' - 'IDEtNjMgY2hhcmFjdGVycyBhbmQgaGF2ZSBvbmx5IGxvd2VyY2FzZSBsZXR0ZXJzLCBudW1lcm' - 'ljcywgdW5kZXJzY29yZXMsIGFuZCBkYXNoZXMsIGFuZCBtdXN0IHN0YXJ0IHdpdGggYSBsb3dl' - 'cmNhc2UgbGV0dGVyGid0aGlzLm1hdGNoZXMoJ15bYS16XVthLXowLTlfLV17MCw2Mn0kJykqow' - 'G6AZ8BChZ2YWxpZF9hbm5vdGF0aW9uX3ZhbHVlEmF2YWx1ZXMgbXVzdCBiZSAwLTYzIGNoYXJh' - 'Y3RlcnMgYW5kIGhhdmUgb25seSBsb3dlcmNhc2UgbGV0dGVycywgbnVtZXJpY3MsIHVuZGVyc2' - 'NvcmVzLCBhbmQgZGFzaGVzGiJ0aGlzLm1hdGNoZXMoJ15bYS16MC05Xy1dezAsNjN9JCcpUgth' - 'bm5vdGF0aW9ucxIlCgtyZWNvbmNpbGluZxgLIAEoCEID4EEDUgtyZWNvbmNpbGluZxKTAQoOcH' - 'JpbWFyeV9yZWdpb24YDCABKAlCbOBBAbpIZroBYwoUdmFsaWRfcHJpbWFyeV9yZWdpb24SJXBy' - 'aW1hcnlfcmVnaW9uIG11c3QgYmUgYSB2YWxpZCByZWdpb24aJHRoaXMubWF0Y2hlcygnXlthLX' - 'pdKy1bYS16XStbMC05XSQnKVINcHJpbWFyeVJlZ2lvbho+ChBBbm5vdGF0aW9uc0VudHJ5EhAK' - 'A2tleRgBIAEoCVIDa2V5EhQKBXZhbHVlGAIgASgJUgV2YWx1ZToCOAE6YOpBXQodY2xvdWQuY2' - 'VsZXN0LmRldi9Pcmdhbml6YXRpb24SHG9yZ2FuaXphdGlvbnMve29yZ2FuaXphdGlvbn0qDW9y' - 'Z2FuaXphdGlvbnMyDG9yZ2FuaXphdGlvblIBAUIJCgdfcGFyZW50'); + 'ED4ozP1wgCCAFSA3VpZBIbCgZwYXJlbnQYAyABKAlCA+BBAVIGcGFyZW50Ei8KD29yZ2FuaXph' + 'dGlvbl9pZBgEIAEoCUIG4EEF4EEDUg5vcmdhbml6YXRpb25JZBJECgVzdGF0ZRgNIAEoDjIpLm' + 'NlbGVzdC5jbG91ZC52MWFscGhhMS5Pcmdhbml6YXRpb24uU3RhdGVCA+BBA1IFc3RhdGUSKQoM' + 'ZGlzcGxheV9uYW1lGAUgASgJQgbgQQLgQQRSC2Rpc3BsYXlOYW1lEkAKC2NyZWF0ZV90aW1lGA' + 'YgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcEID4EEDUgpjcmVhdGVUaW1lEkAKC3Vw' + 'ZGF0ZV90aW1lGAcgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcEID4EEDUgp1cGRhdG' + 'VUaW1lEkAKC2RlbGV0ZV90aW1lGAggASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcEID' + '4EEDUgpkZWxldGVUaW1lEj4KCnB1cmdlX3RpbWUYDiABKAsyGi5nb29nbGUucHJvdG9idWYuVG' + 'ltZXN0YW1wQgPgQQNSCXB1cmdlVGltZRIXCgRldGFnGAkgASgJQgPgQQNSBGV0YWcS3AMKC2Fu' + 'bm90YXRpb25zGAogAygLMjQuY2VsZXN0LmNsb3VkLnYxYWxwaGExLk9yZ2FuaXphdGlvbi5Bbm' + '5vdGF0aW9uc0VudHJ5QoMD4EEBukj8ApoB+AIQQCLNAboByQEKFHZhbGlkX2Fubm90YXRpb25f' + 'a2V5EocBa2V5cyBtdXN0IGJlIDEtNjMgY2hhcmFjdGVycyBhbmQgaGF2ZSBvbmx5IGxvd2VyY2' + 'FzZSBsZXR0ZXJzLCBudW1lcmljcywgdW5kZXJzY29yZXMsIGFuZCBkYXNoZXMsIGFuZCBtdXN0' + 'IHN0YXJ0IHdpdGggYSBsb3dlcmNhc2UgbGV0dGVyGid0aGlzLm1hdGNoZXMoJ15bYS16XVthLX' + 'owLTlfLV17MCw2Mn0kJykqowG6AZ8BChZ2YWxpZF9hbm5vdGF0aW9uX3ZhbHVlEmF2YWx1ZXMg' + 'bXVzdCBiZSAwLTYzIGNoYXJhY3RlcnMgYW5kIGhhdmUgb25seSBsb3dlcmNhc2UgbGV0dGVycy' + 'wgbnVtZXJpY3MsIHVuZGVyc2NvcmVzLCBhbmQgZGFzaGVzGiJ0aGlzLm1hdGNoZXMoJ15bYS16' + 'MC05Xy1dezAsNjN9JCcpUgthbm5vdGF0aW9ucxIlCgtyZWNvbmNpbGluZxgLIAEoCEID4EEDUg' + 'tyZWNvbmNpbGluZxIqCg5wcmltYXJ5X3JlZ2lvbhgMIAEoCUID4EEBUg1wcmltYXJ5UmVnaW9u' + 'Gj4KEEFubm90YXRpb25zRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSFAoFdmFsdWUYAiABKAlSBX' + 'ZhbHVlOgI4ASJaCgVTdGF0ZRIVChFTVEFURV9VTlNQRUNJRklFRBAAEgwKCENSRUFUSU5HEAES' + 'EwoPQ1JFQVRJT05fRkFJTEVEEAISCgoGQUNUSVZFEAMSCwoHREVMRVRFRBAEOmDqQV0KHWNsb3' + 'VkLmNlbGVzdC5kZXYvT3JnYW5pemF0aW9uEhxvcmdhbml6YXRpb25zL3tvcmdhbml6YXRpb259' + 'Kg1vcmdhbml6YXRpb25zMgxvcmdhbml6YXRpb25SAQE='); @$core.Deprecated('Use createOrganizationRequestDescriptor instead') const CreateOrganizationRequest$json = { @@ -159,6 +180,7 @@ const CreateOrganizationRequest$json = { '10': 'validateOnly' }, ], + '7': {}, }; /// Descriptor for `CreateOrganizationRequest`. Decode as a `google.protobuf.DescriptorProto`. @@ -172,7 +194,9 @@ final $typed_data.Uint8List createOrganizationRequestDescriptor = $convert.base6 'aXphdGlvbiBhbGlhcxomdGhpcy5tYXRjaGVzKCdeW2Etel1bYS16MC05LV17NSwyOX0kJylSDm' '9yZ2FuaXphdGlvbklkEkwKDG9yZ2FuaXphdGlvbhgDIAEoCzIjLmNlbGVzdC5jbG91ZC52MWFs' 'cGhhMS5Pcmdhbml6YXRpb25CA+BBAlIMb3JnYW5pemF0aW9uEigKDXZhbGlkYXRlX29ubHkYBC' - 'ABKAhCA+BBAVIMdmFsaWRhdGVPbmx5'); + 'ABKAhCA+BBAVIMdmFsaWRhdGVPbmx5OoUBukiBARp/ChR2YWxpZF9wcmltYXJ5X3JlZ2lvbhIl' + 'cHJpbWFyeV9yZWdpb24gbXVzdCBiZSBhIHZhbGlkIHJlZ2lvbhpAdGhpcy5vcmdhbml6YXRpb2' + '4ucHJpbWFyeV9yZWdpb24ubWF0Y2hlcygnXlthLXpdKy1bYS16XStbMC05XSQnKQ=='); @$core.Deprecated('Use createOrganizationMetadataDescriptor instead') const CreateOrganizationMetadata$json = { @@ -284,12 +308,16 @@ final $typed_data.Uint8List updateOrganizationRequestDescriptor = $convert.base6 'VzdC5jbG91ZC52MWFscGhhMS5Pcmdhbml6YXRpb25CA+BBAlIMb3JnYW5pemF0aW9uEkAKC3Vw' 'ZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFza0ID4EEBUgp1cGRhdG' 'VNYXNrEigKDWFsbG93X21pc3NpbmcYAyABKAhCA+BBAVIMYWxsb3dNaXNzaW5nEigKDXZhbGlk' - 'YXRlX29ubHkYBCABKAhCA+BBAVIMdmFsaWRhdGVPbmx5Op8CukibAhpyCg12YWxpZF9vcHRpb2' + 'YXRlX29ubHkYBCABKAhCA+BBAVIMdmFsaWRhdGVPbmx5Ou0DukjpAxpyCg12YWxpZF9vcHRpb2' '5zEi1jYW5ub3Qgc2V0IGJvdGggYWxsb3dfbWlzc2luZyBhbmQgdXBkYXRlX21hc2saMnRoaXMu' - 'YWxsb3dfbWlzc2luZyA/ICFoYXModGhpcy51cGRhdGVfbWFzaykgOiB0cnVlGqQBChB2YWxpZF' - '9maWVsZF9tYXNrEjNhIGZpZWxkIG1hc2sgcGF0aCBtdXN0IGJlIHZhbGlkIGZvciBhbiBvcmdh' - 'bml6YXRpb24aW3RoaXMudXBkYXRlX21hc2sucGF0aHMuYWxsKHBhdGgsIHBhdGggaW4gWydkaX' - 'NwbGF5X25hbWUnLCAnYW5ub3RhdGlvbnMnLCAncHJpbWFyeV9yZWdpb24nXSk='); + 'YWxsb3dfbWlzc2luZyA/ICFoYXModGhpcy51cGRhdGVfbWFzaykgOiB0cnVlGsYBChB2YWxpZF' + '9maWVsZF9tYXNrEk11cGRhdGVfbWFzayBtYXkgb25seSBpbmNsdWRlOiAnZGlzcGxheV9uYW1l' + 'JywgJ2Fubm90YXRpb25zJywgJ3ByaW1hcnlfcmVnaW9uJxpjdGhpcy51cGRhdGVfbWFzay5wYX' + 'Rocy5hbGwocGF0aCwgcGF0aCBpbiBbJ25hbWUnLCAnZGlzcGxheV9uYW1lJywgJ2Fubm90YXRp' + 'b25zJywgJ3ByaW1hcnlfcmVnaW9uJ10pGqkBChR2YWxpZF9wcmltYXJ5X3JlZ2lvbhIlcHJpbW' + 'FyeV9yZWdpb24gbXVzdCBiZSBhIHZhbGlkIHJlZ2lvbhpqIWhhcyh0aGlzLm9yZ2FuaXphdGlv' + 'bi5wcmltYXJ5X3JlZ2lvbikgfHwgdGhpcy5vcmdhbml6YXRpb24ucHJpbWFyeV9yZWdpb24ubW' + 'F0Y2hlcygnXlthLXpdKy1bYS16XStbMC05XSQnKQ=='); @$core.Deprecated('Use getOrganizationRequestDescriptor instead') const GetOrganizationRequest$json = { @@ -315,6 +343,7 @@ const ListOrganizationsRequest$json = { {'1': 'page_token', '3': 3, '4': 1, '5': 9, '8': {}, '10': 'pageToken'}, {'1': 'filter', '3': 4, '4': 1, '5': 9, '8': {}, '10': 'filter'}, {'1': 'order_by', '3': 5, '4': 1, '5': 9, '8': {}, '10': 'orderBy'}, + {'1': 'show_deleted', '3': 6, '4': 1, '5': 8, '8': {}, '10': 'showDeleted'}, ], }; @@ -325,7 +354,8 @@ final $typed_data.Uint8List listOrganizationsRequestDescriptor = $convert.base64 'bXVzdCBiZSBhIHZhbGlkIHBhcmVudBoldGhpcy5tYXRjaGVzKCdeb3JnYW5pemF0aW9ucy9bXi' '9dKyQnKVIGcGFyZW50EicKCXBhZ2Vfc2l6ZRgCIAEoBUIK4EEBukgEGgIoAFIIcGFnZVNpemUS' 'IgoKcGFnZV90b2tlbhgDIAEoCUID4EEBUglwYWdlVG9rZW4SGwoGZmlsdGVyGAQgASgJQgPgQQ' - 'FSBmZpbHRlchIeCghvcmRlcl9ieRgFIAEoCUID4EEBUgdvcmRlckJ5'); + 'FSBmZpbHRlchIeCghvcmRlcl9ieRgFIAEoCUID4EEBUgdvcmRlckJ5EiYKDHNob3dfZGVsZXRl' + 'ZBgGIAEoCEID4EEBUgtzaG93RGVsZXRlZA=='); @$core.Deprecated('Use listOrganizationsResponseDescriptor instead') const ListOrganizationsResponse$json = { @@ -339,27 +369,15 @@ const ListOrganizationsResponse$json = { '6': '.celest.cloud.v1alpha1.Organization', '10': 'organizations' }, - { - '1': 'next_page_token', - '3': 2, - '4': 1, - '5': 9, - '9': 0, - '10': 'nextPageToken', - '17': true - }, - ], - '8': [ - {'1': '_next_page_token'}, + {'1': 'next_page_token', '3': 2, '4': 1, '5': 9, '10': 'nextPageToken'}, ], }; /// Descriptor for `ListOrganizationsResponse`. Decode as a `google.protobuf.DescriptorProto`. final $typed_data.Uint8List listOrganizationsResponseDescriptor = $convert.base64Decode( 'ChlMaXN0T3JnYW5pemF0aW9uc1Jlc3BvbnNlEkkKDW9yZ2FuaXphdGlvbnMYASADKAsyIy5jZW' - 'xlc3QuY2xvdWQudjFhbHBoYTEuT3JnYW5pemF0aW9uUg1vcmdhbml6YXRpb25zEisKD25leHRf' - 'cGFnZV90b2tlbhgCIAEoCUgAUg1uZXh0UGFnZVRva2VuiAEBQhIKEF9uZXh0X3BhZ2VfdG9rZW' - '4='); + 'xlc3QuY2xvdWQudjFhbHBoYTEuT3JnYW5pemF0aW9uUg1vcmdhbml6YXRpb25zEiYKD25leHRf' + 'cGFnZV90b2tlbhgCIAEoCVINbmV4dFBhZ2VUb2tlbg=='); @$core.Deprecated('Use deleteOrganizationRequestDescriptor instead') const DeleteOrganizationRequest$json = { @@ -396,6 +414,31 @@ final $typed_data.Uint8List deleteOrganizationRequestDescriptor = $convert.base6 'CgRldGFnGAMgASgJQgPgQQFSBGV0YWcSKAoNYWxsb3dfbWlzc2luZxgEIAEoCEID4EEBUgxhbG' 'xvd01pc3NpbmcSKAoNdmFsaWRhdGVfb25seRgFIAEoCEID4EEBUgx2YWxpZGF0ZU9ubHk='); +@$core.Deprecated('Use undeleteOrganizationRequestDescriptor instead') +const UndeleteOrganizationRequest$json = { + '1': 'UndeleteOrganizationRequest', + '2': [ + {'1': 'name', '3': 1, '4': 1, '5': 9, '8': {}, '10': 'name'}, + { + '1': 'validate_only', + '3': 2, + '4': 1, + '5': 8, + '8': {}, + '10': 'validateOnly' + }, + {'1': 'etag', '3': 3, '4': 1, '5': 9, '8': {}, '10': 'etag'}, + ], +}; + +/// Descriptor for `UndeleteOrganizationRequest`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List undeleteOrganizationRequestDescriptor = $convert.base64Decode( + 'ChtVbmRlbGV0ZU9yZ2FuaXphdGlvblJlcXVlc3QSowEKBG5hbWUYASABKAlCjgHgQQL6QR8KHW' + 'Nsb3VkLmNlbGVzdC5kZXYvT3JnYW5pemF0aW9uukhmugFjChJ2YWxpZF9vcmdhbml6YXRpb24S' + 'Jm5hbWUgbXVzdCBiZSBhIHZhbGlkIG9yZ2FuaXphdGlvbiBuYW1lGiV0aGlzLm1hdGNoZXMoJ1' + '5vcmdhbml6YXRpb25zL1teL10rJCcpUgRuYW1lEigKDXZhbGlkYXRlX29ubHkYAiABKAhCA+BB' + 'AVIMdmFsaWRhdGVPbmx5EhcKBGV0YWcYAyABKAlCA+BBAVIEZXRhZw=='); + @$core.Deprecated('Use renameOrganizationRequestDescriptor instead') const RenameOrganizationRequest$json = { '1': 'RenameOrganizationRequest', diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pb.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pb.dart index c6e3b769..59cf9f74 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pb.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pb.dart @@ -272,7 +272,7 @@ class Project extends $pb.GeneratedMessage { @$pb.TagNumber(9) $20.Timestamp ensureDeleteTime() => $_ensure(8); - /// Output only. The time the project is scheduled for deletion. + /// Output only. The time the project is scheduled for permanent deletion. @$pb.TagNumber(10) $20.Timestamp get purgeTime => $_getN(9); @$pb.TagNumber(10) @@ -959,8 +959,9 @@ class DeleteProjectRequest extends $pb.GeneratedMessage { $pb.GeneratedMessage.$_defaultFor(create); static DeleteProjectRequest? _defaultInstance; - /// The name of the project to delete. - /// Format: `organizations/{organization}/projects/{project}` + /// Required. The name of the project to delete. + /// + /// Format: `organizations/{organization}/projects/{project}` @$pb.TagNumber(1) $core.String get name => $_getSZ(0); @$pb.TagNumber(1) @@ -973,7 +974,7 @@ class DeleteProjectRequest extends $pb.GeneratedMessage { @$pb.TagNumber(1) void clearName() => clearField(1); - /// If set to true, any resources associated with the project will also be marked for deletion. + /// Optional. If set to true, any resources associated with the project will also be marked for deletion. /// (Otherwise, the request will only work if the project has no resources.) @$pb.TagNumber(2) $core.bool get force => $_getBF(1); @@ -1001,7 +1002,7 @@ class DeleteProjectRequest extends $pb.GeneratedMessage { @$pb.TagNumber(3) void clearEtag() => clearField(3); - /// If set to true, and the project is not found, the request will succeed + /// Optional. If set to true, and the project is not found, the request will succeed /// but no action will be taken on the server. @$pb.TagNumber(4) $core.bool get allowMissing => $_getBF(3); @@ -1015,7 +1016,7 @@ class DeleteProjectRequest extends $pb.GeneratedMessage { @$pb.TagNumber(4) void clearAllowMissing() => clearField(4); - /// If set to true, the request is validated but not actually executed. + /// Optional. If set to true, the request is validated but not actually executed. @$pb.TagNumber(5) $core.bool get validateOnly => $_getBF(4); @$pb.TagNumber(5) diff --git a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pbjson.dart b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pbjson.dart index cc1f7166..f6580b43 100644 --- a/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pbjson.dart +++ b/packages/celest_cloud/lib/src/proto/celest/cloud/v1alpha1/projects.pbjson.dart @@ -127,14 +127,14 @@ final $typed_data.Uint8List projectDescriptor = $convert.base64Decode( 'lkX2Fubm90YXRpb25fdmFsdWUSYXZhbHVlcyBtdXN0IGJlIDAtNjMgY2hhcmFjdGVycyBhbmQg' 'aGF2ZSBvbmx5IGxvd2VyY2FzZSBsZXR0ZXJzLCBudW1lcmljcywgdW5kZXJzY29yZXMsIGFuZC' 'BkYXNoZXMaInRoaXMubWF0Y2hlcygnXlthLXowLTlfLV17MCw2M30kJylSC2Fubm90YXRpb25z' - 'EiUKC3JlY29uY2lsaW5nGA0gASgIQgPgQQNSC3JlY29uY2lsaW5nEocBCgZyZWdpb24YDiABKA' - 'lCb+BBAeBBBbpIZroBYwoUdmFsaWRfcHJpbWFyeV9yZWdpb24SJXByaW1hcnlfcmVnaW9uIG11' - 'c3QgYmUgYSB2YWxpZCByZWdpb24aJHRoaXMubWF0Y2hlcygnXlthLXpdKy1bYS16XStbMC05XS' - 'QnKVIGcmVnaW9uGj4KEEFubm90YXRpb25zRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSFAoFdmFs' - 'dWUYAiABKAlSBXZhbHVlOgI4ASJaCgVTdGF0ZRIVChFTVEFURV9VTlNQRUNJRklFRBAAEgwKCE' - 'NSRUFUSU5HEAESEwoPQ1JFQVRJT05fRkFJTEVEEAISCgoGQUNUSVZFEAMSCwoHREVMRVRFRBAE' - 'OmTqQWEKGGNsb3VkLmNlbGVzdC5kZXYvUHJvamVjdBIvb3JnYW5pemF0aW9ucy97b3JnYW5pem' - 'F0aW9ufS9wcm9qZWN0cy97cHJvamVjdH0qCHByb2plY3RzMgdwcm9qZWN0UgEB'); + 'EiUKC3JlY29uY2lsaW5nGA0gASgIQgPgQQNSC3JlY29uY2lsaW5nEncKBnJlZ2lvbhgOIAEoCU' + 'Jf4EEB4EEFukhWugFTCgx2YWxpZF9yZWdpb24SHXJlZ2lvbiBtdXN0IGJlIGEgdmFsaWQgcmVn' + 'aW9uGiR0aGlzLm1hdGNoZXMoJ15bYS16XSstW2Etel0rWzAtOV0kJylSBnJlZ2lvbho+ChBBbm' + '5vdGF0aW9uc0VudHJ5EhAKA2tleRgBIAEoCVIDa2V5EhQKBXZhbHVlGAIgASgJUgV2YWx1ZToC' + 'OAEiWgoFU3RhdGUSFQoRU1RBVEVfVU5TUEVDSUZJRUQQABIMCghDUkVBVElORxABEhMKD0NSRU' + 'FUSU9OX0ZBSUxFRBACEgoKBkFDVElWRRADEgsKB0RFTEVURUQQBDpk6kFhChhjbG91ZC5jZWxl' + 'c3QuZGV2L1Byb2plY3QSL29yZ2FuaXphdGlvbnMve29yZ2FuaXphdGlvbn0vcHJvamVjdHMve3' + 'Byb2plY3R9Kghwcm9qZWN0czIHcHJvamVjdFIBAQ=='); @$core.Deprecated('Use createProjectRequestDescriptor instead') const CreateProjectRequest$json = { @@ -283,12 +283,12 @@ final $typed_data.Uint8List updateProjectRequestDescriptor = $convert.base64Deco 'YxYWxwaGExLlByb2plY3RCA+BBAlIHcHJvamVjdBJACgt1cGRhdGVfbWFzaxgCIAEoCzIaLmdv' 'b2dsZS5wcm90b2J1Zi5GaWVsZE1hc2tCA+BBAVIKdXBkYXRlTWFzaxIoCg1hbGxvd19taXNzaW' '5nGAMgASgIQgPgQQFSDGFsbG93TWlzc2luZxIoCg12YWxpZGF0ZV9vbmx5GAQgASgIQgPgQQFS' - 'DHZhbGlkYXRlT25seTqHArpIgwIacgoNdmFsaWRfb3B0aW9ucxItY2Fubm90IHNldCBib3RoIG' + 'DHZhbGlkYXRlT25seTqdArpImQIacgoNdmFsaWRfb3B0aW9ucxItY2Fubm90IHNldCBib3RoIG' 'FsbG93X21pc3NpbmcgYW5kIHVwZGF0ZV9tYXNrGjJ0aGlzLmFsbG93X21pc3NpbmcgPyAhaGFz' - 'KHRoaXMudXBkYXRlX21hc2spIDogdHJ1ZRqMAQoQdmFsaWRfZmllbGRfbWFzaxItYSBmaWVsZC' - 'BtYXNrIHBhdGggbXVzdCBiZSB2YWxpZCBmb3IgYSBwcm9qZWN0Gkl0aGlzLnVwZGF0ZV9tYXNr' - 'LnBhdGhzLmFsbChwYXRoLCBwYXRoIGluIFsnZGlzcGxheV9uYW1lJywgJ2Fubm90YXRpb25zJ1' - '0p'); + 'KHRoaXMudXBkYXRlX21hc2spIDogdHJ1ZRqiAQoQdmFsaWRfZmllbGRfbWFzaxI7dXBkYXRlX2' + '1hc2sgbWF5IG9ubHkgaW5jbHVkZTogJ2Rpc3BsYXlfbmFtZScsICdhbm5vdGF0aW9ucycaUXRo' + 'aXMudXBkYXRlX21hc2sucGF0aHMuYWxsKHBhdGgsIHBhdGggaW4gWyduYW1lJywgJ2Rpc3BsYX' + 'lfbmFtZScsICdhbm5vdGF0aW9ucyddKQ=='); @$core.Deprecated('Use deleteProjectRequestDescriptor instead') const DeleteProjectRequest$json = { diff --git a/packages/celest_cloud/lib/src/proto/operations.dart b/packages/celest_cloud/lib/src/proto/operations.dart index 0296ccc4..39b9144e 100644 --- a/packages/celest_cloud/lib/src/proto/operations.dart +++ b/packages/celest_cloud/lib/src/proto/operations.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:celest_cloud/celest_cloud.dart'; import 'package:celest_cloud/src/cloud/operations/operations_protocol.dart'; import 'package:celest_cloud/src/proto/google/longrunning/operations.pbgrpc.dart'; import 'package:celest_cloud/src/proto/google/protobuf/any.pb.dart'; @@ -216,7 +217,11 @@ final class OperationWaiter { _operation = await _client.get( GetOperationRequest(name: _operation.name), ); - _logger?.fine(() => _operation.toProto3Json().toString()); + _logger?.fine( + () => _operation + .toProto3Json(typeRegistry: CelestCloud.typeRegistry) + .toString(), + ); } if (_operation.hasError()) { throw GrpcError.custom( diff --git a/packages/celest_cloud/test/cloud/cloud_test.dart b/packages/celest_cloud/test/cloud/cloud_test.dart index 6216fe8e..3b6ce8ea 100644 --- a/packages/celest_cloud/test/cloud/cloud_test.dart +++ b/packages/celest_cloud/test/cloud/cloud_test.dart @@ -38,16 +38,13 @@ void main() { group('Organizations', () { test('create organization (validate-only)', () async { - final state = await celest.organizations - .create( - organizationId: 'test-organization', - organization: Organization( - displayName: 'Test Organization', - ), - validateOnly: true, - ) - .last; - expect(state, isA()); + await celest.organizations.create( + organizationId: 'test-organization', + organization: Organization( + displayName: 'Test Organization', + ), + validateOnly: true, + ); expect( await celest.organizations.get('organizations/test-organization'), isNull, @@ -55,18 +52,14 @@ void main() { }); test('create organization', () async { - final state = await celest.organizations - .create( - organizationId: 'test-organization', - organization: Organization( - displayName: 'Test Organization', - ), - ) - .last; - expect(state, isA()); - expect(state.metadata, isNotNull); + final organization = await celest.organizations.create( + organizationId: 'test-organization', + organization: Organization( + displayName: 'Test Organization', + ), + ); expect( - state.response, + organization, isA() .having( (org) => org.organizationId, diff --git a/packages/celest_core/lib/src/exception/cloud_exception.dart b/packages/celest_core/lib/src/exception/cloud_exception.dart index 2a41ebdc..75362ee5 100644 --- a/packages/celest_core/lib/src/exception/cloud_exception.dart +++ b/packages/celest_core/lib/src/exception/cloud_exception.dart @@ -77,7 +77,7 @@ abstract mixin class CloudException implements CelestException { code: error.code, message: error.message, details: error.details - ?.map((det) => det.toProto3Json() as JsonValue) + ?.map((det) => det.writeToJsonMap() as JsonValue) .toList() as JsonList, ); } diff --git a/packages/celest_core/lib/src/http/celest_http_client.dart b/packages/celest_core/lib/src/http/celest_http_client.dart index d1c71bef..71ca0317 100644 --- a/packages/celest_core/lib/src/http/celest_http_client.dart +++ b/packages/celest_core/lib/src/http/celest_http_client.dart @@ -1,30 +1,41 @@ import 'package:celest_core/_internal.dart'; -import 'package:celest_core/src/auth/authenticator.dart'; import 'package:celest_core/src/http/http_client.vm.dart' if (dart.library.js_interop) 'package:celest_core/src/http/http_client.web.dart'; import 'package:http/http.dart' as http; +import 'package:logging/logging.dart'; final class CelestHttpClient extends http.BaseClient { CelestHttpClient({ NativeSecureStorage? secureStorage, + Authenticator? authenticator, http.Client? baseClient, - }) : _authenticator = Authenticator( - secureStorage: secureStorage ?? NativeSecureStorage(), - ), + Logger? logger, + }) : _authenticator = authenticator ?? + Authenticator( + secureStorage: secureStorage ?? NativeSecureStorage(), + ), _ownsInner = baseClient == null, - _inner = baseClient ?? createHttpClient(); + _inner = baseClient ?? createHttpClient(), + _logger = logger; final Authenticator _authenticator; final bool _ownsInner; final http.Client _inner; + final Logger? _logger; @override Future send(http.BaseRequest request) async { - final cork = await _authenticator.token; - if (cork != null) { - request.headers['authorization'] = 'Bearer $cork'; + final token = await _authenticator.token; + if (token != null) { + request.headers['authorization'] = 'Bearer $token'; } - return _inner.send(request); + return _inner.send(request).then((response) async { + if (response.statusCode == HttpStatus.unauthorized) { + _logger?.finer('Revoking token'); + await _authenticator.revoke(); + } + return response; + }); } @override