File size: 5,924 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package assignment

// Target contains information about the target, or assignee of an assignment.
type Target interface {
	TargetType() TargetType
	TargetID() string
}
type RawTarget struct {
	Type TargetType
	ID   string
	Name string `json:"-"`
}

func NewRawTarget(t Target) RawTarget {
	return RawTarget{Type: t.TargetType(), ID: t.TargetID()}
}
func (rt RawTarget) TargetType() TargetType {
	return rt.Type
}
func (rt RawTarget) TargetID() string {
	return rt.ID
}

// TargetName returns the name of the target. If unavailable, an empty string is returned.
func (rt RawTarget) TargetName() string {
	return rt.Name
}

// TargetNamer allows getting the friendly name of a target.
// Note: TargetName may return an empty string if the name is unavailable.
type TargetNamer interface {
	TargetName() string
}

type (
	// EscalationPolicyTarget implements the Target interface by wrapping an EscalationPolicy ID.
	EscalationPolicyTarget string
	// NotificationPolicyTarget implements the Target interface by wrapping a NotificationPolicy ID.
	NotificationPolicyTarget string
	// RotationTarget implements the Target interface by wrapping a Rotation ID.
	RotationTarget string
	// ServiceTarget implements the Target interface by wrapping a Service ID.
	ServiceTarget string
	// ScheduleTarget implements the Target interface by wrapping a Schedule ID.
	ScheduleTarget string
	// UserTarget implements the Target interface by wrapping a User ID.
	UserTarget string
	// NotificationChannelTarget implements the Target interface by wrapping a notification channel ID.
	NotificationChannelTarget string
	// IntegrationKeyTarget implements the Target interface by wrapping an IntegrationKey ID.
	IntegrationKeyTarget string
	// UserOverrideTarget implements the Target interface by wrapping an UserOverride ID.
	UserOverrideTarget string
	// ContactMethodTarget implements the Target interface by wrapping a ContactMethod ID.
	ContactMethodTarget string
	// NotificationRuleTarget implements the Target interface by wrapping an NotificationRule ID.
	NotificationRuleTarget string
	// HeartbeatMonitorTarget implements the Target interface by wrapping a HeartbeatMonitor ID.
	HeartbeatMonitorTarget string
	// CalendarSubscriptionTarget implements the Target interface by wrapping a CalendarSubscription ID.
	CalendarSubscriptionTarget string
	// UserSessionTarget implements the Target interface by wrapping a UserSession ID.
	UserSessionTarget string
)

// TargetType implements the Target interface.
func (EscalationPolicyTarget) TargetType() TargetType { return TargetTypeEscalationPolicy }

// TargetID implements the Target interface.
func (e EscalationPolicyTarget) TargetID() string { return string(e) }

// TargetType implements the Target interface.
func (NotificationPolicyTarget) TargetType() TargetType { return TargetTypeNotificationPolicy }

// TargetID implements the Target interface.
func (n NotificationPolicyTarget) TargetID() string { return string(n) }

// TargetType implements the Target interface.
func (RotationTarget) TargetType() TargetType { return TargetTypeRotation }

// TargetID implements the Target interface.
func (r RotationTarget) TargetID() string { return string(r) }

// TargetType implements the Target interface.
func (ServiceTarget) TargetType() TargetType { return TargetTypeService }

// TargetID implements the Target interface.
func (s ServiceTarget) TargetID() string { return string(s) }

// TargetType implements the Target interface.
func (ScheduleTarget) TargetType() TargetType { return TargetTypeSchedule }

// TargetID implements the Target interface.
func (s ScheduleTarget) TargetID() string { return string(s) }

// TargetType implements the Target interface.
func (UserTarget) TargetType() TargetType { return TargetTypeUser }

// TargetID implements the Target interface.
func (u UserTarget) TargetID() string { return string(u) }

// TargetType implements the Target interface.
func (NotificationChannelTarget) TargetType() TargetType { return TargetTypeNotificationChannel }

// TargetID implements the Target interface.
func (nc NotificationChannelTarget) TargetID() string { return string(nc) }

// TargetType implements the Target interface.
func (IntegrationKeyTarget) TargetType() TargetType { return TargetTypeIntegrationKey }

// TargetID implements the Target interface.
func (k IntegrationKeyTarget) TargetID() string { return string(k) }

// TargetType implements the Target interface.
func (UserOverrideTarget) TargetType() TargetType { return TargetTypeUserOverride }

// TargetID implements the Target interface.
func (k UserOverrideTarget) TargetID() string { return string(k) }

// TargetType implements the Target interface.
func (ContactMethodTarget) TargetType() TargetType { return TargetTypeContactMethod }

// TargetID implements the Target interface.
func (k ContactMethodTarget) TargetID() string { return string(k) }

// TargetType implements the Target interface.
func (CalendarSubscriptionTarget) TargetType() TargetType { return TargetTypeCalendarSubscription }

// TargetID implements the Target interface.
func (k CalendarSubscriptionTarget) TargetID() string { return string(k) }

// TargetType implements the Target interface.
func (NotificationRuleTarget) TargetType() TargetType { return TargetTypeNotificationRule }

// TargetID implements the Target interface.
func (k NotificationRuleTarget) TargetID() string { return string(k) }

// TargetType implements the Target interface.
func (HeartbeatMonitorTarget) TargetType() TargetType { return TargetTypeHeartbeatMonitor }

// TargetID implements the Target interface.
func (k HeartbeatMonitorTarget) TargetID() string { return string(k) }

// TargetType implements the Target interface.
func (UserSessionTarget) TargetType() TargetType { return TargetTypeUserSession }

// TargetID implements the Target interface.
func (s UserSessionTarget) TargetID() string { return string(s) }