Skip to content

Commit

Permalink
feat: filters (#349)
Browse files Browse the repository at this point in the history
Co-authored-by: Jérôme Gurhem <[email protected]>
Co-authored-by: Dylan Brasseur <[email protected]>
Co-authored-by: ngruelaneo <[email protected]>
  • Loading branch information
4 people authored Jul 27, 2023
1 parent 45fcbba commit da9b639
Show file tree
Hide file tree
Showing 23 changed files with 631 additions and 409 deletions.
60 changes: 3 additions & 57 deletions Protos/V1/applications_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ syntax = "proto3";

package armonik.api.grpc.v1.applications;

import "objects.proto";
import "applications_fields.proto";
import "applications_filters.proto";
import "sort_direction.proto";

option csharp_namespace = "ArmoniK.Api.gRPC.V1.Applications";
Expand All @@ -22,30 +23,6 @@ message ApplicationRaw {
string service = 4; /** Application service used in the excecuted class. */
}

/**
* Represents every available field in an application.
*/
enum ApplicationRawEnumField {
APPLICATION_RAW_ENUM_FIELD_UNSPECIFIED = 0; /** Unspecified */
APPLICATION_RAW_ENUM_FIELD_NAME = 1; /** Application name. */
APPLICATION_RAW_ENUM_FIELD_VERSION = 2; /** Application version. */
APPLICATION_RAW_ENUM_FIELD_NAMESPACE = 3; /** Application namespace. */
APPLICATION_RAW_ENUM_FIELD_SERVICE = 4; /** Application service. */
}

/**
* This message is used to wrap the enum in order to facilitate the 'oneOf' generation.
*/
message ApplicationRawField {
ApplicationRawEnumField field = 1;
}

message ApplicationField {
oneof field {
ApplicationRawField application_field = 1;
}
}

/**
* Request to list applications.
*
Expand All @@ -55,23 +32,7 @@ message ListApplicationsRequest {
int32 page = 1; /** The page number. Start at 0. */
int32 page_size = 2; /** Number of items per page. */

/**
* Represents a filter with all available fields.
*
* Any fields can be used at the same time.
*/
message Filter {
string name = 1; /** Application name. */
string version = 2; /** Application version. */
string namespace = 3; /** Application namespace. */
string service = 4; /** Application service. */
}

/** The filter.
*
* Must be set for every request but allowed to be empty.
*/
Filter filter = 3;
Filters filters = 3; /** The filters. */

/**
* Represents the sort object.
Expand Down Expand Up @@ -101,18 +62,3 @@ message ListApplicationsResponse {
int32 page_size = 3; /** Number of items per page. */
int32 total = 4; /** Total number of items. */
}

/**
* Request to get count from tasks status by application.
*/
message CountTasksByStatusRequest {
string name = 1; /** Application name. Must fail when name is empty. */
string version = 2; /** Application version. Must fail when version is emtpy. */
}

/**
* Response to get count from tasks status by application.
*/
message CountTasksByStatusResponse {
repeated StatusCount status = 1; /** Number of tasks by status. Expected to have only 1 object by task status. */
}
29 changes: 29 additions & 0 deletions Protos/V1/applications_fields.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
syntax = "proto3";

package armonik.api.grpc.v1.applications;

option csharp_namespace = "ArmoniK.Api.gRPC.V1.Applications";

/**
* Represents every available field in an application.
*/
enum ApplicationRawEnumField {
APPLICATION_RAW_ENUM_FIELD_UNSPECIFIED = 0; /** Unspecified */
APPLICATION_RAW_ENUM_FIELD_NAME = 1; /** Application name. */
APPLICATION_RAW_ENUM_FIELD_VERSION = 2; /** Application version. */
APPLICATION_RAW_ENUM_FIELD_NAMESPACE = 3; /** Application namespace. */
APPLICATION_RAW_ENUM_FIELD_SERVICE = 4; /** Application service. */
}

/**
* This message is used to wrap the enum in order to facilitate the 'oneOf' generation.
*/
message ApplicationRawField {
ApplicationRawEnumField field = 1;
}

message ApplicationField {
oneof field {
ApplicationRawField application_field = 1;
}
}
25 changes: 25 additions & 0 deletions Protos/V1/applications_filters.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

package armonik.api.grpc.v1.applications;

