/
custom_field.go
141 lines (122 loc) · 5.28 KB
/
custom_field.go
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
package pagerduty
import (
"context"
"errors"
)
const customFieldDeprecationMessage = "standalone custom field functionality has been removed"
func customFieldDeprecationError() error {
return errors.New(customFieldDeprecationMessage)
}
// CustomFieldService handles the communication with field related methods of the PagerDuty API.
//
// Deprecated: This service should no longer be used. IncidentCustomFieldService provides similar functionality.
type CustomFieldService service
// CustomField represents a custom field.
//
// Deprecated: This struct should no longer be used. IncidentCustomField is similar but not identical.
type CustomField struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Type string `json:"type,omitempty"`
Summary string `json:"summary,omitempty"`
Self string `json:"self,omitempty"`
DataType CustomFieldDataType `json:"datatype,omitempty"`
Description *string `json:"description,omitempty"`
MultiValue bool `json:"multi_value"`
FixedOptions bool `json:"fixed_options"`
FieldOptions []*CustomFieldOption `json:"field_options,omitempty"`
}
// ListCustomFieldResponse represents a list response of fields
//
// Deprecated: This struct should no longer be used.
type ListCustomFieldResponse struct {
Total int `json:"total,omitempty"`
Fields []*CustomField `json:"fields,omitempty"`
Offset int `json:"offset,omitempty"`
More bool `json:"more,omitempty"`
Limit int `json:"limit,omitempty"`
}
// CustomFieldPayload represents payload with a field object
//
// Deprecated: This struct should no longer be used.
type CustomFieldPayload struct {
Field *CustomField `json:"field,omitempty"`
}
// ListCustomFieldOptions represents options when retrieving a list of fields.
//
// Deprecated: This struct should no longer be used.
type ListCustomFieldOptions struct {
Offset int `url:"offset,omitempty"`
Limit int `url:"limit,omitempty"`
Total bool `url:"total,omitempty"`
Includes []string `url:"include,brackets,omitempty"`
}
// GetCustomFieldOptions represents options when retrieving a field.
//
// Deprecated: This struct should no longer be used.
type GetCustomFieldOptions struct {
Includes []string `url:"include,brackets,omitempty"`
}
// List lists existing custom fields. If a non-zero Limit is passed as an option, only a single page of results will be
// returned. Otherwise, the entire list of fields will be returned.
//
// Deprecated: Use IncidentCustomFieldService.List
func (s *CustomFieldService) List(o *ListCustomFieldOptions) (*ListCustomFieldResponse, *Response, error) {
return s.ListContext(context.Background(), o)
}
// ListContext lists existing custom fields. If a non-zero Limit is passed as an option, only a single page of results will be
// returned. Otherwise, the entire list of fields will be returned.
//
// Deprecated: Use IncidentCustomFieldService.ListContext
func (s *CustomFieldService) ListContext(_ context.Context, _ *ListCustomFieldOptions) (*ListCustomFieldResponse, *Response, error) {
return nil, nil, customFieldDeprecationError()
}
// Get gets a custom field.
//
// Deprecated: Use IncidentCustomFieldService.Get
func (s *CustomFieldService) Get(id string, o *GetCustomFieldOptions) (*CustomField, *Response, error) {
return s.GetContext(context.Background(), id, o)
}
// GetContext gets a custom field.
//
// Deprecated: Use IncidentCustomFieldService.GetContext
func (s *CustomFieldService) GetContext(_ context.Context, _ string, _ *GetCustomFieldOptions) (*CustomField, *Response, error) {
return nil, nil, customFieldDeprecationError()
}
// Create creates a new custom field.
//
// Deprecated: Use IncidentCustomFieldService.Create
func (s *CustomFieldService) Create(field *CustomField) (*CustomField, *Response, error) {
return s.CreateContext(context.Background(), field)
}
// CreateContext creates a new custom field.
//
// Deprecated: Use IncidentCustomFieldService.CreateContext
func (s *CustomFieldService) CreateContext(_ context.Context, _ *CustomField) (*CustomField, *Response, error) {
return nil, nil, customFieldDeprecationError()
}
// Delete removes an existing custom field.
//
// Deprecated: Use IncidentCustomFieldService.Delete
func (s *CustomFieldService) Delete(id string) (*Response, error) {
return s.DeleteContext(context.Background(), id)
}
// DeleteContext removes an existing custom field.
//
// Deprecated: Use IncidentCustomFieldService.DeleteContext
func (s *CustomFieldService) DeleteContext(_ context.Context, _ string) (*Response, error) {
return nil, customFieldDeprecationError()
}
// Update updates an existing custom field.
//
// Deprecated: Use IncidentCustomFieldService.Update
func (s *CustomFieldService) Update(id string, field *CustomField) (*CustomField, *Response, error) {
return s.UpdateContext(context.Background(), id, field)
}
// UpdateContext updates an existing custom field.
//
// Deprecated: Use IncidentCustomFieldService.UpdateContext
func (s *CustomFieldService) UpdateContext(_ context.Context, _ string, _ *CustomField) (*CustomField, *Response, error) {
return nil, nil, customFieldDeprecationError()
}