Class: OpsgenieSdk::IncidentApi

Inherits:
Object
  • Object
show all
Defined in:
lib/opsgenie_sdk/api/incident_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ IncidentApi

Returns a new instance of IncidentApi.



19
20
21
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#close_incident(identifier, opts = {}) ⇒ SuccessResponse

Close Incident Closes incident with given identifier

Parameters:

  • identifier

    Identifier of incident which could be incident id or tiny id

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifier_type (String)

    Type of the identifier that is provided as an in-line parameter. Possible values are 'id' or 'tiny. Default is id' (default to id)

  • :body (CloseIncidentPayload)

    Request payload of closing incident action

Returns:



29
30
31
32
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 29

def close_incident(identifier, opts = {})
  data, _status_code, _headers = close_incident_with_http_info(identifier, opts)
  data
end

#close_incident_with_http_info(identifier, opts = {}) ⇒ Array<(SuccessResponse, Fixnum, Hash)>

Close Incident Closes incident with given identifier

Parameters:

  • identifier

    Identifier of incident which could be incident id or tiny id

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifier_type (String)

    Type of the identifier that is provided as an in-line parameter. Possible values are &#39;id&#39; or &#39;tiny. Default is id&#39;

  • :body (CloseIncidentPayload)

    Request payload of closing incident action

Returns:

  • (Array<(SuccessResponse, Fixnum, Hash)>)

    SuccessResponse data, response status code and response headers



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
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 41

