[POSTGRESQL] az postgresql flexible-server maintenance-event list | show | apply-now | reschedule: Add commands for maintenance events#33662
Conversation
🔄AzureCLI-FullTest
|
|
Hi @nasc17, |
❌AzureCLI-BreakingChangeTest
Please submit your Breaking Change Pre-announcement ASAP if you haven't already. Please note:
|
|
POSTGRESQL |
There was a problem hiding this comment.
Pull request overview
Adds a new postgres flexible-server maintenance-event command group to Azure CLI’s PostgreSQL module, wiring it to the PostgreSQL Flexible Server management SDK so users can list, inspect, and act on scheduled maintenance events.
Changes:
- Registers new CLI commands:
maintenance-event list|show|reschedule|apply-nowfor PostgreSQL flexible servers. - Introduces a new command implementation module plus a client factory for
maintenance_events. - Adds argument definitions, help text, and unit tests for the new command functions.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/postgresql/flexible_server_commands.py | Registers the new maintenance-event command group and its commands. |
| src/azure-cli/azure/cli/command_modules/postgresql/commands/maintenance_event_commands.py | Implements the list/show/reschedule/apply-now command handlers. |
| src/azure-cli/azure/cli/command_modules/postgresql/_client_factory.py | Adds a client factory for maintenance_events operations. |
| src/azure-cli/azure/cli/command_modules/postgresql/_params.py | Adds CLI parameters for maintenance event ID, status filter, and reschedule start time. |
| src/azure-cli/azure/cli/command_modules/postgresql/_help.py | Adds help entries and examples for the new maintenance-event commands. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_maintenance_event_commands.py | Adds unit tests for the new maintenance event command functions. |
| src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/init.py | Initializes the new unit test package directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| result = flexible_server_maintenance_event_list( | ||
| self.mock_client, | ||
| self.resource_group, | ||
| self.server_name, | ||
| maintenance_status='Planned' | ||
| ) | ||
|
|
||
| self.assertEqual(result, expected_events) | ||
| self.mock_client.list.assert_called_once_with( | ||
| resource_group_name=self.resource_group, | ||
| server_name=self.server_name, | ||
| maintenance_status='Planned' | ||
| ) |
| with self.command_group('postgres flexible-server maintenance-event', postgres_flexible_maintenance_events_sdk, | ||
| custom_command_type=maintenance_event_commands, | ||
| client_factory=cf_postgres_flexible_maintenance_events) as g: | ||
| g.custom_command('list', 'flexible_server_maintenance_event_list') | ||
| g.custom_command('show', 'flexible_server_maintenance_event_show') |
|
Note: There is no public API for maintenance event creation. Maintenance events are scheduled for servers based on backend logic that is not directly exposed. Therefore the standard E2E test pattern of creating a new server and performing reschedule/apply now commands on it will not work, because a new server may not necessarily get maintenance events scheduled. That is why for these commands we opt to test via unit tests. Unit Test Output: test_apply_now_maintenance_event (azure.cli.command_modules.postgresql.tests.unit.test_maintenance_event_commands.MaintenanceEventCommandsTest.test_apply_now_maintenance_event) Ran 9 tests in 0.010s OK |
| resource_discovery_mode: | ||
| rule_exclusions: | ||
| - option_length_too_long | ||
| postgres flexible-server maintenance-event apply-now: |
There was a problem hiding this comment.
These exclusions should go in src\azure-cli\azure\cli\command_modules\postgresql\linter_exclusions.yml
There was a problem hiding this comment.
Also to fix: FAIL - HIGH severity: no_ids_for_list_commands
Command: postgres flexible-server maintenance-event list - List commands should not expose --ids argument
Add
postgres flexible-server maintenance-event list:
rule_exclusions:
- no_ids_for_list_commands
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Related command
az postgresql flexible-server maintenance-event listaz postgresql flexible-server maintenance-event showaz postgresql flexible-server maintenance-event apply-nowaz postgresql flexible-server maintenance-event rescheduleDescription
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.