Skip to content

allow passing empty scheduled actions #468

Open
@cluarkhpe

Description

the following code to create a service will fail with an error saying that scheduled actions must be specified:

_, err = pagerdutyClient.CreateServiceWithContext(context.Background(), pagerduty.Service{
                Name:             "testlibfailservice",
                Description:      "for testing lib failures",
                EscalationPolicy: *escalationPolicy,
                AlertCreation:    "create_alerts_and_incidents",
                IncidentUrgencyRule: &pagerduty.IncidentUrgencyRule{
                        Type:    "use_support_hours",
                        Urgency: "severity_based",
                        DuringSupportHours: &pagerduty.IncidentUrgencyType{
                                Type:    "constant",
                                Urgency: "high",
                        },
                        OutsideSupportHours: &pagerduty.IncidentUrgencyType{
                                Type:    "constant",
                                Urgency: "low",
                        },
                },
                SupportHours: &pagerduty.SupportHours{
                        Type:       "fixed_time_per_day",
                        Timezone:   "America/Lima",
                        StartTime:  "09:00:00",
                        EndTime:    "17:00:00",
                        DaysOfWeek: []uint{1, 2, 3, 4, 5},
                },
                ScheduledActions: []pagerduty.ScheduledAction{},
        })

a direct call to the api with the same inputs works
curl -X POST --data "@service.json" -H "Authorization: Token token=$PAGERDUTY_TOKEN" -H "Content-Type: application/json" https://api.pagerduty.com/services
service.json:

{
  "service": {
    "name": "testapifailservice",
    "description": "for testing api",
    "alert_creation": "create_alerts_and_incidents",
    "scheduled_actions": [],
    "support_hours": {
      "type": "fixed_time_per_day",
      "time_zone": "America/Lima",
      "days_of_week": [
        1,
        2,
        3,
        4,
        5
      ],
      "start_time": "09:00:00",
      "end_time": "17:00:00"
    },
    "escalation_policy": {
      "id": "<ESCALATION_POLICY_ID>",
      "type": "escalation_policy_reference"
    },
    "incident_urgency_rule": {
      "type": "use_support_hours",
      "during_support_hours": {
        "type": "constant",
        "urgency": "high"
      },
      "outside_support_hours": {
        "type": "constant",
        "urgency": "low"
      }
    },
    "type": "service"
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions