Skip to content

Commit

Permalink
Merge pull request #147 from rafaelldi/resource-stop-start
Browse files Browse the repository at this point in the history
Add resource stop action
  • Loading branch information
rafaelldi authored May 8, 2024
2 parents b7e69cc + e2fe842 commit e00143f
Show file tree
Hide file tree
Showing 18 changed files with 465 additions and 167 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## [Unreleased]

### Added

- Stop Resource action to the dashboard

## [0.7.0] - 2024-05-08

### Changed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = me.rafaelldi.aspire
pluginName = aspire-plugin
pluginRepositoryUrl = https://github.com/rafaelldi/aspire-plugin
# SemVer format -> https://semver.org
pluginVersion = 0.7.0
pluginVersion = 0.7.1
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 241
pluginUntilBuild = 241.*
Expand Down
252 changes: 126 additions & 126 deletions src/dotnet/aspire-session-host/Resources/resource_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message ApplicationInformationRequest {
}

message ApplicationInformationResponse {
string application_name = 1;
string application_name = 1;
}

////////////////////////////////////////////
Expand All @@ -24,215 +24,215 @@ message ApplicationInformationResponse {
// When a command is to be executed, an instance of ResourceCommandRequest is constructed
// using data from this message.
message ResourceCommand {
// Unique identifier for the command. Not intended for display.
string command_type = 1;
// The display name of the command, to be shown in the UI. May be localized.
string display_name = 2;
// When present, this message must be shown to the user and their confirmation obtained
// before sending the request for this command to be executed.
// The user will be presented with Ok/Cancel options.
optional string confirmation_message = 3;
// Optional parameter that configures the command in some way.
// Clients must return any value provided by the server when invoking
// the command.
optional google.protobuf.Value parameter = 4;
// Unique identifier for the command. Not intended for display.
string command_type = 1;
// The display name of the command, to be shown in the UI. May be localized.
string display_name = 2;
// When present, this message must be shown to the user and their confirmation obtained
// before sending the request for this command to be executed.
// The user will be presented with Ok/Cancel options.
optional string confirmation_message = 3;
// Optional parameter that configures the command in some way.
// Clients must return any value provided by the server when invoking
// the command.
optional google.protobuf.Value parameter = 4;
}

// Represents a request to execute a command.
// Sent by the dashboard to DashboardService.ExecuteResourceCommand.
// Constructed with data from a corresponding
message ResourceCommandRequest {
// Unique identifier for the command.
// Copied from the ResourceCommand that this request object is initialized from.
string command_type = 1;
// The name of the resource to apply the command to. Matches Resource.name.
// Copied from the ResourceCommand that this request object is initialized from.
string resource_name = 2;
// The unique name of the resource type. Matches ResourceType.unique_name and Resource.resource_type.
// Copied from the ResourceCommand that this request object is initialized from.
string resource_type = 3;
// An optional parameter to accompany the command.
// Copied from the ResourceCommand that this request object is initialized from.
optional google.protobuf.Value parameter = 4;
// Unique identifier for the command.
// Copied from the ResourceCommand that this request object is initialized from.
string command_type = 1;
// The name of the resource to apply the command to. Matches Resource.name.
// Copied from the ResourceCommand that this request object is initialized from.
string resource_name = 2;
// The unique name of the resource type. Matches ResourceType.unique_name and Resource.resource_type.
// Copied from the ResourceCommand that this request object is initialized from.
string resource_type = 3;
// An optional parameter to accompany the command.
// Copied from the ResourceCommand that this request object is initialized from.
optional google.protobuf.Value parameter = 4;
}

enum ResourceCommandResponseKind {
UNDEFINED = 0;
SUCCEEDED = 1;
FAILED = 2;
CANCELLED = 3;
UNDEFINED = 0;
SUCCEEDED = 1;
FAILED = 2;
CANCELLED = 3;
}

message ResourceCommandResponse {
ResourceCommandResponseKind kind = 1;
optional string error_message = 2;
ResourceCommandResponseKind kind = 1;
optional string error_message = 2;
}

////////////////////////////////////////////

message ResourceType {
// Unique name for the resource type. Equivalent to Resource.resource_type
// If "display_name" is omitted, this value will be used in UIs.
string unique_name = 1;
// Unique name for the resource type. Equivalent to Resource.resource_type
// If "display_name" is omitted, this value will be used in UIs.
string unique_name = 1;

// Display string for references to this type in UI. May be localized.
// If this value is omitted, UIs will show "unique_name" instead.
optional string display_name = 2;
// Display string for references to this type in UI. May be localized.
// If this value is omitted, UIs will show "unique_name" instead.
optional string display_name = 2;

// Any commands that may be executed against resources of this type, avoiding
// the need to copy the value to every Resource instance.
//
// Note that these commands must apply to matching resources at any time.
//
// If the set of commands changes over time, use the "commands" property
// of the Resource itself.
repeated ResourceCommand commands = 3;
// Any commands that may be executed against resources of this type, avoiding
// the need to copy the value to every Resource instance.
//
// Note that these commands must apply to matching resources at any time.
//
// If the set of commands changes over time, use the "commands" property
// of the Resource itself.
repeated ResourceCommand commands = 3;
}

////////////////////////////////////////////

message EnvironmentVariable {
string name = 1;
optional string value = 2;
bool is_from_spec = 3;
string name = 1;
optional string value = 2;
bool is_from_spec = 3;
}

message Endpoint {
string endpoint_url = 1;
string proxy_url = 2;
string endpoint_url = 1;
string proxy_url = 2;
}

message Service {
string name = 1;
optional string allocated_address = 2;
optional int32 allocated_port = 3;
string name = 1;
optional string allocated_address = 2;
optional int32 allocated_port = 3;
}

message Url {
// The name of the url
string name = 1;
// The uri of the url. Format is scheme://host:port/{*path}
string full_url = 2;
// Determines if this url shows up in the details view only by default.
// If true, the url will not be shown in the list of urls in the top level resources view.
bool is_internal = 3;
// The name of the url
string name = 1;
// The uri of the url. Format is scheme://host:port/{*path}
string full_url = 2;
// Determines if this url shows up in the details view only by default.
// If true, the url will not be shown in the list of urls in the top level resources view.
bool is_internal = 3;
}

message ResourceProperty {
// Name of the data item, e.g. "container.id", "executable.pid", "project.path", ...
string name = 1;
// TODO move display_name to reference data, sent once when the connection starts
// Optional display name, may be localized
optional string display_name = 2;
// The data value. May be null, a number, a string, a boolean, a dictionary of values (Struct), or a list of values (ValueList).
google.protobuf.Value value = 3;
// Name of the data item, e.g. "container.id", "executable.pid", "project.path", ...
string name = 1;
// TODO move display_name to reference data, sent once when the connection starts
// Optional display name, may be localized
optional string display_name = 2;
// The data value. May be null, a number, a string, a boolean, a dictionary of values (Struct), or a list of values (ValueList).
google.protobuf.Value value = 3;
}

// Models the full state of an resource (container, executable, project, etc) at a particular point in time.
message Resource {
string name = 1;
string resource_type = 2;
string display_name = 3;
string uid = 4;
optional string state = 5;
optional google.protobuf.Timestamp created_at = 6;
repeated EnvironmentVariable environment = 7;

// Deprecated and replaced with urls
optional int32 expected_endpoints_count = 8 [deprecated = true];
repeated Endpoint endpoints = 9 [deprecated = true];
repeated Service services = 10 [deprecated = true];

repeated ResourceCommand commands = 11;

// Properties holding data not modeled directly on the message.
//
// For:
// - Containers: image, container_id, ports
// - Executables: process_id, executable_path, working_directory, arguments
// - Projects: process_id, project_path
repeated ResourceProperty properties = 12;

// The list of urls that this resource exposes
repeated Url urls = 13;

// The style of the state. This is used to determine the state icon.
// Supported styles are "success", "info", "warning" and "error". Any other style
// will be treated as "unknown".
optional string state_style = 14;
string name = 1;
string resource_type = 2;
string display_name = 3;
string uid = 4;
optional string state = 5;
optional google.protobuf.Timestamp created_at = 6;
repeated EnvironmentVariable environment = 7;

// Deprecated and replaced with urls
optional int32 expected_endpoints_count = 8 [deprecated = true];
repeated Endpoint endpoints = 9 [deprecated = true];
repeated Service services = 10 [deprecated = true];

repeated ResourceCommand commands = 11;

// Properties holding data not modeled directly on the message.
//
// For:
// - Containers: image, container_id, ports
// - Executables: process_id, executable_path, working_directory, arguments
// - Projects: process_id, project_path
repeated ResourceProperty properties = 12;

// The list of urls that this resource exposes
repeated Url urls = 13;

// The style of the state. This is used to determine the state icon.
// Supported styles are "success", "info", "warning" and "error". Any other style
// will be treated as "unknown".
optional string state_style = 14;
}

////////////////////////////////////////////

// Models a snapshot of resource state
message InitialResourceData {
repeated Resource resources = 1;
repeated ResourceType resource_types = 2;
repeated Resource resources = 1;
repeated ResourceType resource_types = 2;
}

////////////////////////////////////////////

message ResourceDeletion {
string resource_name = 1;
string resource_type = 2;
string resource_name = 1;
string resource_type = 2;
}

message WatchResourcesChange {
oneof kind {
ResourceDeletion delete = 1;
Resource upsert = 2;
}
oneof kind {
ResourceDeletion delete = 1;
Resource upsert = 2;
}
}

message WatchResourcesChanges {
repeated WatchResourcesChange value = 1;
repeated WatchResourcesChange value = 1;
}

////////////////////////////////////////////

// Initiates a subscription for data about resources.
message WatchResourcesRequest {
// True if the client is establishing this connection because a prior one closed unexpectedly.
optional bool is_reconnect = 1;
// True if the client is establishing this connection because a prior one closed unexpectedly.
optional bool is_reconnect = 1;
}

// A message received from the server when watching resources. Has multiple types of payload.
message WatchResourcesUpdate {
oneof kind {
// The current resource state, along with other reference data such as the set of resource types that may exist.
// Received once upon connection, before any changes.
InitialResourceData initial_data = 1;
// One or more deltas to apply.
WatchResourcesChanges changes = 2;
}
oneof kind {
// The current resource state, along with other reference data such as the set of resource types that may exist.
// Received once upon connection, before any changes.
InitialResourceData initial_data = 1;
// One or more deltas to apply.
WatchResourcesChanges changes = 2;
}
}

////////////////////////////////////////////

message ConsoleLogLine {
string text = 1;
// Indicates whether this line came from STDERR or not.
optional bool is_std_err = 2;
int32 line_number = 3;
string text = 1;
// Indicates whether this line came from STDERR or not.
optional bool is_std_err = 2;
int32 line_number = 3;
}

// Initiates a subscription for the logs of a resource.
message WatchResourceConsoleLogsRequest {
// Specifies the resource to watch logs from.
string resource_name = 1;
// Specifies the resource to watch logs from.
string resource_name = 1;
}

// A message received from the server when watching resource logs.
// Contains potentially many lines to be appended to the log.
message WatchResourceConsoleLogsUpdate {
repeated ConsoleLogLine log_lines = 1;
repeated ConsoleLogLine log_lines = 1;
}

////////////////////////////////////////////

service DashboardService {
rpc GetApplicationInformation(ApplicationInformationRequest) returns (ApplicationInformationResponse);
rpc WatchResources(WatchResourcesRequest) returns (stream WatchResourcesUpdate);
rpc WatchResourceConsoleLogs(WatchResourceConsoleLogsRequest) returns (stream WatchResourceConsoleLogsUpdate);
rpc ExecuteResourceCommand(ResourceCommandRequest) returns (ResourceCommandResponse);
rpc GetApplicationInformation(ApplicationInformationRequest) returns (ApplicationInformationResponse);
rpc WatchResources(WatchResourcesRequest) returns (stream WatchResourcesUpdate);
rpc WatchResourceConsoleLogs(WatchResourceConsoleLogsRequest) returns (stream WatchResourceConsoleLogsUpdate);
rpc ExecuteResourceCommand(ResourceCommandRequest) returns (ResourceCommandResponse);
}
Loading

0 comments on commit e00143f

Please sign in to comment.