Class: DatadogAPIClient::V2::WidgetsAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_api_client/v2/api/widgets_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ WidgetsAPI

Returns a new instance of WidgetsAPI.



22
23
24
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 22

def initialize(api_client = DatadogAPIClient::APIClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



20
21
22
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#create_widget(experience_type, body, opts = {}) ⇒ Object

Create a widget.



29
30
31
32
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 29

def create_widget(experience_type, body, opts = {})
  data, _status_code, _headers = create_widget_with_http_info(experience_type, body, opts)
  data
end

#create_widget_with_http_info(experience_type, body, opts = {}) ⇒ Array<(WidgetResponse, Integer, Hash)>

Create a widget.

Create a new widget for a given experience type.

Parameters:

Returns:

  • (Array<(WidgetResponse, Integer, Hash)>)

    WidgetResponse data, response status code and response headers



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
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 42

def create_widget_with_http_info(experience_type, body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WidgetsAPI.create_widget ...'
  end
  # verify the required parameter 'experience_type' is set
  if @api_client.config.client_side_validation && experience_type.nil?
    fail ArgumentError, "Missing the required parameter 'experience_type' when calling WidgetsAPI.create_widget"
  end
  # verify enum value
  allowable_values = ['ccm_reports', 'logs_reports', 'csv_reports', 'product_analytics']
  if @api_client.config.client_side_validation && !allowable_values.include?(experience_type)
    fail ArgumentError, "invalid value for \"experience_type\", must be one of #{allowable_values}"
  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 WidgetsAPI.create_widget"
  end
  # resource path
  local_var_path = '/api/v2/widgets/{experience_type}'.sub('{experience_type}', CGI.escape(experience_type.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'WidgetResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :create_widget,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V2"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WidgetsAPI#create_widget\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_widget(experience_type, uuid, opts = {}) ⇒ Object

Delete a widget.



106
107
108
109
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 106

def delete_widget(experience_type, uuid, opts = {})
  delete_widget_with_http_info(experience_type, uuid, opts)
  nil
end

#delete_widget_with_http_info(experience_type, uuid, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete a widget.

Soft-delete a widget by its UUID for a given experience type.

Parameters:

  • experience_type (WidgetExperienceType)

    The experience type for the widget.

  • uuid (UUID)

    The UUID of the widget.

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

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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
150
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
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 119

def delete_widget_with_http_info(experience_type, uuid, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WidgetsAPI.delete_widget ...'
  end
  # verify the required parameter 'experience_type' is set
  if @api_client.config.client_side_validation && experience_type.nil?
    fail ArgumentError, "Missing the required parameter 'experience_type' when calling WidgetsAPI.delete_widget"
  end
  # verify enum value
  allowable_values = ['ccm_reports', 'logs_reports', 'csv_reports', 'product_analytics']
  if @api_client.config.client_side_validation && !allowable_values.include?(experience_type)
    fail ArgumentError, "invalid value for \"experience_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'uuid' is set
  if @api_client.config.client_side_validation && uuid.nil?
    fail ArgumentError, "Missing the required parameter 'uuid' when calling WidgetsAPI.delete_widget"
  end
  # resource path
  local_var_path = '/api/v2/widgets/{experience_type}/{uuid}'.sub('{experience_type}', CGI.escape(experience_type.to_s).gsub('%2F', '/')).sub('{uuid}', CGI.escape(uuid.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :delete_widget,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V2"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WidgetsAPI#delete_widget\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_widget(experience_type, uuid, opts = {}) ⇒ Object

Get a widget.



181
182
183
184
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 181

def get_widget(experience_type, uuid, opts = {})
  data, _status_code, _headers = get_widget_with_http_info(experience_type, uuid, opts)
  data
end

#get_widget_with_http_info(experience_type, uuid, opts = {}) ⇒ Array<(WidgetResponse, Integer, Hash)>

Get a widget.

Retrieve a widget by its UUID for a given experience type.

Parameters:

  • experience_type (WidgetExperienceType)

    The experience type for the widget.

  • uuid (UUID)

    The UUID of the widget.

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

    the optional parameters

Returns:

  • (Array<(WidgetResponse, Integer, Hash)>)

    WidgetResponse data, response status code and response headers



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
250
251
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 194

def get_widget_with_http_info(experience_type, uuid, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WidgetsAPI.get_widget ...'
  end
  # verify the required parameter 'experience_type' is set
  if @api_client.config.client_side_validation && experience_type.nil?
    fail ArgumentError, "Missing the required parameter 'experience_type' when calling WidgetsAPI.get_widget"
  end
  # verify enum value
  allowable_values = ['ccm_reports', 'logs_reports', 'csv_reports', 'product_analytics']
  if @api_client.config.client_side_validation && !allowable_values.include?(experience_type)
    fail ArgumentError, "invalid value for \"experience_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'uuid' is set
  if @api_client.config.client_side_validation && uuid.nil?
    fail ArgumentError, "Missing the required parameter 'uuid' when calling WidgetsAPI.get_widget"
  end
  # resource path
  local_var_path = '/api/v2/widgets/{experience_type}/{uuid}'.sub('{experience_type}', CGI.escape(experience_type.to_s).gsub('%2F', '/')).sub('{uuid}', CGI.escape(uuid.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}

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

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WidgetResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :get_widget,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V2"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WidgetsAPI#get_widget\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_widgets(experience_type, opts = {}) ⇒ Object

Search widgets.



256
257
258
259
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 256

def search_widgets(experience_type, opts = {})
  data, _status_code, _headers = search_widgets_with_http_info(experience_type, opts)
  data
end

#search_widgets_with_http_info(experience_type, opts = {}) ⇒ Array<(WidgetListResponse, Integer, Hash)>

Search widgets.

Search and list widgets for a given experience type. Supports filtering by widget type, creator, title, and tags, as well as sorting and pagination.

Parameters:

  • experience_type (WidgetExperienceType)

    The experience type for the widget.

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

    the optional parameters

Options Hash (opts):

  • :filter_widget_type (WidgetType)

    Filter widgets by widget type.

  • :filter_creator_handle (String)

    Filter widgets by the email handle of the creator.

  • :filter_is_favorited (Boolean)

    Filter to only widgets favorited by the current user.

  • :filter_title (String)

    Filter widgets by title (substring match).

  • :filter_tags (String)

    Filter widgets by tags. Format as bracket-delimited CSV, e.g. [tag1,tag2].

  • :sort (String)

    Sort field for the results. Prefix with - for descending order. Allowed values: title, created_at, modified_at.

  • :page_number (Integer)

    Page number for pagination (0-indexed).

  • :page_size (Integer)

    Number of widgets per page.

Returns:

  • (Array<(WidgetListResponse, Integer, Hash)>)

    WidgetListResponse data, response status code and response headers



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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 276

def search_widgets_with_http_info(experience_type, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WidgetsAPI.search_widgets ...'
  end
  # verify the required parameter 'experience_type' is set
  if @api_client.config.client_side_validation && experience_type.nil?
    fail ArgumentError, "Missing the required parameter 'experience_type' when calling WidgetsAPI.search_widgets"
  end
  # verify enum value
  allowable_values = ['ccm_reports', 'logs_reports', 'csv_reports', 'product_analytics']
  if @api_client.config.client_side_validation && !allowable_values.include?(experience_type)
    fail ArgumentError, "invalid value for \"experience_type\", must be one of #{allowable_values}"
  end
  allowable_values = ['bar_chart', 'change', 'cloud_cost_summary', 'cohort', 'funnel', 'geomap', 'list_stream', 'query_table', 'query_value', 'retention_curve', 'sankey', 'sunburst', 'timeseries', 'toplist', 'treemap']
  if @api_client.config.client_side_validation && opts[:'filter_widget_type'] && !allowable_values.include?(opts[:'filter_widget_type'])
    fail ArgumentError, "invalid value for \"filter_widget_type\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'page_number'].nil? && opts[:'page_number'] < 0
    fail ArgumentError, 'invalid value for "opts[:"page_number"]" when calling WidgetsAPI.search_widgets, must be greater than or equal to 0.'
  end
  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling WidgetsAPI.search_widgets, must be smaller than or equal to 100.'
  end
  # resource path
  local_var_path = '/api/v2/widgets/{experience_type}'.sub('{experience_type}', CGI.escape(experience_type.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter[widgetType]'] = opts[:'filter_widget_type'] if !opts[:'filter_widget_type'].nil?
  query_params[:'filter[creatorHandle]'] = opts[:'filter_creator_handle'] if !opts[:'filter_creator_handle'].nil?
  query_params[:'filter[isFavorited]'] = opts[:'filter_is_favorited'] if !opts[:'filter_is_favorited'].nil?
  query_params[:'filter[title]'] = opts[:'filter_title'] if !opts[:'filter_title'].nil?
  query_params[:'filter[tags]'] = opts[:'filter_tags'] if !opts[:'filter_tags'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?

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

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WidgetListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :search_widgets,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V2"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WidgetsAPI#search_widgets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_widget(experience_type, uuid, body, opts = {}) ⇒ Object

Update a widget.



352
353
354
355
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 352

def update_widget(experience_type, uuid, body, opts = {})
  data, _status_code, _headers = update_widget_with_http_info(experience_type, uuid, body, opts)
  data
end

#update_widget_with_http_info(experience_type, uuid, body, opts = {}) ⇒ Array<(WidgetResponse, Integer, Hash)>

Update a widget.

Update a widget by its UUID for a given experience type. This performs a full replacement of the widget definition.

Parameters:

  • experience_type (WidgetExperienceType)

    The experience type for the widget.

  • uuid (UUID)

    The UUID of the widget.

  • body (CreateOrUpdateWidgetRequest)

    Widget request body.

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

    the optional parameters

Returns:

  • (Array<(WidgetResponse, Integer, Hash)>)

    WidgetResponse data, response status code and response headers



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/datadog_api_client/v2/api/widgets_api.rb', line 366

def update_widget_with_http_info(experience_type, uuid, body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WidgetsAPI.update_widget ...'
  end
  # verify the required parameter 'experience_type' is set
  if @api_client.config.client_side_validation && experience_type.nil?
    fail ArgumentError, "Missing the required parameter 'experience_type' when calling WidgetsAPI.update_widget"
  end
  # verify enum value
  allowable_values = ['ccm_reports', 'logs_reports', 'csv_reports', 'product_analytics']
  if @api_client.config.client_side_validation && !allowable_values.include?(experience_type)
    fail ArgumentError, "invalid value for \"experience_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'uuid' is set
  if @api_client.config.client_side_validation && uuid.nil?
    fail ArgumentError, "Missing the required parameter 'uuid' when calling WidgetsAPI.update_widget"
  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 WidgetsAPI.update_widget"
  end
  # resource path
  local_var_path = '/api/v2/widgets/{experience_type}/{uuid}'.sub('{experience_type}', CGI.escape(experience_type.to_s).gsub('%2F', '/')).sub('{uuid}', CGI.escape(uuid.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'WidgetResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :update_widget,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V2"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WidgetsAPI#update_widget\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end