import "applications_fields.proto";
import "filters_common.proto";

option csharp_namespace = "ArmoniK.Api.gRPC.V1.Applications";

message FilterField {
ApplicationField field = 1;
oneof value_condition {
FilterString filter_string = 2;
}
}

message FiltersAnd {
repeated FilterField and = 1;
}

message Filters {
repeated FiltersAnd or = 1;
}

// TODO: I think that we could add a duration filter.
5 changes: 0 additions & 5 deletions Protos/V1/applications_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,4 @@ service Applications {
* Get a applications list using pagination, filters and sorting;
*/
rpc ListApplications(ListApplicationsRequest) returns (ListApplicationsResponse) {}

/**
* Get count from tasks by status using an application.
*/
rpc CountTasksByStatus(CountTasksByStatusRequest) returns (CountTasksByStatusResponse) {}
}
73 changes: 73 additions & 0 deletions Protos/V1/filters_common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
syntax = "proto3";

package armonik.api.grpc.v1;

import "google/protobuf/timestamp.proto";

option csharp_namespace = "Armonik.Api.gRPC.V1";

enum FilterStringOperator {
FILTER_STRING_OPERATOR_EQUAL = 0; /** Equal */
FILTER_STRING_OPERATOR_NOT_EQUAL = 1; /** Not equal */
FILTER_STRING_OPERATOR_CONTAINS = 2; /** Contains */
FILTER_STRING_OPERATOR_NOT_CONTAINS = 3; /** Not contains */
FILTER_STRING_OPERATOR_STARTS_WITH = 4; /** Starts with */
FILTER_STRING_OPERATOR_ENDS_WITH = 5; /** Ends with */
}

message FilterString {
string value = 1;
FilterStringOperator operator = 2;
}

enum FilterNumberOperator {
FILTER_NUMBER_OPERATOR_EQUAL = 0; /** Equal */
FILTER_NUMBER_OPERATOR_NOT_EQUAL = 1; /** Not equal */
FILTER_NUMBER_OPERATOR_LESS_THAN = 2; /** Less than */
FILTER_NUMBER_OPERATOR_LESS_THAN_OR_EQUAL = 3; /** Less than or equal */
FILTER_NUMBER_OPERATOR_GREATER_THAN_OR_EQUAL = 4; /** Greater than or equal */
FILTER_NUMBER_OPERATOR_GREATER_THAN = 5; /** Greater than */
}

message FilterNumber {
int64 value = 1;
FilterNumberOperator operator = 2;
}

enum FilterDateOperator {
FILTER_DATE_OPERATOR_EQUAL = 0; /** Equal */
FILTER_DATE_OPERATOR_NOT_EQUAL = 1; /** Not equal */
FILTER_DATE_OPERATOR_BEFORE = 2; /** Before */
FILTER_DATE_OPERATOR_BEFORE_OR_EQUAL = 3; /** Before or equal */
FILTER_DATE_OPERATOR_AFTER_OR_EQUAL = 4; /** After or equal */
FILTER_DATE_OPERATOR_AFTER = 5; /** After */
}

message FilterDate {
google.protobuf.Timestamp value = 1;
FilterDateOperator operator = 2;
}

enum FilterArrayOperator {
FILTER_ARRAY_OPERATOR_CONTAINS = 0; /** Contains */
FILTER_ARRAY_OPERATOR_NOT_CONTAINS = 1; /** Not contains */
}

message FilterArray {
string value = 1;
FilterArrayOperator operator = 2;
}

enum FilterStatusOperator {
FILTER_STATUS_OPERATOR_EQUAL = 0; /** Equal */
FILTER_STATUS_OPERATOR_NOT_EQUAL = 1; /** Not equal */
}

enum FilterBooleanOperator {
FILTER_BOOLEAN_OPERATOR_IS = 0; /** Is */
}

message FilterBoolean {
bool value = 1;
FilterBooleanOperator operator = 2;
}
50 changes: 3 additions & 47 deletions Protos/V1/partitions_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package armonik.api.grpc.v1.partitions;

import "partitions_fields.proto";
import "partitions_filters.proto";
import "sort_direction.proto";

option csharp_namespace = "Armonik.Api.Grpc.V1.Partitions";
Expand All @@ -21,60 +23,14 @@ message PartitionRaw {
int64 priority = 6; /** The priority of the partition. */
}

