datadog_api_client 1.11.0 → 2.0.2
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.
- checksums.yaml +4 -4
- data/.apigentools-info +4 -4
- data/.generator/conftest.py +2 -1
- data/.generator/schemas/v1/openapi.yaml +293 -116
- data/.generator/schemas/v2/openapi.yaml +1156 -41
- data/.generator/src/generator/cli.py +57 -40
- data/.generator/src/generator/openapi.py +12 -6
- data/.generator/src/generator/templates/api.j2 +14 -13
- data/.generator/src/generator/templates/api_client.j2 +63 -11
- data/.generator/src/generator/templates/configuration.j2 +12 -8
- data/.generator/src/generator/templates/example.j2 +6 -1
- data/.generator/src/generator/templates/inflector.j2 +28 -0
- data/.generator/src/generator/templates/model_base.j2 +2 -2
- data/.generator/src/generator/templates/model_oneof.j2 +1 -1
- data/.generator/src/generator/templates/package.j2 +7 -12
- data/.github/workflows/approved_status.yml +0 -2
- data/.github/workflows/codeql-analysis.yml +49 -0
- data/.github/workflows/docs.yml +1 -1
- data/.github/workflows/prepare_release.yml +1 -1
- data/.github/workflows/publish.yml +1 -1
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/test.yml +4 -6
- data/.github/workflows/test_integration.yml +1 -1
- data/.pre-commit-config.yaml +3 -12
- data/CHANGELOG.md +44 -0
- data/Gemfile +1 -0
- data/Makefile +1 -2
- data/README.md +13 -13
- data/datadog_api_client.gemspec +2 -0
- data/examples/v1/downtimes/CreateDowntime_1393233946.rb +3 -0
- data/examples/v1/downtimes/CreateDowntime_2908359488.rb +3 -0
- data/examples/v1/downtimes/CreateDowntime_3059354445.rb +3 -0
- data/examples/v1/events/ListEvents.rb +1 -1
- data/examples/v1/pagerduty-integration/DeletePagerDutyIntegrationService.rb +2 -2
- data/examples/v1/service-level-objectives/GetSLOHistory.rb +1 -1
- data/examples/v1/service-level-objectives/SearchSLO.rb +1 -1
- data/examples/v1/synthetics/CreateSyntheticsBrowserTest_2932742688.rb +1 -1
- data/examples/v1/synthetics/GetAPITestLatestResults.rb +1 -1
- data/examples/v1/synthetics/GetAPITestResult.rb +1 -1
- data/examples/v1/synthetics/GetBrowserTestLatestResults.rb +1 -1
- data/examples/v1/synthetics/GetBrowserTestResult.rb +1 -1
- data/examples/v1/usage-metering/GetDailyCustomReports.rb +1 -1
- data/examples/v1/usage-metering/GetHourlyUsageAttribution.rb +0 -3
- data/examples/v1/usage-metering/GetMonthlyCustomReports.rb +1 -1
- data/examples/v1/usage-metering/GetMonthlyUsageAttribution.rb +0 -3
- data/examples/v1/usage-metering/GetSpecifiedDailyCustomReports.rb +1 -1
- data/examples/v1/usage-metering/GetSpecifiedMonthlyCustomReports.rb +1 -1
- data/examples/v1/usage-metering/GetUsageAttribution.rb +1 -1
- data/examples/v1/usage-metering/GetUsageCIApp.rb +2 -5
- data/examples/v1/usage-metering/GetUsageCIApp_1064440884.rb +8 -0
- data/examples/v1/usage-metering/GetUsageCWS.rb +2 -5
- data/examples/v1/usage-metering/GetUsageCWS_736958514.rb +8 -0
- data/examples/v1/usage-metering/GetUsageDBM.rb +2 -5
- data/examples/v1/usage-metering/GetUsageDBM_3446806203.rb +8 -0
- data/examples/v1/usage-metering/GetUsageLambda.rb +2 -5
- data/examples/v1/usage-metering/GetUsageLambda_3132428705.rb +8 -0
- data/examples/v1/usage-metering/GetUsageLogs.rb +2 -5
- data/examples/v1/usage-metering/GetUsageLogsByIndex.rb +2 -5
- data/examples/v1/usage-metering/GetUsageLogsByIndex_1025184776.rb +8 -0
- data/examples/v1/usage-metering/GetUsageLogs_2562396405.rb +8 -0
- data/examples/v1/usage-metering/GetUsageNetworkFlows.rb +2 -5
- data/examples/v1/usage-metering/GetUsageNetworkFlows_1239422069.rb +8 -0
- data/examples/v1/usage-metering/GetUsageNetworkHosts.rb +2 -5
- data/examples/v1/usage-metering/GetUsageNetworkHosts_1249907835.rb +8 -0
- data/examples/v1/usage-metering/GetUsageOnlineArchive.rb +2 -5
- data/examples/v1/usage-metering/GetUsageOnlineArchive_1501172903.rb +8 -0
- data/examples/v1/usage-metering/GetUsageRumSessions.rb +2 -5
- data/examples/v1/usage-metering/GetUsageRumSessions_714937291.rb +8 -0
- data/examples/v1/usage-metering/GetUsageRumUnits.rb +2 -5
- data/examples/v1/usage-metering/GetUsageRumUnits_3959755399.rb +8 -0
- data/examples/v1/usage-metering/GetUsageSDS.rb +2 -5
- data/examples/v1/usage-metering/GetUsageSDS_271128478.rb +8 -0
- data/examples/v1/usage-metering/GetUsageSynthetics.rb +1 -1
- data/examples/v1/usage-metering/GetUsageSyntheticsAPI.rb +2 -5
- data/examples/v1/usage-metering/GetUsageSyntheticsAPI_4048033529.rb +8 -0
- data/examples/v1/usage-metering/GetUsageSyntheticsBrowser.rb +2 -5
- data/examples/v1/usage-metering/GetUsageSyntheticsBrowser_1704663299.rb +8 -0
- data/examples/v2/audit/ListAuditLogs_1275402458.rb +8 -0
- data/examples/v2/audit/SearchAuditLogs_3215529662.rb +22 -0
- data/examples/v2/events/ListEvents.rb +8 -0
- data/examples/v2/events/ListEvents_1527584014.rb +13 -0
- data/examples/v2/events/ListEvents_2663715109.rb +14 -0
- data/examples/v2/events/SearchEvents.rb +23 -0
- data/examples/v2/events/SearchEvents_3856995058.rb +25 -0
- data/examples/v2/incident-services/CreateIncidentService.rb +1 -1
- data/examples/v2/incident-services/DeleteIncidentService.rb +1 -1
- data/examples/v2/incident-services/GetIncidentService.rb +1 -1
- data/examples/v2/incident-services/ListIncidentServices.rb +1 -1
- data/examples/v2/incident-services/UpdateIncidentService.rb +1 -1
- data/examples/v2/incident-teams/CreateIncidentTeam.rb +1 -1
- data/examples/v2/incident-teams/DeleteIncidentTeam.rb +1 -1
- data/examples/v2/incident-teams/GetIncidentTeam.rb +1 -1
- data/examples/v2/incident-teams/ListIncidentTeams.rb +1 -1
- data/examples/v2/incident-teams/UpdateIncidentTeam.rb +1 -1
- data/examples/v2/incidents/CreateIncident.rb +1 -1
- data/examples/v2/incidents/DeleteIncident.rb +1 -1
- data/examples/v2/incidents/GetIncident.rb +1 -1
- data/examples/v2/incidents/ListIncidents.rb +1 -1
- data/examples/v2/incidents/ListIncidents_2665616954.rb +11 -0
- data/examples/v2/incidents/UpdateIncident.rb +1 -1
- data/examples/v2/incidents/UpdateIncident_1009194038.rb +1 -1
- data/examples/v2/incidents/UpdateIncident_3369341440.rb +1 -1
- data/examples/v2/logs/ListLogsGet_738202670.rb +8 -0
- data/examples/v2/logs/ListLogs_3138392594.rb +25 -0
- data/examples/v2/metrics/SubmitMetrics.rb +6 -0
- data/examples/v2/processes/ListProcesses_797840471.rb +8 -0
- data/examples/v2/rum/ListRUMEvents_2680821282.rb +8 -0
- data/examples/v2/rum/SearchRUMEvents_574690310.rb +21 -0
- data/examples/v2/security-monitoring/EditSecurityMonitoringSignalAssignee.rb +15 -0
- data/examples/v2/security-monitoring/EditSecurityMonitoringSignalIncidents.rb +15 -0
- data/examples/v2/security-monitoring/EditSecurityMonitoringSignalState.rb +14 -0
- data/examples/v2/security-monitoring/ListSecurityMonitoringSignals_3960412991.rb +8 -0
- data/examples/v2/security-monitoring/SearchSecurityMonitoringSignals_1309350146.rb +20 -0
- data/examples/v2/security-monitoring/UpdateSecurityMonitoringRule.rb +1 -0
- data/examples/v2/usage-metering/GetEstimatedCostByOrg.rb +5 -2
- data/examples/v2/usage-metering/GetEstimatedCostByOrg_2734954020.rb +11 -0
- data/examples/v2/usage-metering/GetEstimatedCostByOrg_3186693804.rb +11 -0
- data/examples/v2/usage-metering/GetUsageApplicationSecurityMonitoring.rb +2 -5
- data/examples/v2/usage-metering/GetUsageApplicationSecurityMonitoring_3959166796.rb +8 -0
- data/examples/v2/usage-metering/GetUsageLambdaTracedInvocations.rb +2 -5
- data/examples/v2/usage-metering/GetUsageLambdaTracedInvocations_1436752065.rb +8 -0
- data/examples/v2/usage-metering/GetUsageObservabilityPipelines.rb +2 -5
- data/examples/v2/usage-metering/GetUsageObservabilityPipelines_970725512.rb +8 -0
- data/lib/datadog_api_client/{v2/api_client.rb → api_client.rb} +63 -11
- data/lib/datadog_api_client/api_key_configuration.rb +1 -18
- data/lib/datadog_api_client/{v1/configuration.rb → configuration.rb} +84 -31
- data/lib/datadog_api_client/inflector.rb +1293 -0
- data/lib/datadog_api_client/models.rb +66 -0
- data/lib/datadog_api_client/v1/api/authentication_api.rb +3 -11
- data/lib/datadog_api_client/v1/api/aws_integration_api.rb +19 -91
- data/lib/datadog_api_client/v1/api/aws_logs_integration_api.rb +15 -71
- data/lib/datadog_api_client/v1/api/azure_integration_api.rb +11 -51
- data/lib/datadog_api_client/v1/api/dashboard_lists_api.rb +11 -51
- data/lib/datadog_api_client/v1/api/dashboards_api.rb +15 -71
- data/lib/datadog_api_client/v1/api/downtimes_api.rb +15 -71
- data/lib/datadog_api_client/v1/api/events_api.rb +9 -33
- data/lib/datadog_api_client/v1/api/gcp_integration_api.rb +9 -41
- data/lib/datadog_api_client/v1/api/hosts_api.rb +9 -41
- data/lib/datadog_api_client/v1/api/ip_ranges_api.rb +3 -11
- data/lib/datadog_api_client/v1/api/key_management_api.rb +21 -101
- data/lib/datadog_api_client/v1/api/logs_api.rb +5 -21
- data/lib/datadog_api_client/v1/api/logs_indexes_api.rb +13 -61
- data/lib/datadog_api_client/v1/api/logs_pipelines_api.rb +15 -71
- data/lib/datadog_api_client/v1/api/metrics_api.rb +15 -71
- data/lib/datadog_api_client/v1/api/monitors_api.rb +21 -101
- data/lib/datadog_api_client/v1/api/notebooks_api.rb +11 -51
- data/lib/datadog_api_client/v1/api/organizations_api.rb +13 -61
- data/lib/datadog_api_client/v1/api/pager_duty_integration_api.rb +9 -41
- data/lib/datadog_api_client/v1/api/security_monitoring_api.rb +8 -32
- data/lib/datadog_api_client/v1/api/service_checks_api.rb +3 -11
- data/lib/datadog_api_client/v1/api/service_level_objective_corrections_api.rb +11 -51
- data/lib/datadog_api_client/v1/api/service_level_objectives_api.rb +31 -99
- data/lib/datadog_api_client/v1/api/slack_integration_api.rb +11 -51
- data/lib/datadog_api_client/v1/api/snapshots_api.rb +3 -11
- data/lib/datadog_api_client/v1/api/synthetics_api.rb +55 -271
- data/lib/datadog_api_client/v1/api/tags_api.rb +11 -51
- data/lib/datadog_api_client/v1/api/usage_metering_api.rb +171 -418
- data/lib/datadog_api_client/v1/api/users_api.rb +11 -51
- data/lib/datadog_api_client/v1/api/webhooks_integration_api.rb +17 -81
- data/lib/datadog_api_client/v1/model_base.rb +2 -2
- data/lib/datadog_api_client/v1/models/distribution_point_item.rb +1 -1
- data/lib/datadog_api_client/v1/models/distribution_widget_histogram_request_query.rb +1 -1
- data/lib/datadog_api_client/v1/models/formula_and_function_query_definition.rb +1 -1
- data/lib/datadog_api_client/v1/models/hourly_usage_attribution_body.rb +5 -1
- data/lib/datadog_api_client/v1/models/hourly_usage_attribution_usage_type.rb +7 -0
- data/lib/datadog_api_client/v1/models/logs_processor.rb +1 -1
- data/lib/datadog_api_client/v1/models/monitor_formula_and_function_query_definition.rb +1 -1
- data/lib/datadog_api_client/v1/models/monthly_usage_attribution_body.rb +6 -2
- data/lib/datadog_api_client/v1/models/monthly_usage_attribution_supported_metrics.rb +14 -0
- data/lib/datadog_api_client/v1/models/monthly_usage_attribution_values.rb +21 -1
- data/lib/datadog_api_client/v1/models/notebook_cell_create_request_attributes.rb +1 -1
- data/lib/datadog_api_client/v1/models/notebook_cell_response_attributes.rb +1 -1
- data/lib/datadog_api_client/v1/models/notebook_cell_time.rb +1 -1
- data/lib/datadog_api_client/v1/models/notebook_cell_update_request_attributes.rb +1 -1
- data/lib/datadog_api_client/v1/models/notebook_global_time.rb +1 -1
- data/lib/datadog_api_client/v1/models/notebook_update_cell.rb +1 -1
- data/lib/datadog_api_client/v1/models/sunburst_widget_legend.rb +1 -1
- data/lib/datadog_api_client/v1/models/synthetics_assertion.rb +1 -1
- data/lib/datadog_api_client/v1/models/synthetics_basic_auth.rb +1 -1
- data/lib/datadog_api_client/v1/models/tree_map_color_by.rb +1 -1
- data/lib/datadog_api_client/v1/models/tree_map_group_by.rb +1 -1
- data/lib/datadog_api_client/v1/models/tree_map_size_by.rb +1 -1
- data/lib/datadog_api_client/v1/models/tree_map_widget_definition.rb +28 -6
- data/lib/datadog_api_client/v1/models/usage_attribution_body.rb +6 -2
- data/lib/datadog_api_client/v1/models/usage_attribution_sort.rb +2 -0
- data/lib/datadog_api_client/v1/models/usage_attribution_supported_metrics.rb +2 -0
- data/lib/datadog_api_client/v1/models/usage_attribution_values.rb +22 -2
- data/lib/datadog_api_client/v1/models/widget_definition.rb +1 -1
- data/lib/datadog_api_client/v2/api/audit_api.rb +11 -25
- data/lib/datadog_api_client/v2/api/authn_mappings_api.rb +11 -51
- data/lib/datadog_api_client/v2/api/cloud_workload_security_api.rb +13 -61
- data/lib/datadog_api_client/v2/api/dashboard_lists_api.rb +9 -41
- data/lib/datadog_api_client/v2/api/events_api.rb +228 -0
- data/lib/datadog_api_client/v2/api/incident_services_api.rb +36 -46
- data/lib/datadog_api_client/v2/api/incident_teams_api.rb +36 -46
- data/lib/datadog_api_client/v2/api/incidents_api.rb +39 -48
- data/lib/datadog_api_client/v2/api/key_management_api.rb +29 -141
- data/lib/datadog_api_client/v2/api/logs_api.rb +15 -45
- data/lib/datadog_api_client/v2/api/logs_archives_api.rb +21 -101
- data/lib/datadog_api_client/v2/api/logs_metrics_api.rb +11 -51
- data/lib/datadog_api_client/v2/api/metrics_api.rb +26 -112
- data/lib/datadog_api_client/v2/api/opsgenie_integration_api.rb +11 -51
- data/lib/datadog_api_client/v2/api/organizations_api.rb +3 -11
- data/lib/datadog_api_client/v2/api/processes_api.rb +6 -13
- data/lib/datadog_api_client/v2/api/roles_api.rb +27 -131
- data/lib/datadog_api_client/v2/api/rum_api.rb +13 -35
- data/lib/datadog_api_client/v2/api/security_monitoring_api.rb +247 -125
- data/lib/datadog_api_client/v2/api/service_accounts_api.rb +11 -51
- data/lib/datadog_api_client/v2/api/usage_metering_api.rb +132 -68
- data/lib/datadog_api_client/v2/api/users_api.rb +21 -101
- data/lib/datadog_api_client/v2/model_base.rb +2 -2
- data/lib/datadog_api_client/v2/models/api_key_response_included_item.rb +1 -1
- data/lib/datadog_api_client/v2/models/application_key_response_included_item.rb +1 -1
- data/lib/datadog_api_client/v2/models/authn_mapping_included.rb +1 -1
- data/lib/datadog_api_client/v2/models/event.rb +141 -0
- data/lib/datadog_api_client/v2/models/event_attributes.rb +305 -0
- data/lib/datadog_api_client/v2/models/event_priority.rb +27 -0
- data/lib/datadog_api_client/v2/models/event_response.rb +133 -0
- data/lib/datadog_api_client/v2/models/event_response_attributes.rb +133 -0
- data/lib/datadog_api_client/v2/models/event_status_type.rb +35 -0
- data/lib/datadog_api_client/v2/models/event_type.rb +26 -0
- data/lib/datadog_api_client/v2/models/events_list_request.rb +142 -0
- data/lib/datadog_api_client/v2/models/events_list_response.rb +133 -0
- data/lib/datadog_api_client/v2/models/events_list_response_links.rb +112 -0
- data/lib/datadog_api_client/v2/models/events_query_filter.rb +137 -0
- data/lib/datadog_api_client/v2/models/events_query_options.rb +124 -0
- data/lib/datadog_api_client/v2/models/events_request_page.rb +134 -0
- data/lib/datadog_api_client/v2/models/events_response_metadata.rb +144 -0
- data/lib/datadog_api_client/v2/models/events_response_metadata_page.rb +112 -0
- data/lib/datadog_api_client/v2/models/events_sort.rb +27 -0
- data/lib/datadog_api_client/v2/models/events_warning.rb +131 -0
- data/lib/datadog_api_client/v2/models/hourly_usage.rb +133 -0
- data/lib/datadog_api_client/v2/models/hourly_usage_attributes.rb +163 -0
- data/lib/datadog_api_client/v2/models/hourly_usage_measurement.rb +122 -0
- data/lib/datadog_api_client/v2/models/hourly_usage_metadata.rb +111 -0
- data/lib/datadog_api_client/v2/models/hourly_usage_pagination.rb +112 -0
- data/lib/datadog_api_client/v2/models/hourly_usage_response.rb +123 -0
- data/lib/datadog_api_client/v2/models/incident_field_attributes.rb +1 -1
- data/lib/datadog_api_client/v2/models/incident_response_included_item.rb +1 -1
- data/lib/datadog_api_client/v2/models/incident_service_included_items.rb +1 -1
- data/lib/datadog_api_client/v2/models/incident_team_included_items.rb +1 -1
- data/lib/datadog_api_client/v2/models/incident_timeline_cell_create_attributes.rb +1 -1
- data/lib/datadog_api_client/v2/models/logs_aggregate_bucket_value.rb +1 -1
- data/lib/datadog_api_client/v2/models/logs_archive_create_request_destination.rb +1 -1
- data/lib/datadog_api_client/v2/models/logs_archive_destination.rb +1 -1
- data/lib/datadog_api_client/v2/models/logs_group_by_missing.rb +1 -1
- data/lib/datadog_api_client/v2/models/logs_group_by_total.rb +1 -1
- data/lib/datadog_api_client/v2/models/metric_intake_type.rb +1 -2
- data/lib/datadog_api_client/v2/models/metric_resource.rb +2 -2
- data/lib/datadog_api_client/v2/models/metric_series.rb +1 -1
- data/lib/datadog_api_client/v2/models/metric_volumes.rb +1 -1
- data/lib/datadog_api_client/v2/models/metrics_and_metric_tag_configurations.rb +1 -1
- data/lib/datadog_api_client/v2/models/monitor_type.rb +215 -0
- data/lib/datadog_api_client/v2/models/rum_aggregate_bucket_value.rb +1 -1
- data/lib/datadog_api_client/v2/models/rum_group_by_missing.rb +1 -1
- data/lib/datadog_api_client/v2/models/rum_group_by_total.rb +1 -1
- data/lib/datadog_api_client/v2/models/security_monitoring_rule_query.rb +13 -1
- data/lib/datadog_api_client/v2/models/security_monitoring_rule_query_create.rb +13 -1
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_archive_reason.rb +29 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_assignee_update_attributes.rb +132 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_assignee_update_data.rb +122 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_assignee_update_request.rb +122 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_incidents_update_attributes.rb +134 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_incidents_update_data.rb +122 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_incidents_update_request.rb +122 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_state.rb +28 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_state_update_attributes.rb +152 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_state_update_data.rb +122 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_state_update_request.rb +122 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_triage_attributes.rb +248 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_triage_update_data.rb +111 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_signal_triage_update_response.rb +122 -0
- data/lib/datadog_api_client/v2/models/security_monitoring_triage_user.rb +152 -0
- data/lib/datadog_api_client/v2/models/user_response_included_item.rb +1 -1
- data/lib/datadog_api_client/version.rb +1 -1
- data/lib/datadog_api_client.rb +13 -5
- data/spec/{v1/api_client_spec.rb → api_client_spec.rb} +29 -29
- data/spec/{v1/configuration_spec.rb → configuration_spec.rb} +3 -3
- data/spec/spec_helper.rb +1 -3
- metadata +109 -22
- data/.dockerignore +0 -1
- data/.generator/src/generator/templates/api_error.j2 +0 -49
- data/examples/v2/usage-metering/GetEstimatedCostByOrg_1171921972.rb +0 -9
- data/examples/v2/usage-metering/GetEstimatedCostByOrg_627383212.rb +0 -9
- data/lib/datadog_api_client/v1/api_client.rb +0 -453
- data/lib/datadog_api_client/v1/api_error.rb +0 -60
- data/lib/datadog_api_client/v1.rb +0 -813
- data/lib/datadog_api_client/v2/api_error.rb +0 -60
- data/lib/datadog_api_client/v2/configuration.rb +0 -420
- data/lib/datadog_api_client/v2.rb +0 -555
- data/spec/v2/api_client_spec.rb +0 -210
- data/spec/v2/configuration_spec.rb +0 -45
|
@@ -12,9 +12,9 @@ MODULE_NAME = "DatadogAPIClient"
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@click.command()
|
|
15
|
-
@click.
|
|
16
|
-
"
|
|
17
|
-
|
|
15
|
+
@click.argument(
|
|
16
|
+
"specs",
|
|
17
|
+
nargs=-1,
|
|
18
18
|
type=click.Path(exists=True, file_okay=True, dir_okay=False, path_type=pathlib.Path),
|
|
19
19
|
)
|
|
20
20
|
@click.option(
|
|
@@ -22,14 +22,10 @@ MODULE_NAME = "DatadogAPIClient"
|
|
|
22
22
|
"--output",
|
|
23
23
|
type=click.Path(path_type=pathlib.Path),
|
|
24
24
|
)
|
|
25
|
-
def cli(
|
|
25
|
+
def cli(specs, output):
|
|
26
26
|
"""
|
|
27
27
|
Generate a Ruby code snippet from OpenAPI specification.
|
|
28
28
|
"""
|
|
29
|
-
spec = openapi.load(input)
|
|
30
|
-
|
|
31
|
-
version = input.parent.name
|
|
32
|
-
|
|
33
29
|
env = Environment(loader=FileSystemLoader(str(pathlib.Path(__file__).parent / "templates")))
|
|
34
30
|
|
|
35
31
|
env.filters["accept_headers"] = openapi.accept_headers
|
|
@@ -48,8 +44,6 @@ def cli(input, output):
|
|
|
48
44
|
env.globals["gem_name"] = GEM_NAME
|
|
49
45
|
env.globals["module_name"] = MODULE_NAME
|
|
50
46
|
env.globals["enumerate"] = enumerate
|
|
51
|
-
env.globals["version"] = version
|
|
52
|
-
env.globals["openapi"] = spec
|
|
53
47
|
env.globals["get_name"] = openapi.get_name
|
|
54
48
|
env.globals["type_to_ruby"] = openapi.type_to_ruby
|
|
55
49
|
env.globals["get_type_for_attribute"] = openapi.get_type_for_attribute
|
|
@@ -63,38 +57,61 @@ def cli(input, output):
|
|
|
63
57
|
package_j2 = env.get_template("package.j2")
|
|
64
58
|
|
|
65
59
|
extra_files = {
|
|
66
|
-
"api_client.rb": env.get_template("api_client.j2"),
|
|
67
|
-
"api_error.rb": env.get_template("api_error.j2"),
|
|
68
|
-
"configuration.rb": env.get_template("configuration.j2"),
|
|
69
60
|
"model_base.rb": env.get_template("model_base.j2"),
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
with package.open("w") as fp:
|
|
78
|
-
fp.write(package_j2.render(apis=apis, models=models))
|
|
79
|
-
|
|
80
|
-
gem_path = output / GEM_NAME / version
|
|
81
|
-
gem_path.mkdir(parents=True, exist_ok=True)
|
|
63
|
+
common_files = {
|
|
64
|
+
"api_client.rb": env.get_template("api_client.j2"),
|
|
65
|
+
"configuration.rb": env.get_template("configuration.j2"),
|
|
66
|
+
"inflector.rb": env.get_template("inflector.j2"),
|
|
67
|
+
}
|
|
82
68
|
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
all_specs = {}
|
|
70
|
+
all_apis = {}
|
|
71
|
+
all_models = {}
|
|
72
|
+
for spec_path in specs:
|
|
73
|
+
version = spec_path.parent.name
|
|
74
|
+
|
|
75
|
+
spec = openapi.load(spec_path)
|
|
76
|
+
all_specs[version] = spec
|
|
77
|
+
|
|
78
|
+
apis = openapi.apis(spec)
|
|
79
|
+
all_apis[version] = apis
|
|
80
|
+
|
|
81
|
+
models = openapi.models(spec)
|
|
82
|
+
all_models[version] = models
|
|
83
|
+
|
|
84
|
+
env.globals["openapi"] = spec
|
|
85
|
+
env.globals["version"] = version
|
|
86
|
+
|
|
87
|
+
gem_path = output / GEM_NAME / version
|
|
88
|
+
gem_path.mkdir(parents=True, exist_ok=True)
|
|
89
|
+
|
|
90
|
+
for name, template in extra_files.items():
|
|
91
|
+
filename = gem_path / name
|
|
92
|
+
with filename.open("w") as fp:
|
|
93
|
+
fp.write(template.render(apis=apis, models=models))
|
|
94
|
+
|
|
95
|
+
for name, model in models.items():
|
|
96
|
+
filename = formatter.snake_case(name) + ".rb"
|
|
97
|
+
model_path = gem_path / "models" / filename
|
|
98
|
+
model_path.parent.mkdir(parents=True, exist_ok=True)
|
|
99
|
+
with model_path.open("w") as fp:
|
|
100
|
+
fp.write(model_j2.render(name=name, model=model))
|
|
101
|
+
|
|
102
|
+
for name, operations in apis.items():
|
|
103
|
+
filename = formatter.snake_case(name) + "_api.rb"
|
|
104
|
+
api_path = gem_path / "api" / filename
|
|
105
|
+
api_path.parent.mkdir(parents=True, exist_ok=True)
|
|
106
|
+
with api_path.open("w") as fp:
|
|
107
|
+
fp.write(api_j2.render(name=name, operations=operations))
|
|
108
|
+
|
|
109
|
+
models_output = output / GEM_NAME / "models.rb"
|
|
110
|
+
with models_output.open("w") as fp:
|
|
111
|
+
fp.write(package_j2.render(all_apis=all_apis, all_models=all_models))
|
|
112
|
+
|
|
113
|
+
common_output = output / GEM_NAME
|
|
114
|
+
for name, template in common_files.items():
|
|
115
|
+
filename = common_output / name
|
|
85
116
|
with filename.open("w") as fp:
|
|
86
|
-
fp.write(template.render(
|
|
87
|
-
|
|
88
|
-
for name, model in models.items():
|
|
89
|
-
filename = formatter.snake_case(name) + ".rb"
|
|
90
|
-
model_path = gem_path / "models" / filename
|
|
91
|
-
model_path.parent.mkdir(parents=True, exist_ok=True)
|
|
92
|
-
with model_path.open("w") as fp:
|
|
93
|
-
fp.write(model_j2.render(name=name, model=model))
|
|
94
|
-
|
|
95
|
-
for name, operations in apis.items():
|
|
96
|
-
filename = formatter.snake_case(name) + "_api.rb"
|
|
97
|
-
api_path = gem_path / "api" / filename
|
|
98
|
-
api_path.parent.mkdir(parents=True, exist_ok=True)
|
|
99
|
-
with api_path.open("w") as fp:
|
|
100
|
-
fp.write(api_j2.render(name=name, operations=operations))
|
|
117
|
+
fp.write(template.render(all_apis=all_apis, all_specs=all_specs, all_models=all_models))
|
|
@@ -32,7 +32,10 @@ def type_to_ruby(schema, alternative_name=None):
|
|
|
32
32
|
if name:
|
|
33
33
|
if "enum" in schema:
|
|
34
34
|
return name
|
|
35
|
-
if
|
|
35
|
+
if (
|
|
36
|
+
not (schema.get("additionalProperties") and not schema.get("properties"))
|
|
37
|
+
and schema.get("type", "object") == "object"
|
|
38
|
+
):
|
|
36
39
|
return name
|
|
37
40
|
|
|
38
41
|
type_ = schema.get("type")
|
|
@@ -117,9 +120,9 @@ def child_models(schema, alternative_name=None, seen=None):
|
|
|
117
120
|
seen=seen,
|
|
118
121
|
)
|
|
119
122
|
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
)
|
|
123
|
+
if (schema.get("type") == "object" or "properties" in schema or has_sub_models) and not (
|
|
124
|
+
"additionalProperties" in schema and "properties" not in schema
|
|
125
|
+
):
|
|
123
126
|
if not has_sub_models and name is None:
|
|
124
127
|
# this is a basic map object so we don't need a type
|
|
125
128
|
return
|
|
@@ -458,7 +461,6 @@ def get_default(operation, attribute_path):
|
|
|
458
461
|
|
|
459
462
|
|
|
460
463
|
def get_container(operation, attribute_path, with_type=False):
|
|
461
|
-
|
|
462
464
|
def get_type(parameter):
|
|
463
465
|
if with_type:
|
|
464
466
|
return f", {get_type_for_parameter(parameter)}"
|
|
@@ -468,7 +470,11 @@ def get_container(operation, attribute_path, with_type=False):
|
|
|
468
470
|
for name, parameter in parameters(operation):
|
|
469
471
|
if name == attribute_name:
|
|
470
472
|
if parameter["required"]:
|
|
471
|
-
return '{}, "{}"{}'.format(
|
|
473
|
+
return '{}, "{}"{}'.format(
|
|
474
|
+
name,
|
|
475
|
+
".".join(formatter.attribute_name(a) for a in attribute_path.split(".")[1:]),
|
|
476
|
+
get_type(parameter),
|
|
477
|
+
)
|
|
472
478
|
return f'opts, "{formatter.attribute_path(attribute_path)}"{get_type(parameter)}'
|
|
473
479
|
|
|
474
480
|
|
|
@@ -9,7 +9,7 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
9
9
|
class {{ classname }}
|
|
10
10
|
attr_accessor :api_client
|
|
11
11
|
|
|
12
|
-
def initialize(api_client = APIClient.default)
|
|
12
|
+
def initialize(api_client = {{ module_name }}::APIClient.default)
|
|
13
13
|
@api_client = api_client
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -40,15 +40,14 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
40
40
|
{%- endfor %}
|
|
41
41
|
# @return [Array<({% if returnType %}{{ returnType }}{% else %}nil{% endif %}, Integer, Hash)>] {% if returnType %}{{ returnType }} data{% else %}nil{% endif %}, response status code and response headers
|
|
42
42
|
def {{ operation.operationId|snake_case }}_with_http_info({% for name, parameter in operation|parameters if parameter.required %}{{ name|attribute_name }}, {% endfor %}opts = {})
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
raise APIError.new(message: format("Unstable operation '%s' is disabled", "{{ operation.operationId|snake_case }}"))
|
|
50
|
-
end
|
|
43
|
+
{%- if "x-unstable" in operation %}
|
|
44
|
+
unstable_enabled = @api_client.config.unstable_operations["{{ version }}.{{ operation.operationId|snake_case }}".to_sym]
|
|
45
|
+
if unstable_enabled
|
|
46
|
+
@api_client.config.logger.warn format("Using unstable operation '%s'", "{{ version }}.{{ operation.operationId|snake_case }}")
|
|
47
|
+
else
|
|
48
|
+
raise {{ module_name }}::APIError.new(message: format("Unstable operation '%s' is disabled", "{{ version }}.{{ operation.operationId|snake_case }}"))
|
|
51
49
|
end
|
|
50
|
+
{%- endif %}
|
|
52
51
|
|
|
53
52
|
if @api_client.config.debugging
|
|
54
53
|
@api_client.config.logger.debug 'Calling API: {{classname}}.{{ operation.operationId|snake_case }} ...'
|
|
@@ -198,7 +197,8 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
198
197
|
:form_params => form_params,
|
|
199
198
|
:body => post_body,
|
|
200
199
|
:auth_names => auth_names,
|
|
201
|
-
:return_type => return_type
|
|
200
|
+
:return_type => return_type,
|
|
201
|
+
:api_version => "{{ version|upper }}"
|
|
202
202
|
)
|
|
203
203
|
|
|
204
204
|
data, status_code, headers = @api_client.call_api(Net::HTTP::{{ httpMethod|camel_case }}, local_var_path, new_options)
|
|
@@ -218,8 +218,9 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
218
218
|
#
|
|
219
219
|
# @yield [{{ get_type_at_path(operation, pagination.resultsPath) }}] Paginated items
|
|
220
220
|
def {{ operation.operationId|snake_case }}_with_pagination({% for name, parameter in operation|parameters if parameter.required %}{{ name|attribute_name }}, {% endfor %}opts = {})
|
|
221
|
+
api_version = "{{ version|upper }}"
|
|
221
222
|
page_size = @api_client.get_attribute_from_path({{ get_container(operation, pagination.limitParam) }}, {{ get_default(operation, pagination.limitParam) }})
|
|
222
|
-
@api_client.set_attribute_from_path({{ get_container(operation, pagination.limitParam, True) }}, page_size)
|
|
223
|
+
@api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.limitParam, True) }}, page_size)
|
|
223
224
|
while true do
|
|
224
225
|
response = {{ operation.operationId|snake_case }}({% for name, parameter in operation|parameters if parameter.required %}{{ name|attribute_name }}, {% endfor %}opts)
|
|
225
226
|
@api_client.get_attribute_from_path(response, "{{ pagination.resultsPath|attribute_path }}").each { |item| yield(item) }
|
|
@@ -227,10 +228,10 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
227
228
|
break
|
|
228
229
|
end
|
|
229
230
|
{%- if pagination.pageOffsetParam %}
|
|
230
|
-
@api_client.set_attribute_from_path({{ get_container(operation, pagination.pageOffsetParam, True) }}, @api_client.get_attribute_from_path({{ get_container(operation, pagination.pageOffsetParam) }}, 0) + page_size)
|
|
231
|
+
@api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.pageOffsetParam, True) }}, @api_client.get_attribute_from_path({{ get_container(operation, pagination.pageOffsetParam) }}, 0) + page_size)
|
|
231
232
|
{%- endif %}
|
|
232
233
|
{%- if pagination.cursorParam %}
|
|
233
|
-
@api_client.set_attribute_from_path({{ get_container(operation, pagination.cursorParam, True) }}, @api_client.get_attribute_from_path(response, "{{ pagination.cursorPath }}"))
|
|
234
|
+
@api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.cursorParam, True) }}, @api_client.get_attribute_from_path(response, "{{ pagination.cursorPath }}"))
|
|
234
235
|
{%- endif %}
|
|
235
236
|
end
|
|
236
237
|
end
|
|
@@ -8,8 +8,12 @@ require 'logger'
|
|
|
8
8
|
require 'tempfile'
|
|
9
9
|
require 'time'
|
|
10
10
|
require 'httparty'
|
|
11
|
+
begin
|
|
12
|
+
require 'zstandard'
|
|
13
|
+
rescue LoadError
|
|
14
|
+
end
|
|
11
15
|
|
|
12
|
-
module {{ module_name }}
|
|
16
|
+
module {{ module_name }}
|
|
13
17
|
class APIClient
|
|
14
18
|
# The Configuration object holding settings to be used in the API client.
|
|
15
19
|
attr_accessor :config
|
|
@@ -100,7 +104,7 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
100
104
|
end
|
|
101
105
|
|
|
102
106
|
if opts[:return_type]
|
|
103
|
-
data = deserialize(response, opts[:return_type])
|
|
107
|
+
data = deserialize(opts[:api_version], response, opts[:return_type])
|
|
104
108
|
else
|
|
105
109
|
data = nil
|
|
106
110
|
end
|
|
@@ -187,6 +191,8 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
187
191
|
gzip.close
|
|
188
192
|
elsif header_params['Content-Encoding'] == 'deflate'
|
|
189
193
|
data = Zlib::deflate(data)
|
|
194
|
+
elsif header_params['Content-Encoding'] == 'zstd1'
|
|
195
|
+
data = Zstandard.deflate(data)
|
|
190
196
|
end
|
|
191
197
|
data
|
|
192
198
|
end
|
|
@@ -205,9 +211,10 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
205
211
|
|
|
206
212
|
# Deserialize the response to the given return type.
|
|
207
213
|
#
|
|
214
|
+
# @param [String] the api version
|
|
208
215
|
# @param [Response] response HTTP response
|
|
209
216
|
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
|
210
|
-
def deserialize(response, return_type)
|
|
217
|
+
def deserialize(api_version, response, return_type)
|
|
211
218
|
body = response.body
|
|
212
219
|
|
|
213
220
|
# handle file downloading - return the File instance processed in request callbacks
|
|
@@ -240,14 +247,14 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
240
247
|
end
|
|
241
248
|
end
|
|
242
249
|
|
|
243
|
-
convert_to_type data, return_type
|
|
250
|
+
convert_to_type data, return_type, api_version
|
|
244
251
|
end
|
|
245
252
|
|
|
246
253
|
# Convert data to the given return type.
|
|
247
254
|
# @param [Object] data Data to be converted
|
|
248
255
|
# @param [String] return_type Return type
|
|
249
256
|
# @return [Mixed] Data in a particular type
|
|
250
|
-
def convert_to_type(data, return_type)
|
|
257
|
+
def convert_to_type(data, return_type, api_version)
|
|
251
258
|
return nil if data.nil?
|
|
252
259
|
case return_type
|
|
253
260
|
when 'String'
|
|
@@ -270,16 +277,16 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
270
277
|
when /\AArray<(.+)>\z/
|
|
271
278
|
# e.g. Array<Pet>
|
|
272
279
|
sub_type = $1
|
|
273
|
-
data.map { |item| convert_to_type(item, sub_type) }
|
|
280
|
+
data.map { |item| convert_to_type(item, sub_type, api_version) }
|
|
274
281
|
when /\AHash\<String, (.+)\>\z/
|
|
275
282
|
# e.g. Hash<String, Integer>
|
|
276
283
|
sub_type = $1
|
|
277
284
|
{}.tap do |hash|
|
|
278
|
-
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
|
285
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type, api_version) }
|
|
279
286
|
end
|
|
280
287
|
else
|
|
281
288
|
# models (e.g. Pet) or oneOf
|
|
282
|
-
klass = {{ module_name }}
|
|
289
|
+
klass = {{ module_name }}.const_get(api_version).const_get(return_type)
|
|
283
290
|
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
|
284
291
|
end
|
|
285
292
|
end
|
|
@@ -296,7 +303,7 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
296
303
|
def build_request_url(path, opts = {})
|
|
297
304
|
# Add leading and trailing slashes to path
|
|
298
305
|
path = "/#{path}".gsub(/\/+/, '/')
|
|
299
|
-
@config.base_url(opts[:operation]) + path
|
|
306
|
+
@config.base_url("#{opts[:api_version].respond_to?(:downcase) ? opts[:api_version].downcase : opts[:api_version]}.#{opts[:operation]}") + path
|
|
300
307
|
end
|
|
301
308
|
|
|
302
309
|
# Update header and query params based on authentication settings.
|
|
@@ -411,12 +418,13 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
411
418
|
|
|
412
419
|
# Set an attribute at the given path
|
|
413
420
|
#
|
|
421
|
+
# @param [String] api_version The api version
|
|
414
422
|
# @param [Object] obj The source object
|
|
415
423
|
# @param [String] attribute_path The path spefication, separated by "."
|
|
416
424
|
# @param [Object] builder The class matching the top level attribute
|
|
417
425
|
# @param [Object] value The value to set
|
|
418
426
|
# @!visibility private
|
|
419
|
-
def set_attribute_from_path(obj, attribute_path, builder, value)
|
|
427
|
+
def set_attribute_from_path(api_version, obj, attribute_path, builder, value)
|
|
420
428
|
attrs = attribute_path.split(".")
|
|
421
429
|
last = attrs.pop
|
|
422
430
|
i = 0
|
|
@@ -427,7 +435,7 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
427
435
|
else
|
|
428
436
|
obj = obj.send(attr)
|
|
429
437
|
end
|
|
430
|
-
builder = DatadogAPIClient
|
|
438
|
+
builder = DatadogAPIClient.const_get(api_version).const_get(builder.openapi_types[attr.to_sym]) if i > 0
|
|
431
439
|
obj = builder.new if obj.nil?
|
|
432
440
|
i += 1
|
|
433
441
|
end
|
|
@@ -439,4 +447,48 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
439
447
|
end
|
|
440
448
|
end
|
|
441
449
|
end
|
|
450
|
+
|
|
451
|
+
class APIError < StandardError
|
|
452
|
+
attr_reader :code, :response_headers, :response_body
|
|
453
|
+
|
|
454
|
+
# Usage examples:
|
|
455
|
+
# APIError.new
|
|
456
|
+
# APIError.new("message")
|
|
457
|
+
# APIError.new(:code => 500, :response_headers => {}, :response_body => "")
|
|
458
|
+
# APIError.new(:code => 404, :message => "Not Found")
|
|
459
|
+
def initialize(arg = nil)
|
|
460
|
+
if arg.is_a? Hash
|
|
461
|
+
if arg.key?(:message) || arg.key?('message')
|
|
462
|
+
super(arg[:message] || arg['message'])
|
|
463
|
+
else
|
|
464
|
+
super arg
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
arg.each do |k, v|
|
|
468
|
+
instance_variable_set "@#{k}", v
|
|
469
|
+
end
|
|
470
|
+
else
|
|
471
|
+
super arg
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
# Override to_s to display a friendly error message
|
|
476
|
+
def to_s
|
|
477
|
+
message
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def message
|
|
481
|
+
if @message.nil?
|
|
482
|
+
msg = "Error message: the server returns an error"
|
|
483
|
+
else
|
|
484
|
+
msg = @message
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
msg += "\nHTTP status code: #{code}" if code
|
|
488
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
|
489
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
|
490
|
+
|
|
491
|
+
msg
|
|
492
|
+
end
|
|
493
|
+
end
|
|
442
494
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{% include "api_info.j2" %}
|
|
3
3
|
=end
|
|
4
4
|
|
|
5
|
-
module {{ module_name }}
|
|
5
|
+
module {{ module_name }}
|
|
6
6
|
class Configuration
|
|
7
7
|
# Defines url scheme
|
|
8
8
|
attr_accessor :scheme
|
|
@@ -148,13 +148,15 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
148
148
|
@compress = true
|
|
149
149
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
|
150
150
|
@unstable_operations = {
|
|
151
|
-
{%- for
|
|
152
|
-
{%- for
|
|
151
|
+
{%- for version, apis in all_apis.items() %}
|
|
152
|
+
{%- for operations in apis.values() %}
|
|
153
|
+
{%- for _, _, operation in operations|sort(attribute="2.operationId") %}
|
|
153
154
|
{%- if "x-unstable" in operation %}
|
|
154
|
-
{{ operation.operationId|snake_case }}: false,
|
|
155
|
+
"{{ version }}.{{ operation.operationId|snake_case }}": false,
|
|
155
156
|
{%- endif %}
|
|
156
157
|
{%- endfor %}
|
|
157
158
|
{%- endfor %}
|
|
159
|
+
{%- endfor %}
|
|
158
160
|
}
|
|
159
161
|
@server_variables[:site] = ENV['DD_SITE'] if ENV.key? 'DD_SITE'
|
|
160
162
|
{%- for name, schema in openapi.components.securitySchemes.items() if "x-env-name" in schema and schema.in == "header" and schema.type == "apiKey" %}
|
|
@@ -191,10 +193,10 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
191
193
|
|
|
192
194
|
# Returns base URL for specified operation based on server settings
|
|
193
195
|
def base_url(operation = nil)
|
|
194
|
-
index = server_operation_index.fetch(operation, server_index)
|
|
196
|
+
index = server_operation_index.fetch(operation.to_sym, server_index)
|
|
195
197
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
|
|
196
198
|
|
|
197
|
-
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
|
199
|
+
server_url(index, server_operation_variables.fetch(operation.to_sym, server_variables), operation_server_settings[operation.to_sym])
|
|
198
200
|
end
|
|
199
201
|
|
|
200
202
|
# Gets API key (with prefix if set).
|
|
@@ -294,11 +296,12 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
294
296
|
|
|
295
297
|
def operation_server_settings
|
|
296
298
|
{
|
|
297
|
-
{%- for
|
|
299
|
+
{%- for version, spec in all_specs.items() %}
|
|
300
|
+
{%- for path in spec.paths.values() %}
|
|
298
301
|
{%- for operation in path.values() %}
|
|
299
302
|
{%- for server in operation.servers %}
|
|
300
303
|
{%- if loop.first %}
|
|
301
|
-
{{ operation.operationId|snake_case }}: [
|
|
304
|
+
"{{ version }}.{{ operation.operationId|snake_case }}": [
|
|
302
305
|
{%- endif %}
|
|
303
306
|
{{ server_configuration(server)|indent(10) }}{% if not loop.last %},{% endif %}
|
|
304
307
|
{%- if loop.last %}
|
|
@@ -307,6 +310,7 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
307
310
|
{%- endfor %}
|
|
308
311
|
{%- endfor %}
|
|
309
312
|
{%- endfor %}
|
|
313
|
+
{%- endfor %}
|
|
310
314
|
}
|
|
311
315
|
end
|
|
312
316
|
|
|
@@ -8,7 +8,7 @@ require 'datadog_api_client'
|
|
|
8
8
|
{%- if context._enable_operations %}
|
|
9
9
|
DatadogAPIClient::V2.configure do |config|
|
|
10
10
|
{%- for operation in context._enable_operations %}
|
|
11
|
-
config.unstable_operations[
|
|
11
|
+
config.unstable_operations["{{ version }}.{{ operation|snake_case }}".to_sym] = true
|
|
12
12
|
{%- endfor %}
|
|
13
13
|
end
|
|
14
14
|
{%- endif %}
|
|
@@ -33,8 +33,13 @@ opts = {
|
|
|
33
33
|
{%- endfor %}
|
|
34
34
|
}
|
|
35
35
|
{%- endif %}
|
|
36
|
+
|
|
37
|
+
{%- if context.pagination %}
|
|
38
|
+
api_instance.{{ context.api_request.operation_id|snake_case }}_with_pagination({{ parameters }}) { |item| puts item }
|
|
39
|
+
{%- else %}
|
|
36
40
|
{%- if context.status_code != 204 %}
|
|
37
41
|
p api_instance.{{ context.api_request.operation_id|snake_case }}({{ parameters }})
|
|
38
42
|
{%- else %}
|
|
39
43
|
api_instance.{{ context.api_request.operation_id|snake_case }}({{ parameters }})
|
|
40
44
|
{%- endif %}
|
|
45
|
+
{%- endif %}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'zeitwerk'
|
|
2
|
+
|
|
3
|
+
module {{ module_name }}
|
|
4
|
+
class {{ module_name }}Inflector < Zeitwerk::Inflector
|
|
5
|
+
def camelize(basename, abspath)
|
|
6
|
+
model_name = "#{abspath.match('v[0-9]')}.#{basename}"
|
|
7
|
+
overrides[model_name] || basename.split('_').each(&:capitalize!).join
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def overrides
|
|
11
|
+
@overrides ||= {
|
|
12
|
+
# Models
|
|
13
|
+
{%- for version, models in all_models.items() %}
|
|
14
|
+
{%- for model in models|sort %}
|
|
15
|
+
"{{ version }}.{{ model|snake_case }}" => "{{ model }}",
|
|
16
|
+
{%- endfor %}
|
|
17
|
+
{%- endfor %}
|
|
18
|
+
# APIs
|
|
19
|
+
{%- for version, apis in all_apis.items() %}
|
|
20
|
+
{%- for api in apis|sort %}
|
|
21
|
+
{%- set name = api.replace(" ", "") + "API" %}
|
|
22
|
+
"{{ version }}.{{ api|snake_case }}_api" => "{{ name }}"{%-if not loop.last %},{% endif %}
|
|
23
|
+
{%- endfor %}{%-if not loop.last %},{% endif %}
|
|
24
|
+
{%- endfor %}
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -10,7 +10,7 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
10
10
|
# @!visibility private
|
|
11
11
|
def build_from_hash(value)
|
|
12
12
|
constantValues = self.class.constants.select { |c| self.class::const_get(c) == value }
|
|
13
|
-
constantValues.empty? ? {{ module_name }}::
|
|
13
|
+
constantValues.empty? ? {{ module_name }}::UnparsedObject.new(value) : value
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
module ClassMethods
|
|
@@ -107,7 +107,7 @@ module {{ module_name }}::{{ version|upper }}
|
|
|
107
107
|
# models (e.g. Pet) or oneOf
|
|
108
108
|
klass = {{ module_name }}::{{ version|upper }}.const_get(type)
|
|
109
109
|
res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
110
|
-
if res.instance_of? {{ module_name }}::
|
|
110
|
+
if res.instance_of? {{ module_name }}::UnparsedObject
|
|
111
111
|
self._unparsed = true
|
|
112
112
|
end
|
|
113
113
|
res
|
|
@@ -5,22 +5,17 @@
|
|
|
5
5
|
# Common files
|
|
6
6
|
require 'datadog_api_client/version'
|
|
7
7
|
require 'datadog_api_client/user_agent'
|
|
8
|
-
require '{{ gem_name }}/
|
|
9
|
-
require '{{ gem_name }}/
|
|
10
|
-
require '{{ gem_name }}/
|
|
8
|
+
require '{{ gem_name }}/api_client'
|
|
9
|
+
require '{{ gem_name }}/configuration'
|
|
10
|
+
require '{{ gem_name }}/api_key_configuration'
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
# Model base
|
|
13
|
+
## Load in the model_base modules which also initializes the V1 and V2 namespaces
|
|
14
|
+
{%- for version, models in all_models.items() %}
|
|
13
15
|
require '{{ gem_name }}/{{ version }}/model_base'
|
|
14
|
-
{%- for model in models|sort %}
|
|
15
|
-
require '{{ gem_name }}/{{ version }}/models/{{ model|snake_case }}'
|
|
16
16
|
{%- endfor %}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
{%- for api in apis|sort %}
|
|
20
|
-
require '{{ gem_name }}/{{ version }}/api/{{ api|snake_case }}_api'
|
|
21
|
-
{%- endfor %}
|
|
22
|
-
|
|
23
|
-
module {{ module_name }}::{{ version|upper }}
|
|
18
|
+
module {{ module_name }}
|
|
24
19
|
class << self
|
|
25
20
|
# Customize default settings for the SDK using block.
|
|
26
21
|
# {{ module_name }}::{{ version|upper }}.configure do |config|
|
|
@@ -26,8 +26,6 @@ jobs:
|
|
|
26
26
|
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
|
|
27
27
|
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
|
|
28
28
|
repository: DataDog/datadog-api-spec
|
|
29
|
-
- name: Checkout code
|
|
30
|
-
uses: actions/checkout@v2
|
|
31
29
|
- name: Post PR review status check
|
|
32
30
|
uses: DataDog/github-actions/post-review-status@v1.0.0
|
|
33
31
|
with:
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
# The branches below must be a subset of the branches above
|
|
8
|
+
branches: [ "master" ]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
analyze:
|
|
12
|
+
name: Analyze
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
actions: read
|
|
16
|
+
contents: read
|
|
17
|
+
security-events: write
|
|
18
|
+
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
language: [ 'ruby' ]
|
|
23
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
24
|
+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- name: Checkout repository
|
|
28
|
+
uses: actions/checkout@v3
|
|
29
|
+
|
|
30
|
+
# Initializes the CodeQL tools for scanning.
|
|
31
|
+
- name: Initialize CodeQL
|
|
32
|
+
uses: github/codeql-action/init@v2
|
|
33
|
+
with:
|
|
34
|
+
languages: ${{ matrix.language }}
|
|
35
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
36
|
+
# By default, queries listed here will override any specified in a config file.
|
|
37
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
38
|
+
|
|
39
|
+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
40
|
+
# queries: security-extended,security-and-quality
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
44
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
45
|
+
- name: Autobuild
|
|
46
|
+
uses: github/codeql-action/autobuild@v2
|
|
47
|
+
|
|
48
|
+
- name: Perform CodeQL Analysis
|
|
49
|
+
uses: github/codeql-action/analyze@v2
|
data/.github/workflows/docs.yml
CHANGED
|
@@ -21,7 +21,7 @@ jobs:
|
|
|
21
21
|
with:
|
|
22
22
|
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
|
|
23
23
|
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
|
|
24
|
-
- uses: actions/checkout@
|
|
24
|
+
- uses: actions/checkout@v3
|
|
25
25
|
with:
|
|
26
26
|
fetch-depth: 0
|
|
27
27
|
token: ${{ steps.get_token.outputs.token }}
|
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'published')
|
|
13
13
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
15
|
with:
|
|
16
16
|
ref: ${{ github.event.release.tag_name }}
|
|
17
17
|
|