-
Notifications
You must be signed in to change notification settings - Fork 85
feat: add ACLP list entities method #674
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
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -7,11 +7,13 @@ | |
|
|
||
| __all__ = [ | ||
| "AggregateFunction", | ||
| "Alert", | ||
| "AlertChannel", | ||
| "AlertDefinition", | ||
| "AlertDefinitionChannel", | ||
| "AlertDefinitionEntity", | ||
| "AlertEntities", | ||
| "AlertScope", | ||
| "AlertType", | ||
|
mgwoj marked this conversation as resolved.
|
||
| "Alerts", | ||
| "MonitorDashboard", | ||
| "MonitorMetricsDefinition", | ||
| "MonitorService", | ||
|
|
@@ -341,15 +343,15 @@ class RuleCriteria(JSONObject): | |
|
|
||
|
|
||
| @dataclass | ||
| class Alert(JSONObject): | ||
| class AlertDefinitionChannel(JSONObject): | ||
| """ | ||
| Represents an alert definition reference within an AlertChannel. | ||
| Represents the notification channel set up for use with an alert. | ||
|
|
||
| Fields: | ||
| - id: int - Unique identifier of the alert definition. | ||
| - label: str - Human-readable name for the alert definition. | ||
| - type: str - Type of the alert (e.g., 'alerts-definitions'). | ||
| - url: str - API URL for the alert definition. | ||
| - id: int - Unique identifier for this notification channel. | ||
| - label: str - Human-readable name for the alert channel. | ||
| - type: str - Type of notification used with the channel. For a user alert definition, only `email` is supported. | ||
| - url: str - URL for the channel that ends in the channel's id. | ||
| """ | ||
|
|
||
| id: int = 0 | ||
|
|
@@ -358,18 +360,6 @@ class Alert(JSONObject): | |
| url: str = "" | ||
|
|
||
|
|
||
| @dataclass | ||
| class Alerts(JSONObject): | ||
| """ | ||
| Represents a collection of alert definitions within an AlertChannel. | ||
|
|
||
| Fields: | ||
| - items: List[Alert] - List of alert definitions. | ||
| """ | ||
|
|
||
| items: List[Alert] = field(default_factory=list) | ||
|
|
||
|
|
||
| class AlertType(StrEnum): | ||
| """ | ||
| Enumeration of alert origin types used by alert definitions. | ||
|
|
@@ -387,6 +377,43 @@ class AlertType(StrEnum): | |
| user = "user" | ||
|
|
||
|
|
||
| class AlertScope(StrEnum): | ||
| """ | ||
| Scope values supported for alert definitions. | ||
| """ | ||
|
|
||
| entity = "entity" | ||
| region = "region" | ||
| account = "account" | ||
|
|
||
|
|
||
| @dataclass | ||
| class AlertEntities(JSONObject): | ||
| """ | ||
| Represents entity metadata for an alert definition. | ||
|
|
||
| For entity scoped alerts, `entities` envelope contains the URL to list entities, | ||
| a count, and a has_more_resources flag. | ||
| For region/account scoped alerts, the `entities` are returned as an empty object. | ||
| """ | ||
|
|
||
| url: str = "" | ||
| count: int = 0 | ||
| has_more_resources: bool = False | ||
|
|
||
|
|
||
| @dataclass | ||
| class AlertDefinitionEntity(JSONObject): | ||
| """ | ||
| Represents an entity associated with an alert definition. | ||
| """ | ||
|
|
||
| id: str = "" | ||
| label: str = "" | ||
| url: str = "" | ||
| _type: str = field(default="", metadata={"json_key": "type"}) | ||
|
|
||
|
|
||
| class AlertDefinition(DerivedBase): | ||
| """ | ||
| Represents an alert definition for a monitor service. | ||
|
|
@@ -406,17 +433,22 @@ class AlertDefinition(DerivedBase): | |
| "severity": Property(mutable=True), | ||
| "type": Property(mutable=True), | ||
| "status": Property(mutable=True), | ||
| "has_more_resources": Property(mutable=True), | ||
| "scope": Property(AlertScope), | ||
| "regions": Property(mutable=True), | ||
| "has_more_resources": Property(), # Deprecated; use entities.has_more_resources | ||
| "entities": Property(json_object=AlertEntities), | ||
| "rule_criteria": Property(mutable=True, json_object=RuleCriteria), | ||
| "trigger_conditions": Property( | ||
| mutable=True, json_object=TriggerConditions | ||
| ), | ||
| "alert_channels": Property(mutable=True, json_object=Alerts), | ||
| "alert_channels": Property(json_object=AlertDefinitionChannel), | ||
| "created": Property(is_datetime=True), | ||
| "updated": Property(is_datetime=True), | ||
| "updated_by": Property(), | ||
| "created_by": Property(), | ||
| "entity_ids": Property(mutable=True), | ||
| "entity_ids": Property( | ||
| mutable=True | ||
| ), # Deprecated; use entities.url to fetch associated entities | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we still use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I have removed the comment |
||
| "description": Property(mutable=True), | ||
| "service_class": Property(alias_of="class"), | ||
| } | ||
|
|
||
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
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
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
25 changes: 25 additions & 0 deletions
25
test/fixtures/monitor_services_dbaas_alert-definitions_12345_entities.json
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,25 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "id": "1", | ||
| "label": "mydatabase-1", | ||
| "url": "/v4/databases/mysql/instances/1", | ||
| "type": "dbaas" | ||
| }, | ||
| { | ||
| "id": "2", | ||
| "label": "mydatabase-2", | ||
| "url": "/v4/databases/mysql/instances/2", | ||
| "type": "dbaas" | ||
| }, | ||
| { | ||
| "id": "3", | ||
| "label": "mydatabase-3", | ||
| "url": "/v4/databases/mysql/instances/3", | ||
| "type": "dbaas" | ||
| } | ||
| ], | ||
| "page": 1, | ||
| "pages": 1, | ||
| "results": 3 | ||
| } |
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
Oops, something went wrong.
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.