Skip to content
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

allow passing empty scheduled actions #468

Open
cluarkhpe opened this issue Oct 24, 2022 · 0 comments
Open

allow passing empty scheduled actions #468

cluarkhpe opened this issue Oct 24, 2022 · 0 comments

Comments

@cluarkhpe
Copy link
Contributor

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"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant