datadog_api_client 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.apigentools-info +4 -4
  3. data/.generator/schemas/v1/openapi.yaml +181 -16
  4. data/.generator/schemas/v2/openapi.yaml +391 -151
  5. data/.generator/src/generator/formatter.py +34 -29
  6. data/.generator/src/generator/templates/api_client.j2 +81 -53
  7. data/.generator/src/generator/templates/configuration.j2 +21 -0
  8. data/.pre-commit-config.yaml +2 -2
  9. data/CHANGELOG.md +31 -0
  10. data/README.md +23 -0
  11. data/examples/v1/azure-integration/CreateAzureIntegration.rb +3 -0
  12. data/examples/v1/azure-integration/DeleteAzureIntegration.rb +3 -0
  13. data/examples/v1/azure-integration/UpdateAzureHostFilters.rb +3 -0
  14. data/examples/v1/azure-integration/UpdateAzureIntegration.rb +3 -0
  15. data/examples/v1/dashboards/CreateDashboard_252716965.rb +6 -0
  16. data/examples/v1/dashboards/DeletePublicDashboardInvitation.rb +3 -3
  17. data/examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.rb +1 -0
  18. data/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent.rb +3 -0
  19. data/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_129899466.rb +3 -0
  20. data/examples/v2/logs/AggregateLogs_2955613758.rb +1 -1
  21. data/examples/v2/teams/CreateTeam.rb +2 -2
  22. data/examples/v2/teams/CreateTeam_252121814.rb +24 -0
  23. data/examples/v2/teams/GetUserMemberships.rb +8 -0
  24. data/examples/v2/teams/UpdateTeam.rb +9 -0
  25. data/lib/datadog_api_client/api_client.rb +81 -53
  26. data/lib/datadog_api_client/configuration.rb +22 -0
  27. data/lib/datadog_api_client/inflector.rb +10 -1
  28. data/lib/datadog_api_client/v1/api/service_level_objective_corrections_api.rb +2 -2
  29. data/lib/datadog_api_client/v1/api/service_level_objectives_api.rb +10 -10
  30. data/lib/datadog_api_client/v1/api/usage_metering_api.rb +3 -3
  31. data/lib/datadog_api_client/v1/models/azure_account.rb +32 -1
  32. data/lib/datadog_api_client/v1/models/distribution_widget_definition.rb +13 -1
  33. data/lib/datadog_api_client/v1/models/hourly_usage_attribution_usage_type.rb +3 -0
  34. data/lib/datadog_api_client/v1/models/monthly_usage_attribution_supported_metrics.rb +6 -0
  35. data/lib/datadog_api_client/v1/models/monthly_usage_attribution_values.rb +61 -1
  36. data/lib/datadog_api_client/v1/models/synthetics_test_request.rb +11 -1
  37. data/lib/datadog_api_client/v1/models/usage_ci_visibility_hour.rb +12 -1
  38. data/lib/datadog_api_client/v1/models/usage_summary_date.rb +24 -4
  39. data/lib/datadog_api_client/v1/models/usage_summary_date_org.rb +24 -4
  40. data/lib/datadog_api_client/v1/models/usage_summary_response.rb +24 -4
  41. data/lib/datadog_api_client/v1/models/widget_comparator.rb +1 -0
  42. data/lib/datadog_api_client/v2/api/ci_visibility_pipelines_api.rb +10 -6
  43. data/lib/datadog_api_client/v2/api/ip_allowlist_api.rb +2 -2
  44. data/lib/datadog_api_client/v2/api/metrics_api.rb +1 -1
  45. data/lib/datadog_api_client/v2/api/security_monitoring_api.rb +3 -3
  46. data/lib/datadog_api_client/v2/api/spans_metrics_api.rb +2 -2
  47. data/lib/datadog_api_client/v2/api/teams_api.rb +65 -0
  48. data/lib/datadog_api_client/v2/models/application_key_create_attributes.rb +1 -1
  49. data/lib/datadog_api_client/v2/models/application_key_update_attributes.rb +1 -1
  50. data/lib/datadog_api_client/v2/models/audit_logs_event_attributes.rb +11 -1
  51. data/lib/datadog_api_client/v2/models/ci_app_event_attributes.rb +9 -21
  52. data/lib/datadog_api_client/v2/models/ci_app_pipeline_event.rb +1 -1
  53. data/lib/datadog_api_client/v2/models/{team_data.rb → ci_app_pipeline_event_attributes.rb} +24 -62
  54. data/lib/datadog_api_client/v2/models/ci_app_pipeline_level.rb +30 -0
  55. data/lib/datadog_api_client/v2/models/ci_app_pipelines_query_filter.rb +1 -1
  56. data/lib/datadog_api_client/v2/models/ci_app_test_level.rb +29 -0
  57. data/lib/datadog_api_client/v2/models/ci_app_tests_analytics_aggregate_response.rb +1 -1
  58. data/lib/datadog_api_client/v2/models/ci_app_tests_query_filter.rb +1 -1
  59. data/lib/datadog_api_client/v2/models/cloud_configuration_rule_compliance_signal_options.rb +25 -1
  60. data/lib/datadog_api_client/v2/models/dashboard_list_item.rb +25 -1
  61. data/lib/datadog_api_client/v2/models/downtime_schedule_one_time_response.rb +19 -1
  62. data/lib/datadog_api_client/v2/models/formula_limit.rb +1 -0
  63. data/lib/datadog_api_client/v2/models/full_application_key_attributes.rb +1 -1
  64. data/lib/datadog_api_client/v2/models/logs_aggregate_request.rb +1 -1
  65. data/lib/datadog_api_client/v2/models/logs_aggregate_request_page.rb +1 -1
  66. data/lib/datadog_api_client/v2/models/logs_group_by.rb +3 -2
  67. data/lib/datadog_api_client/v2/models/logs_group_by_histogram.rb +1 -1
  68. data/lib/datadog_api_client/v2/models/logs_list_request.rb +1 -1
  69. data/lib/datadog_api_client/v2/models/logs_query_options.rb +1 -1
  70. data/lib/datadog_api_client/v2/models/logs_response_metadata_page.rb +1 -1
  71. data/lib/datadog_api_client/v2/models/on_demand_concurrency_cap.rb +14 -4
  72. data/lib/datadog_api_client/v2/models/on_demand_concurrency_cap_type.rb +26 -0
  73. data/lib/datadog_api_client/v2/models/partial_application_key_attributes.rb +1 -1
  74. data/lib/datadog_api_client/v2/models/query_formula.rb +1 -0
  75. data/lib/datadog_api_client/v2/models/relationship_to_team_links.rb +14 -4
  76. data/lib/datadog_api_client/v2/models/relationship_to_user_team_permission.rb +14 -4
  77. data/lib/datadog_api_client/v2/models/security_monitoring_signal_metadata_type.rb +26 -0
  78. data/lib/datadog_api_client/v2/models/security_monitoring_signal_response.rb +80 -0
  79. data/lib/datadog_api_client/v2/models/security_monitoring_signal_rule_response_query.rb +26 -2
  80. data/lib/datadog_api_client/v2/models/security_monitoring_signal_state_update_data.rb +24 -4
  81. data/lib/datadog_api_client/v2/models/security_monitoring_signal_triage_update_data.rb +24 -4
  82. data/lib/datadog_api_client/v2/models/security_monitoring_standard_rule_query.rb +1 -19
  83. data/lib/datadog_api_client/v2/models/security_monitoring_triage_user.rb +11 -1
  84. data/lib/datadog_api_client/v2/models/sensitive_data_scanner_get_config_response_data.rb +11 -1
  85. data/lib/datadog_api_client/v2/models/sensitive_data_scanner_meta.rb +11 -1
  86. data/lib/datadog_api_client/v2/models/sensitive_data_scanner_standard_pattern_attributes.rb +11 -1
  87. data/lib/datadog_api_client/v2/models/team_attributes.rb +50 -4
  88. data/lib/datadog_api_client/v2/models/team_create_attributes.rb +57 -4
  89. data/lib/datadog_api_client/v2/models/team_relationships_links.rb +80 -0
  90. data/lib/datadog_api_client/v2/models/team_response.rb +1 -1
  91. data/lib/datadog_api_client/v2/models/team_update_attributes.rb +57 -4
  92. data/lib/datadog_api_client/v2/models/teams_response.rb +24 -4
  93. data/lib/datadog_api_client/v2/models/teams_response_links.rb +129 -0
  94. data/lib/datadog_api_client/v2/models/teams_response_meta.rb +80 -0
  95. data/lib/datadog_api_client/v2/models/teams_response_meta_pagination.rb +150 -0
  96. data/lib/datadog_api_client/v2/models/usage_attributes_object.rb +11 -1
  97. data/lib/datadog_api_client/v2/models/user_teams_response.rb +24 -4
  98. data/lib/datadog_api_client/version.rb +1 -1
  99. data/spec/configuration_spec.rb +17 -0
  100. data/spec/retry_spec.rb +44 -0
  101. metadata +16 -3
@@ -2,7 +2,6 @@
2
2
  import pathlib
3
3
  import json
4
4
  import re
5
- import warnings
6
5
  from functools import singledispatch
7
6
 
8
7
 
@@ -185,6 +184,8 @@ def _format_oneof(data, schema, name_prefix=None, replace_values=None):
185
184
  matched = 0
186
185
  for sub_schema in schema["oneOf"]:
187
186
  try:
187
+ if "items" in sub_schema and not isinstance(data, list):
188
+ continue
188
189
  formatted = format_data_with_schema(
189
190
  data,
190
191
  sub_schema,
@@ -196,13 +197,11 @@ def _format_oneof(data, schema, name_prefix=None, replace_values=None):
196
197
  # parameters += formatted
197
198
  parameters = formatted
198
199
  matched += 1
199
- except (KeyError, ValueError):
200
+ except (KeyError, ValueError, TypeError):
200
201
  pass
201
202
 
202
- if matched == 0:
203
+ if matched != 1:
203
204
  raise ValueError(f"[{matched}] {data} is not valid for schema")
204
- elif matched > 1:
205
- warnings.warn(f"[{matched}] {data} is not valid for schema")
206
205
 
207
206
  return parameters
208
207
 
@@ -246,11 +245,28 @@ def format_data_with_schema(
246
245
  def open_file(x):
247
246
  return f"File.open({repr(x)}, 'r')"
248
247
 
248
+ def format_number(x):
249
+ if isinstance(x, (bool, str)):
250
+ raise TypeError(f"{x} is not supported type {schema}")
251
+ return str(x)
252
+
253
+ def format_string(x):
254
+ if isinstance(x, bool):
255
+ raise TypeError(f"{x} is not supported type {schema}")
256
+ if schema.get("format") == "binary":
257
+ return open_file(x)
258
+ return repr(x)
259
+
260
+ def format_boolean(x):
261
+ if not isinstance(x, bool):
262
+ raise TypeError(f"{x} is not supported type {schema}")
263
+ return "true" if x else "false"
264
+
249
265
  formatter = {
250
- "number": str,
251
- "integer": str,
252
- "boolean": lambda x: "true" if x else "false",
253
- "string": open_file if schema.get("format") == "binary" else repr,
266
+ "number": format_number,
267
+ "integer": format_number,
268
+ "boolean": format_boolean,
269
+ "string": format_string,
254
270
  None: repr,
255
271
  }[schema.get("type")]
256
272
 
@@ -281,18 +297,7 @@ def format_data_with_schema_list(
281
297
  name = get_name(schema)
282
298
 
283
299
  if "oneOf" in schema:
284
- for sub_schema in schema["oneOf"]:
285
- try:
286
- value = format_data_with_schema(
287
- data,
288
- sub_schema,
289
- replace_values=replace_values,
290
- default_name=name,
291
- )
292
- except (KeyError, ValueError):
293
- continue
294
- return value
295
- raise ValueError(f"{data} is not valid oneOf {schema}")
300
+ return _format_oneof(data, schema, name_prefix=name_prefix, replace_values=replace_values)
296
301
 
297
302
  parameters = ""
298
303
  for d in data:
@@ -324,7 +329,7 @@ def format_data_with_schema_dict(
324
329
  missing = required_properties - set(data.keys())
325
330
  if missing:
326
331
  raise ValueError(f"missing required properties: {missing}")
327
-
332
+
328
333
  for k, v in data.items():
329
334
  if k not in schema["properties"]:
330
335
  continue
@@ -355,18 +360,18 @@ def format_data_with_schema_dict(
355
360
  if default_name and not schema.get("additionalProperties") and schema.get("properties"):
356
361
  name = default_name
357
362
  else:
358
- name = "dict"
359
- warnings.warn(f"Unnamed schema {schema} for {data}")
363
+ if not parameters and data:
364
+ parameters = ", ".join(f"\"{k}\": \"{v}\"" for k, v in data.items())
365
+ return f"{{\n{parameters}}}"
360
366
 
361
367
  if "oneOf" in schema:
362
368
  name = None
363
369
  parameters = _format_oneof(data, schema, name_prefix=name_prefix, replace_values=replace_values)
364
370
 
365
- if name == "dict":
366
- if not parameters and data:
367
- parameters = ", ".join(f"\"{k}\": \"{v}\"" for k, v in data.items())
368
- return f"{{\n{parameters}}}"
369
- elif name:
371
+ if parameters == "" and schema.get("type") == "string":
372
+ raise ValueError(f"No schema matched for {data}")
373
+
374
+ if name:
370
375
  return f"{name_prefix}{name}.new({{\n{parameters}}})"
371
376
 
372
377
  return parameters
@@ -44,71 +44,99 @@ module {{ module_name }}
44
44
  # the data deserialized from response body (could be nil), response status code and response headers.
45
45
  def call_api(http_method, path, opts = {})
46
46
  request = build_request(http_method, path, opts)
47
- if opts[:stream_body]
48
- tempfile = nil
49
- encoding = nil
50
-
51
- response = request.perform do | chunk |
52
- unless tempfile
53
- content_disposition = chunk.http_response.header['Content-Disposition']
54
- if content_disposition && content_disposition =~ /filename=/i
55
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
56
- prefix = sanitize_filename(filename)
57
- else
58
- prefix = 'download-'
59
- end
60
- prefix = prefix + '-' unless prefix.end_with?('-')
61
- unless encoding
62
- encoding = chunk.encoding
47
+ attempt = 0
48
+ loop do
49
+ if opts[:stream_body]
50
+ tempfile = nil
51
+ encoding = nil
52
+
53
+ response = request.perform do | chunk |
54
+ unless tempfile
55
+ content_disposition = chunk.http_response.header['Content-Disposition']
56
+ if content_disposition && content_disposition =~ /filename=/i
57
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
58
+ prefix = sanitize_filename(filename)
59
+ else
60
+ prefix = 'download-'
61
+ end
62
+ prefix = prefix + '-' unless prefix.end_with?('-')
63
+ unless encoding
64
+ encoding = chunk.encoding
65
+ end
66
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
67
+ @tempfile = tempfile
63
68
  end
64
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
65
- @tempfile = tempfile
69
+ chunk.force_encoding(encoding)
70
+ tempfile.write(chunk)
71
+ end
72
+ if tempfile
73
+ tempfile.close
74
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
75
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
76
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
77
+ "explicitly with `tempfile.delete`"
66
78
  end
67
- chunk.force_encoding(encoding)
68
- tempfile.write(chunk)
79
+ else
80
+ response = request.perform
69
81
  end
70
- if tempfile
71
- tempfile.close
72
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
73
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
74
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
75
- "explicitly with `tempfile.delete`"
82
+
83
+ if @config.debugging
84
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
76
85
  end
77
- else
78
- response = request.perform
79
- end
80
86
 
81
- if @config.debugging
82
- @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
83
- end
87
+ unless response.success?
88
+ if response.request_timeout?
89
+ fail APIError.new('Connection timed out')
90
+ elsif response.code == 0
91
+ # Errors from libcurl will be made visible here
92
+ fail APIError.new(:code => 0,
93
+ :message => response.return_message)
94
+ else
95
+ body = response.body
96
+ if response.headers['Content-Encoding'].eql?('gzip') && !(body.nil? || body.empty?) then
97
+ gzip = Zlib::Inflate.new(Zlib::MAX_WBITS + 16)
98
+ body = gzip.inflate(body)
99
+ gzip.close
100
+ end
101
+ if should_retry(attempt, @config.max_retries, response.code, @config.enable_retry)
102
+ sleep calculate_retry_interval(response, @config.backoff_base, @config.backoff_multiplier, attempt, @config.timeout)
103
+ attempt = attempt + 1
104
+ next
105
+ else
106
+ fail APIError.new(:code => response.code,
107
+ :response_headers => response.headers,
108
+ :response_body => body),
109
+ response.message
110
+ end
111
+ end
112
+ end
84
113
 
85
- unless response.success?
86
- if response.request_timeout?
87
- fail APIError.new('Connection timed out')
88
- elsif response.code == 0
89
- # Errors from libcurl will be made visible here
90
- fail APIError.new(:code => 0,
91
- :message => response.return_message)
114
+ if opts[:return_type]
115
+ data = deserialize(opts[:api_version], response, opts[:return_type])
92
116
  else
93
- body = response.body
94
- if response.headers['Content-Encoding'].eql?('gzip') && !(body.nil? || body.empty?) then
95
- gzip = Zlib::Inflate.new(Zlib::MAX_WBITS + 16)
96
- body = gzip.inflate(body)
97
- gzip.close
98
- end
99
- fail APIError.new(:code => response.code,
100
- :response_headers => response.headers,
101
- :response_body => body),
102
- response.message
117
+ data = nil
103
118
  end
119
+ return data, response.code, response.headers
104
120
  end
121
+ end
122
+
123
+ # Check if an http request should be retried
124
+ def should_retry(attempt, max_retries, http_code, enable_retry)
125
+ (http_code == 429 || http_code >= 500) && max_retries > attempt && enable_retry
126
+ end
105
127
 
106
- if opts[:return_type]
107
- data = deserialize(opts[:api_version], response, opts[:return_type])
128
+ # Calculate the sleep interval between 2 retry attempts
129
+ def calculate_retry_interval(response, backoff_base, backoff_multiplier, attempt, timeout)
130
+ reset_header = response.headers['X-Ratelimit-Reset']
131
+ if !reset_header.nil? && !reset_header.empty?
132
+ sleep_time = reset_header.to_i
108
133
  else
109
- data = nil
134
+ sleep_time = (backoff_multiplier**attempt) * backoff_base
135
+ if timeout && timeout > 0
136
+ sleep_time = [timeout, sleep_time].min
137
+ end
110
138
  end
111
- return data, response.code, response.headers
139
+ sleep_time
112
140
  end
113
141
 
114
142
  # Build the HTTP request
@@ -138,6 +138,16 @@ module {{ module_name }}
138
138
  # Password for proxy server authentication
139
139
  attr_accessor :http_proxypass
140
140
 
141
+ # Enable retry when rate limited
142
+ attr_accessor :enable_retry
143
+
144
+ # Retry backoff calculation parameters
145
+ attr_accessor :backoff_base
146
+ attr_accessor :backoff_multiplier
147
+
148
+ # Maximum number of retry attempts allowed
149
+ attr_accessor :max_retries
150
+
141
151
  def initialize
142
152
  {%- set default_server = openapi.servers[0]|format_server %}
143
153
  @scheme = '{{ default_server.scheme }}'
@@ -149,6 +159,10 @@ module {{ module_name }}
149
159
  @server_operation_variables = {}
150
160
  @api_key = {}
151
161
  @api_key_prefix = {}
162
+ @enable_retry = false
163
+ @backoff_base = 2
164
+ @backoff_multiplier = 2
165
+ @max_retries = 3
152
166
  @timeout = nil
153
167
  @client_side_validation = true
154
168
  @verify_ssl = true
@@ -188,6 +202,13 @@ module {{ module_name }}
188
202
  @@default ||= Configuration.new
189
203
  end
190
204
 
205
+ def backoff_base=(value)
206
+ if value < 2
207
+ raise ArgumentError, 'backoff_base cannot be smaller than 2'
208
+ end
209
+ @backoff_base = value
210
+ end
211
+
191
212
  def configure
192
213
  yield(self) if block_given?
193
214
  end
@@ -19,7 +19,7 @@ repos:
19
19
  name: Format documentation
20
20
  stages: [manual]
21
21
  language: node
22
- language_version: 14.12.0
22
+ language_version: 20.5.0
23
23
  entry: prettier --write --list-different --ignore-unknown README.md
24
24
  "types": [text]
25
25
  files: 'README.md'
@@ -27,7 +27,7 @@ repos:
27
27
  additional_dependencies:
28
28
  # When updating the version of prettier, make sure to check the pre-commit file
29
29
  # And keep the `entry` here up to date https://github.com/pre-commit/mirrors-prettier/blob/master/.pre-commit-hooks.yaml
30
- - prettier@2.5.1
30
+ - prettier@3.0.0
31
31
  - id: generator
32
32
  name: generator
33
33
  language: python
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.14.0 / 2023-08-23
4
+
5
+ ### Fixed
6
+ * Update team schemas by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1470
7
+ * Mark downtime v2 start response as required by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1482
8
+ * Document new properties and fix security monitoring schemas by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1469
9
+ * Add missing CI App fields `page` and `test_level` by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1448
10
+ ### Added
11
+ * Update stated limit for api/v2/metrics from 14 days to 30 days by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1476
12
+ * Add missing sensitive data scanner fields by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1466
13
+ * Add Workflow Executions to usage metering API by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1478
14
+ * Add missing `type` field for OnDemandConcurrencyCap response by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1468
15
+ * Add CI Visibility Intelligent Test Runner to usage metering API by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1477
16
+ * Add custom_links to distribution widget schema by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1485
17
+ * Add usage field `region` by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1486
18
+ * Add `message` field to audit logs response by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1488
19
+ * Add `tags` field to dashboard list response by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1487
20
+ * API specs for user team memberships by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1495
21
+ * Document `EQUAL` comparator by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1498
22
+ * Add persistCookies option synthetics test request by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1497
23
+ * Expose sds_scanned_bytes_usage in usage attribution API by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1501
24
+ * Add support in azure integration endpoint for app service plan filters/cspm/custom metrics by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1496
25
+ * Add APM and USM usage attribution type by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1494
26
+ * Document new attributes for team models by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/1492
27
+ * Add retry support by @HantingZhang2 in https://github.com/DataDog/datadog-api-client-ruby/pull/1502
28
+
29
+ ## New Contributors
30
+ * @HantingZhang2 made their first contribution in https://github.com/DataDog/datadog-api-client-ruby/pull/1502
31
+
32
+ **Full Changelog**: https://github.com/DataDog/datadog-api-client-ruby/compare/v2.13.0...v2.14.0
33
+
3
34
  ## 2.13.0 / 2023-07-20
4
35
 
5
36
  ### Fixed
data/README.md CHANGED
@@ -165,6 +165,29 @@ api_instance.list_incidents_with_pagination() do |incident|
165
165
  end
166
166
  ```
167
167
 
168
+ ### Retry
169
+
170
+ To enable the client to retry when rate limited (status 429) or status 500 and above:
171
+
172
+ ```ruby
173
+ config = DatadogAPIClient::Configuration.new
174
+ config.enable_retry = true
175
+ client = DatadogAPIClient::APIClient.new(config)
176
+ ```
177
+
178
+ The interval between 2 retry attempts will be the value of the `x-ratelimit-reset` response header when available.
179
+ If not, it will be :
180
+
181
+ ```ruby
182
+ (config.backoffMultiplier ** current_retry_count) * config.backoffBase
183
+ ```
184
+
185
+ The maximum number of retry attempts is `3` by default and can be modified with
186
+
187
+ ```ruby
188
+ config.maxRetries
189
+ ```
190
+
168
191
  ## Documentation
169
192
 
170
193
  If you are interested in general documentation for all public Datadog API endpoints, checkout the [general documentation site][api docs].
@@ -4,9 +4,12 @@ require "datadog_api_client"
4
4
  api_instance = DatadogAPIClient::V1::AzureIntegrationAPI.new
5
5
 
6
6
  body = DatadogAPIClient::V1::AzureAccount.new({
7
+ app_service_plan_filters: "key:value,filter:example",
7
8
  automute: true,
8
9
  client_id: "testc7f6-1234-5678-9101-3fcbf464test",
9
10
  client_secret: "testingx./Sw*g/Y33t..R1cH+hScMDt",
11
+ cspm_enabled: true,
12
+ custom_metrics_enabled: true,
10
13
  errors: [
11
14
  "*",
12
15
  ],
@@ -4,9 +4,12 @@ require "datadog_api_client"
4
4
  api_instance = DatadogAPIClient::V1::AzureIntegrationAPI.new
5
5
 
6
6
  body = DatadogAPIClient::V1::AzureAccount.new({
7
+ app_service_plan_filters: "key:value,filter:example",
7
8
  automute: true,
8
9
  client_id: "testc7f6-1234-5678-9101-3fcbf464test",
9
10
  client_secret: "testingx./Sw*g/Y33t..R1cH+hScMDt",
11
+ cspm_enabled: true,
12
+ custom_metrics_enabled: true,
10
13
  errors: [
11
14
  "*",
12
15
  ],
@@ -4,9 +4,12 @@ require "datadog_api_client"
4
4
  api_instance = DatadogAPIClient::V1::AzureIntegrationAPI.new
5
5
 
6
6
  body = DatadogAPIClient::V1::AzureAccount.new({
7
+ app_service_plan_filters: "key:value,filter:example",
7
8
  automute: true,
8
9
  client_id: "testc7f6-1234-5678-9101-3fcbf464test",
9
10
  client_secret: "testingx./Sw*g/Y33t..R1cH+hScMDt",
11
+ cspm_enabled: true,
12
+ custom_metrics_enabled: true,
10
13
  errors: [
11
14
  "*",
12
15
  ],
@@ -4,9 +4,12 @@ require "datadog_api_client"
4
4
  api_instance = DatadogAPIClient::V1::AzureIntegrationAPI.new
5
5
 
6
6
  body = DatadogAPIClient::V1::AzureAccount.new({
7
+ app_service_plan_filters: "key:value,filter:example",
7
8
  automute: true,
8
9
  client_id: "testc7f6-1234-5678-9101-3fcbf464test",
9
10
  client_secret: "testingx./Sw*g/Y33t..R1cH+hScMDt",
11
+ cspm_enabled: true,
12
+ custom_metrics_enabled: true,
10
13
  errors: [
11
14
  "*",
12
15
  ],
@@ -13,6 +13,12 @@ body = DatadogAPIClient::V1::Dashboard.new({
13
13
  title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
14
14
  show_legend: false,
15
15
  type: DatadogAPIClient::V1::DistributionWidgetDefinitionType::DISTRIBUTION,
16
+ custom_links: [
17
+ DatadogAPIClient::V1::WidgetCustomLink.new({
18
+ label: "Example",
19
+ link: "https://example.org/",
20
+ }),
21
+ ],
16
22
  xaxis: DatadogAPIClient::V1::DistributionWidgetXAxis.new({
17
23
  max: "auto",
18
24
  include_zero: true,
@@ -5,11 +5,11 @@ api_instance = DatadogAPIClient::V1::DashboardsAPI.new
5
5
 
6
6
  body = DatadogAPIClient::V1::SharedDashboardInvites.new({
7
7
  data: [
8
- SharedDashboardInvitesDataObject.new({
9
- attributes: SharedDashboardInvitesDataObjectAttributes.new({
8
+ DatadogAPIClient::V1::SharedDashboardInvitesDataObject.new({
9
+ attributes: DatadogAPIClient::V1::SharedDashboardInvitesDataObjectAttributes.new({
10
10
  email: "test@datadoghq.com",
11
11
  }),
12
- type: DashboardInviteType::PUBLIC_DASHBOARD_INVITATION,
12
+ type: DatadogAPIClient::V1::DashboardInviteType::PUBLIC_DASHBOARD_INVITATION,
13
13
  }),
14
14
  ],
15
15
  })
@@ -77,6 +77,7 @@ body = DatadogAPIClient::V1::SyntheticsAPITest.new({
77
77
  token_api_authentication: DatadogAPIClient::V1::SyntheticsBasicAuthOauthTokenApiAuthentication::HEADER,
78
78
  type: DatadogAPIClient::V1::SyntheticsBasicAuthOauthClientType::OAUTH_CLIENT,
79
79
  }),
80
+ persist_cookies: true,
80
81
  }),
81
82
  }),
82
83
  locations: [
@@ -1,6 +1,9 @@
1
1
  # Send pipeline event returns "Request accepted for processing" response
2
2
 
3
3
  require "datadog_api_client"
4
+ DatadogAPIClient.configure do |config|
5
+ config.unstable_operations["v2.create_ci_app_pipeline_event".to_sym] = true
6
+ end
4
7
  api_instance = DatadogAPIClient::V2::CIVisibilityPipelinesAPI.new
5
8
 
6
9
  body = DatadogAPIClient::V2::CIAppCreatePipelineEventRequest.new({
@@ -1,6 +1,9 @@
1
1
  # Send pipeline job event returns "Request accepted for processing" response
2
2
 
3
3
  require "datadog_api_client"
4
+ DatadogAPIClient.configure do |config|
5
+ config.unstable_operations["v2.create_ci_app_pipeline_event".to_sym] = true
6
+ end
4
7
  api_instance = DatadogAPIClient::V2::CIVisibilityPipelinesAPI.new
5
8
 
6
9
  body = DatadogAPIClient::V2::CIAppCreatePipelineEventRequest.new({
@@ -29,7 +29,7 @@ body = DatadogAPIClient::V2::LogsAggregateRequest.new({
29
29
  aggregation: DatadogAPIClient::V2::LogsAggregationFunction::PERCENTILE_90,
30
30
  metric: "@duration",
31
31
  }),
32
- total: true,
32
+ total: "recall",
33
33
  }),
34
34
  ],
35
35
  })
@@ -6,8 +6,8 @@ api_instance = DatadogAPIClient::V2::TeamsAPI.new
6
6
  body = DatadogAPIClient::V2::TeamCreateRequest.new({
7
7
  data: DatadogAPIClient::V2::TeamCreate.new({
8
8
  attributes: DatadogAPIClient::V2::TeamCreateAttributes.new({
9
- handle: "handle-a0fc0297eb519635",
10
- name: "name-a0fc0297eb519635",
9
+ handle: "test-handle-a0fc0297eb519635",
10
+ name: "test-name-a0fc0297eb519635",
11
11
  }),
12
12
  relationships: DatadogAPIClient::V2::TeamCreateRelationships.new({
13
13
  users: DatadogAPIClient::V2::RelationshipToUsers.new({
@@ -0,0 +1,24 @@
1
+ # Create a team with V2 fields returns "CREATED" response
2
+
3
+ require "datadog_api_client"
4
+ api_instance = DatadogAPIClient::V2::TeamsAPI.new
5
+
6
+ body = DatadogAPIClient::V2::TeamCreateRequest.new({
7
+ data: DatadogAPIClient::V2::TeamCreate.new({
8
+ attributes: DatadogAPIClient::V2::TeamCreateAttributes.new({
9
+ handle: "test-handle-a0fc0297eb519635",
10
+ name: "test-name-a0fc0297eb519635",
11
+ avatar: "🥑",
12
+ banner: 7,
13
+ visible_modules: [
14
+ "m1",
15
+ "m2",
16
+ ],
17
+ hidden_modules: [
18
+ "m3",
19
+ ],
20
+ }),
21
+ type: DatadogAPIClient::V2::TeamType::TEAM,
22
+ }),
23
+ })
24
+ p api_instance.create_team(body)
@@ -0,0 +1,8 @@
1
+ # Get user memberships returns "Represents a user's association to a team" response
2
+
3
+ require "datadog_api_client"
4
+ api_instance = DatadogAPIClient::V2::TeamsAPI.new
5
+
6
+ # there is a valid "user" in the system
7
+ USER_DATA_ID = ENV["USER_DATA_ID"]
8
+ p api_instance.get_user_memberships(USER_DATA_ID)
@@ -13,6 +13,15 @@ body = DatadogAPIClient::V2::TeamUpdateRequest.new({
13
13
  attributes: DatadogAPIClient::V2::TeamUpdateAttributes.new({
14
14
  handle: DD_TEAM_DATA_ATTRIBUTES_HANDLE,
15
15
  name: "Example Team updated",
16
+ avatar: "🥑",
17
+ banner: 7,
18
+ hidden_modules: [
19
+ "m3",
20
+ ],
21
+ visible_modules: [
22
+ "m1",
23
+ "m2",
24
+ ],
16
25
  }),
17
26
  type: DatadogAPIClient::V2::TeamType::TEAM,
18
27
  }),