-
Notifications
You must be signed in to change notification settings - Fork 98
Adding ACLP monitor APIs #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yec-akamai
merged 12 commits into
linode:main
from
rbajoria26:DI-23858-add-monitor-apis-2
Apr 28, 2025
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
28f837e
Adding ACLP monitor APIs
rbajoria26 755f999
updating variables names to avoid potential conflicting names
rbajoria26 63323c0
Merge branch 'main' into DI-23858-add-monitor-apis-2
rbajoria26 1f30844
updating variables names to avoid potential conflicting names
rbajoria26 09a224b
Merge branch 'DI-23858-add-monitor-apis-2' of https://github.com/rbaj…
rbajoria26 3bc14ea
updating variables names to avoid potential conflicting names
rbajoria26 9ac28cb
Update monitor_dashboards.go
rbajoria26 904c9d8
Update monitor_dashboards.go
rbajoria26 bc5df8e
updated names for metric-definitions unit types
rbajoria26 880cb6c
updating variables names to avoid potential conflicting names
rbajoria26 fba9eeb
updating variables names to avoid potential conflicting names
rbajoria26 cb238a2
Merge branch 'main' into DI-23858-add-monitor-apis-2
rbajoria26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| package linodego | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "time" | ||
|
|
||
| "github.com/linode/linodego/internal/parseabletime" | ||
| ) | ||
|
|
||
| // MonitorDashboard represents an ACLP Dashboard object | ||
| type MonitorDashboard struct { | ||
| ID int `json:"id"` | ||
| Type DashboardType `json:"type"` | ||
| ServiceType ServiceType `json:"service_type"` | ||
| Label string `json:"label"` | ||
| Created *time.Time `json:"-"` | ||
| Updated *time.Time `json:"-"` | ||
| Widgets []DashboardWidget `json:"widgets"` | ||
| } | ||
|
|
||
| // enum object for serviceType | ||
| type ServiceType string | ||
|
|
||
| const ( | ||
| Linode ServiceType = "linode" | ||
| LKE ServiceType = "lke" | ||
| DBaaS ServiceType = "dbaas" | ||
| ACLB ServiceType = "aclb" | ||
| Nodebalancer ServiceType = "nodebalancer" | ||
| ObjectStorage ServiceType = "objectstorage" | ||
| Vpc ServiceType = "vpc" | ||
| FirewallService ServiceType = "firewall" | ||
| ) | ||
|
|
||
| // enum object for DashboardType | ||
| type DashboardType string | ||
|
|
||
| const ( | ||
| Standard DashboardType = "standard" | ||
| Custom DashboardType = "custom" | ||
rbajoria26 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| // DashboardWidget represents an ACLP DashboardWidget object | ||
| type DashboardWidget struct { | ||
| Metric string `json:"metric"` | ||
| Unit string `json:"unit"` | ||
| Label string `json:"label"` | ||
| Color string `json:"color"` | ||
| Size int `json:"size"` | ||
| ChartType ChartType `json:"chart_type"` | ||
| YLabel string `json:"y_label"` | ||
| AggregateFunction AggregateFunction `json:"aggregate_function"` | ||
| } | ||
|
|
||
| // Enum object for AggregateFunction | ||
| type AggregateFunction string | ||
|
|
||
| const ( | ||
| Min AggregateFunction = "min" | ||
| Max AggregateFunction = "max" | ||
| Avg AggregateFunction = "avg" | ||
| Sum AggregateFunction = "sum" | ||
| Rate AggregateFunction = "rate" | ||
| Increase AggregateFunction = "increase" | ||
| Count AggregateFunction = "count" | ||
| Last AggregateFunction = "last" | ||
lgarber-akamai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| // Enum object for Chart type | ||
| type ChartType string | ||
|
|
||
| const ( | ||
| Line ChartType = "line" | ||
lgarber-akamai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Area ChartType = "area" | ||
| ) | ||
|
|
||
| // ListMonitorDashboards lists all the ACLP Monitor Dashboards | ||
| func (c *Client) ListMonitorDashboards(ctx context.Context, opts *ListOptions) ([]MonitorDashboard, error) { | ||
| return getPaginatedResults[MonitorDashboard](ctx, c, "monitor/dashboards", opts) | ||
| } | ||
|
|
||
| // GetMonitorDashboard gets an ACLP Monitor Dashboard for a given dashboardID | ||
| func (c *Client) GetMonitorDashboard(ctx context.Context, dashboardID int) (*MonitorDashboard, error) { | ||
| e := formatAPIPath("monitor/dashboards/%d", dashboardID) | ||
| return doGETRequest[MonitorDashboard](ctx, c, e) | ||
| } | ||
|
|
||
| // ListMonitorDashboardsByServiceType lists ACLP Monitor Dashboards for a given serviceType | ||
| func (c *Client) ListMonitorDashboardsByServiceType(ctx context.Context, serviceType string, opts *ListOptions) ([]MonitorDashboard, error) { | ||
| e := formatAPIPath("monitor/services/%s/dashboards", serviceType) | ||
| return getPaginatedResults[MonitorDashboard](ctx, c, e, opts) | ||
| } | ||
|
|
||
| // UnmarshalJSON implements the json.Unmarshaler interface | ||
| func (i *MonitorDashboard) UnmarshalJSON(b []byte) error { | ||
| type Mask MonitorDashboard | ||
|
|
||
| p := struct { | ||
| *Mask | ||
| Created *parseabletime.ParseableTime `json:"created"` | ||
| Updated *parseabletime.ParseableTime `json:"updated"` | ||
| }{ | ||
| Mask: (*Mask)(i), | ||
| } | ||
|
|
||
| if err := json.Unmarshal(b, &p); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| i.Created = (*time.Time)(p.Created) | ||
| i.Updated = (*time.Time)(p.Updated) | ||
|
|
||
| return nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package linodego | ||
|
|
||
| import ( | ||
| "context" | ||
| ) | ||
|
|
||
| // MonitorMetricsDefinition represents an ACLP MetricsDefinition object | ||
| type MonitorMetricsDefinition struct { | ||
| AvailableAggregateFunctions []AggregateFunction `json:"available_aggregate_functions"` | ||
| Dimensions []MonitorDimension `json:"dimensions"` | ||
| IsAlertable bool `json:"is_alertable"` | ||
| Label string `json:"label"` | ||
| Metric string `json:"metric"` | ||
| MetricType MetricType `json:"metric_type"` | ||
| ScrapeInterval string `json:"scrape_interval"` | ||
| Unit Unit `json:"unit"` | ||
| } | ||
|
|
||
| // Enum object for MetricType | ||
| type MetricType string | ||
|
|
||
| const ( | ||
| Counter MetricType = "counter" | ||
| Histogram MetricType = "histogram" | ||
| Gauge MetricType = "gauge" | ||
| Summary MetricType = "summary" | ||
| ) | ||
|
|
||
| // Enum object for Unit | ||
| type Unit string | ||
lgarber-akamai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const ( | ||
| CountUnit Unit = "count" | ||
| Percent Unit = "percent" | ||
| Byte Unit = "byte" | ||
| Second Unit = "second" | ||
| BitsPerSecond Unit = "bits_per_second" | ||
| Millisecond Unit = "millisecond" | ||
| KB Unit = "KB" | ||
| MB Unit = "MB" | ||
| GB Unit = "GB" | ||
| RateUnit Unit = "rate" | ||
| BytesPerSecond Unit = "bytes_per_second" | ||
| Percentile Unit = "percentile" | ||
| Ratio Unit = "ratio" | ||
| OpsPerSecond Unit = "ops_per_second" | ||
| Iops Unit = "iops" | ||
| ) | ||
lgarber-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // MonitorDimension represents an ACLP MonitorDimension object | ||
| type MonitorDimension struct { | ||
| DimensionLabel string `json:"dimension_label"` | ||
| Label string `json:"label"` | ||
| Values []string `json:"values"` | ||
| } | ||
|
|
||
| // ListMonitorMetricsDefinitionByServiceType lists metric definitions | ||
| func (c *Client) ListMonitorMetricsDefinitionByServiceType(ctx context.Context, serviceType string, opts *ListOptions) ([]MonitorMetricsDefinition, error) { | ||
| e := formatAPIPath("monitor/services/%s/metric-definitions", serviceType) | ||
| return getPaginatedResults[MonitorMetricsDefinition](ctx, c, e, opts) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package linodego | ||
|
|
||
| import ( | ||
| "context" | ||
| ) | ||
|
|
||
| // MonitorService represents a MonitorService object | ||
| type MonitorService struct { | ||
| Label string `json:"label"` | ||
| ServiceType string `json:"service_type"` | ||
| } | ||
|
|
||
| // ListMonitorServices lists all the registered ACLP MonitorServices | ||
| func (c *Client) ListMonitorServices(ctx context.Context, opts *ListOptions) ([]MonitorService, error) { | ||
| return getPaginatedResults[MonitorService](ctx, c, "monitor/services", opts) | ||
| } | ||
|
|
||
| // ListMonitorServiceByType lists monitor services by a given service_type | ||
| func (c *Client) ListMonitorServiceByType(ctx context.Context, serviceType string, opts *ListOptions) ([]MonitorService, error) { | ||
| e := formatAPIPath("monitor/services/%s", serviceType) | ||
| return getPaginatedResults[MonitorService](ctx, c, e, opts) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package linodego | ||
|
|
||
| import ( | ||
| "context" | ||
| ) | ||
|
|
||
| // MonitorServiceToken represents a MonitorServiceToken object | ||
| type MonitorServiceToken struct { | ||
| Token string `json:"token"` | ||
| } | ||
|
|
||
| // Create token options | ||
| type MonitorTokenCreateOptions struct { | ||
| EntityIDs []int `json:"entity_ids"` | ||
| } | ||
|
|
||
| // CreateMonitorServiceTokenForServiceType to create token for a given serviceType | ||
| func (c *Client) CreateMonitorServiceTokenForServiceType(ctx context.Context, serviceType string, opts MonitorTokenCreateOptions) (*MonitorServiceToken, error) { | ||
| e := formatAPIPath("monitor/services/%s/token", serviceType) | ||
| return doPOSTRequest[MonitorServiceToken](ctx, c, e, opts) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.