datadog_api_client 1.11.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (292) hide show
  1. checksums.yaml +4 -4
  2. data/.apigentools-info +4 -4
  3. data/.generator/conftest.py +2 -1
  4. data/.generator/schemas/v1/openapi.yaml +293 -116
  5. data/.generator/schemas/v2/openapi.yaml +1156 -41
  6. data/.generator/src/generator/cli.py +57 -40
  7. data/.generator/src/generator/openapi.py +12 -6
  8. data/.generator/src/generator/templates/api.j2 +14 -13
  9. data/.generator/src/generator/templates/api_client.j2 +63 -11
  10. data/.generator/src/generator/templates/configuration.j2 +12 -8
  11. data/.generator/src/generator/templates/example.j2 +6 -1
  12. data/.generator/src/generator/templates/inflector.j2 +28 -0
  13. data/.generator/src/generator/templates/model_base.j2 +2 -2
  14. data/.generator/src/generator/templates/model_oneof.j2 +1 -1
  15. data/.generator/src/generator/templates/package.j2 +7 -12
  16. data/.github/workflows/approved_status.yml +0 -2
  17. data/.github/workflows/codeql-analysis.yml +49 -0
  18. data/.github/workflows/docs.yml +1 -1
  19. data/.github/workflows/prepare_release.yml +1 -1
  20. data/.github/workflows/publish.yml +1 -1
  21. data/.github/workflows/release.yml +1 -1
  22. data/.github/workflows/test.yml +4 -6
  23. data/.github/workflows/test_integration.yml +1 -1
  24. data/.pre-commit-config.yaml +3 -12
  25. data/CHANGELOG.md +44 -0
  26. data/Gemfile +1 -0
  27. data/Makefile +1 -2
  28. data/README.md +13 -13
  29. data/datadog_api_client.gemspec +2 -0
  30. data/examples/v1/downtimes/CreateDowntime_1393233946.rb +3 -0
  31. data/examples/v1/downtimes/CreateDowntime_2908359488.rb +3 -0
  32. data/examples/v1/downtimes/CreateDowntime_3059354445.rb +3 -0
  33. data/examples/v1/events/ListEvents.rb +1 -1
  34. data/examples/v1/pagerduty-integration/DeletePagerDutyIntegrationService.rb +2 -2
  35. data/examples/v1/service-level-objectives/GetSLOHistory.rb +1 -1
  36. data/examples/v1/service-level-objectives/SearchSLO.rb +1 -1
  37. data/examples/v1/synthetics/CreateSyntheticsBrowserTest_2932742688.rb +1 -1
  38. data/examples/v1/synthetics/GetAPITestLatestResults.rb +1 -1
  39. data/examples/v1/synthetics/GetAPITestResult.rb +1 -1
  40. data/examples/v1/synthetics/GetBrowserTestLatestResults.rb +1 -1
  41. data/examples/v1/synthetics/GetBrowserTestResult.rb +1 -1
  42. data/examples/v1/usage-metering/GetDailyCustomReports.rb +1 -1
  43. data/examples/v1/usage-metering/GetHourlyUsageAttribution.rb +0 -3
  44. data/examples/v1/usage-metering/GetMonthlyCustomReports.rb +1 -1
  45. data/examples/v1/usage-metering/GetMonthlyUsageAttribution.rb +0 -3
  46. data/examples/v1/usage-metering/GetSpecifiedDailyCustomReports.rb +1 -1
  47. data/examples/v1/usage-metering/GetSpecifiedMonthlyCustomReports.rb +1 -1
  48. data/examples/v1/usage-metering/GetUsageAttribution.rb +1 -1
  49. data/examples/v1/usage-metering/GetUsageCIApp.rb +2 -5
  50. data/examples/v1/usage-metering/GetUsageCIApp_1064440884.rb +8 -0
  51. data/examples/v1/usage-metering/GetUsageCWS.rb +2 -5
  52. data/examples/v1/usage-metering/GetUsageCWS_736958514.rb +8 -0
  53. data/examples/v1/usage-metering/GetUsageDBM.rb +2 -5
  54. data/examples/v1/usage-metering/GetUsageDBM_3446806203.rb +8 -0
  55. data/examples/v1/usage-metering/GetUsageLambda.rb +2 -5
  56. data/examples/v1/usage-metering/GetUsageLambda_3132428705.rb +8 -0
  57. data/examples/v1/usage-metering/GetUsageLogs.rb +2 -5
  58. data/examples/v1/usage-metering/GetUsageLogsByIndex.rb +2 -5
  59. data/examples/v1/usage-metering/GetUsageLogsByIndex_1025184776.rb +8 -0
  60. data/examples/v1/usage-metering/GetUsageLogs_2562396405.rb +8 -0
  61. data/examples/v1/usage-metering/GetUsageNetworkFlows.rb +2 -5
  62. data/examples/v1/usage-metering/GetUsageNetworkFlows_1239422069.rb +8 -0
  63. data/examples/v1/usage-metering/GetUsageNetworkHosts.rb +2 -5
  64. data/examples/v1/usage-metering/GetUsageNetworkHosts_1249907835.rb +8 -0
  65. data/examples/v1/usage-metering/GetUsageOnlineArchive.rb +2 -5
  66. data/examples/v1/usage-metering/GetUsageOnlineArchive_1501172903.rb +8 -0
  67. data/examples/v1/usage-metering/GetUsageRumSessions.rb +2 -5
  68. data/examples/v1/usage-metering/GetUsageRumSessions_714937291.rb +8 -0
  69. data/examples/v1/usage-metering/GetUsageRumUnits.rb +2 -5
  70. data/examples/v1/usage-metering/GetUsageRumUnits_3959755399.rb +8 -0
  71. data/examples/v1/usage-metering/GetUsageSDS.rb +2 -5
  72. data/examples/v1/usage-metering/GetUsageSDS_271128478.rb +8 -0
  73. data/examples/v1/usage-metering/GetUsageSynthetics.rb +1 -1
  74. data/examples/v1/usage-metering/GetUsageSyntheticsAPI.rb +2 -5
  75. data/examples/v1/usage-metering/GetUsageSyntheticsAPI_4048033529.rb +8 -0
  76. data/examples/v1/usage-metering/GetUsageSyntheticsBrowser.rb +2 -5
  77. data/examples/v1/usage-metering/GetUsageSyntheticsBrowser_1704663299.rb +8 -0
  78. data/examples/v2/audit/ListAuditLogs_1275402458.rb +8 -0
  79. data/examples/v2/audit/SearchAuditLogs_3215529662.rb +22 -0
  80. data/examples/v2/events/ListEvents.rb +8 -0
  81. data/examples/v2/events/ListEvents_1527584014.rb +13 -0
  82. data/examples/v2/events/ListEvents_2663715109.rb +14 -0
  83. data/examples/v2/events/SearchEvents.rb +23 -0
  84. data/examples/v2/events/SearchEvents_3856995058.rb +25 -0
  85. data/examples/v2/incident-services/CreateIncidentService.rb +1 -1
  86. data/examples/v2/incident-services/DeleteIncidentService.rb +1 -1
  87. data/examples/v2/incident-services/GetIncidentService.rb +1 -1
  88. data/examples/v2/incident-services/ListIncidentServices.rb +1 -1
  89. data/examples/v2/incident-services/UpdateIncidentService.rb +1 -1
  90. data/examples/v2/incident-teams/CreateIncidentTeam.rb +1 -1
  91. data/examples/v2/incident-teams/DeleteIncidentTeam.rb +1 -1
  92. data/examples/v2/incident-teams/GetIncidentTeam.rb +1 -1
  93. data/examples/v2/incident-teams/ListIncidentTeams.rb +1 -1
  94. data/examples/v2/incident-teams/UpdateIncidentTeam.rb +1 -1
  95. data/examples/v2/incidents/CreateIncident.rb +1 -1
  96. data/examples/v2/incidents/DeleteIncident.rb +1 -1
  97. data/examples/v2/incidents/GetIncident.rb +1 -1
  98. data/examples/v2/incidents/ListIncidents.rb +1 -1
  99. data/examples/v2/incidents/ListIncidents_2665616954.rb +11 -0
  100. data/examples/v2/incidents/UpdateIncident.rb +1 -1
  101. data/examples/v2/incidents/UpdateIncident_1009194038.rb +1 -1
  102. data/examples/v2/incidents/UpdateIncident_3369341440.rb +1 -1
  103. data/examples/v2/logs/ListLogsGet_738202670.rb +8 -0
  104. data/examples/v2/logs/ListLogs_3138392594.rb +25 -0
  105. data/examples/v2/metrics/SubmitMetrics.rb +6 -0
  106. data/examples/v2/processes/ListProcesses_797840471.rb +8 -0
  107. data/examples/v2/rum/ListRUMEvents_2680821282.rb +8 -0
  108. data/examples/v2/rum/SearchRUMEvents_574690310.rb +21 -0
  109. data/examples/v2/security-monitoring/EditSecurityMonitoringSignalAssignee.rb +15 -0
  110. data/examples/v2/security-monitoring/EditSecurityMonitoringSignalIncidents.rb +15 -0
  111. data/examples/v2/security-monitoring/EditSecurityMonitoringSignalState.rb +14 -0
  112. data/examples/v2/security-monitoring/ListSecurityMonitoringSignals_3960412991.rb +8 -0
  113. data/examples/v2/security-monitoring/SearchSecurityMonitoringSignals_1309350146.rb +20 -0
  114. data/examples/v2/security-monitoring/UpdateSecurityMonitoringRule.rb +1 -0
  115. data/examples/v2/usage-metering/GetEstimatedCostByOrg.rb +5 -2
  116. data/examples/v2/usage-metering/GetEstimatedCostByOrg_2734954020.rb +11 -0
  117. data/examples/v2/usage-metering/GetEstimatedCostByOrg_3186693804.rb +11 -0
  118. data/examples/v2/usage-metering/GetUsageApplicationSecurityMonitoring.rb +2 -5
  119. data/examples/v2/usage-metering/GetUsageApplicationSecurityMonitoring_3959166796.rb +8 -0
  120. data/examples/v2/usage-metering/GetUsageLambdaTracedInvocations.rb +2 -5
  121. data/examples/v2/usage-metering/GetUsageLambdaTracedInvocations_1436752065.rb +8 -0
  122. data/examples/v2/usage-metering/GetUsageObservabilityPipelines.rb +2 -5
  123. data/examples/v2/usage-metering/GetUsageObservabilityPipelines_970725512.rb +8 -0
  124. data/lib/datadog_api_client/{v2/api_client.rb → api_client.rb} +63 -11
  125. data/lib/datadog_api_client/api_key_configuration.rb +1 -18
  126. data/lib/datadog_api_client/{v1/configuration.rb → configuration.rb} +84 -31
  127. data/lib/datadog_api_client/inflector.rb +1293 -0
  128. data/lib/datadog_api_client/models.rb +66 -0
  129. data/lib/datadog_api_client/v1/api/authentication_api.rb +3 -11
  130. data/lib/datadog_api_client/v1/api/aws_integration_api.rb +19 -91
  131. data/lib/datadog_api_client/v1/api/aws_logs_integration_api.rb +15 -71
  132. data/lib/datadog_api_client/v1/api/azure_integration_api.rb +11 -51
  133. data/lib/datadog_api_client/v1/api/dashboard_lists_api.rb +11 -51
  134. data/lib/datadog_api_client/v1/api/dashboards_api.rb +15 -71
  135. data/lib/datadog_api_client/v1/api/downtimes_api.rb +15 -71
  136. data/lib/datadog_api_client/v1/api/events_api.rb +9 -33
  137. data/lib/datadog_api_client/v1/api/gcp_integration_api.rb +9 -41
  138. data/lib/datadog_api_client/v1/api/hosts_api.rb +9 -41
  139. data/lib/datadog_api_client/v1/api/ip_ranges_api.rb +3 -11
  140. data/lib/datadog_api_client/v1/api/key_management_api.rb +21 -101
  141. data/lib/datadog_api_client/v1/api/logs_api.rb +5 -21
  142. data/lib/datadog_api_client/v1/api/logs_indexes_api.rb +13 -61
  143. data/lib/datadog_api_client/v1/api/logs_pipelines_api.rb +15 -71
  144. data/lib/datadog_api_client/v1/api/metrics_api.rb +15 -71
  145. data/lib/datadog_api_client/v1/api/monitors_api.rb +21 -101
  146. data/lib/datadog_api_client/v1/api/notebooks_api.rb +11 -51
  147. data/lib/datadog_api_client/v1/api/organizations_api.rb +13 -61
  148. data/lib/datadog_api_client/v1/api/pager_duty_integration_api.rb +9 -41
  149. data/lib/datadog_api_client/v1/api/security_monitoring_api.rb +8 -32
  150. data/lib/datadog_api_client/v1/api/service_checks_api.rb +3 -11
  151. data/lib/datadog_api_client/v1/api/service_level_objective_corrections_api.rb +11 -51
  152. data/lib/datadog_api_client/v1/api/service_level_objectives_api.rb +31 -99
  153. data/lib/datadog_api_client/v1/api/slack_integration_api.rb +11 -51
  154. data/lib/datadog_api_client/v1/api/snapshots_api.rb +3 -11
  155. data/lib/datadog_api_client/v1/api/synthetics_api.rb +55 -271
  156. data/lib/datadog_api_client/v1/api/tags_api.rb +11 -51
  157. data/lib/datadog_api_client/v1/api/usage_metering_api.rb +171 -418
  158. data/lib/datadog_api_client/v1/api/users_api.rb +11 -51
  159. data/lib/datadog_api_client/v1/api/webhooks_integration_api.rb +17 -81
  160. data/lib/datadog_api_client/v1/model_base.rb +2 -2
  161. data/lib/datadog_api_client/v1/models/distribution_point_item.rb +1 -1
  162. data/lib/datadog_api_client/v1/models/distribution_widget_histogram_request_query.rb +1 -1
  163. data/lib/datadog_api_client/v1/models/formula_and_function_query_definition.rb +1 -1
  164. data/lib/datadog_api_client/v1/models/hourly_usage_attribution_body.rb +5 -1
  165. data/lib/datadog_api_client/v1/models/hourly_usage_attribution_usage_type.rb +7 -0
  166. data/lib/datadog_api_client/v1/models/logs_processor.rb +1 -1
  167. data/lib/datadog_api_client/v1/models/monitor_formula_and_function_query_definition.rb +1 -1
  168. data/lib/datadog_api_client/v1/models/monthly_usage_attribution_body.rb +6 -2
  169. data/lib/datadog_api_client/v1/models/monthly_usage_attribution_supported_metrics.rb +14 -0
  170. data/lib/datadog_api_client/v1/models/monthly_usage_attribution_values.rb +21 -1
  171. data/lib/datadog_api_client/v1/models/notebook_cell_create_request_attributes.rb +1 -1
  172. data/lib/datadog_api_client/v1/models/notebook_cell_response_attributes.rb +1 -1
  173. data/lib/datadog_api_client/v1/models/notebook_cell_time.rb +1 -1
  174. data/lib/datadog_api_client/v1/models/notebook_cell_update_request_attributes.rb +1 -1
  175. data/lib/datadog_api_client/v1/models/notebook_global_time.rb +1 -1
  176. data/lib/datadog_api_client/v1/models/notebook_update_cell.rb +1 -1
  177. data/lib/datadog_api_client/v1/models/sunburst_widget_legend.rb +1 -1
  178. data/lib/datadog_api_client/v1/models/synthetics_assertion.rb +1 -1
  179. data/lib/datadog_api_client/v1/models/synthetics_basic_auth.rb +1 -1
  180. data/lib/datadog_api_client/v1/models/tree_map_color_by.rb +1 -1
  181. data/lib/datadog_api_client/v1/models/tree_map_group_by.rb +1 -1
  182. data/lib/datadog_api_client/v1/models/tree_map_size_by.rb +1 -1
  183. data/lib/datadog_api_client/v1/models/tree_map_widget_definition.rb +28 -6
  184. data/lib/datadog_api_client/v1/models/usage_attribution_body.rb +6 -2
  185. data/lib/datadog_api_client/v1/models/usage_attribution_sort.rb +2 -0
  186. data/lib/datadog_api_client/v1/models/usage_attribution_supported_metrics.rb +2 -0
  187. data/lib/datadog_api_client/v1/models/usage_attribution_values.rb +22 -2
  188. data/lib/datadog_api_client/v1/models/widget_definition.rb +1 -1
  189. data/lib/datadog_api_client/v2/api/audit_api.rb +11 -25
  190. data/lib/datadog_api_client/v2/api/authn_mappings_api.rb +11 -51
  191. data/lib/datadog_api_client/v2/api/cloud_workload_security_api.rb +13 -61
  192. data/lib/datadog_api_client/v2/api/dashboard_lists_api.rb +9 -41
  193. data/lib/datadog_api_client/v2/api/events_api.rb +228 -0
  194. data/lib/datadog_api_client/v2/api/incident_services_api.rb +36 -46
  195. data/lib/datadog_api_client/v2/api/incident_teams_api.rb +36 -46
  196. data/lib/datadog_api_client/v2/api/incidents_api.rb +39 -48
  197. data/lib/datadog_api_client/v2/api/key_management_api.rb +29 -141
  198. data/lib/datadog_api_client/v2/api/logs_api.rb +15 -45
  199. data/lib/datadog_api_client/v2/api/logs_archives_api.rb +21 -101
  200. data/lib/datadog_api_client/v2/api/logs_metrics_api.rb +11 -51
  201. data/lib/datadog_api_client/v2/api/metrics_api.rb +26 -112
  202. data/lib/datadog_api_client/v2/api/opsgenie_integration_api.rb +11 -51
  203. data/lib/datadog_api_client/v2/api/organizations_api.rb +3 -11
  204. data/lib/datadog_api_client/v2/api/processes_api.rb +6 -13
  205. data/lib/datadog_api_client/v2/api/roles_api.rb +27 -131
  206. data/lib/datadog_api_client/v2/api/rum_api.rb +13 -35
  207. data/lib/datadog_api_client/v2/api/security_monitoring_api.rb +247 -125
  208. data/lib/datadog_api_client/v2/api/service_accounts_api.rb +11 -51
  209. data/lib/datadog_api_client/v2/api/usage_metering_api.rb +132 -68
  210. data/lib/datadog_api_client/v2/api/users_api.rb +21 -101
  211. data/lib/datadog_api_client/v2/model_base.rb +2 -2
  212. data/lib/datadog_api_client/v2/models/api_key_response_included_item.rb +1 -1
  213. data/lib/datadog_api_client/v2/models/application_key_response_included_item.rb +1 -1
  214. data/lib/datadog_api_client/v2/models/authn_mapping_included.rb +1 -1
  215. data/lib/datadog_api_client/v2/models/event.rb +141 -0
  216. data/lib/datadog_api_client/v2/models/event_attributes.rb +305 -0
  217. data/lib/datadog_api_client/v2/models/event_priority.rb +27 -0
  218. data/lib/datadog_api_client/v2/models/event_response.rb +133 -0
  219. data/lib/datadog_api_client/v2/models/event_response_attributes.rb +133 -0
  220. data/lib/datadog_api_client/v2/models/event_status_type.rb +35 -0
  221. data/lib/datadog_api_client/v2/models/event_type.rb +26 -0
  222. data/lib/datadog_api_client/v2/models/events_list_request.rb +142 -0
  223. data/lib/datadog_api_client/v2/models/events_list_response.rb +133 -0
  224. data/lib/datadog_api_client/v2/models/events_list_response_links.rb +112 -0
  225. data/lib/datadog_api_client/v2/models/events_query_filter.rb +137 -0
  226. data/lib/datadog_api_client/v2/models/events_query_options.rb +124 -0
  227. data/lib/datadog_api_client/v2/models/events_request_page.rb +134 -0
  228. data/lib/datadog_api_client/v2/models/events_response_metadata.rb +144 -0
  229. data/lib/datadog_api_client/v2/models/events_response_metadata_page.rb +112 -0
  230. data/lib/datadog_api_client/v2/models/events_sort.rb +27 -0
  231. data/lib/datadog_api_client/v2/models/events_warning.rb +131 -0
  232. data/lib/datadog_api_client/v2/models/hourly_usage.rb +133 -0
  233. data/lib/datadog_api_client/v2/models/hourly_usage_attributes.rb +163 -0
  234. data/lib/datadog_api_client/v2/models/hourly_usage_measurement.rb +122 -0
  235. data/lib/datadog_api_client/v2/models/hourly_usage_metadata.rb +111 -0
  236. data/lib/datadog_api_client/v2/models/hourly_usage_pagination.rb +112 -0
  237. data/lib/datadog_api_client/v2/models/hourly_usage_response.rb +123 -0
  238. data/lib/datadog_api_client/v2/models/incident_field_attributes.rb +1 -1
  239. data/lib/datadog_api_client/v2/models/incident_response_included_item.rb +1 -1
  240. data/lib/datadog_api_client/v2/models/incident_service_included_items.rb +1 -1
  241. data/lib/datadog_api_client/v2/models/incident_team_included_items.rb +1 -1
  242. data/lib/datadog_api_client/v2/models/incident_timeline_cell_create_attributes.rb +1 -1
  243. data/lib/datadog_api_client/v2/models/logs_aggregate_bucket_value.rb +1 -1
  244. data/lib/datadog_api_client/v2/models/logs_archive_create_request_destination.rb +1 -1
  245. data/lib/datadog_api_client/v2/models/logs_archive_destination.rb +1 -1
  246. data/lib/datadog_api_client/v2/models/logs_group_by_missing.rb +1 -1
  247. data/lib/datadog_api_client/v2/models/logs_group_by_total.rb +1 -1
  248. data/lib/datadog_api_client/v2/models/metric_intake_type.rb +1 -2
  249. data/lib/datadog_api_client/v2/models/metric_resource.rb +2 -2
  250. data/lib/datadog_api_client/v2/models/metric_series.rb +1 -1
  251. data/lib/datadog_api_client/v2/models/metric_volumes.rb +1 -1
  252. data/lib/datadog_api_client/v2/models/metrics_and_metric_tag_configurations.rb +1 -1
  253. data/lib/datadog_api_client/v2/models/monitor_type.rb +215 -0
  254. data/lib/datadog_api_client/v2/models/rum_aggregate_bucket_value.rb +1 -1
  255. data/lib/datadog_api_client/v2/models/rum_group_by_missing.rb +1 -1
  256. data/lib/datadog_api_client/v2/models/rum_group_by_total.rb +1 -1
  257. data/lib/datadog_api_client/v2/models/security_monitoring_rule_query.rb +13 -1
  258. data/lib/datadog_api_client/v2/models/security_monitoring_rule_query_create.rb +13 -1
  259. data/lib/datadog_api_client/v2/models/security_monitoring_signal_archive_reason.rb +29 -0
  260. data/lib/datadog_api_client/v2/models/security_monitoring_signal_assignee_update_attributes.rb +132 -0
  261. data/lib/datadog_api_client/v2/models/security_monitoring_signal_assignee_update_data.rb +122 -0
  262. data/lib/datadog_api_client/v2/models/security_monitoring_signal_assignee_update_request.rb +122 -0
  263. data/lib/datadog_api_client/v2/models/security_monitoring_signal_incidents_update_attributes.rb +134 -0
  264. data/lib/datadog_api_client/v2/models/security_monitoring_signal_incidents_update_data.rb +122 -0
  265. data/lib/datadog_api_client/v2/models/security_monitoring_signal_incidents_update_request.rb +122 -0
  266. data/lib/datadog_api_client/v2/models/security_monitoring_signal_state.rb +28 -0
  267. data/lib/datadog_api_client/v2/models/security_monitoring_signal_state_update_attributes.rb +152 -0
  268. data/lib/datadog_api_client/v2/models/security_monitoring_signal_state_update_data.rb +122 -0
  269. data/lib/datadog_api_client/v2/models/security_monitoring_signal_state_update_request.rb +122 -0
  270. data/lib/datadog_api_client/v2/models/security_monitoring_signal_triage_attributes.rb +248 -0
  271. data/lib/datadog_api_client/v2/models/security_monitoring_signal_triage_update_data.rb +111 -0
  272. data/lib/datadog_api_client/v2/models/security_monitoring_signal_triage_update_response.rb +122 -0
  273. data/lib/datadog_api_client/v2/models/security_monitoring_triage_user.rb +152 -0
  274. data/lib/datadog_api_client/v2/models/user_response_included_item.rb +1 -1
  275. data/lib/datadog_api_client/version.rb +1 -1
  276. data/lib/datadog_api_client.rb +13 -5
  277. data/spec/{v1/api_client_spec.rb → api_client_spec.rb} +29 -29
  278. data/spec/{v1/configuration_spec.rb → configuration_spec.rb} +3 -3
  279. data/spec/spec_helper.rb +1 -3
  280. metadata +109 -22
  281. data/.dockerignore +0 -1
  282. data/.generator/src/generator/templates/api_error.j2 +0 -49
  283. data/examples/v2/usage-metering/GetEstimatedCostByOrg_1171921972.rb +0 -9
  284. data/examples/v2/usage-metering/GetEstimatedCostByOrg_627383212.rb +0 -9
  285. data/lib/datadog_api_client/v1/api_client.rb +0 -453
  286. data/lib/datadog_api_client/v1/api_error.rb +0 -60
  287. data/lib/datadog_api_client/v1.rb +0 -813
  288. data/lib/datadog_api_client/v2/api_error.rb +0 -60
  289. data/lib/datadog_api_client/v2/configuration.rb +0 -420
  290. data/lib/datadog_api_client/v2.rb +0 -555
  291. data/spec/v2/api_client_spec.rb +0 -210
  292. data/spec/v2/configuration_spec.rb +0 -45
@@ -1,453 +0,0 @@
1
- =begin
2
- #Datadog API V1 Collection
3
-
4
- #Collection of all Datadog Public endpoints.
5
-
6
- The version of the OpenAPI document: 1.0
7
- Contact: support@datadoghq.com
8
- Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9
-
10
- Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11
- This product includes software developed at Datadog (https://www.datadoghq.com/).
12
- Copyright 2020-Present Datadog, Inc.
13
-
14
- =end
15
-
16
- require 'date'
17
- require 'json'
18
- require 'logger'
19
- require 'tempfile'
20
- require 'time'
21
- require 'httparty'
22
-
23
- module DatadogAPIClient::V1
24
- class APIClient
25
- # The Configuration object holding settings to be used in the API client.
26
- attr_accessor :config
27
-
28
- # Defines the headers to be used in HTTP requests of all API calls by default.
29
- #
30
- # @return [Hash]
31
- attr_accessor :default_headers
32
-
33
- # Initializes the APIClient
34
- # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
35
- def initialize(config = Configuration.default)
36
- @config = config
37
- @user_agent = "#{DatadogAPIClient::USER_AGENT}"
38
- @default_headers = {
39
- 'User-Agent' => @user_agent
40
- }
41
- @default_headers['Accept-Encoding'] = 'gzip' if @config.compress
42
- end
43
-
44
- def self.default
45
- @@default ||= APIClient.new
46
- end
47
-
48
- # Call an API with given options.
49
- #
50
- # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
51
- # the data deserialized from response body (could be nil), response status code and response headers.
52
- def call_api(http_method, path, opts = {})
53
- request = build_request(http_method, path, opts)
54
- if opts[:stream_body]
55
- tempfile = nil
56
- encoding = nil
57
-
58
- response = request.perform do | chunk |
59
- unless tempfile
60
- content_disposition = chunk.http_response.header['Content-Disposition']
61
- if content_disposition && content_disposition =~ /filename=/i
62
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
63
- prefix = sanitize_filename(filename)
64
- else
65
- prefix = 'download-'
66
- end
67
- prefix = prefix + '-' unless prefix.end_with?('-')
68
- unless encoding
69
- encoding = chunk.encoding
70
- end
71
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
72
- @tempfile = tempfile
73
- end
74
- chunk.force_encoding(encoding)
75
- tempfile.write(chunk)
76
- end
77
- if tempfile
78
- tempfile.close
79
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
80
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
81
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
82
- "explicitly with `tempfile.delete`"
83
- end
84
- else
85
- response = request.perform
86
- end
87
-
88
- if @config.debugging
89
- @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
90
- end
91
-
92
- unless response.success?
93
- if response.request_timeout?
94
- fail APIError.new('Connection timed out')
95
- elsif response.code == 0
96
- # Errors from libcurl will be made visible here
97
- fail APIError.new(:code => 0,
98
- :message => response.return_message)
99
- else
100
- body = response.body
101
- if response.headers['Content-Encoding'].eql?('gzip') && !(body.nil? || body.empty?) then
102
- gzip = Zlib::Inflate.new(Zlib::MAX_WBITS + 16)
103
- body = gzip.inflate(body)
104
- gzip.close
105
- end
106
- fail APIError.new(:code => response.code,
107
- :response_headers => response.headers,
108
- :response_body => body),
109
- response.message
110
- end
111
- end
112
-
113
- if opts[:return_type]
114
- data = deserialize(response, opts[:return_type])
115
- else
116
- data = nil
117
- end
118
- return data, response.code, response.headers
119
- end
120
-
121
- # Build the HTTP request
122
- #
123
- # @param [String] http_method HTTP method/verb (e.g. POST)
124
- # @param [String] path URL path (e.g. /account/new)
125
- # @option opts [Hash] :header_params Header parameters
126
- # @option opts [Hash] :query_params Query parameters
127
- # @option opts [Hash] :form_params Query parameters
128
- # @option opts [Object] :body HTTP body (JSON/XML)
129
- # @return [HTTParty::Request] A httparty Request
130
- def build_request(http_method, path, opts = {})
131
- url = build_request_url(path, opts)
132
- header_params = @default_headers.merge(opts[:header_params] || {})
133
- query_params = opts[:query_params] || {}
134
- form_params = opts[:form_params] || {}
135
-
136
- update_params_for_auth! header_params, query_params, opts[:auth_names]
137
-
138
- # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
139
- _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
140
-
141
- req_opts = {
142
- :method => http_method,
143
- :headers => header_params,
144
- :query => query_params,
145
- :timeout => @config.timeout,
146
- :verify_peer => @config.verify_ssl,
147
- :verify => _verify_ssl_host,
148
- :verbose => @config.debugging
149
- }
150
-
151
- req_opts[:pem] = File.read(@config.cert_file) if @config.cert_file
152
- req_opts[:pem_password] = File.read(@config.key_file) if @config.key_file
153
-
154
- opts[:stream_body] = true if opts[:return_type] == 'File'
155
-
156
- # set custom cert, if provided
157
- req_opts[:ssl_ca_file] = File.read(@config.ssl_ca_cert) if @config.ssl_ca_cert
158
-
159
- if ["POST", "PATCH", "PUT", "DELETE"].include?(http_method.const_get(:METHOD))
160
- req_body = build_request_body(header_params, form_params, opts[:body])
161
- req_opts.update :body => req_body
162
- if @config.debugging
163
- @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
164
- end
165
- end
166
-
167
- HTTParty::Request.new(http_method, url, req_opts)
168
- end
169
-
170
- # Build the HTTP request body
171
- #
172
- # @param [Hash] header_params Header parameters
173
- # @param [Hash] form_params Query parameters
174
- # @param [Object] body HTTP body (JSON/XML)
175
- # @return [String] HTTP body data in the form of string
176
- def build_request_body(header_params, form_params, body)
177
- # http form
178
- if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
179
- header_params['Content-Type'] == 'multipart/form-data'
180
- data = {}
181
- form_params.each do |key, value|
182
- case value
183
- when ::File, ::Array, nil
184
- # let httparty handle File, Array and nil parameters
185
- data[key] = value
186
- else
187
- data[key] = value.to_s
188
- end
189
- end
190
- elsif body
191
- data = body.is_a?(String) ? body : body.to_json
192
- else
193
- data = nil
194
- end
195
- if header_params['Content-Encoding'] == 'gzip'
196
- gzip = Zlib::Deflate.new(nil, Zlib::MAX_WBITS + 16)
197
- data = gzip.deflate(data, Zlib::FINISH)
198
- gzip.close
199
- elsif header_params['Content-Encoding'] == 'deflate'
200
- data = Zlib::deflate(data)
201
- end
202
- data
203
- end
204
-
205
- # Check if the given MIME is a JSON MIME.
206
- # JSON MIME examples:
207
- # application/json
208
- # application/json; charset=UTF8
209
- # APPLICATION/JSON
210
- # */*
211
- # @param [String] mime MIME
212
- # @return [Boolean] True if the MIME is application/json
213
- def json_mime?(mime)
214
- (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? || (mime == 'text/json')
215
- end
216
-
217
- # Deserialize the response to the given return type.
218
- #
219
- # @param [Response] response HTTP response
220
- # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
221
- def deserialize(response, return_type)
222
- body = response.body
223
-
224
- # handle file downloading - return the File instance processed in request callbacks
225
- # note that response body is empty when the file is written in chunks in request on_body callback
226
- return @tempfile if return_type == 'File'
227
-
228
- return nil if body.nil? || body.empty?
229
-
230
- if response.headers['Content-Encoding'].eql?('gzip') then
231
- gzip = Zlib::Inflate.new(Zlib::MAX_WBITS + 16)
232
- body = gzip.inflate(body)
233
- gzip.close
234
- end
235
-
236
- # return response body directly for String return type
237
- return body if return_type == 'String'
238
-
239
- # ensuring a default content type
240
- content_type = response.headers['Content-Type'] || 'application/json'
241
-
242
- fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
243
-
244
- begin
245
- data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
246
- rescue JSON::ParserError => e
247
- if %w(String Date Time).include?(return_type)
248
- data = body
249
- else
250
- raise e
251
- end
252
- end
253
-
254
- convert_to_type data, return_type
255
- end
256
-
257
- # Convert data to the given return type.
258
- # @param [Object] data Data to be converted
259
- # @param [String] return_type Return type
260
- # @return [Mixed] Data in a particular type
261
- def convert_to_type(data, return_type)
262
- return nil if data.nil?
263
- case return_type
264
- when 'String'
265
- data.to_s
266
- when 'Integer'
267
- data.to_i
268
- when 'Float'
269
- data.to_f
270
- when 'Boolean'
271
- data == true
272
- when 'Time'
273
- # parse date time (expecting ISO 8601 format)
274
- Time.parse data
275
- when 'Date'
276
- # parse date time (expecting ISO 8601 format)
277
- Date.parse data
278
- when 'Object'
279
- # generic object (usually a Hash), return directly
280
- data
281
- when /\AArray<(.+)>\z/
282
- # e.g. Array<Pet>
283
- sub_type = $1
284
- data.map { |item| convert_to_type(item, sub_type) }
285
- when /\AHash\<String, (.+)\>\z/
286
- # e.g. Hash<String, Integer>
287
- sub_type = $1
288
- {}.tap do |hash|
289
- data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
290
- end
291
- else
292
- # models (e.g. Pet) or oneOf
293
- klass = DatadogAPIClient::V1.const_get(return_type)
294
- klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
295
- end
296
- end
297
-
298
- # Sanitize filename by removing path.
299
- # e.g. ../../sun.gif becomes sun.gif
300
- #
301
- # @param [String] filename the filename to be sanitized
302
- # @return [String] the sanitized filename
303
- def sanitize_filename(filename)
304
- filename.gsub(/.*[\/\\]/, '')
305
- end
306
-
307
- def build_request_url(path, opts = {})
308
- # Add leading and trailing slashes to path
309
- path = "/#{path}".gsub(/\/+/, '/')
310
- @config.base_url(opts[:operation]) + path
311
- end
312
-
313
- # Update header and query params based on authentication settings.
314
- #
315
- # @param [Hash] header_params Header parameters
316
- # @param [Hash] query_params Query parameters
317
- # @param [String] auth_names Authentication scheme name
318
- def update_params_for_auth!(header_params, query_params, auth_names)
319
- Array(auth_names).each do |auth_name|
320
- auth_setting = @config.auth_settings[auth_name]
321
- next unless auth_setting
322
- case auth_setting[:in]
323
- when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
324
- when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
325
- else fail ArgumentError, 'Authentication token must be in `query` or `header`'
326
- end
327
- end
328
- end
329
-
330
- # Sets user agent in HTTP header
331
- #
332
- # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
333
- def user_agent=(user_agent)
334
- @user_agent = user_agent
335
- @default_headers['User-Agent'] = @user_agent
336
- end
337
-
338
- # Return Accept header based on an array of accepts provided.
339
- # @param [Array] accepts array for Accept
340
- # @return [String] the Accept header (e.g. application/json)
341
- def select_header_accept(accepts)
342
- return nil if accepts.nil? || accepts.empty?
343
- accepts.join(', ')
344
- end
345
-
346
- # Return Content-Type header based on an array of content types provided.
347
- # @param [Array] content_types array for Content-Type
348
- # @return [String] the Content-Type header (e.g. application/json)
349
- def select_header_content_type(content_types)
350
- # use application/json by default
351
- return 'application/json' if content_types.nil? || content_types.empty?
352
- # use JSON when present, otherwise use the first one
353
- json_content_type = content_types.find { |s| json_mime?(s) }
354
- json_content_type || content_types.first
355
- end
356
-
357
- # Convert object (array, hash, object, etc) to JSON string.
358
- # @param [Object] model object to be converted into JSON string
359
- # @return [String] JSON string representation of the object
360
- def object_to_http_body(model)
361
- return model if model.nil? || model.is_a?(String)
362
- local_body = nil
363
- if model.is_a?(Array)
364
- local_body = model.map { |m| object_to_hash(m) }
365
- else
366
- local_body = object_to_hash(model)
367
- end
368
- local_body.to_json
369
- end
370
-
371
- # Convert object(non-array) to hash.
372
- # @param [Object] obj object to be converted into JSON string
373
- # @return [String] JSON string representation of the object
374
- def object_to_hash(obj)
375
- if obj.respond_to?(:to_hash)
376
- obj.to_hash
377
- else
378
- obj
379
- end
380
- end
381
-
382
- # Build parameter value according to the given collection format.
383
- # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
384
- def build_collection_param(param, collection_format)
385
- case collection_format
386
- when :csv
387
- param.join(',')
388
- when :ssv
389
- param.join(' ')
390
- when :tsv
391
- param.join("\t")
392
- when :pipes
393
- param.join('|')
394
- when :multi
395
- # return the array directly as httparty will handle it as expected
396
- param
397
- else
398
- fail "unknown collection format: #{collection_format.inspect}"
399
- end
400
- end
401
-
402
-
403
- # Retrieve an attribute from a path specification.
404
- #
405
- # @param [Object] obj The source object
406
- # @param [String] attribute_path The path spefication, separated by "."
407
- # @param [Object] default The default value, if not found
408
- # @return [Object] The value found, or default
409
- # @!visibility private
410
- def get_attribute_from_path(obj, attribute_path, default=nil)
411
- for attr in attribute_path.split(".") do
412
- case obj
413
- when Hash
414
- obj = !obj[attr.to_sym].nil? ? obj[attr.to_sym] : obj[attr]
415
- else
416
- obj = obj.send(attr)
417
- end
418
- return default if obj.nil?
419
- end
420
- obj
421
- end
422
-
423
- # Set an attribute at the given path
424
- #
425
- # @param [Object] obj The source object
426
- # @param [String] attribute_path The path spefication, separated by "."
427
- # @param [Object] builder The class matching the top level attribute
428
- # @param [Object] value The value to set
429
- # @!visibility private
430
- def set_attribute_from_path(obj, attribute_path, builder, value)
431
- attrs = attribute_path.split(".")
432
- last = attrs.pop
433
- i = 0
434
- for attr in attrs do
435
- case obj
436
- when Hash
437
- obj = !obj[attr.to_sym].nil? ? obj[attr.to_sym] : obj[attr]
438
- else
439
- obj = obj.send(attr)
440
- end
441
- builder = DatadogAPIClient::V2.const_get(builder.openapi_types[attr.to_sym]) if i > 0
442
- obj = builder.new if obj.nil?
443
- i += 1
444
- end
445
- case obj
446
- when Hash
447
- obj[last.to_sym] = value
448
- else
449
- obj.send(last + "=", value)
450
- end
451
- end
452
- end
453
- end
@@ -1,60 +0,0 @@
1
- =begin
2
- #Datadog API V1 Collection
3
-
4
- #Collection of all Datadog Public endpoints.
5
-
6
- The version of the OpenAPI document: 1.0
7
- Contact: support@datadoghq.com
8
- Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9
-
10
- Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11
- This product includes software developed at Datadog (https://www.datadoghq.com/).
12
- Copyright 2020-Present Datadog, Inc.
13
-
14
- =end
15
-
16
- module DatadogAPIClient::V1
17
- class APIError < StandardError
18
- attr_reader :code, :response_headers, :response_body
19
-
20
- # Usage examples:
21
- # APIError.new
22
- # APIError.new("message")
23
- # APIError.new(:code => 500, :response_headers => {}, :response_body => "")
24
- # APIError.new(:code => 404, :message => "Not Found")
25
- def initialize(arg = nil)
26
- if arg.is_a? Hash
27
- if arg.key?(:message) || arg.key?('message')
28
- super(arg[:message] || arg['message'])
29
- else
30
- super arg
31
- end
32
-
33
- arg.each do |k, v|
34
- instance_variable_set "@#{k}", v
35
- end
36
- else
37
- super arg
38
- end
39
- end
40
-
41
- # Override to_s to display a friendly error message
42
- def to_s
43
- message
44
- end
45
-
46
- def message
47
- if @message.nil?
48
- msg = "Error message: the server returns an error"
49
- else
50
- msg = @message
51
- end
52
-
53
- msg += "\nHTTP status code: #{code}" if code
54
- msg += "\nResponse headers: #{response_headers}" if response_headers
55
- msg += "\nResponse body: #{response_body}" if response_body
56
-
57
- msg
58
- end
59
- end
60
- end