Skip to content

Commit

Permalink
feat: adds an extremely simply AppCapabilities model to support perce…
Browse files Browse the repository at this point in the history
…ntage-based rollouts
  • Loading branch information
bryanoltman committed Nov 5, 2024
1 parent 6704e56 commit 51770e7
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'get_app_capabilities_response.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';

part 'get_app_capabilities_response.g.dart';

/// {@template get_app_capabilities_response}
/// The capabilities of the requesting user for the specified app.
/// {@endtemplate}
@JsonSerializable()
class GetAppCapabilitiesResponse {
/// {@macro get_app_capabilities_response}
GetAppCapabilitiesResponse({required this.capabilities});

/// Deserializes the [GetAppCapabilitiesResponse] from a JSON map.
factory GetAppCapabilitiesResponse.fromJson(Map<String, dynamic> json) =>
_$GetAppCapabilitiesResponseFromJson(json);

/// Converts this [GetAppCapabilitiesResponse] to a JSON map.
Map<String, dynamic> toJson() => _$GetAppCapabilitiesResponseToJson(this);

/// The list of capabilities the user has for the app. There are the things
/// that the requesting user can do to or in relation to the app. These are
/// determined by the user's role in the organization that owns the app, the
/// user's app collaborator status, and the plan associated with the app's
/// organization.
final List<AppCapability> capabilities;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export 'create_patch_artifact/create_patch_artifact.dart';
export 'create_release/create_release.dart';
export 'create_release_artifact/create_release_artifact.dart';
export 'create_user/create_user.dart';
export 'get_app_capabilities/get_app_capabilities.dart';
export 'get_apps/get_apps.dart';
export 'get_organization_apps/get_organization_apps.dart';
export 'get_organization_users/get_organization_users.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// Operations that a user may or may not be able to perform to or in relation
/// to an app.
enum AppCapability {
/// Allows the user to create patches for an app at a non-100 rollout
/// percentage.
phasedPatchRollout,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export 'app.dart';
export 'app_capability.dart';
export 'app_collaborator_role.dart';
export 'app_metadata.dart';
export 'auth_provider.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
import 'package:test/test.dart';

void main() {
group(GetAppCapabilitiesResponse, () {
test('can be (de)serialized', () {
final response = GetAppCapabilitiesResponse(capabilities: [
AppCapability.phasedPatchRollout,
]);
expect(
GetAppCapabilitiesResponse.fromJson(response.toJson()).toJson(),
equals(response.toJson()),
);
});
});
}

0 comments on commit 51770e7

Please sign in to comment.