Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose v2 usage endpoint for application security monitoring #978

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.2",
"regenerated": "2022-05-03 07:52:47.817555",
"spec_repo_commit": "31bcc455"
"regenerated": "2022-05-03 09:44:37.404709",
"spec_repo_commit": "b0dd9845"
},
"v2": {
"apigentools_version": "1.6.2",
"regenerated": "2022-05-03 07:52:47.832455",
"spec_repo_commit": "31bcc455"
"regenerated": "2022-05-03 09:44:37.416812",
"spec_repo_commit": "b0dd9845"
}
}
}
70 changes: 70 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1666,10 +1666,12 @@ components:
HourlyUsageType:
description: Usage type that is being measured.
enum:
- app_sec_host_count
- observability_pipelines_bytes_processed
example: observability_pipelines_bytes_processed
type: string
x-enum-varnames:
- APP_SEC_HOST_COUNT
- OBSERVABILITY_PIPELINES_BYTES_PROCESSSED
IdPMetadataFormData:
description: The form data submitted to upload IdP metadata
Expand Down Expand Up @@ -6531,6 +6533,15 @@ components:
required:
- data
type: object
UsageApplicationSecurityMonitoringResponse:
description: Application Security Monitoring usage response.
properties:
data:
description: Response containing Application Security Monitoring usage.
items:
$ref: '#/components/schemas/UsageDataObject'
type: array
type: object
UsageAttributesObject:
description: Usage attributes data.
properties:
Expand Down Expand Up @@ -12070,6 +12081,65 @@ paths:
x-unstable: '**Note**: This endpoint is in public beta.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/usage/application_security:
get:
description: Get hourly usage for Application Security .
operationId: GetUsageApplicationSecurityMonitoring
parameters:
- description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]`
for usage beginning at this hour.'
in: query
name: start_hr
required: true
schema:
format: date-time
type: string
- description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]`
for usage ending
**before** this hour.'
in: query
name: end_hr
required: false
schema:
format: date-time
type: string
responses:
'200':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/UsageApplicationSecurityMonitoringResponse'
description: OK
'400':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Bad Request
'403':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Forbidden - User is not authorized
'429':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Too many requests
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- usage_read
summary: Get hourly usage for Application Security
tags:
- Usage Metering
x-menu-order: 38
x-undo:
type: safe
/api/v2/usage/cost_by_org:
get:
description: Get Cost Across Multi-Org Account.
Expand Down
8 changes: 8 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3329,6 +3329,14 @@ service\_account\_create\_request
:undoc-members:
:show-inheritance:

usage\_application\_security\_monitoring\_response
--------------------------------------------------

.. automodule:: datadog_api_client.v2.model.usage_application_security_monitoring_response
:members:
:undoc-members:
:show-inheritance:

usage\_attributes\_object
-------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Get hourly usage for Application Security returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client.v2 import ApiClient, Configuration
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = UsageMeteringApi(api_client)
response = api_instance.get_usage_application_security_monitoring(
start_hr=(datetime.now() + relativedelta(days=-5)).isoformat(timespec="seconds"),
end_hr=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
)

print(response)
80 changes: 80 additions & 0 deletions src/datadog_api_client/v2/api/usage_metering_api.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/datadog_api_client/v2/model/hourly_usage_type.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-03-29T08:59:44.790Z
2022-03-28T15:06:36.041Z
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactions:
uri: https://api.datadoghq.com/api/v2/rum/analytics/aggregate
response:
body:
string: '{"meta":{"status":"done","request_id":"pddv1ChZiX1d1RWNfM1JuaURhSkJ6elFsRHpnIi0KHQJFlSKZaC6T1BR15cquEEJdzvJ8iKfJO5Kr37vkEgyJYfau6iiq_M5ftbo","elapsed":0},"data":{"buckets":[]}}
string: '{"meta":{"status":"done","request_id":"pddv1ChZyS2R0R2cwbFNTR3dXWHE0T1V4SkV3IiwKHO-LyxpZr85euhVxgr_zcJZpbjq-uQVUzkFlD0ISDPnlZXRCg4-gaoMc2w","elapsed":0},"data":{"buckets":[]}}
'
headers:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-05-02T16:40:49.302Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interactions:
- request:
body: null
headers:
accept:
- application/json;datetime-format=rfc3339
method: GET
uri: https://api.datadoghq.com/api/v2/usage/application_security?start_hr=2022-04-29T16%3A40%3A49.302Z&end_hr=2022-04-27T16%3A40%3A49.302Z
response:
body:
string: '{"errors":["start_hr [YYYY-MM-DDThh] must be before end_hr [YYYY-MM-DDThh]"]}
'
headers:
content-type:
- application/json
status:
code: 400
message: Bad Request
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-05-02T16:40:49.556Z
Loading