/**
* Represents every available field in a partition.
*/
enum PartitionRawEnumField {
PARTITION_RAW_ENUM_FIELD_UNSPECIFIED = 0; /** Unspecified. */
PARTITION_RAW_ENUM_FIELD_ID = 1; /** The partition ID. */
PARTITION_RAW_ENUM_FIELD_PARENT_PARTITION_IDS = 2; /** The parent partition IDs. */
PARTITION_RAW_ENUM_FIELD_POD_RESERVED = 3; /** Whether the partition is reserved for pods. */
PARTITION_RAW_ENUM_FIELD_POD_MAX = 4; /** The maximum number of pods that can be used by sessions using the partition. */
PARTITION_RAW_ENUM_FIELD_PREEMPTION_PERCENTAGE = 5; /** The percentage of the partition that can be preempted. */
PARTITION_RAW_ENUM_FIELD_PRIORITY = 6; /** The priority of the partition. */
}

/**
* This message is used to wrap the enum in order to facilitate the 'oneOf' generation.
*/
message PartitionRawField {
PartitionRawEnumField field = 1;
}

message PartitionField {
oneof field {
PartitionRawField partition_raw_field = 1; /** The partition raw field. */
}
}

/**
* Request to list partitions.
*/
message ListPartitionsRequest {
int32 page = 1; /** The page number. Start at 0. */
int32 page_size = 2; /** The number of items per page. */

/**
* Represents a filter with all available fields.
*
* Any fields can be used at the same time.
*/
message Filter {
string id = 1; /** The partition ID. */
string parent_partition_id = 2; /** The parent partition ID. */
int32 pod_reserved = 3; /** Whether the partition is reserved for pods. */
int32 pod_max = 4; /** The maximum number of pods that can be used by sessions using the partition. */

int32 preemption_percentage = 5; /** The percentage of the partition that can be preempted. */
int32 priority = 6; /** The priority of the partition. */
}

/**
* The filter.
*
* Must be set for every request but allowed to be empty.
*/
Filter filter = 3;
Filters filters = 3; /** The filter. */

/**
* Represents the sort object.
Expand Down
31 changes: 31 additions & 0 deletions Protos/V1/partitions_fields.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
syntax = "proto3";

package armonik.api.grpc.v1.partitions;

option csharp_namespace = "Armonik.Api.Grpc.V1.Partitions";

/**
* Represents every available field in a partition.
*/
enum PartitionRawEnumField {
PARTITION_RAW_ENUM_FIELD_UNSPECIFIED = 0; /** Unspecified. */
PARTITION_RAW_ENUM_FIELD_ID = 1; /** The partition ID. */
PARTITION_RAW_ENUM_FIELD_PARENT_PARTITION_IDS = 2; /** The parent partition IDs. */
PARTITION_RAW_ENUM_FIELD_POD_RESERVED = 3; /** Whether the partition is reserved for pods. */
PARTITION_RAW_ENUM_FIELD_POD_MAX = 4; /** The maximum number of pods that can be used by sessions using the partition. */
PARTITION_RAW_ENUM_FIELD_PREEMPTION_PERCENTAGE = 5; /** The percentage of the partition that can be preempted. */
PARTITION_RAW_ENUM_FIELD_PRIORITY = 6; /** The priority of the partition. */
}

/**
* This message is used to wrap the enum in order to facilitate the 'oneOf' generation.
*/
message PartitionRawField {
PartitionRawEnumField field = 1;
}

message PartitionField {
oneof field {
PartitionRawField partition_raw_field = 1; /** The partition raw field. */
}
}
28 changes: 28 additions & 0 deletions Protos/V1/partitions_filters.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";

package armonik.api.grpc.v1.partitions;

import "filters_common.proto";
import "partitions_fields.proto";

option csharp_namespace = "Armonik.Api.Grpc.V1.Partitions";

message FilterField {
PartitionField field = 1;
oneof value_condition {
FilterString filter_string = 2;
FilterNumber filter_number = 3;
FilterBoolean filter_boolean = 4;
FilterArray filter_array = 5;
}
}

message FiltersAnd {
repeated FilterField and = 1;
}

message Filters {
repeated FiltersAnd or = 1;
}

// TODO: I think that we could add a duration filter.
Loading

0 comments on commit da9b639

Please sign in to comment.