oncall-engine/engine/apps/public_api/serializers
Joey Orlando 4a5c4263e0
feat: convert schedule.channel (char field) to schedule.slack_channel (foreign key) (#5199)
# What this PR does

`OnCallSchedule` equivalent of
https://github.com/grafana/oncall/pull/5191.

**NOTE**: merge after https://github.com/grafana/oncall/pull/5224 (so
that I can use some of the new serializer fields defined in there)

### Migration
```bash
Running migrations:                                                                                                                                                                                                │
│ source=engine:app google_trace_id=none logger=apps.schedules.migrations.0019_auto_20241021_1735 Starting migration to populate slack_channel field.                                                                │
│ source=engine:app google_trace_id=none logger=apps.schedules.migrations.0019_auto_20241021_1735 Total schedules to process: 1                                                                                      │
│ source=engine:app google_trace_id=none logger=apps.schedules.migrations.0019_auto_20241021_1735 Schedule 26 updated with SlackChannel 2 (slack_id: C043LL6RTS7).                                                   │
│ source=engine:app google_trace_id=none logger=apps.schedules.migrations.0019_auto_20241021_1735 Bulk updated 1 OnCallSchedules with their Slack channel.                                                           │
│ source=engine:app google_trace_id=none logger=apps.schedules.migrations.0019_auto_20241021_1735 Finished migration. Total schedules processed: 1. Schedules updated: 1. Missing SlackChannels: 0.                  │
│   Applying schedules.0019_auto_20241021_1735... OK
```

### Tested Public API
```txt
POST {{oncall_host}}/api/v1/schedules/
Authorization: {{oncall_api_key}}
Content-Type: application/json

{
    "name": "Demo testy testy2",
    "type": "web",
    "time_zone": "America/Los_Angeles",
    "slack": {
        "channel_id": "C05PPLYN1U1"
    }
}

HTTP/1.1 201 Created
Content-Type: application/json
Vary: Accept, Origin
Allow: GET, POST, HEAD, OPTIONS
X-Frame-Options: DENY
Content-Length: 198
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Cross-Origin-Opener-Policy: same-origin

{
  "id": "SBBN73UTUTVCE",
  "team_id": null,
  "name": "Demo testy testy2",
  "time_zone": "America/Los_Angeles",
  "on_call_now": [],
  "shifts": [],
  "slack": {
    "channel_id": "C05PPLYN1U1",
    "user_group_id": null
  },
  "type": "web"
}
```

### Tested via UI (eg; internal API)

https://www.loom.com/share/e66bf3468b144dd782da5eb6e0bfd0af

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-11-04 14:27:21 -05:00
..
__init__.py Update alert groups public API filters support (#4832) 2024-08-15 19:58:25 +00:00
action.py Fix action/webhook API not accepting empty/null user (#3094) 2023-10-03 14:33:05 +00:00
alert_groups.py Add latest alert to public api alert groups endpoint (#5059) 2024-10-02 17:09:50 +00:00
alerts.py remove all references to deprecated AlertGroup.is_restricted field (#3228) 2023-10-31 20:10:45 +00:00
escalation.py add POST /escalation public API endpoint + add public API docs for teams/organization endpoints (#4815) 2024-08-15 18:31:35 +00:00
escalation_chains.py Minor optimizations for public API endpoints (#5172) 2024-10-11 19:39:39 +00:00
escalation_policies.py Allow more escalation step wait times over public api (#5201) 2024-10-23 18:19:01 +00:00
integrations.py Minor optimizations for public API endpoints (#5172) 2024-10-11 19:39:39 +00:00
integtration_heartbeat.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
maintenance.py add mypy static type checker to backend codebase (#2151) 2023-06-12 12:50:33 -04:00
on_call_shifts.py Minor optimizations for public API endpoints (#5172) 2024-10-11 19:39:39 +00:00
organizations.py remove organization maintenance mode + fix integration maintenance mode (#2511) 2023-07-12 16:41:44 -04:00
personal_notification_rules.py Fix duplicate orders on routes and escalation policies (#2568) 2023-07-18 17:17:53 +00:00
resolution_notes.py Allow OnCall API to use Grafana Service Accounts (#3189) 2023-11-23 16:42:27 +00:00
routes.py chore: convert two slack channel ID char fields to foreign keys (#5224) 2024-11-04 13:34:06 -05:00
schedules_base.py feat: convert schedule.channel (char field) to schedule.slack_channel (foreign key) (#5199) 2024-11-04 14:27:21 -05:00
schedules_calendar.py feat: convert schedule.channel (char field) to schedule.slack_channel (foreign key) (#5199) 2024-11-04 14:27:21 -05:00
schedules_ical.py feat: convert schedule.channel (char field) to schedule.slack_channel (foreign key) (#5199) 2024-11-04 14:27:21 -05:00
schedules_polymorphic.py Initial web schedule model and serializers. Add override shift type. 2022-07-05 12:41:55 -03:00
schedules_web.py feat: convert schedule.channel (char field) to schedule.slack_channel (foreign key) (#5199) 2024-11-04 14:27:21 -05:00
slack_channel.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
teams.py feat: add Grafana IDs to users and teams public API endpoints (#5075) 2024-09-24 19:16:22 +00:00
user_groups.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
users.py feat: add Grafana IDs to users and teams public API endpoints (#5075) 2024-09-24 19:16:22 +00:00
webhooks.py Minor optimizations for public API endpoints (#5172) 2024-10-11 19:39:39 +00:00