Skip to content

Commit

Permalink
Merge pull request #462 from ImMin5/master
Browse files Browse the repository at this point in the history
Add metric, metric_data, metric_example
  • Loading branch information
ImMin5 authored Nov 29, 2024
2 parents 79fae3d + a85d66d commit c578ff0
Show file tree
Hide file tree
Showing 3 changed files with 405 additions and 0 deletions.
193 changes: 193 additions & 0 deletions proto/spaceone/api/inventory_v2/v1/metric.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
syntax = "proto3";

package spaceone.api.inventory_v2.v1;

import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "spaceone/api/core/v2/query.proto";

option go_package = "github.com/cloudforet-io/api/dist/go/spaceone/api/inventory_v2/v1";

service Metric {
rpc create (CreateMetricRequest) returns (MetricInfo) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/create"
body: "*"
};
}

rpc update (UpdateMetricRequest) returns (MetricInfo) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/update"
body: "*"
};
}

rpc delete (MetricRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/delete"
body: "*"
};
}

rpc run (MetricRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/run"
body: "*"
};
}

rpc test (MetricTestRequest) returns (google.protobuf.Struct) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/test"
body: "*"
};
}

rpc get (MetricRequest) returns (MetricInfo) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/get"
body: "*"
};
}

rpc list (MetricQuery) returns (MetricsInfo) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/list"
body: "*"
};
}

rpc stat (MetricStatQuery) returns (google.protobuf.Struct) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric/stat"
body: "*"
};
}
}

enum MetricType {
METRIC_TYPE_NONE = 0;
COUNTER = 1;
GAUGE = 2;
}

//{
//
//}
message CreateMetricRequest {
enum ResourceGroup {
RESOURCE_GROUP_NONE = 0;
DOMAIN = 1;
WORKSPACE = 2;
}

// +optional
string metric_id = 1;
string name = 2;
MetricType metric_type = 3;
// +optional
string resource_type = 4;
spaceone.api.core.v2.AnalyzeQuery query_options = 5;
// +optional
string date_field = 6;
// +optional
string unit = 7;
// +optional
google.protobuf.Struct tags = 8;
string namespace_id = 9;
ResourceGroup resource_group = 20;
// +optional
string workspace_id = 21;
}

//{
//
//}
message UpdateMetricRequest {
string metric_id = 1;
// +optional
string name = 2;
// +optional
spaceone.api.core.v2.AnalyzeQuery query_options = 3;
// +optional
string date_field = 4;
// +optional
string unit = 5;
// +optional
google.protobuf.Struct tags = 6;
}

//{
//
//}
message MetricRequest {
string metric_id = 1;
}

//{
//
//}
message MetricTestRequest {
string metric_id = 1;
spaceone.api.core.v2.AnalyzeQuery query_options = 2;
}

//{
//
//}
message MetricQuery {
// +optional
spaceone.api.core.v2.Query query = 1;
// +optional
string metric_id = 2;
// +optional
MetricType metric_type = 3;
// +optional
string resource_type = 4;
// +optional
string is_managed = 5;
// +optional
string namespace_id = 21;
}

//{
//
//}
message MetricInfo {
enum ResourceGroup {
RESOURCE_GROUP_NONE = 0;
DOMAIN = 1;
WORKSPACE = 2;
}

string metric_id = 1;
string name = 2;
MetricType metric_type = 3;
string resource_type = 4;
spaceone.api.core.v2.AnalyzeQuery query_options = 5;
string date_field = 6;
string unit = 7;
google.protobuf.Struct tags = 8;
repeated google.protobuf.Struct labels_info = 9;
bool is_managed = 10;

ResourceGroup resource_group = 20;
string domain_id = 21;
string workspace_id = 22;
string namespace_id = 23;

string created_at = 31;
string updated_at = 32;
}


message MetricsInfo {
repeated MetricInfo results = 1;
int32 total_count = 2;
}

message MetricStatQuery {
spaceone.api.core.v2.StatisticsQuery query = 1;
}
84 changes: 84 additions & 0 deletions proto/spaceone/api/inventory_v2/v1/metric_data.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
syntax = "proto3";

package spaceone.api.inventory.v1;

import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "spaceone/api/core/v2/query.proto";
import "spaceone/api/inventory_v2/v1/metric.proto";

option go_package = "github.com/cloudforet-io/api/dist/go/spaceone/api/inventory_v2/v1";

service MetricData {
rpc list (MetricDataQuery) returns (MetricDatasInfo) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric-data/list"
body: "*"
};
}

rpc stat (MetricDataStatQuery) returns (google.protobuf.Struct) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric-data/stat"
body: "*"
};
}

rpc analyze (MetricDataAnalyzeQuery) returns (google.protobuf.Struct) {
option (google.api.http) = {
post: "/inventory-v2/v1/metric-data/analyze"
body: "*"
};
}
}

//{
//
//}
message MetricDataQuery {
// +optional
spaceone.api.core.v2.Query query = 1;
string metric_id = 2;
// +optional
string workspace_id = 21;
// +optional
string project_id = 22;
}


//{
//
//}
message MetricDataInfo {
string metric_id = 1;
float value = 2;
string unit = 3;
google.protobuf.Struct labels = 4;

string domain_id = 21;
string workspace_id = 22;
string project_id = 23;
string service_account_id = 24;
string namespace_id = 25;

string created_year = 31;
string created_month = 32;
string created_date = 33;
}

message MetricDatasInfo {
repeated MetricDataInfo results = 1;
int32 total_count = 2;
}

message MetricDataAnalyzeQuery {
spaceone.api.core.v2.TimeSeriesAnalyzeQuery query = 1;
string metric_id = 2;
}

message MetricDataStatQuery {
spaceone.api.core.v2.StatisticsQuery query = 1;
// +optional
string metric_id = 2;
}
Loading

0 comments on commit c578ff0

Please sign in to comment.