def close_incident_with_http_info(identifier, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: IncidentApi.close_incident ...'
  end
  # verify the required parameter 'identifier' is set
  if @api_client.config.client_side_validation && identifier.nil?
    fail ArgumentError, "Missing the required parameter 'identifier' when calling IncidentApi.close_incident"
  end
  if @api_client.config.client_side_validation && opts[:'identifier_type'] && !['id', 'tiny'].include?(opts[:'identifier_type'])
    fail ArgumentError, 'invalid value for "identifier_type", must be one of id, tiny'
  end
  # resource path
  local_var_path = '/v1/incidents/{identifier}/close'.sub('{' + 'identifier' + '}', identifier.to_s)

  # query parameters
  query_params = {}
  query_params[:'identifierType'] = opts[:'identifier_type'] if !opts[:'identifier_type'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(opts[:'body'])
  auth_names = ['GenieKey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SuccessResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: IncidentApi#close_incident\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_incident(body, opts = {}) ⇒ SuccessResponse

Create Incident Creates a new incident

Parameters:

  • body

    Request payload of created incident

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



87
88
89
90
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 87

def create_incident(body, opts = {})
  data, _status_code, _headers = create_incident_with_http_info(body, opts)
  data
end

#create_incident_with_http_info(body, opts = {}) ⇒ Array<(SuccessResponse, Fixnum, Hash)>

Create Incident Creates a new incident

Parameters:

  • body

    Request payload of created incident

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(SuccessResponse, Fixnum, Hash)>)

    SuccessResponse data, response status code and response headers



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
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 97

def create_incident_with_http_info(body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: IncidentApi.create_incident ...'
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling IncidentApi.create_incident"
  end
  # resource path
  local_var_path = '/v1/incidents/create'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(body)
  auth_names = ['GenieKey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SuccessResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: IncidentApi#create_incident\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_incident(identifier, opts = {}) ⇒ SuccessResponse

Delete Incident Deletes an incident using incident id or the tiny id

Parameters:

  • identifier

    Identifier of incident which could be incident id or tiny id

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifier_type (String)

    Type of the identifier that is provided as an in-line parameter. Possible values are &#39;id&#39; or &#39;tiny. Default is id&#39; (default to id)

Returns:



140
141
142
143
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 140

def delete_incident(identifier, opts = {})
  data, _status_code, _headers = delete_incident_with_http_info(identifier, opts)
  data
end

#delete_incident_with_http_info(identifier, opts = {}) ⇒ Array<(SuccessResponse, Fixnum, Hash)>

Delete Incident Deletes an incident using incident id or the tiny id

Parameters:

  • identifier

    Identifier of incident which could be incident id or tiny id

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifier_type (String)

    Type of the identifier that is provided as an in-line parameter. Possible values are &#39;id&#39; or &#39;tiny. Default is id&#39;

Returns:

  • (Array<(SuccessResponse, Fixnum, Hash)>)

    SuccessResponse data, response status code and response headers



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 151

def delete_incident_with_http_info(identifier, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: IncidentApi.delete_incident ...'
  end
  # verify the required parameter 'identifier' is set
  if @api_client.config.client_side_validation && identifier.nil?
    fail ArgumentError, "Missing the required parameter 'identifier' when calling IncidentApi.delete_incident"
  end
  if @api_client.config.client_side_validation && opts[:'identifier_type'] && !['id', 'tiny'].include?(opts[:'identifier_type'])
    fail ArgumentError, 'invalid value for "identifier_type", must be one of id, tiny'
  end
  # resource path
  local_var_path = '/v1/incidents/{identifier}'.sub('{' + 'identifier' + '}', identifier.to_s)

  # query parameters
  query_params = {}
  query_params[:'identifierType'] = opts[:'identifier_type'] if !opts[:'identifier_type'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['GenieKey']
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SuccessResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: IncidentApi#delete_incident\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_incident(identifier, opts = {}) ⇒ GetIncidentResponse

Get Incident Returns incident with given id, tiny id or alias

Parameters:

  • identifier

    Identifier of incident which could be incident id or tiny id

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifier_type (String)

    Type of the identifier that is provided as an in-line parameter. Possible values are &#39;id&#39; or &#39;tiny. Default is id&#39; (default to id)

Returns:



198
199
200
201
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 198

def get_incident(identifier, opts = {})
  data, _status_code, _headers = get_incident_with_http_info(identifier, opts)
  data
end

#get_incident_request_status(request_id, opts = {}) ⇒ GetIncidentRequestStatusResponse

Get Request Status of Incident Used to track the status and incident details (if any) of the request whose identifier is given

Parameters:

  • request_id

    Universally unique identifier of the questioned request

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



255
256
257
258
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 255

def get_incident_request_status(request_id, opts = {})
  data, _status_code, _headers = get_incident_request_status_with_http_info(request_id, opts)
  data
end

#get_incident_request_status_with_http_info(request_id, opts = {}) ⇒ Array<(GetIncidentRequestStatusResponse, Fixnum, Hash)>

Get Request Status of Incident Used to track the status and incident details (if any) of the request whose identifier is given

Parameters:

  • request_id

    Universally unique identifier of the questioned request

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 265

def get_incident_request_status_with_http_info(request_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: IncidentApi.get_incident_request_status ...'
  end
  # verify the required parameter 'request_id' is set
  if @api_client.config.client_side_validation && request_id.nil?
    fail ArgumentError, "Missing the required parameter 'request_id' when calling IncidentApi.get_incident_request_status"
  end
  # resource path
  local_var_path = '/v1/incidents/requests/{requestId}'.sub('{' + 'requestId' + '}', request_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['GenieKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetIncidentRequestStatusResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: IncidentApi#get_incident_request_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_incident_with_http_info(identifier, opts = {}) ⇒ Array<(GetIncidentResponse, Fixnum, Hash)>

Get Incident Returns incident with given id, tiny id or alias

Parameters:

  • identifier

    Identifier of incident which could be incident id or tiny id

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifier_type (String)

    Type of the identifier that is provided as an in-line parameter. Possible values are &#39;id&#39; or &#39;tiny. Default is id&#39;

Returns:

  • (Array<(GetIncidentResponse, Fixnum, Hash)>)

    GetIncidentResponse data, response status code and response headers



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 209

def get_incident_with_http_info(identifier, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: IncidentApi.get_incident ...'
  end
  # verify the required parameter 'identifier' is set
  if @api_client.config.client_side_validation && identifier.nil?
    fail ArgumentError, "Missing the required parameter 'identifier' when calling IncidentApi.get_incident"
  end
  if @api_client.config.client_side_validation && opts[:'identifier_type'] && !['id', 'tiny'].include?(opts[:'identifier_type'])
    fail ArgumentError, 'invalid value for "identifier_type", must be one of id, tiny'
  end
  # resource path
  local_var_path = '/v1/incidents/{identifier}'.sub('{' + 'identifier' + '}', identifier.to_s)

  # query parameters
  query_params = {}
  query_params[:'identifierType'] = opts[:'identifier_type'] if !opts[:'identifier_type'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['GenieKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetIncidentResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: IncidentApi#get_incident\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_incidents(query, opts = {}) ⇒ ListIncidentsResponse

List incidents Return list of incidents

Parameters:

  • query

    Search query to apply while filtering the incidents.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :offset (Integer)

    Start index of the result set (to apply pagination). Minimum value (and also default value) is 0.

  • :limit (Integer)

    Maximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100

  • :sort (String)

    Name of the field that result set will be sorted by (default to createdAt)

  • :order (String)

    Sorting order of the result set (default to desc)

Returns:



311
312
313
314
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 311

def list_incidents(query, opts = {})
  data, _status_code, _headers = list_incidents_with_http_info(query, opts)
  data
end

#list_incidents_with_http_info(query, opts = {}) ⇒ Array<(ListIncidentsResponse, Fixnum, Hash)>

List incidents Return list of incidents

Parameters:

  • query

    Search query to apply while filtering the incidents.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :offset (Integer)

    Start index of the result set (to apply pagination). Minimum value (and also default value) is 0.

  • :limit (Integer)

    Maximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100

  • :sort (String)

    Name of the field that result set will be sorted by

  • :order (String)

    Sorting order of the result set

Returns:

  • (Array<(ListIncidentsResponse, Fixnum, Hash)>)

    ListIncidentsResponse data, response status code and response headers



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/opsgenie_sdk/api/incident_api.rb', line 325

def list_incidents_with_http_info(query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: IncidentApi.list_incidents ...'
  end
  # verify the required parameter 'query' is set
  if @api_client.config.client_side_validation && query.nil?
    fail ArgumentError, "Missing the required parameter 'query' when calling IncidentApi.list_incidents"
  end
  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling IncidentApi.list_incidents, must be greater than or equal to 0.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling IncidentApi.list_incidents, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling IncidentApi.list_incidents, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && opts[:'sort'] && !['createdAt', 'tinyId', 'message', 'status', 'isSeen', 'owner'].include?(opts[:'sort'])
    fail ArgumentError, 'invalid value for "sort", must be one of createdAt, tinyId, message, status, isSeen, owner'
  end
  if @api_client.config.client_side_validation && opts[:'order'] && !['asc', 'desc'].include?(opts[:'order'])
    fail ArgumentError, 'invalid value for "order", must be one of asc, desc'
  end
  # resource path
  local_var_path = '/v1/incidents/'

  # query parameters
  query_params = {}
  query_params[:'query'] = query
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['GenieKey']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ListIncidentsResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: IncidentApi#list_incidents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end